From: Matt Corallo Date: Thu, 5 Sep 2024 01:27:23 +0000 (+0000) Subject: Add missing `rustc` `metadata` override for `lightning_types` X-Git-Tag: v0.0.124.1^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmain;hp=ec9dcae005c7ec808c37bad053cdffc0f99e0e8f;p=ldk-c-bindings Add missing `rustc` `metadata` override for `lightning_types` This should resolve non-determinism in builds. --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c606d73..f78c28d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: run: | git clone https://github.com/rust-bitcoin/rust-lightning cd rust-lightning - git checkout 0.0.121-bindings + git checkout 0.0.124-bindings - name: Fix Github Actions to not be broken run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings - name: Pin proc-macro and quote to meet MSRV @@ -106,7 +106,7 @@ jobs: run: | git clone https://github.com/rust-bitcoin/rust-lightning cd rust-lightning - git checkout 0.0.121-bindings + git checkout 0.0.124-bindings - name: Fix Github Actions to not be broken run: git config --global --add safe.directory /__w/ldk-c-bindings/ldk-c-bindings - name: Fetch MacOS SDK @@ -153,7 +153,7 @@ jobs: run: | git clone https://github.com/rust-bitcoin/rust-lightning cd rust-lightning - git checkout 0.0.121-bindings + git checkout 0.0.124-bindings - name: Rebuild bindings using Apple clang, and check the sample app builds + links run: ./genbindings.sh ./rust-lightning true - name: Rebuild bindings using upstream clang, and check the sample app builds + links diff --git a/c-bindings-gen/src/blocks.rs b/c-bindings-gen/src/blocks.rs index 664ca44..ce6c2b1 100644 --- a/c-bindings-gen/src/blocks.rs +++ b/c-bindings-gen/src/blocks.rs @@ -521,7 +521,7 @@ fn writeln_docs_impl<'a, W: std::io::Write, I>(w: &mut W, attrs: &[syn::Attribut /// this_param is used when returning Self or accepting a self parameter, and should be the /// concrete, mapped type. pub fn write_method_params(w: &mut W, sig: &syn::Signature, this_param: &str, types: &mut TypeResolver, generics: Option<&GenericTypes>, self_ptr: bool, fn_decl: bool) { - if sig.constness.is_some() || sig.asyncness.is_some() || sig.unsafety.is_some() || + if sig.asyncness.is_some() || sig.unsafety.is_some() || sig.abi.is_some() || sig.variadic.is_some() { unimplemented!(); } @@ -540,22 +540,32 @@ pub fn write_method_params(w: &mut W, sig: &syn::Signature, t let mut first_arg = true; let mut num_unused = 0; for inp in sig.inputs.iter() { + let mut handle_self = |is_ref: bool, is_mut: bool| { + write!(w, "{}this_arg: {}{}", if !is_ref { "mut " } else { "" }, + if is_ref { + match (self_ptr, is_mut) { + (true, true) => "*mut ", + (true, false) => "*const ", + (false, true) => "&mut ", + (false, false) => "&", + } + } else { "" }, this_param).unwrap(); + assert!(first_arg); + first_arg = false; + }; match inp { syn::FnArg::Receiver(recv) => { if !recv.attrs.is_empty() { unimplemented!(); } - write!(w, "{}this_arg: {}{}", if recv.reference.is_none() { "mut " } else { "" }, - if recv.reference.is_some() { - match (self_ptr, recv.mutability.is_some()) { - (true, true) => "*mut ", - (true, false) => "*const ", - (false, true) => "&mut ", - (false, false) => "&", - } - } else { "" }, this_param).unwrap(); - assert!(first_arg); - first_arg = false; + handle_self(recv.reference.is_some(), recv.mutability.is_some()); }, syn::FnArg::Typed(arg) => { + if let syn::Pat::Ident(id) = &*arg.pat { + if format!("{}", id.ident) == "self" { + handle_self(id.by_ref.is_some(), id.mutability.is_some()); + continue; + } + } + if types.skip_arg(&*arg.ty, generics) { continue; } if !arg.attrs.is_empty() { unimplemented!(); } // First get the c type so that we can check if it ends up being a reference: @@ -583,14 +593,19 @@ pub fn write_method_params(w: &mut W, sig: &syn::Signature, t write!(w, ")").unwrap(); match &sig.output { syn::ReturnType::Type(_, rtype) => { - write!(w, " -> ").unwrap(); - if let Some(mut remaining_path) = first_seg_self(&*rtype) { - if remaining_path.next().is_none() { - write!(w, "{}", this_param).unwrap(); - return; + let mut ret_ty = Vec::new(); + types.write_c_type(&mut ret_ty, &*rtype, generics, true); + + if !ret_ty.is_empty() { + write!(w, " -> ").unwrap(); + if let Some(mut remaining_path) = first_seg_self(&*rtype) { + if remaining_path.next().is_none() { + write!(w, "{}", this_param).unwrap(); + return; + } } + w.write_all(&ret_ty).unwrap(); } - types.write_c_type(w, &*rtype, generics, true); }, _ => {}, } @@ -606,6 +621,12 @@ pub fn write_method_var_decl_body(w: &mut W, sig: &syn::Signa match inp { syn::FnArg::Receiver(_) => {}, syn::FnArg::Typed(arg) => { + if let syn::Pat::Ident(id) = &*arg.pat { + if format!("{}", id.ident) == "self" { + continue; + } + } + if types.skip_arg(&*arg.ty, generics) { continue; } if !arg.attrs.is_empty() { unimplemented!(); } macro_rules! write_new_var { @@ -666,6 +687,17 @@ pub fn write_method_call_params(w: &mut W, sig: &syn::Signatu } }, syn::FnArg::Typed(arg) => { + if let syn::Pat::Ident(id) = &*arg.pat { + if format!("{}", id.ident) == "self" { + if to_c { + if id.by_ref.is_none() && !matches!(&*arg.ty, syn::Type::Reference(_)) { unimplemented!(); } + write!(w, "self.this_arg").unwrap(); + first_arg = false; + } + continue; + } + } + if types.skip_arg(&*arg.ty, generics) { if !to_c { if !first_arg { @@ -748,14 +780,18 @@ pub fn write_method_call_params(w: &mut W, sig: &syn::Signatu /// Prints concrete generic parameters for a struct/trait/function, including the less-than and /// greater-than symbols, if any generic parameters are defined. pub fn maybe_write_generics(w: &mut W, generics: &syn::Generics, generics_impld: &syn::PathArguments, types: &TypeResolver, concrete_lifetimes: bool) { - maybe_write_generics_intern(w, generics, generics_impld, types, concrete_lifetimes, false); + maybe_write_generics_intern(w, generics, Some(generics_impld), types, concrete_lifetimes, false); } pub fn maybe_write_non_lifetime_generics(w: &mut W, generics: &syn::Generics, generics_impld: &syn::PathArguments, types: &TypeResolver) { - maybe_write_generics_intern(w, generics, generics_impld, types, false, true); + maybe_write_generics_intern(w, generics, Some(generics_impld), types, false, true); } -fn maybe_write_generics_intern(w: &mut W, generics: &syn::Generics, generics_impld: &syn::PathArguments, types: &TypeResolver, concrete_lifetimes: bool, dummy_lifetimes: bool) { +pub fn maybe_write_type_non_lifetime_generics(w: &mut W, generics: &syn::Generics, types: &TypeResolver) { + maybe_write_generics_intern(w, generics, None, types, false, true); +} + +fn maybe_write_generics_intern(w: &mut W, generics: &syn::Generics, generics_impld: Option<&syn::PathArguments>, types: &TypeResolver, concrete_lifetimes: bool, dummy_lifetimes: bool) { let mut gen_types = GenericTypes::new(None); assert!(gen_types.learn_generics(generics, types)); if generics.params.is_empty() { return; } @@ -784,25 +820,28 @@ fn maybe_write_generics_intern(w: &mut W, generics: &syn::Gen for (idx, generic) in generics.params.iter().enumerate() { match generic { syn::GenericParam::Type(type_param) => { - write!(w, "{}", if idx != 0 { ", " } else { "" }).unwrap(); + let mut out = Vec::new(); let type_ident = &type_param.ident; if types.understood_c_type(&syn::parse_quote!(#type_ident), Some(&gen_types)) { - types.write_c_type_in_generic_param(w, &syn::parse_quote!(#type_ident), Some(&gen_types), false); + types.write_c_type_in_generic_param(&mut out, &syn::parse_quote!(#type_ident), Some(&gen_types), false); } else { - if let syn::PathArguments::AngleBracketed(args) = generics_impld { + if let Some(syn::PathArguments::AngleBracketed(args)) = generics_impld { if let syn::GenericArgument::Type(ty) = &args.args[idx] { - types.write_c_type_in_generic_param(w, &ty, Some(&gen_types), false); + types.write_c_type_in_generic_param(&mut out, &ty, Some(&gen_types), false); } } } + if !out.is_empty() { + write!(w, "{}, ", String::from_utf8(out).unwrap()).unwrap(); + } }, syn::GenericParam::Lifetime(lt) => { if dummy_lifetimes { - write!(w, "'_").unwrap(); + write!(w, "'_, ").unwrap(); } else if concrete_lifetimes { - write!(w, "'static").unwrap(); + write!(w, "'static, ").unwrap(); } else { - write!(w, "{}'{}", if idx != 0 { ", " } else { "" }, lt.lifetime.ident).unwrap(); + write!(w, "'{}, ", lt.lifetime.ident).unwrap(); } }, _ => unimplemented!(), diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index 4572f7d..6dd63f8 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -62,18 +62,22 @@ fn maybe_convert_trait_impl(w: &mut W, trait_path: &syn::Path if let Some(t) = types.maybe_resolve_path(&trait_path, Some(generics)) { let for_obj; let full_obj_path; + let native_path; let mut has_inner = false; if let syn::Type::Path(ref p) = for_ty { let resolved_path = types.resolve_path(&p.path, Some(generics)); for_obj = format!("{}", p.path.segments.last().unwrap().ident); full_obj_path = format!("crate::{}", resolved_path); has_inner = types.c_type_has_inner_from_path(&resolved_path); + let (path, name) = full_obj_path.rsplit_once("::").unwrap(); + native_path = path.to_string() + "::native" + name; } else { // We assume that anything that isn't a Path is somehow a generic that ends up in our // derived-types module. let mut for_obj_vec = Vec::new(); types.write_c_type(&mut for_obj_vec, for_ty, Some(generics), false); full_obj_path = String::from_utf8(for_obj_vec).unwrap(); + native_path = full_obj_path.clone(); if !full_obj_path.starts_with(TypeResolver::generated_container_path()) { return; } for_obj = full_obj_path[TypeResolver::generated_container_path().len() + 2..].into(); } @@ -98,7 +102,7 @@ fn maybe_convert_trait_impl(w: &mut W, trait_path: &syn::Path writeln!(w, "#[allow(unused)]").unwrap(); writeln!(w, "pub(crate) extern \"C\" fn {}_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z {{", for_obj).unwrap(); if has_inner { - writeln!(w, "\tcrate::c_types::serialize_obj(unsafe {{ &*(obj as *const native{}) }})", for_obj).unwrap(); + writeln!(w, "\tcrate::c_types::serialize_obj(unsafe {{ &*(obj as *const {}) }})", native_path).unwrap(); } else { writeln!(w, "\t{}_write(unsafe {{ &*(obj as *const {}) }})", for_obj, for_obj).unwrap(); } @@ -221,6 +225,11 @@ fn do_write_impl_trait(w: &mut W, trait_path: &str, _trait_na writeln!(w, "\t\tlet vec = (self.write)(self.this_arg);").unwrap(); writeln!(w, "\t\tw.write_all(vec.as_slice())").unwrap(); writeln!(w, "\t}}\n}}").unwrap(); + writeln!(w, "impl {} for {}Ref {{", trait_path, for_obj).unwrap(); + writeln!(w, "\tfn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {{").unwrap(); + writeln!(w, "\t\tlet vec = (self.0.write)(self.0.this_arg);").unwrap(); + writeln!(w, "\t\tw.write_all(vec.as_slice())").unwrap(); + writeln!(w, "\t}}\n}}").unwrap(); }, _ => panic!(), } @@ -446,6 +455,47 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty ($t: expr, $impl_accessor: expr, $type_resolver: expr, $generic_impls: expr) => { let mut trait_gen_types = gen_types.push_ctx(); assert!(trait_gen_types.learn_generics_with_impls(&$t.generics, $generic_impls, $type_resolver)); + + let mut ref_types = HashSet::new(); + for item in $t.items.iter() { + if let syn::TraitItem::Type(ref t) = &item { + if t.default.is_some() || t.generics.lt_token.is_some() { panic!("10"); } + let mut bounds_iter = t.bounds.iter(); + loop { + match bounds_iter.next().unwrap() { + syn::TypeParamBound::Trait(tr) => { + match $type_resolver.resolve_path(&tr.path, None).as_str() { + "core::ops::Deref"|"core::ops::DerefMut"|"std::ops::Deref"|"std::ops::DerefMut" => { + // Handle cases like + // trait A { + // type B; + // type C: Deref; + // } + // by tracking if we have any B's here and making them + // the *Ref types below. + if let syn::PathArguments::AngleBracketed(args) = &tr.path.segments.iter().last().unwrap().arguments { + if let syn::GenericArgument::Binding(bind) = args.args.iter().last().unwrap() { + assert_eq!(format!("{}", bind.ident), "Target"); + if let syn::Type::Path(p) = &bind.ty { + assert!(p.qself.is_none()); + let mut segs = p.path.segments.iter(); + assert_eq!(format!("{}", segs.next().unwrap().ident), "Self"); + ref_types.insert(format!("{}", segs.next().unwrap().ident)); + assert!(segs.next().is_none()); + } else { panic!(); } + } + } + }, + _ => {}, + } + break; + } + syn::TypeParamBound::Lifetime(_) => {}, + } + } + } + } + for item in $t.items.iter() { match item { syn::TraitItem::Method(m) => { @@ -534,7 +584,11 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty loop { match bounds_iter.next().unwrap() { syn::TypeParamBound::Trait(tr) => { - writeln!(w, "\ttype {} = crate::{};", t.ident, $type_resolver.resolve_path(&tr.path, Some(&gen_types))).unwrap(); + write!(w, "\ttype {} = crate::{}", t.ident, $type_resolver.resolve_path(&tr.path, Some(&gen_types))).unwrap(); + if ref_types.contains(&format!("{}", t.ident)) { + write!(w, "Ref").unwrap(); + } + writeln!(w, ";").unwrap(); for bound in bounds_iter { if let syn::TypeParamBound::Trait(t) = bound { // We only allow for `Sized` here. @@ -577,10 +631,15 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, "impl core::cmp::Eq for {} {{}}", trait_name).unwrap(); writeln!(w, "impl core::cmp::PartialEq for {} {{", trait_name).unwrap(); writeln!(w, "\tfn eq(&self, o: &Self) -> bool {{ (self.eq)(self.this_arg, o) }}\n}}").unwrap(); + writeln!(w, "impl core::cmp::Eq for {}Ref {{}}", trait_name).unwrap(); + writeln!(w, "impl core::cmp::PartialEq for {}Ref {{", trait_name).unwrap(); + writeln!(w, "\tfn eq(&self, o: &Self) -> bool {{ (self.0.eq)(self.0.this_arg, &o.0) }}\n}}").unwrap(); }, ("std::hash::Hash", _, _)|("core::hash::Hash", _, _) => { writeln!(w, "impl core::hash::Hash for {} {{", trait_name).unwrap(); writeln!(w, "\tfn hash(&self, hasher: &mut H) {{ hasher.write_u64((self.hash)(self.this_arg)) }}\n}}").unwrap(); + writeln!(w, "impl core::hash::Hash for {}Ref {{", trait_name).unwrap(); + writeln!(w, "\tfn hash(&self, hasher: &mut H) {{ hasher.write_u64((self.0.hash)(self.0.this_arg)) }}\n}}").unwrap(); }, ("Send", _, _) => {}, ("Sync", _, _) => {}, ("Clone", _, _) => { @@ -594,6 +653,10 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, "\tfn clone(&self) -> Self {{").unwrap(); writeln!(w, "\t\t{}_clone(self)", trait_name).unwrap(); writeln!(w, "\t}}\n}}").unwrap(); + writeln!(w, "impl Clone for {}Ref {{", trait_name).unwrap(); + writeln!(w, "\tfn clone(&self) -> Self {{").unwrap(); + writeln!(w, "\t\tSelf({}_clone(&self.0))", trait_name).unwrap(); + writeln!(w, "\t}}\n}}").unwrap(); }, ("std::fmt::Debug", _, _)|("core::fmt::Debug", _, _) => { writeln!(w, "impl core::fmt::Debug for {} {{", trait_name).unwrap(); @@ -601,6 +664,11 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, "\t\tf.write_str((self.debug_str)(self.this_arg).into_str())").unwrap(); writeln!(w, "\t}}").unwrap(); writeln!(w, "}}").unwrap(); + writeln!(w, "impl core::fmt::Debug for {}Ref {{", trait_name).unwrap(); + writeln!(w, "\tfn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {{").unwrap(); + writeln!(w, "\t\tf.write_str((self.0.debug_str)(self.0.this_arg).into_str())").unwrap(); + writeln!(w, "\t}}").unwrap(); + writeln!(w, "}}").unwrap(); }, (s, i, generic_args) => { if let Some(supertrait) = types.crate_types.traits.get(s) { @@ -617,9 +685,16 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty write!(w, " {}", $s).unwrap(); maybe_write_generics(w, &$supertrait.generics, $generic_args, types, false); writeln!(w, " for {} {{", trait_name).unwrap(); - impl_trait_for_c!($supertrait, format!(".{}", $i), &resolver, $generic_args); writeln!(w, "}}").unwrap(); + + write!(w, "impl").unwrap(); + maybe_write_lifetime_generics(w, &$supertrait.generics, types); + write!(w, " {}", $s).unwrap(); + maybe_write_generics(w, &$supertrait.generics, $generic_args, types, false); + writeln!(w, " for {}Ref {{", trait_name).unwrap(); + impl_trait_for_c!($supertrait, format!(".0.{}", $i), &resolver, $generic_args); + writeln!(w, "}}").unwrap(); } } impl_supertrait!(s, supertrait, i, generic_args); @@ -646,12 +721,22 @@ fn writeln_trait<'a, 'b, W: std::io::Write>(w: &mut W, t: &'a syn::ItemTrait, ty writeln!(w, " for {} {{", trait_name).unwrap(); impl_trait_for_c!(t, "", types, &syn::PathArguments::None); writeln!(w, "}}\n").unwrap(); + + writeln!(w, "pub struct {}Ref({});", trait_name, trait_name).unwrap(); + write!(w, "impl").unwrap(); + maybe_write_lifetime_generics(w, &t.generics, types); + write!(w, " rust{}", t.ident).unwrap(); + maybe_write_generics(w, &t.generics, &syn::PathArguments::None, types, false); + writeln!(w, " for {}Ref {{", trait_name).unwrap(); + impl_trait_for_c!(t, ".0", types, &syn::PathArguments::None); + writeln!(w, "}}\n").unwrap(); + writeln!(w, "// We're essentially a pointer already, or at least a set of pointers, so allow us to be used").unwrap(); writeln!(w, "// directly as a Deref trait in higher-level structs:").unwrap(); - writeln!(w, "impl core::ops::Deref for {} {{\n\ttype Target = Self;", trait_name).unwrap(); - writeln!(w, "\tfn deref(&self) -> &Self {{\n\t\tself\n\t}}\n}}").unwrap(); + writeln!(w, "impl core::ops::Deref for {} {{\n\ttype Target = {}Ref;", trait_name, trait_name).unwrap(); + writeln!(w, "\tfn deref(&self) -> &Self::Target {{\n\t\tunsafe {{ &*(self as *const _ as *const {}Ref) }}\n\t}}\n}}", trait_name).unwrap(); writeln!(w, "impl core::ops::DerefMut for {} {{", trait_name).unwrap(); - writeln!(w, "\tfn deref_mut(&mut self) -> &mut Self {{\n\t\tself\n\t}}\n}}").unwrap(); + writeln!(w, "\tfn deref_mut(&mut self) -> &mut {}Ref {{\n\t\tunsafe {{ &mut *(self as *mut _ as *mut {}Ref) }}\n\t}}\n}}", trait_name, trait_name).unwrap(); } writeln!(w, "/// Calls the free function if one is set").unwrap(); @@ -689,15 +774,26 @@ fn writeln_opaque(w: &mut W, ident: &syn::Ident, struct_name: writeln!(w, "\t/// this to be true and invalidate the object pointed to by inner.").unwrap(); writeln!(w, "\tpub is_owned: bool,").unwrap(); writeln!(w, "}}\n").unwrap(); + + writeln!(w, "impl core::ops::Deref for {} {{", struct_name).unwrap(); + writeln!(w, "\ttype Target = native{};", struct_name).unwrap(); + writeln!(w, "\tfn deref(&self) -> &Self::Target {{ unsafe {{ &*ObjOps::untweak_ptr(self.inner) }} }}").unwrap(); + writeln!(w, "}}").unwrap(); + + writeln!(w, "unsafe impl core::marker::Send for {} {{ }}", struct_name).unwrap(); + writeln!(w, "unsafe impl core::marker::Sync for {} {{ }}", struct_name).unwrap(); + writeln!(w, "impl Drop for {} {{\n\tfn drop(&mut self) {{", struct_name).unwrap(); writeln!(w, "\t\tif self.is_owned && !<*mut native{}>::is_null(self.inner) {{", ident).unwrap(); writeln!(w, "\t\t\tlet _ = unsafe {{ Box::from_raw(ObjOps::untweak_ptr(self.inner)) }};\n\t\t}}\n\t}}\n}}").unwrap(); + writeln!(w, "/// Frees any resources used by the {}, if is_owned is set and inner is non-NULL.", struct_name).unwrap(); writeln!(w, "#[no_mangle]\npub extern \"C\" fn {}_free(this_obj: {}) {{ }}", struct_name, struct_name).unwrap(); writeln!(w, "#[allow(unused)]").unwrap(); writeln!(w, "/// Used only if an object of this type is returned as a trait impl by a method").unwrap(); writeln!(w, "pub(crate) extern \"C\" fn {}_free_void(this_ptr: *mut c_void) {{", struct_name).unwrap(); writeln!(w, "\tlet _ = unsafe {{ Box::from_raw(this_ptr as *mut native{}) }};\n}}", struct_name).unwrap(); + writeln!(w, "#[allow(unused)]").unwrap(); writeln!(w, "impl {} {{", struct_name).unwrap(); writeln!(w, "\tpub(crate) fn get_native_ref(&self) -> &'static native{} {{", struct_name).unwrap(); @@ -712,6 +808,9 @@ fn writeln_opaque(w: &mut W, ident: &syn::Ident, struct_name: writeln!(w, "\t\tlet ret = ObjOps::untweak_ptr(self.inner);").unwrap(); writeln!(w, "\t\tself.inner = core::ptr::null_mut();").unwrap(); writeln!(w, "\t\tret").unwrap(); + writeln!(w, "\t}}").unwrap(); + writeln!(w, "\tpub(crate) fn as_ref_to(&self) -> Self {{").unwrap(); + writeln!(w, "\t\tSelf {{ inner: self.inner, is_owned: false }}").unwrap(); writeln!(w, "\t}}\n}}").unwrap(); write_cpp_wrapper(cpp_headers, &format!("{}", ident), true, None); @@ -1185,28 +1284,29 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet { + takes_self = true; + break; + }, + syn::FnArg::Typed(ty) => { + if let syn::Pat::Ident(id) = &*ty.pat { + if format!("{}", id.ident) == "self" { + takes_self = true; + break; + } + } + } } } - let mut t_gen_args = String::new(); - for (idx, _) in $trait.generics.params.iter().enumerate() { - if idx != 0 { t_gen_args += ", " }; - t_gen_args += "_" - } - // rustc doesn't like <_> if the _ is actually a lifetime, so - // if all the parameters are lifetimes just skip it. - let mut nonlifetime_param = false; - for param in $trait.generics.params.iter() { - if let syn::GenericParam::Lifetime(_) = param {} - else { nonlifetime_param = true; } - } - if !nonlifetime_param { t_gen_args = String::new(); } + let mut t_gen_args_vec = Vec::new(); + maybe_write_type_non_lifetime_generics(&mut t_gen_args_vec, &$trait.generics, &trait_resolver); + let t_gen_args = String::from_utf8(t_gen_args_vec).unwrap(); if takes_self { - write!(w, ">::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait_path, t_gen_args, $m.sig.ident, ident).unwrap(); + write!(w, "::{}(unsafe {{ &mut *(this_arg as *mut native{}) }}, ", ident, $trait_path, t_gen_args, $m.sig.ident, ident).unwrap(); } else { - write!(w, ">::{}(", ident, $trait_path, t_gen_args, $m.sig.ident).unwrap(); + write!(w, "::{}(", ident, $trait_path, t_gen_args, $m.sig.ident).unwrap(); } let mut real_type = "".to_string(); @@ -1226,13 +1326,13 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet(w: &mut W, w_uses: &mut HashSet Str {{", ident, resolved_path).unwrap(); @@ -1456,10 +1558,23 @@ fn writeln_impl(w: &mut W, w_uses: &mut HashSet { + takes_self = true; + if r.mutability.is_some() { takes_mut_self = true; } + if r.reference.is_none() { takes_owned_self = true; } + break; + }, + syn::FnArg::Typed(ty) => { + if let syn::Pat::Ident(id) = &*ty.pat { + if format!("{}", id.ident) == "self" { + takes_self = true; + if id.mutability.is_some() { takes_mut_self = true; } + if id.by_ref.is_none() { takes_owned_self = true; } + break; + } + } + } } } if !takes_mut_self && !takes_self { diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index 47ff515..2e5b33e 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -656,7 +656,7 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr } } - if p.leading_colon.is_some() { + let result = if p.leading_colon.is_some() { let mut res: String = p.segments.iter().enumerate().map(|(idx, seg)| { format!("{}{}", if idx == 0 { "" } else { "::" }, seg.ident) }).collect(); @@ -667,11 +667,10 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr Some(res) } else if let Some(id) = p.get_ident() { self.maybe_resolve_ident(id) + } else if p.segments.len() == 1 { + let seg = p.segments.iter().next().unwrap(); + self.maybe_resolve_ident(&seg.ident) } else { - if p.segments.len() == 1 { - let seg = p.segments.iter().next().unwrap(); - return self.maybe_resolve_ident(&seg.ident); - } let mut seg_iter = p.segments.iter(); let first_seg = seg_iter.next().unwrap(); let remaining: String = seg_iter.map(|seg| { @@ -693,6 +692,13 @@ impl<'mod_lifetime, 'crate_lft: 'mod_lifetime> ImportResolver<'mod_lifetime, 'cr } else if self.library.modules.get(&format!("{}::{}", self.module_path, first_seg.ident)).is_some() { Some(format!("{}::{}{}", self.module_path, first_seg.ident, remaining)) } else { None } + }; + // We're only set up to handle `Vec` imported via the prelude, but its often imported + // via the alloc stdlib crate, so map it here. + if result.as_ref().map(|s| s.as_str()) == Some("alloc::vec::Vec") { + Some("Vec".to_string()) + } else { + result } } @@ -861,6 +867,7 @@ fn initial_clonable_types() -> HashSet { let mut res = HashSet::new(); res.insert("crate::c_types::U5".to_owned()); res.insert("crate::c_types::U128".to_owned()); + res.insert("crate::c_types::ThreeBytes".to_owned()); res.insert("crate::c_types::FourBytes".to_owned()); res.insert("crate::c_types::TwelveBytes".to_owned()); res.insert("crate::c_types::SixteenBytes".to_owned()); @@ -869,6 +876,7 @@ fn initial_clonable_types() -> HashSet { res.insert("crate::c_types::EightU16s".to_owned()); res.insert("crate::c_types::SecretKey".to_owned()); res.insert("crate::c_types::PublicKey".to_owned()); + res.insert("crate::c_types::TweakedPublicKey".to_owned()); res.insert("crate::c_types::Transaction".to_owned()); res.insert("crate::c_types::Witness".to_owned()); res.insert("crate::c_types::WitnessVersion".to_owned()); @@ -1046,10 +1054,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[u8; 3]" if !is_ref => Some("crate::c_types::ThreeBytes"), // Used for RGB values "[u16; 32]" if !is_ref => Some("crate::c_types::ThirtyTwoU16s"), - "str" if is_ref => Some("crate::c_types::Str"), + "str" => Some("crate::c_types::Str"), "alloc::string::String"|"String"|"std::path::PathBuf" => Some("crate::c_types::Str"), - "bitcoin::Address" => Some("crate::c_types::Str"), + "bitcoin::address::Address"|"bitcoin::Address" => Some("crate::c_types::Str"), "std::time::Duration"|"core::time::Duration" => Some("u64"), "std::time::SystemTime" => Some("u64"), @@ -1069,8 +1077,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::bech32::u5"|"bech32::u5" => Some("crate::c_types::U5"), "u128" => Some("crate::c_types::U128"), "core::num::NonZeroU8" => Some("u8"), + "core::num::NonZeroU64" => Some("u64"), "secp256k1::PublicKey"|"bitcoin::secp256k1::PublicKey" => Some("crate::c_types::PublicKey"), + "bitcoin::key::TweakedPublicKey" => Some("crate::c_types::TweakedPublicKey"), "bitcoin::secp256k1::ecdsa::Signature" => Some("crate::c_types::ECDSASignature"), "bitcoin::secp256k1::schnorr::Signature" => Some("crate::c_types::SchnorrSignature"), "bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some("crate::c_types::RecoverableSignature"), @@ -1081,50 +1091,54 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::secp256k1::Scalar" if !is_ref => Some("crate::c_types::BigEndianScalar"), "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), - "bitcoin::blockdata::script::Script"|"bitcoin::Script" => Some("crate::c_types::u8slice"), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some("crate::c_types::derived::CVec_u8Z"), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction"), + "bitcoin::amount::Amount" => Some("u64"), + + "bitcoin::script::Script"|"bitcoin::Script" => Some("crate::c_types::u8slice"), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some("crate::c_types::derived::CVec_u8Z"), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction"), "bitcoin::Witness" => Some("crate::c_types::Witness"), - "bitcoin::TxIn"|"bitcoin::blockdata::transaction::TxIn" if !is_ref => Some("crate::c_types::TxIn"), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" => Some("crate::c_types::TxOut"), - "bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network"), - "bitcoin::address::WitnessVersion" => Some("crate::c_types::WitnessVersion"), - "bitcoin::address::WitnessProgram" => Some("crate::c_types::WitnessProgram"), - "bitcoin::blockdata::block::Header" if is_ref => Some("*const [u8; 80]"), - "bitcoin::blockdata::block::Block" if is_ref => Some("crate::c_types::u8slice"), + "bitcoin::TxIn"|"bitcoin::transaction::TxIn" if !is_ref => Some("crate::c_types::TxIn"), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" => Some("crate::c_types::TxOut"), + "bitcoin::network::constants::Network"|"bitcoin::network::Network" => Some("crate::bitcoin::network::Network"), + "bitcoin::WitnessVersion"|"bitcoin::address::WitnessVersion" => Some("crate::c_types::WitnessVersion"), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" => Some("crate::c_types::WitnessProgram"), + "bitcoin::block::Header" if is_ref => Some("*const [u8; 80]"), + "bitcoin::block::Block" if is_ref => Some("crate::c_types::u8slice"), - "bitcoin::blockdata::locktime::absolute::LockTime" => Some("u32"), + "bitcoin::locktime::absolute::LockTime" => Some("u32"), - "bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"), + "bitcoin::Psbt"|"bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"| - "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::ScriptHash"|"bitcoin::ScriptHash" if !is_ref => Some("crate::c_types::TwentyBytes"), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"| - "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::ScriptHash"|"bitcoin::ScriptHash" if is_ref => Some("*const [u8; 20]"), - "bitcoin::hash_types::WScriptHash" + "bitcoin::WScriptHash"|"bitcoin::WScriptHash" if is_ref => Some("*const [u8; 32]"), // Newtypes that we just expose in their original form. - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash" if is_ref => Some("*const [u8; 32]"), - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash"|"bitcoin::hashes::sha256::Hash" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "bitcoin::secp256k1::Message" if is_ref => Some("*const [u8; 32]"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some("*const [u8; 32]"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"), "lightning::io::Read" => Some("crate::c_types::u8slice"), @@ -1159,7 +1173,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[u8]" if is_ref => Some(""), "[usize]" if is_ref => Some(""), - "str" if is_ref => Some(""), + "str" => Some(""), "alloc::string::String"|"String"|"std::path::PathBuf" => Some(""), "std::io::Error"|"lightning::io::Error"|"lightning::io::ErrorKind" => Some(""), // Note that we'll panic for String if is_ref, as we only have non-owned memory, we @@ -1179,9 +1193,12 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::bech32::u5"|"bech32::u5" => Some(""), "u128" => Some(""), "core::num::NonZeroU8" => Some("core::num::NonZeroU8::new("), + "core::num::NonZeroU64" => Some("core::num::NonZeroU64::new("), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" if is_ref => Some("&"), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(""), + "bitcoin::key::TweakedPublicKey" if is_ref => Some("&"), + "bitcoin::key::TweakedPublicKey" => Some(""), "bitcoin::secp256k1::ecdsa::Signature"|"bitcoin::secp256k1::schnorr::Signature" if is_ref => Some("&"), "bitcoin::secp256k1::ecdsa::Signature"|"bitcoin::secp256k1::schnorr::Signature" => Some(""), "bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(""), @@ -1192,55 +1209,57 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::secp256k1::Scalar" if !is_ref => Some(""), "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes("), - "bitcoin::blockdata::script::Script"|"bitcoin::Script" => Some("::bitcoin::blockdata::script::Script::from_bytes("), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some("::bitcoin::blockdata::script::ScriptBuf::from("), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("&"), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(""), + "bitcoin::amount::Amount" => Some("::bitcoin::amount::Amount::from_sat("), + + "bitcoin::script::Script"|"bitcoin::Script" => Some("::bitcoin::script::Script::from_bytes("), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some("::bitcoin::script::ScriptBuf::from("), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("&"), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" => Some(""), "bitcoin::Witness" if is_ref => Some("&"), "bitcoin::Witness" => Some(""), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" => Some("crate::c_types::C_to_bitcoin_outpoint("), - "bitcoin::TxIn"|"bitcoin::blockdata::transaction::TxIn" if !is_ref => Some(""), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(""), - "bitcoin::network::constants::Network" => Some(""), - "bitcoin::address::WitnessVersion" => Some(""), - "bitcoin::address::WitnessProgram" if is_ref => Some("&"), - "bitcoin::address::WitnessProgram" if !is_ref => Some(""), - "bitcoin::blockdata::block::Header" => Some("&::bitcoin::consensus::encode::deserialize(unsafe { &*"), - "bitcoin::blockdata::block::Block" if is_ref => Some("&::bitcoin::consensus::encode::deserialize("), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" => Some("crate::c_types::C_to_bitcoin_outpoint("), + "bitcoin::TxIn"|"bitcoin::transaction::TxIn" if !is_ref => Some(""), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" if !is_ref => Some(""), + "bitcoin::network::constants::Network"|"bitcoin::network::Network" => Some(""), + "bitcoin::WitnessVersion"|"bitcoin::address::WitnessVersion" => Some(""), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" if is_ref => Some("&"), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" if !is_ref => Some(""), + "bitcoin::block::Header" => Some("&::bitcoin::consensus::encode::deserialize(unsafe { &*"), + "bitcoin::block::Block" if is_ref => Some("&::bitcoin::consensus::encode::deserialize("), - "bitcoin::blockdata::locktime::absolute::LockTime" => Some("::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus("), + "bitcoin::locktime::absolute::LockTime" => Some("::bitcoin::locktime::absolute::LockTime::from_consensus("), - "bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some("::bitcoin::psbt::PartiallySignedTransaction::deserialize("), + "bitcoin::Psbt"|"bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some("::bitcoin::Psbt::deserialize("), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash" if !is_ref => - Some("bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array("), + Some("bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array("), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash" if is_ref => - Some("&bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), - "bitcoin::hash_types::WPubkeyHash" if is_ref => - Some("&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), - "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if !is_ref => - Some("bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array("), - "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if is_ref => - Some("&bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), - "bitcoin::hash_types::WScriptHash" if is_ref => - Some("&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), + Some("&bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash" if is_ref => + Some("&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), + "bitcoin::ScriptHash"|"bitcoin::ScriptHash" if !is_ref => + Some("bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array("), + "bitcoin::ScriptHash"|"bitcoin::ScriptHash" if is_ref => + Some("&bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), + "bitcoin::WScriptHash"|"bitcoin::WScriptHash" if is_ref => + Some("&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *"), // Newtypes that we just expose in their original form. - "bitcoin::hash_types::Txid" if is_ref => Some("&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*"), - "bitcoin::hash_types::Txid" if !is_ref => Some("::bitcoin::hash_types::Txid::from_slice(&"), + "bitcoin::Txid"|"bitcoin::hash_types::Txid" if is_ref => Some("&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*"), + "bitcoin::Txid"|"bitcoin::hash_types::Txid" if !is_ref => Some("::bitcoin::hash_types::Txid::from_slice(&"), "bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" => Some("::bitcoin::hash_types::BlockHash::from_slice(&"), - "bitcoin::blockdata::constants::ChainHash" => Some("::bitcoin::blockdata::constants::ChainHash::from(&"), - "lightning::ln::PaymentHash" if !is_ref => Some("::lightning::ln::PaymentHash("), - "lightning::ln::PaymentHash" if is_ref => Some("&::lightning::ln::PaymentHash(unsafe { *"), - "lightning::ln::PaymentPreimage" if !is_ref => Some("::lightning::ln::PaymentPreimage("), - "lightning::ln::PaymentPreimage" if is_ref => Some("&::lightning::ln::PaymentPreimage(unsafe { *"), - "lightning::ln::PaymentSecret" if !is_ref => Some("::lightning::ln::PaymentSecret("), + "bitcoin::constants::ChainHash" => Some("::bitcoin::constants::ChainHash::from(&"), + "bitcoin::hashes::sha256::Hash" if is_ref => Some("&::bitcoin::hashes::sha256::Hash::from_slice(&unsafe { &*"), + "bitcoin::hashes::sha256::Hash" => Some("::bitcoin::hashes::sha256::Hash::from_slice(&"), + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" if !is_ref => Some("::lightning::ln::types::PaymentHash("), + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" if is_ref => Some("&::lightning::ln::types::PaymentHash(unsafe { *"), + "lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if !is_ref => Some("::lightning::ln::types::PaymentPreimage("), + "lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" if is_ref => Some("&::lightning::ln::types::PaymentPreimage(unsafe { *"), + "lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" if !is_ref => Some("::lightning::ln::types::PaymentSecret("), "lightning::ln::channelmanager::PaymentId" if !is_ref => Some("::lightning::ln::channelmanager::PaymentId("), "lightning::ln::channelmanager::PaymentId" if is_ref=> Some("&::lightning::ln::channelmanager::PaymentId( unsafe { *"), "lightning::ln::channelmanager::InterceptId" if !is_ref => Some("::lightning::ln::channelmanager::InterceptId("), "lightning::ln::channelmanager::InterceptId" if is_ref=> Some("&::lightning::ln::channelmanager::InterceptId( unsafe { *"), - "lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some("::lightning::ln::ChannelId("), - "lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some("&::lightning::ln::ChannelId(unsafe { *"), "lightning::sign::KeyMaterial" if !is_ref => Some("::lightning::sign::KeyMaterial("), "lightning::sign::KeyMaterial" if is_ref=> Some("&::lightning::sign::KeyMaterial( unsafe { *"), "lightning::chain::ClaimId" if !is_ref => Some("::lightning::chain::ClaimId("), @@ -1275,6 +1294,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[usize]" if is_ref => Some(".to_slice()"), "str" if is_ref => Some(".into_str()"), + "str" if !is_ref => Some(".into_string()"), "alloc::string::String"|"String" => Some(".into_string()"), "std::path::PathBuf" => Some(".into_pathbuf()"), "std::io::Error"|"lightning::io::Error" => Some(".to_rust()"), @@ -1294,8 +1314,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"), "u128" => Some(".into()"), "core::num::NonZeroU8" => Some(").expect(\"Value must be non-zero\")"), + "core::num::NonZeroU64" => Some(").expect(\"Value must be non-zero\")"), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(".into_rust()"), + "bitcoin::key::TweakedPublicKey" => Some(".into_rust()"), "bitcoin::secp256k1::ecdsa::Signature"|"bitcoin::secp256k1::schnorr::Signature" => Some(".into_rust()"), "bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(".into_rust()"), "bitcoin::secp256k1::SecretKey" if !is_ref => Some(".into_rust()"), @@ -1304,46 +1326,53 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::secp256k1::Scalar" => Some(".into_rust()"), "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some(".data)"), - "bitcoin::blockdata::script::Script"|"bitcoin::Script" => Some(".to_slice())"), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some(".into_rust())"), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(".into_bitcoin()"), + "bitcoin::amount::Amount" => Some(")"), + + "bitcoin::script::Script"|"bitcoin::Script" => Some(".to_slice())"), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some(".into_rust())"), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" => Some(".into_bitcoin()"), "bitcoin::Witness" => Some(".into_bitcoin()"), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" => Some(")"), - "bitcoin::TxIn"|"bitcoin::blockdata::transaction::TxIn" if !is_ref => Some(".into_rust()"), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some(".into_rust()"), - "bitcoin::network::constants::Network" => Some(".into_bitcoin()"), - "bitcoin::address::WitnessVersion" => Some(".into()"), - "bitcoin::address::WitnessProgram" => Some(".into_bitcoin()"), - "bitcoin::blockdata::block::Header" => Some(" }).unwrap()"), - "bitcoin::blockdata::block::Block" => Some(".to_slice()).unwrap()"), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" => Some(")"), + "bitcoin::TxIn"|"bitcoin::transaction::TxIn" if !is_ref => Some(".into_rust()"), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" if !is_ref => Some(".into_rust()"), + "bitcoin::network::constants::Network"|"bitcoin::network::Network" => Some(".into_bitcoin()"), + "bitcoin::WitnessVersion"|"bitcoin::address::WitnessVersion" => Some(".into()"), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" => Some(".into_bitcoin()"), + "bitcoin::block::Header" => Some(" }).unwrap()"), + "bitcoin::block::Block" => Some(".to_slice()).unwrap()"), - "bitcoin::blockdata::locktime::absolute::LockTime" => Some(")"), + "bitcoin::locktime::absolute::LockTime" => Some(")"), - "bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(".as_slice()).expect(\"Invalid PSBT format\")"), + "bitcoin::Psbt"|"bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(".as_slice()).expect(\"Invalid PSBT format\")"), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"|"bitcoin::hash_types::WScriptHash"| + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::WScriptHash"|"bitcoin::hash_types::WScriptHash"| "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if !is_ref => Some(".data))"), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"|"bitcoin::hash_types::WScriptHash"| + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::WScriptHash"|"bitcoin::hash_types::WScriptHash"| "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if is_ref => Some(" }.clone()))"), // Newtypes that we just expose in their original form. - "bitcoin::hash_types::Txid" if is_ref => Some(" }[..]).unwrap()"), - "bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"), + "bitcoin::Txid"|"bitcoin::hash_types::Txid" if is_ref => Some(" }[..]).unwrap()"), + "bitcoin::Txid"|"bitcoin::hash_types::Txid" => Some(".data[..]).unwrap()"), "bitcoin::hash_types::BlockHash"|"bitcoin::BlockHash" if !is_ref => Some(".data[..]).unwrap()"), - "bitcoin::blockdata::constants::ChainHash" if !is_ref => Some(".data)"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "bitcoin::constants::ChainHash" if !is_ref => Some(".data)"), + "bitcoin::hashes::sha256::Hash" => Some(" }[..]).unwrap()"), + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some(".data)"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some(" })"), // List of traits we map (possibly during processing of other files): @@ -1361,8 +1390,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[u8]" if is_ref => Some(("crate::c_types::u8slice::from_slice(", ")")), "[usize]" if is_ref => Some(("crate::c_types::usizeslice::from_slice(", ")")), - "bitcoin::blockdata::block::Header" if is_ref => Some(("{ let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(", ")); s }")), - "bitcoin::blockdata::block::Block" if is_ref => Some(("::bitcoin::consensus::encode::serialize(", ")")), + "bitcoin::block::Header" if is_ref => Some(("{ let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(", ")); s }")), + "bitcoin::block::Block" if is_ref => Some(("::bitcoin::consensus::encode::serialize(", ")")), _ => None, }.map(|s| s.to_owned()) @@ -1383,20 +1412,22 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[u8; 16]" if !is_ref => Some("crate::c_types::SixteenBytes { data: "), "[u8; 12]" if !is_ref => Some("crate::c_types::TwelveBytes { data: "), "[u8; 4]" if !is_ref => Some("crate::c_types::FourBytes { data: "), + "[u8; 3]" if !is_ref => Some("crate::c_types::ThreeBytes { data: "), "[u8; 3]" if is_ref => Some(""), "[u16; 32]" if !is_ref => Some("crate::c_types::ThirtyTwoU16s { data: "), "[u8]" if is_ref => Some("local_"), "[usize]" if is_ref => Some("local_"), - "str" if is_ref => Some(""), + "str" => Some(""), "alloc::string::String"|"String"|"std::path::PathBuf" => Some(""), - "bitcoin::Address" => Some("alloc::string::ToString::to_string(&"), + "bitcoin::address::Address"|"bitcoin::Address" => Some("alloc::string::ToString::to_string(&"), "std::time::Duration"|"core::time::Duration" => Some(""), "std::time::SystemTime" => Some(""), - "std::io::Error"|"lightning::io::Error" => Some("crate::c_types::IOError::from_rust("), + "std::io::Error" => Some("crate::c_types::IOError::from_rust("), + "lightning::io::Error" => Some("crate::c_types::IOError::from_bitcoin("), "lightning::io::ErrorKind" => Some("crate::c_types::IOError::from_rust_kind("), "core::fmt::Arguments" => Some("alloc::format!(\"{}\", "), @@ -1412,8 +1443,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::bech32::u5"|"bech32::u5" => Some(""), "u128" => Some(""), + "core::num::NonZeroU64" => Some(""), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some("crate::c_types::PublicKey::from_rust(&"), + "bitcoin::key::TweakedPublicKey" => Some("crate::c_types::TweakedPublicKey::from_rust(&"), "bitcoin::secp256k1::ecdsa::Signature" => Some("crate::c_types::ECDSASignature::from_rust(&"), "bitcoin::secp256k1::schnorr::Signature" => Some("crate::c_types::SchnorrSignature::from_rust(&"), "bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some("crate::c_types::RecoverableSignature::from_rust(&"), @@ -1423,48 +1456,53 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::secp256k1::Scalar" if !is_ref => Some("crate::c_types::BigEndianScalar::from_rust(&"), "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), - "bitcoin::blockdata::script::Script"|"bitcoin::Script" => Some("crate::c_types::u8slice::from_slice("), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some(""), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction::from_bitcoin(&"), + "bitcoin::amount::Amount" => Some(""), + + "bitcoin::script::Script"|"bitcoin::Script" => Some("crate::c_types::u8slice::from_slice("), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" => Some(""), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" => Some("crate::c_types::Transaction::from_bitcoin(&"), "bitcoin::Witness" if is_ref => Some("crate::c_types::Witness::from_bitcoin("), "bitcoin::Witness" if !is_ref => Some("crate::c_types::Witness::from_bitcoin(&"), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" if is_ref => Some("crate::c_types::bitcoin_to_C_outpoint("), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" if !is_ref => Some("crate::c_types::bitcoin_to_C_outpoint(&"), - "bitcoin::TxIn"|"bitcoin::blockdata::transaction::TxIn" if !is_ref => Some("crate::c_types::TxIn::from_rust(&"), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust(&"), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" if is_ref => Some("crate::c_types::TxOut::from_rust("), - "bitcoin::network::constants::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("), - "bitcoin::address::WitnessVersion" => Some(""), - "bitcoin::address::WitnessProgram" => Some("crate::c_types::WitnessProgram::from_bitcoin("), - "bitcoin::blockdata::block::Header" if is_ref => Some("&local_"), - "bitcoin::blockdata::block::Block" if is_ref => Some("crate::c_types::u8slice::from_slice(&local_"), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" if is_ref => Some("crate::c_types::bitcoin_to_C_outpoint("), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" if !is_ref => Some("crate::c_types::bitcoin_to_C_outpoint(&"), + "bitcoin::TxIn"|"bitcoin::transaction::TxIn" if !is_ref => Some("crate::c_types::TxIn::from_rust(&"), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" if !is_ref => Some("crate::c_types::TxOut::from_rust(&"), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" if is_ref => Some("crate::c_types::TxOut::from_rust("), + "bitcoin::network::constants::Network"|"bitcoin::network::Network" => Some("crate::bitcoin::network::Network::from_bitcoin("), + "bitcoin::WitnessVersion"|"bitcoin::address::WitnessVersion" => Some(""), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" => Some("crate::c_types::WitnessProgram::from_bitcoin("), + "bitcoin::block::Header" if is_ref => Some("&local_"), + "bitcoin::block::Block" if is_ref => Some("crate::c_types::u8slice::from_slice(&local_"), - "bitcoin::blockdata::locktime::absolute::LockTime" => Some(""), + "bitcoin::locktime::absolute::LockTime" => Some(""), - "bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(""), + "bitcoin::Psbt"|"bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(""), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"|"bitcoin::hash_types::WScriptHash"| + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::WScriptHash"|"bitcoin::hash_types::WScriptHash"| "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if !is_ref => Some("crate::c_types::TwentyBytes { data: *"), // Newtypes that we just expose in their original form. - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash"|"bitcoin::hashes::sha256::Hash" if is_ref => Some(""), - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash"|"bitcoin::hashes::sha256::Hash" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: *"), "bitcoin::secp256k1::Message" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), "bitcoin::secp256k1::Message" if is_ref => Some(""), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some("&"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "), "lightning::io::Read" => Some("crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec("), @@ -1488,17 +1526,18 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "[u8; 16]" if !is_ref => Some(" }"), "[u8; 12]" if !is_ref => Some(" }"), "[u8; 4]" if !is_ref => Some(" }"), + "[u8; 3]" if !is_ref => Some(" }"), "[u8; 3]" if is_ref => Some(""), "[u16; 32]" if !is_ref => Some(" }"), "[u8]" if is_ref => Some(""), "[usize]" if is_ref => Some(""), - "str" if is_ref => Some(".into()"), + "str" => Some(".into()"), "alloc::string::String"|"String"|"std::path::PathBuf" if is_ref => Some(".as_str().into()"), "alloc::string::String"|"String"|"std::path::PathBuf" => Some(".into()"), - "bitcoin::Address" => Some(").into()"), + "bitcoin::address::Address"|"bitcoin::Address" => Some(").into()"), "std::time::Duration"|"core::time::Duration" => Some(".as_secs()"), "std::time::SystemTime" => Some(".duration_since(::std::time::SystemTime::UNIX_EPOCH).expect(\"Times must be post-1970\").as_secs()"), @@ -1517,8 +1556,10 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"), "u128" => Some(".into()"), + "core::num::NonZeroU64" => Some(".into()"), "bitcoin::secp256k1::PublicKey"|"secp256k1::PublicKey" => Some(")"), + "bitcoin::key::TweakedPublicKey" => Some(")"), "bitcoin::secp256k1::ecdsa::Signature"|"bitcoin::secp256k1::schnorr::Signature" => Some(")"), "bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(")"), "bitcoin::secp256k1::SecretKey" if !is_ref => Some(")"), @@ -1527,45 +1568,50 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { "bitcoin::secp256k1::Scalar" if !is_ref => Some(")"), "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some(".secret_bytes() }"), - "bitcoin::blockdata::script::Script"|"bitcoin::Script" => Some(".as_ref())"), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" if is_ref => Some(".as_bytes().to_vec().into()"), - "bitcoin::blockdata::script::ScriptBuf"|"bitcoin::ScriptBuf" if !is_ref => Some(".to_bytes().into()"), - "bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(")"), + "bitcoin::amount::Amount" => Some(".to_sat()"), + + "bitcoin::script::Script"|"bitcoin::Script" => Some(".as_ref())"), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" if is_ref => Some(".as_bytes().to_vec().into()"), + "bitcoin::script::ScriptBuf"|"bitcoin::ScriptBuf" if !is_ref => Some(".to_bytes().into()"), + "bitcoin::transaction::Transaction"|"bitcoin::Transaction" => Some(")"), "bitcoin::Witness" => Some(")"), - "bitcoin::OutPoint"|"bitcoin::blockdata::transaction::OutPoint" => Some(")"), - "bitcoin::TxIn"|"bitcoin::blockdata::transaction::TxIn" if !is_ref => Some(")"), - "bitcoin::TxOut"|"bitcoin::blockdata::transaction::TxOut" => Some(")"), - "bitcoin::network::constants::Network" => Some(")"), - "bitcoin::address::WitnessVersion" => Some(".into()"), - "bitcoin::address::WitnessProgram" => Some(")"), - "bitcoin::blockdata::block::Header" if is_ref => Some(""), - "bitcoin::blockdata::block::Block" if is_ref => Some(")"), + "bitcoin::OutPoint"|"bitcoin::transaction::OutPoint" => Some(")"), + "bitcoin::TxIn"|"bitcoin::transaction::TxIn" if !is_ref => Some(")"), + "bitcoin::TxOut"|"bitcoin::transaction::TxOut" => Some(")"), + "bitcoin::network::constants::Network"|"bitcoin::network::Network" => Some(")"), + "bitcoin::WitnessVersion"|"bitcoin::address::WitnessVersion" => Some(".into()"), + "bitcoin::WitnessProgram"|"bitcoin::address::WitnessProgram" => Some(")"), + "bitcoin::block::Header" if is_ref => Some(""), + "bitcoin::block::Block" if is_ref => Some(")"), - "bitcoin::blockdata::locktime::absolute::LockTime" => Some(".to_consensus_u32()"), + "bitcoin::locktime::absolute::LockTime" => Some(".to_consensus_u32()"), - "bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(".serialize().into()"), + "bitcoin::Psbt"|"bitcoin::psbt::PartiallySignedTransaction" if !is_ref => Some(".serialize().into()"), "bitcoin::PubkeyHash"|"bitcoin::hash_types::PubkeyHash"| - "bitcoin::hash_types::WPubkeyHash"|"bitcoin::hash_types::WScriptHash"| + "bitcoin::WPubkeyHash"|"bitcoin::hash_types::WPubkeyHash"| + "bitcoin::WScriptHash"|"bitcoin::hash_types::WScriptHash"| "bitcoin::ScriptHash"|"bitcoin::hash_types::ScriptHash" if !is_ref => Some(".as_ref() }"), // Newtypes that we just expose in their original form. - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash"|"bitcoin::hashes::sha256::Hash" if is_ref => Some(".as_ref()"), - "bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::blockdata::constants::ChainHash" + "bitcoin::Txid"|"bitcoin::hash_types::Txid"|"bitcoin::BlockHash"|"bitcoin::hash_types::BlockHash"|"bitcoin::hashes::sha256::Hash"|"bitcoin::constants::ChainHash"|"bitcoin::hashes::sha256::Hash" if !is_ref => Some(".as_ref() }"), "bitcoin::secp256k1::Message" if !is_ref => Some(".as_ref().clone() }"), "bitcoin::secp256k1::Message" if is_ref => Some(".as_ref()"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if is_ref => Some(".0"), - "lightning::ln::PaymentHash"|"lightning::ln::PaymentPreimage"|"lightning::ln::PaymentSecret" + "lightning::ln::types::PaymentHash"|"lightning_types::payment::PaymentHash" + |"lightning::ln::types::PaymentPreimage"|"lightning_types::payment::PaymentPreimage" + |"lightning::ln::types::PaymentSecret"|"lightning_types::payment::PaymentSecret" |"lightning::ln::channelmanager::PaymentId"|"lightning::ln::channelmanager::InterceptId" |"lightning::sign::KeyMaterial"|"lightning::chain::ClaimId" - |"lightning::ln::ChannelId"|"lightning::ln::channel_id::ChannelId" if !is_ref => Some(".0 }"), "lightning::io::Read" => Some("))"), @@ -1577,6 +1623,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { fn empty_val_check_suffix_from_path(&self, full_path: &str) -> Option<&str> { match full_path { "secp256k1::PublicKey"|"bitcoin::secp256k1::PublicKey" => Some(".is_null()"), + "str" => Some(".is_empty()"), _ => None } } @@ -1961,11 +2008,19 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // the original crate. write!(w, "{}", self.real_rust_type_mapping(&resolved)).unwrap(); } else { + if let Some(trait_impls) = self.crate_types.traits_impld.get(&resolved) { + if self.crate_types.traits.get(&resolved).is_none() && trait_impls.len() == 1 { + write!(w, "crate::{}", trait_impls[0]).unwrap(); + return; + } + } write!(w, "crate::{}", resolved).unwrap(); } } - if let syn::PathArguments::AngleBracketed(args) = &path.segments.iter().last().unwrap().arguments { - self.write_rust_generic_arg(w, generics_resolver, args.args.iter(), with_ref_lifetime); + if !generated_crate_ref { + if let syn::PathArguments::AngleBracketed(args) = &path.segments.iter().last().unwrap().arguments { + self.write_rust_generic_arg(w, generics_resolver, args.args.iter(), with_ref_lifetime); + } } } else { if path.leading_colon.is_some() { @@ -2029,7 +2084,11 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } if let Some(resolved_ty) = self.maybe_resolve_path(&p.path, generics) { generate_crate_ref |= self.maybe_resolve_path(&p.path, None).as_ref() != Some(&resolved_ty); - if self.crate_types.traits.get(&resolved_ty).is_none() { generate_crate_ref = false; } + let mut is_trait = self.crate_types.traits.get(&resolved_ty).is_some(); + is_trait |= self.crate_types.traits_impld.get(&resolved_ty).is_some(); + if !is_trait { + generate_crate_ref = false; + } } self.write_rust_path(w, generics, &p.path, with_ref_lifetime, generate_crate_ref); }, @@ -2214,7 +2273,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } fn write_conversion_inline_intern Option, DL: Fn(&mut W, &DeclType, &str, bool, bool), SC: Fn(bool, Option<&str>) -> String> + LP: Fn(&str, bool, bool) -> Option, DL: Fn(&mut W, &DeclType, &str, bool, bool, bool), SC: Fn(bool, Option<&str>) -> String> (&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, is_mut: bool, ptr_for_ref: bool, tupleconv: &str, prefix: bool, sliceconv: SC, path_lookup: LP, decl_lookup: DL) { match generics.resolve_type(t) { @@ -2237,14 +2296,14 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } else if let Some(c_type) = path_lookup(&resolved_path, is_ref, ptr_for_ref) { write!(w, "{}", c_type).unwrap(); } else if let Some((_, generics)) = self.crate_types.opaques.get(&resolved_path) { - decl_lookup(w, &DeclType::StructImported { generics: &generics }, &resolved_path, is_ref, is_mut); + decl_lookup(w, &DeclType::StructImported { generics: &generics }, &resolved_path, is_ref, is_mut, false); } else if self.crate_types.mirrored_enums.get(&resolved_path).is_some() { - decl_lookup(w, &DeclType::MirroredEnum, &resolved_path, is_ref, is_mut); + decl_lookup(w, &DeclType::MirroredEnum, &resolved_path, is_ref, is_mut, false); } else if let Some(t) = self.crate_types.traits.get(&resolved_path) { - decl_lookup(w, &DeclType::Trait(t), &resolved_path, is_ref, is_mut); + decl_lookup(w, &DeclType::Trait(t), &resolved_path, is_ref, is_mut, false); } else if let Some(ident) = single_ident_generic_path_to_ident(&p.path) { if let Some(decl_type) = self.types.maybe_resolve_declared(ident) { - decl_lookup(w, decl_type, &self.maybe_resolve_ident(ident).unwrap(), is_ref, is_mut); + decl_lookup(w, decl_type, &self.maybe_resolve_ident(ident).unwrap(), is_ref, is_mut, false); } else { unimplemented!(); } } else { if let Some(trait_impls) = self.crate_types.traits_impld.get(&resolved_path) { @@ -2253,7 +2312,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // in the whole crate, just treat it as a reference to whatever the // implementor is. let implementor = self.crate_types.opaques.get(&trait_impls[0]).unwrap(); - decl_lookup(w, &DeclType::StructImported { generics: &implementor.1 }, &trait_impls[0], true, is_mut); + decl_lookup(w, &DeclType::StructImported { generics: &implementor.1 }, &trait_impls[0], true, is_mut, true); return; } } @@ -2337,11 +2396,14 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { fn write_to_c_conversion_inline_prefix_inner(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, ptr_for_ref: bool, from_ptr: bool) { self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "() /*", true, |_, _| "local_".to_owned(), |a, b, c| self.to_c_conversion_inline_prefix_from_path(a, b, c), - |w, decl_type, decl_path, is_ref, _is_mut| { + |w, decl_type, decl_path, is_ref, _is_mut, is_trait_alias| { match decl_type { DeclType::MirroredEnum if is_ref && ptr_for_ref => write!(w, "crate::{}::from_native(", decl_path).unwrap(), DeclType::MirroredEnum if is_ref => write!(w, "&crate::{}::from_native(", decl_path).unwrap(), DeclType::MirroredEnum => write!(w, "crate::{}::native_into(", decl_path).unwrap(), + DeclType::StructImported {..} if is_trait_alias => { + if is_ref { write!(w, "&").unwrap(); } + }, DeclType::EnumIgnored {..}|DeclType::StructImported {..} if is_ref && from_ptr => { if !ptr_for_ref { write!(w, "&").unwrap(); } write!(w, "crate::{} {{ inner: unsafe {{ (", decl_path).unwrap() @@ -2366,8 +2428,11 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { fn write_to_c_conversion_inline_suffix_inner(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, ptr_for_ref: bool, from_ptr: bool) { self.write_conversion_inline_intern(w, t, generics, is_ref, false, ptr_for_ref, "*/", false, |_, _| ".into()".to_owned(), |a, b, c| self.to_c_conversion_inline_suffix_from_path(a, b, c), - |w, decl_type, full_path, is_ref, _is_mut| match decl_type { + |w, decl_type, full_path, is_ref, _is_mut, is_trait_alias| match decl_type { DeclType::MirroredEnum => write!(w, ")").unwrap(), + DeclType::StructImported {..} if is_trait_alias => { + write!(w, ".as_ref_to()").unwrap(); + }, DeclType::EnumIgnored { generics }|DeclType::StructImported { generics } if is_ref => { write!(w, " as *const {}<", full_path).unwrap(); for param in generics.params.iter() { @@ -2404,7 +2469,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { fn write_from_c_conversion_prefix_inner(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>, is_ref: bool, _ptr_for_ref: bool) { self.write_conversion_inline_intern(w, t, generics, is_ref, false, false, "() /*", true, |_, _| "&local_".to_owned(), |a, b, _c| self.from_c_conversion_prefix_from_path(a, b), - |w, decl_type, _full_path, is_ref, _is_mut| match decl_type { + |w, decl_type, _full_path, is_ref, _is_mut, _is_trait_alias| match decl_type { DeclType::StructImported {..} if is_ref => write!(w, "").unwrap(), DeclType::StructImported {..} if !is_ref => write!(w, "*unsafe {{ Box::from_raw(").unwrap(), DeclType::MirroredEnum if is_ref => write!(w, "&").unwrap(), @@ -2425,7 +2490,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { (true, Some(_)) => unreachable!(), }, |a, b, _c| self.from_c_conversion_suffix_from_path(a, b), - |w, decl_type, _full_path, is_ref, is_mut| match decl_type { + |w, decl_type, _full_path, is_ref, is_mut, is_trait_alias| match decl_type { + DeclType::StructImported {..} if is_trait_alias => write!(w, ".as_ref_to()").unwrap(), DeclType::StructImported {..} if is_ref && ptr_for_ref => write!(w, "XXX unimplemented").unwrap(), DeclType::StructImported {..} if is_mut && is_ref => write!(w, ".get_native_mut_ref()").unwrap(), DeclType::StructImported {..} if is_ref => write!(w, ".get_native_ref()").unwrap(), @@ -2442,19 +2508,19 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // Note that compared to the above conversion functions, the following two are generally // significantly undertested: pub fn write_from_c_conversion_to_ref_prefix(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>) { - self.write_conversion_inline_intern(w, t, generics, false, false, false, "() /*", true, |_, _| "&local_".to_owned(), + self.write_conversion_inline_intern(w, t, generics, true, false, false, "() /*", true, |_, _| "&local_".to_owned(), |a, b, _c| { if let Some(conv) = self.from_c_conversion_prefix_from_path(a, b) { Some(format!("&{}", conv)) } else { None } }, - |w, decl_type, _full_path, is_ref, _is_mut| match decl_type { - DeclType::StructImported {..} if !is_ref => write!(w, "").unwrap(), + |w, decl_type, _full_path, _is_ref, _is_mut, _is_trait_alias| match decl_type { + DeclType::StructImported {..} => write!(w, "").unwrap(), _ => unimplemented!(), }); } pub fn write_from_c_conversion_to_ref_suffix(&self, w: &mut W, t: &syn::Type, generics: Option<&GenericTypes>) { - self.write_conversion_inline_intern(w, t, generics, false, false, false, "*/", false, + self.write_conversion_inline_intern(w, t, generics, true, false, false, "*/", false, |has_inner, map_str_opt| match (has_inner, map_str_opt) { (false, Some(map_str)) => format!(".iter(){}.collect::>()[..]", map_str), (false, None) => ".iter().collect::>()[..]".to_owned(), @@ -2462,8 +2528,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { (true, Some(_)) => unreachable!(), }, |a, b, _c| self.from_c_conversion_suffix_from_path(a, b), - |w, decl_type, _full_path, is_ref, _is_mut| match decl_type { - DeclType::StructImported {..} if !is_ref => write!(w, ".get_native_ref()").unwrap(), + |w, decl_type, _full_path, _is_ref, _is_mut, _is_trait_alias| match decl_type { + DeclType::StructImported {..} => write!(w, ".get_native_ref()").unwrap(), _ => unimplemented!(), }); } @@ -3105,9 +3171,8 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // If this is a no-export'd crate and there's only one implementation in the // whole crate, just treat it as a reference to whatever the implementor is. if with_ref_lifetime { - // Hope we're being printed in function generics and let rustc derive the - // type. - write!(w, "_").unwrap(); + // Hope that we're bound on a `Deref` and that the non-ref type works. + write!(w, "crate::{}", trait_impls[0]).unwrap(); } else { write!(w, "&crate::{}", trait_impls[0]).unwrap(); } @@ -3170,7 +3235,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { true } else { let mut inner_c_ty = Vec::new(); - assert!(self.write_c_path_intern(&mut inner_c_ty, &p.path, generics, true, false, ptr_for_ref, with_ref_lifetime, c_ty)); + assert!(self.write_c_path_intern(&mut inner_c_ty, &p.path, generics, false, false, ptr_for_ref, with_ref_lifetime, c_ty)); let inner_ty_str = String::from_utf8(inner_c_ty).unwrap(); if self.is_clonable(&inner_ty_str) { let inner_ty_ident = inner_ty_str.rsplitn(2, "::").next().unwrap(); diff --git a/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml b/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml new file mode 100644 index 0000000..23113e2 --- /dev/null +++ b/deterministic-build-wrappers/compiler-builtins-dummy/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "compiler-builtins-dummy" +version = "0.1.0" +edition = "2021" + +[dependencies] +compiler_builtins = "=0.1.109" diff --git a/deterministic-build-wrappers/compiler-builtins-dummy/src/lib.rs b/deterministic-build-wrappers/compiler-builtins-dummy/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/deterministic-build-wrappers/rustc b/deterministic-build-wrappers/rustc index b05d340..5ac8fe2 100755 --- a/deterministic-build-wrappers/rustc +++ b/deterministic-build-wrappers/rustc @@ -10,7 +10,7 @@ IS_LIGHTNING=false for ((i=0; i<"${#args[@]}"; ++i)); do case ${args[i]} in --crate-name) - if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "ldk" ]; then + if [ "${args[i+1]}" = "lightning" -o "${args[i+1]}" = "lightning_types" -o "${args[i+1]}" = "lightning_background_processor" -o "${args[i+1]}" = "lightning_invoice" -o "${args[i+1]}" = "lightning_persister" -o "${args[i+1]}" = "lightning_rapid_gossip_sync" -o "${args[i+1]}" = "ldk" ]; then IS_LIGHTNING=true fi ;; diff --git a/genbindings.sh b/genbindings.sh index 0e6f0f6..258f666 100755 --- a/genbindings.sh +++ b/genbindings.sh @@ -200,17 +200,19 @@ function drop_crate() { echo > /tmp/crate-source.txt if [ "$2" = "true" ]; then add_crate lightning lightning --features=std + add_crate lightning-types lightning_types add_crate "lightning-persister" "lightning_persister" - add_crate "lightning-background-processor" "lightning_background_processor" --features=std + add_crate "lightning-background-processor" "lightning_background_processor" --features=std,lightning/std add_crate "lightning-invoice" "lightning_invoice" --features=std - add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=std + add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=std,lightning/std CARGO_BUILD_ARGS="--features=std" else add_crate lightning lightning --features=no-std + add_crate lightning-types lightning_types drop_crate "lightning-persister" - add_crate "lightning-background-processor" "lightning_background_processor" --features=no-std - add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=no-std - add_crate "lightning-invoice" "lightning_invoice" --features=no-std + add_crate "lightning-background-processor" "lightning_background_processor" --features=lightning/no-std + add_crate "lightning-rapid-gossip-sync" "lightning_rapid_gossip_sync" --features=lightning/no-std + add_crate "lightning-invoice" "lightning_invoice" CARGO_BUILD_ARGS="--features=no-std" fi @@ -376,19 +378,27 @@ function REALLY_PIN_CC { cargo update -p cc --precise "1.0.79" --verbose ( RUSTC_BOOTSTRAP=1 cargo build --features=std -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n ( RUSTC_BOOTSTRAP=1 cargo build --features=std -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort > /dev/null 2>&1 ) || echo -n + pushd ../deterministic-build-wrappers/compiler-builtins-dummy + cargo build > /dev/null 2>&1 || echo -n + popd # Sadly, std also depends on cc, and we can't pin it in that tree # directly. Instead, we have to delete the file out of the cargo # registry and build --offline to avoid it using the latest version. NEW_CC_DEP="$CARGO_HOME" [ "$NEW_CC_DEP" = "" ] && NEW_CC_DEP="$HOME" - [ -d "$NEW_CC_DEP/.cargo/registry/cache/"github.com-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"github.com-* - [ -d "$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-* ] && CARGO_REGISTRY_CACHE="$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-* + [ -d "$NEW_CC_DEP/.cargo/registry/cache/"github.com-* ] && CARGO_REGISTRY_CACHE="$(echo "$NEW_CC_DEP/.cargo/registry/cache/"github.com-*)" + [ -d "$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-* ] && CARGO_REGISTRY_CACHE="$(echo "$NEW_CC_DEP/.cargo/registry/cache/"index.crates.io-*)" if [ -d "$CARGO_REGISTRY_CACHE" ]; then + if [ -f "$CARGO_REGISTRY_CACHE/compiler_builtins-0.1.109.crate" ]; then + mv "$CARGO_REGISTRY_CACHE/compiler_builtins-0.1.109.crate" ./ + fi if [ -f "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ]; then mv "$CARGO_REGISTRY_CACHE/cc-1.0.79.crate" ./ fi - rm -f "$CARGO_REGISTRY_CACHE/"*/cc-*.crate + rm -f "$CARGO_REGISTRY_CACHE/"cc-*.crate [ -f ./cc-1.0.79.crate ] && mv ./cc-1.0.79.crate "$CARGO_REGISTRY_CACHE/" + rm -f "$CARGO_REGISTRY_CACHE/"compiler_builtins-0.1.11*.crate + [ -f ./compiler_builtins-0.1.109.crate ] && mv ./compiler_builtins-0.1.109.crate "$CARGO_REGISTRY_CACHE/" else echo "Couldn't find cargo cache, build-std builds are likely to fail!" fi @@ -614,8 +624,10 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then for ARG in $CFLAGS_aarch64_apple_darwin; do MANUAL_LINK_CFLAGS="$MANUAL_LINK_CFLAGS -C link-arg=$ARG" done + # While there's no reason LTO should fail here (and it didn't use to), it now fails with errors like + # ld64.lld: error: undefined symbol: core::fmt::Formatter::debug_lower_hex::hf8e8a79f43d62b68 export CFLAGS_aarch64_apple_darwin="$CFLAGS_aarch64_apple_darwin -O3 -fPIC -fembed-bitcode" - RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS --offline -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" cargo build $CARGO_BUILD_ARGS --offline -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort if [ "$HOST_OSX" != "true" ]; then # If we're not on OSX but can build OSX binaries, build the x86_64 OSX release now MANUAL_LINK_CFLAGS="" @@ -623,7 +635,7 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then MANUAL_LINK_CFLAGS="$MANUAL_LINK_CFLAGS -C link-arg=$ARG" done export CFLAGS_x86_64_apple_darwin="$CFLAGS_x86_64_apple_darwin -O3 -fPIC -fembed-bitcode" - RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS --offline -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort + RUSTC_BOOTSTRAP=1 RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS --offline -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort fi fi # If we're on an M1 don't bother building X86 binaries diff --git a/lightning-c-bindings/Cargo.toml b/lightning-c-bindings/Cargo.toml index 245a1c4..0d4ef54 100644 --- a/lightning-c-bindings/Cargo.toml +++ b/lightning-c-bindings/Cargo.toml @@ -15,20 +15,20 @@ crate-type = ["staticlib" ,"cdylib"] [features] -no-std = ["bitcoin/no-std", "lightning/no-std", "lightning-invoice/no-std", "lightning-background-processor/no-std", "core2"] -std = ["bitcoin/std", "lightning/std", "lightning-invoice/std", "lightning-background-processor/std"] +no-std = ["lightning/no-std"] +std = ["bitcoin/std", "lightning/std", "lightning-invoice/std", "lightning-background-processor/std", "lightning-rapid-gossip-sync/std"] [dependencies] -bitcoin = { version = "0.30", default-features = false } -secp256k1 = { version = "0.27", features = ["global-context", "recovery"] } +bitcoin = { version = "0.32", default-features = false } +bech32 = { version = "0.9", default-features = false } +secp256k1 = { version = "0.29", features = ["global-context", "recovery"] } # Note that the following line is matched by genbindings to update the path -lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.121-bindings", default-features = false } -lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.121-bindings", default-features = false } -lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.121-bindings", default-features = false } -lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.121-bindings", default-features = false } -lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.121-bindings", default-features = false } - -core2 = { version = "0.3.0", optional = true, default-features = false } +lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } +lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } +lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } +lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } +lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } +lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.124-bindings", default-features = false } # Always force panic=abort, further options are set in the genbindings.sh build script [profile.dev] diff --git a/lightning-c-bindings/demo.c b/lightning-c-bindings/demo.c index 31754d8..c5993ce 100644 --- a/lightning-c-bindings/demo.c +++ b/lightning-c-bindings/demo.c @@ -32,8 +32,8 @@ LDKCResult_ChannelMonitorUpdateStatusNoneZ add_channel_monitor(const void *this_ LDKChannelMonitorUpdateStatus update_channel_monitor(const void *this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate *monitor) { return ChannelMonitorUpdateStatus_completed(); } -LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { - LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ empty_htlc_vec = { +LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { + LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ empty_htlc_vec = { .data = NULL, .datalen = 0, }; diff --git a/lightning-c-bindings/demo.cpp b/lightning-c-bindings/demo.cpp index f9284ee..7d8f3e6 100644 --- a/lightning-c-bindings/demo.cpp +++ b/lightning-c-bindings/demo.cpp @@ -174,12 +174,12 @@ LDKChannelMonitorUpdateStatus update_channel_monitor(const void *this_arg, LDKOu mons_updated += 1; return ChannelMonitorUpdateStatus_completed(); } -LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { +LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_events(const void *this_arg) { NodeMonitors* arg = (NodeMonitors*) this_arg; std::unique_lock l(arg->mut); if (arg->mons.size() == 0) { - return LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { + return LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { .data = NULL, .datalen = 0, }; @@ -191,9 +191,12 @@ LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_e LDK::C2Tuple_OutPointCVec_u8ZZ funding_info = ChannelMonitor_get_funding_txo(&arg->mons[0].second); LDK::OutPoint outpoint = std::move(funding_info->a); LDKPublicKey counterparty_node_id = ChannelMonitor_get_counterparty_node_id(&arg->mons[0].second); - LDK::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ tuple = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(std::move(outpoint), std::move(events), std::move(counterparty_node_id)); - auto vec = LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - .data = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)malloc(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)), + LDKThirtyTwoBytes channel_id; + memset(&channel_id, 0, sizeof(channel_id)); + LDK::ChannelId chan_id = ChannelId_new(channel_id); + LDK::C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ tuple = C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_new(std::move(outpoint), std::move(chan_id), std::move(events), std::move(counterparty_node_id)); + auto vec = LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + .data = (LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ*)malloc(sizeof(LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ)), .datalen = 1, }; vec.data[0] = std::move(tuple); @@ -204,9 +207,10 @@ LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ monitors_pending_monitor_e struct EventQueue { std::vector events; }; -void handle_event(const void *this_arg, LDKEvent event) { +LDKCResult_NoneReplayEventZ handle_event(const void *this_arg, LDKEvent event) { EventQueue* arg = (EventQueue*) this_arg; arg->events.push_back(std::move(event)); + return CResult_NoneReplayEventZ_ok(); } #ifdef REAL_NET @@ -230,8 +234,8 @@ public: std::cout << __FILE__ << ":" << __LINE__ << " - " << "Awaiting initial handshake completion..." << std::endl; while (true) { // Wait for the initial handshakes to complete... - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids(&net1); - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids(&net2); + LDK::CVec_PeerDetailsZ peers_1 = PeerManager_list_peers(&net1); + LDK::CVec_PeerDetailsZ peers_2 = PeerManager_list_peers(&net2); if (peers_1->datalen == 1 && peers_2->datalen == 1) { break; } std::this_thread::yield(); } @@ -249,8 +253,8 @@ public: std::cout << __FILE__ << ":" << __LINE__ << " - " << "Awaiting new connection handshake..." << std::endl; while (true) { // Wait for the new connection handshake... - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids(&net1); - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids(&net2); + LDK::CVec_PeerDetailsZ peers_1 = PeerManager_list_peers(&net1); + LDK::CVec_PeerDetailsZ peers_2 = PeerManager_list_peers(&net2); if (peers_1->datalen == 1 && peers_2->datalen == 1) { break; } std::this_thread::yield(); } @@ -261,8 +265,8 @@ public: while (true) { PeerManager_disconnect_by_node_id(&net1, ChannelManager_get_our_node_id(&cm2)); // Wait for the peers to disconnect... - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids(&net1); - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids(&net2); + LDK::CVec_PeerDetailsZ peers_1 = PeerManager_list_peers(&net1); + LDK::CVec_PeerDetailsZ peers_2 = PeerManager_list_peers(&net2); if (peers_1->datalen == 0 && peers_2->datalen == 0) { break; } std::this_thread::yield(); } @@ -277,8 +281,8 @@ public: std::cout << __FILE__ << ":" << __LINE__ << " - " << "Awaiting initial handshake completion..." << std::endl; while (true) { // Wait for the initial handshakes to complete... - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids(&net1); - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids(&net2); + LDK::CVec_PeerDetailsZ peers_1 = PeerManager_list_peers(&net1); + LDK::CVec_PeerDetailsZ peers_2 = PeerManager_list_peers(&net2); if (peers_1->datalen == 1 && peers_2->datalen == 1) { break; } std::this_thread::yield(); } @@ -367,8 +371,8 @@ public: std::cout << __FILE__ << ":" << __LINE__ << " - " << "Awaiting initial handshake completion..." << std::endl; while (true) { // Wait for the initial handshakes to complete... - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_1 = PeerManager_get_peer_node_ids(&net1); - LDK::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ peers_2 = PeerManager_get_peer_node_ids(&net2); + LDK::CVec_PeerDetailsZ peers_1 = PeerManager_list_peers(&net1); + LDK::CVec_PeerDetailsZ peers_2 = PeerManager_list_peers(&net2); if (peers_1->datalen == 1 && peers_2->datalen ==1) { break; } std::this_thread::yield(); } @@ -408,11 +412,13 @@ LDKStr custom_onion_msg_str(const void *this_arg) { }; } -LDKCOption_OnionMessageContentsZ handle_custom_onion_message(const void* this_arg, struct LDKOnionMessageContents msg) { +LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ handle_custom_onion_message(const void* this_arg, struct LDKOnionMessageContents msg, LDKCOption_CVec_u8ZZ context, LDKResponder responder) { + LDK::Responder resp(std::move(responder)); + LDK::COption_CVec_u8ZZ ctx(std::move(context)); CustomOnionMsgQueue* arg = (CustomOnionMsgQueue*) this_arg; std::unique_lock lck(arg->mtx); arg->msgs.push_back(std::move(msg)); - return COption_OnionMessageContentsZ_none(); + return COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_none(); } LDKOnionMessageContents build_custom_onion_message() { @@ -435,9 +441,10 @@ LDKCResult_COption_OnionMessageContentsZDecodeErrorZ read_custom_onion_message(c return CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(COption_OnionMessageContentsZ_some(build_custom_onion_message())); } -LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ release_no_messages(const void* this_arg) { - return LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - .data = NULL, .datalen = 0 }; +LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ release_no_messages(const void* this_arg) { + return LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + .data = NULL, .datalen = 0 + }; } struct CustomMsgQueue { @@ -485,6 +492,11 @@ LDKCVec_C2Tuple_PublicKeyTypeZZ never_send_custom_msgs(const void* this_arg) { .data = NULL, .datalen = 0 }; } +void peer_disconnected(const void* this_arg, struct LDKPublicKey _their_node_id) {} +LDKCResult_NoneNoneZ accept_peer_connected(const void* this_arg, struct LDKPublicKey _their_node_id, const struct LDKInit *msg, bool inbound) { + return CResult_NoneNoneZ_ok(); +} + LDKCVec_C2Tuple_PublicKeyTypeZZ create_custom_msg(const void* this_arg) { const LDKPublicKey *counterparty_node_id = (const LDKPublicKey *)this_arg; @@ -611,8 +623,9 @@ int main() { LDK::IgnoringMessageHandler ignoring_handler1 = IgnoringMessageHandler_new(); LDK::CustomMessageHandler custom_msg_handler1 = IgnoringMessageHandler_as_CustomMessageHandler(&ignoring_handler1); LDK::CustomOnionMessageHandler custom_onion_msg_handler1 = IgnoringMessageHandler_as_CustomOnionMessageHandler(&ignoring_handler1); + LDK::AsyncPaymentsMessageHandler async_msg_handler1 = IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&ignoring_handler1); LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new(&net_graph1, KeysManager_as_EntropySource(&keys1)); - LDK::OnionMessenger om1 = OnionMessenger_new(KeysManager_as_EntropySource(&keys1), KeysManager_as_NodeSigner(&keys1), logger1, DefaultMessageRouter_as_MessageRouter(&mr1), IgnoringMessageHandler_as_OffersMessageHandler(&ignoring_handler1), std::move(custom_onion_msg_handler1)); + LDK::OnionMessenger om1 = OnionMessenger_new(KeysManager_as_EntropySource(&keys1), KeysManager_as_NodeSigner(&keys1), logger1, ChannelManager_as_NodeIdLookUp(&cm1), DefaultMessageRouter_as_MessageRouter(&mr1), IgnoringMessageHandler_as_OffersMessageHandler(&ignoring_handler1), std::move(async_msg_handler1), std::move(custom_onion_msg_handler1)); LDK::CVec_ChannelDetailsZ channels = ChannelManager_list_channels(&cm1); assert(channels->datalen == 0); @@ -625,9 +638,9 @@ int main() { // Demo getting a channel key and check that its returning real pubkeys: LDKSixteenBytes user_id_1 { .data = {45, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, 0} }; LDKThirtyTwoBytes chan_signer_id1 = signer_provider1.generate_channel_keys_id(false, 42, U128_new(user_id_1)); - LDK::WriteableEcdsaChannelSigner chan_signer1 = signer_provider1.derive_channel_signer(42, chan_signer_id1); - chan_signer1->EcdsaChannelSigner.ChannelSigner.set_pubkeys(&chan_signer1->EcdsaChannelSigner.ChannelSigner); // Make sure pubkeys is defined - LDKPublicKey payment_point = ChannelPublicKeys_get_payment_point(&chan_signer1->EcdsaChannelSigner.ChannelSigner.pubkeys); + LDK::EcdsaChannelSigner chan_signer1 = signer_provider1.derive_channel_signer(42, chan_signer_id1); + chan_signer1->ChannelSigner.set_pubkeys(&chan_signer1->ChannelSigner); // Make sure pubkeys is defined + LDKPublicKey payment_point = ChannelPublicKeys_get_payment_point(&chan_signer1->ChannelSigner.pubkeys); assert(memcmp(&payment_point, &null_pk, sizeof(null_pk))); // Instantiate classes for node 2: @@ -648,7 +661,7 @@ int main() { LDK::CustomMessageHandler custom_msg_handler2 = IgnoringMessageHandler_as_CustomMessageHandler(&ignoring_handler2); LDK::CustomOnionMessageHandler custom_onion_msg_handler2 = IgnoringMessageHandler_as_CustomOnionMessageHandler(&ignoring_handler2); LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new(&net_graph2, KeysManager_as_EntropySource(&keys2)); - LDK::OnionMessenger om2 = OnionMessenger_new(KeysManager_as_EntropySource(&keys2), KeysManager_as_NodeSigner(&keys2), logger2, DefaultMessageRouter_as_MessageRouter(&mr2), IgnoringMessageHandler_as_OffersMessageHandler(&ignoring_handler2), std::move(custom_onion_msg_handler2)); + LDK::OnionMessenger om2 = OnionMessenger_new(KeysManager_as_EntropySource(&keys2), KeysManager_as_NodeSigner(&keys2), logger2, ChannelManager_as_NodeIdLookUp(&cm2), DefaultMessageRouter_as_MessageRouter(&mr2), IgnoringMessageHandler_as_OffersMessageHandler(&ignoring_handler2), IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&ignoring_handler2), std::move(custom_onion_msg_handler2)); LDK::CVec_ChannelDetailsZ channels2 = ChannelManager_list_channels(&cm2); assert(channels2->datalen == 0); @@ -668,7 +681,7 @@ int main() { PeersConnection conn(cm1, cm2, net1, net2); // Note that we have to bind the result to a C++ class to make sure it gets free'd - LDK::CResult_ThirtyTwoBytesAPIErrorZ res = ChannelManager_create_channel(&cm1, ChannelManager_get_our_node_id(&cm2), 40000, 1000, U128_new(user_id_1), COption_ThirtyTwoBytesZ_none(), UserConfig_default()); + LDK::CResult_ChannelIdAPIErrorZ res = ChannelManager_create_channel(&cm1, ChannelManager_get_our_node_id(&cm2), 40000, 1000, U128_new(user_id_1), LDKChannelId { .inner = NULL, .is_owned = false }, UserConfig_default()); assert(res->result_ok); PeerManager_process_events(&net1); @@ -708,7 +721,7 @@ int main() { assert(!memcmp(queue.events[0]->funding_generation_ready.output_script.data, channel_open_block + 58 + 81, 34)); LDKTransaction funding_transaction { .data = const_cast(channel_open_block + 81), .datalen = sizeof(channel_open_block) - 81, .data_is_owned = false }; - LDK::CResult_NoneAPIErrorZ fund_res = ChannelManager_funding_transaction_generated(&cm1, &queue.events[0]->funding_generation_ready.temporary_channel_id.data, queue.events[0]->funding_generation_ready.counterparty_node_id, funding_transaction); + LDK::CResult_NoneAPIErrorZ fund_res = ChannelManager_funding_transaction_generated(&cm1, ChannelId_clone(&queue.events[0]->funding_generation_ready.temporary_channel_id), queue.events[0]->funding_generation_ready.counterparty_node_id, funding_transaction); assert(fund_res->result_ok); break; } @@ -737,7 +750,7 @@ int main() { ev1.process_pending_events(handler); if (queue.events.size() == 1) { assert(queue.events[0]->tag == LDKEvent_ChannelPending); - assert(!memcmp(queue.events[0]->channel_pending.channel_id.data, expected_chan_id, 32)); + assert(!memcmp(ChannelId_get_a(&queue.events[0]->channel_pending.channel_id), expected_chan_id, 32)); break; } std::this_thread::yield(); @@ -752,7 +765,7 @@ int main() { ev2.process_pending_events(handler); if (queue.events.size() == 1) { assert(queue.events[0]->tag == LDKEvent_ChannelPending); - assert(!memcmp(queue.events[0]->channel_pending.channel_id.data, expected_chan_id, 32)); + assert(!memcmp(ChannelId_get_a(&queue.events[0]->channel_pending.channel_id), expected_chan_id, 32)); break; } std::this_thread::yield(); @@ -793,7 +806,7 @@ int main() { ev2.process_pending_events(handler); if (queue.events.size() == 1) { assert(queue.events[0]->tag == LDKEvent_ChannelReady); - assert(!memcmp(queue.events[0]->channel_ready.channel_id.data, expected_chan_id, 32)); + assert(!memcmp(ChannelId_get_a(&queue.events[0]->channel_ready.channel_id), expected_chan_id, 32)); break; } std::this_thread::yield(); @@ -807,7 +820,7 @@ int main() { ev1.process_pending_events(handler); if (queue.events.size() == 1) { assert(queue.events[0]->tag == LDKEvent_ChannelReady); - assert(!memcmp(queue.events[0]->channel_ready.channel_id.data, expected_chan_id, 32)); + assert(!memcmp(ChannelId_get_a(&queue.events[0]->channel_ready.channel_id), expected_chan_id, 32)); break; } std::this_thread::yield(); @@ -823,7 +836,8 @@ int main() { const LDKChannelDetails *channel = &outbound_channels->data[0]; LDK::ChannelCounterparty counterparty = ChannelDetails_get_counterparty(channel); - assert(!memcmp(ChannelDetails_get_channel_id(channel), expected_chan_id, 32)); + LDK::ChannelId chan_id = ChannelDetails_get_channel_id(channel); + assert(!memcmp(ChannelId_get_a(&chan_id), expected_chan_id, 32)); assert(!memcmp( ChannelCounterparty_get_node_id(&counterparty).compressed_form, ChannelManager_get_our_node_id(&cm2).compressed_form, 33)); @@ -870,16 +884,16 @@ int main() { .inner = NULL, .is_owned = false }, Bolt11Invoice_min_final_cltv_expiry_delta(invoice->contents.result)); LDK::RouteParameters route_params = RouteParameters_from_payment_params_and_value( - PaymentParameters_new(std::move(payee), COption_u64Z_none(), 0xffffffff, 1, 2, + PaymentParameters_new(std::move(payee), COption_u64Z_none(), 0xffffffff, 1, 20, 2, LDKCVec_u64Z { .data = NULL, .datalen = 0 }, LDKCVec_u64Z { .data = NULL, .datalen = 0 }), 5000); random_bytes = entropy_source1.get_secure_random_bytes(); LDK::ProbabilisticScoringFeeParameters params = ProbabilisticScoringFeeParameters_default(); - LDK::CResult_RouteLightningErrorZ route = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &net_graph2, &outbound_channels, logger1, &chan_scorer, ¶ms, &random_bytes.data); + LDK::CResult_RouteLightningErrorZ route_res = find_route(ChannelManager_get_our_node_id(&cm1), &route_params, &net_graph2, &outbound_channels, logger1, &chan_scorer, ¶ms, &random_bytes.data); - assert(route->result_ok); - LDK::CVec_PathZ paths = Route_get_paths(route->contents.result); + assert(route_res->result_ok); + LDK::CVec_PathZ paths = Route_get_paths(route_res->contents.result); assert(paths->datalen == 1); LDK::CVec_RouteHopZ hops = Path_get_hops(&paths->data[0]); assert(hops->datalen == 1); @@ -888,8 +902,9 @@ int main() { assert(RouteHop_get_short_channel_id(&hops->data[0]) == channel_scid); LDKThirtyTwoBytes payment_secret; memcpy(payment_secret.data, Bolt11Invoice_payment_secret(invoice->contents.result), 32); + LDK::Route route(Route_clone(route_res->contents.result)); LDK::CResult_NonePaymentSendFailureZ send_res = ChannelManager_send_payment_with_route(&cm1, - route->contents.result, payment_hash, RecipientOnionFields_secret_only(payment_secret), payment_hash); + std::move(route), payment_hash, RecipientOnionFields_secret_only(payment_secret), payment_hash); assert(send_res->result_ok); } @@ -926,12 +941,12 @@ int main() { assert(queue.events.size() == 1); assert(queue.events[0]->tag == LDKEvent_PaymentClaimable); assert(!memcmp(queue.events[0]->payment_claimable.payment_hash.data, payment_hash.data, 32)); - assert(queue.events[0]->payment_claimable.purpose.tag == LDKPaymentPurpose_InvoicePayment); - assert(!memcmp(queue.events[0]->payment_claimable.purpose.invoice_payment.payment_secret.data, + assert(queue.events[0]->payment_claimable.purpose.tag == LDKPaymentPurpose_Bolt11InvoicePayment); + assert(!memcmp(queue.events[0]->payment_claimable.purpose.bolt11_invoice_payment.payment_secret.data, Bolt11Invoice_payment_secret(invoice->contents.result), 32)); assert(queue.events[0]->payment_claimable.amount_msat == 5000); - assert(queue.events[0]->payment_claimable.purpose.invoice_payment.payment_preimage.tag == LDKCOption_ThirtyTwoBytesZ_Some); - memcpy(payment_preimage.data, queue.events[0]->payment_claimable.purpose.invoice_payment.payment_preimage.some.data, 32); + assert(queue.events[0]->payment_claimable.purpose.bolt11_invoice_payment.payment_preimage.tag == LDKCOption_ThirtyTwoBytesZ_Some); + memcpy(payment_preimage.data, queue.events[0]->payment_claimable.purpose.bolt11_invoice_payment.payment_preimage.some.data, 32); ChannelManager_claim_funds(&cm2, payment_preimage); queue.events.clear(); @@ -939,7 +954,7 @@ int main() { assert(queue.events.size() == 1); assert(queue.events[0]->tag == LDKEvent_PaymentClaimed); assert(!memcmp(queue.events[0]->payment_claimed.payment_hash.data, payment_hash.data, 32)); - assert(queue.events[0]->payment_claimed.purpose.tag == LDKPaymentPurpose_InvoicePayment); + assert(queue.events[0]->payment_claimed.purpose.tag == LDKPaymentPurpose_Bolt11InvoicePayment); } PeerManager_process_events(&net2); // Wait until we've passed through a full set of monitor updates (ie new preimage + CS/RAA messages) @@ -1010,7 +1025,7 @@ int main() { }; LDK::DefaultMessageRouter mr1 = DefaultMessageRouter_new(&net_graph1, KeysManager_as_EntropySource(&keys1)); LDK::IgnoringMessageHandler ignorer_1 = IgnoringMessageHandler_new(); - LDK::OnionMessenger om1 = OnionMessenger_new(KeysManager_as_EntropySource(&keys1), KeysManager_as_NodeSigner(&keys1), logger1, DefaultMessageRouter_as_MessageRouter(&mr1), IgnoringMessageHandler_as_OffersMessageHandler(&ignorer_1), std::move(custom_onion_msg_handler1)); + LDK::OnionMessenger om1 = OnionMessenger_new(KeysManager_as_EntropySource(&keys1), KeysManager_as_NodeSigner(&keys1), logger1, ChannelManager_as_NodeIdLookUp(&cm1), DefaultMessageRouter_as_MessageRouter(&mr1), IgnoringMessageHandler_as_OffersMessageHandler(&ignorer_1), IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&ignorer_1), std::move(custom_onion_msg_handler1)); LDK::CVec_ChannelMonitorZ mons_list2 = LDKCVec_ChannelMonitorZ { .data = (LDKChannelMonitor*)malloc(sizeof(LDKChannelMonitor)), .datalen = 1 }; assert(mons2.mons.size() == 1); @@ -1038,11 +1053,12 @@ int main() { }; LDK::DefaultMessageRouter mr2 = DefaultMessageRouter_new(&net_graph2, KeysManager_as_EntropySource(&keys2)); LDK::IgnoringMessageHandler ignorer_2 = IgnoringMessageHandler_new(); - LDK::OnionMessenger om2 = OnionMessenger_new(KeysManager_as_EntropySource(&keys2), KeysManager_as_NodeSigner(&keys2), logger2, DefaultMessageRouter_as_MessageRouter(&mr2), IgnoringMessageHandler_as_OffersMessageHandler(&ignorer_2), custom_onion_msg_handler2); + LDK::OnionMessenger om2 = OnionMessenger_new(KeysManager_as_EntropySource(&keys2), KeysManager_as_NodeSigner(&keys2), logger2, ChannelManager_as_NodeIdLookUp(&cm2), DefaultMessageRouter_as_MessageRouter(&mr2), IgnoringMessageHandler_as_OffersMessageHandler(&ignorer_2), IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&ignorer_2), custom_onion_msg_handler2); // Attempt to close the channel... - uint8_t chan_id[32]; - for (int i = 0; i < 32; i++) { chan_id[i] = channel_open_txid[31-i]; } + LDKThirtyTwoBytes chan_id_bytes; + for (int i = 0; i < 32; i++) { chan_id_bytes.data[i] = channel_open_txid[31-i]; } + LDK::ChannelId chan_id = ChannelId_new(chan_id_bytes); LDK::CResult_NoneAPIErrorZ close_res = ChannelManager_close_channel(&cm1, &chan_id, ChannelManager_get_our_node_id(&cm2)); assert(!close_res->result_ok); // Note that we can't close while disconnected! @@ -1052,6 +1068,8 @@ int main() { .this_arg = &chan_2_node_id, .handle_custom_message = NULL, // We only create custom messages, not handle them .get_and_clear_pending_msg = create_custom_msg, + .peer_disconnected = peer_disconnected, + .peer_connected = accept_peer_connected, .provided_node_features = custom_node_features, .provided_init_features = custom_init_features, .CustomMessageReader = LDKCustomMessageReader { @@ -1070,6 +1088,8 @@ int main() { .this_arg = &peer_2_custom_messages, .handle_custom_message = handle_custom_message, .get_and_clear_pending_msg = never_send_custom_msgs, + .peer_disconnected = peer_disconnected, + .peer_connected = accept_peer_connected, .provided_node_features = custom_node_features, .provided_init_features = custom_init_features, .CustomMessageReader = LDKCustomMessageReader { @@ -1148,19 +1168,19 @@ int main() { assert(queue2.events[0]->tag == LDKEvent_PaymentClaimable); const struct LDKEvent_LDKPaymentClaimable_Body *event_data = &queue2.events[0]->payment_claimable; assert(!memcmp(event_data->payment_hash.data, Bolt11Invoice_payment_hash(invoice2), 32)); - assert(event_data->purpose.tag == LDKPaymentPurpose_InvoicePayment); - assert(!memcmp(event_data->purpose.invoice_payment.payment_secret.data, + assert(event_data->purpose.tag == LDKPaymentPurpose_Bolt11InvoicePayment); + assert(!memcmp(event_data->purpose.bolt11_invoice_payment.payment_secret.data, Bolt11Invoice_payment_secret(invoice2), 32)); assert(event_data->amount_msat == 10000); - assert(event_data->purpose.invoice_payment.payment_preimage.tag == LDKCOption_ThirtyTwoBytesZ_Some); - ChannelManager_claim_funds(&cm2, event_data->purpose.invoice_payment.payment_preimage.some); + assert(event_data->purpose.bolt11_invoice_payment.payment_preimage.tag == LDKCOption_ThirtyTwoBytesZ_Some); + ChannelManager_claim_funds(&cm2, event_data->purpose.bolt11_invoice_payment.payment_preimage.some); queue2.events.clear(); ev2.process_pending_events(handler2); assert(queue2.events.size() == 1); assert(queue2.events[0]->tag == LDKEvent_PaymentClaimed); assert(!memcmp(queue2.events[0]->payment_claimed.payment_hash.data, Bolt11Invoice_payment_hash(invoice2), 32)); - assert(queue2.events[0]->payment_claimed.purpose.tag == LDKPaymentPurpose_InvoicePayment); + assert(queue2.events[0]->payment_claimed.purpose.tag == LDKPaymentPurpose_Bolt11InvoicePayment); break; } @@ -1202,8 +1222,7 @@ int main() { LDK::CResult_SendSuccessSendErrorZ om_send_res = OnionMessenger_send_onion_message(&om1, build_custom_onion_message(), - Destination_node(ChannelManager_get_our_node_id(&cm2)), - LDKBlindedPath { .inner = NULL, .is_owned = true }); + MessageSendInstructions_without_reply_path(Destination_node(ChannelManager_get_our_node_id(&cm2)))); assert(om_send_res->result_ok); PeerManager_process_events(&net1); std::cout << __FILE__ << ":" << __LINE__ << " - " << "Awaiting onion message..." << std::endl; diff --git a/lightning-c-bindings/include/ldk_rust_types.h b/lightning-c-bindings/include/ldk_rust_types.h index e9988ef..bbc7ca0 100644 --- a/lightning-c-bindings/include/ldk_rust_types.h +++ b/lightning-c-bindings/include/ldk_rust_types.h @@ -10,16 +10,20 @@ #else #define NONNULL_PTR #endif +struct nativeRefundMaybeWithDerivedMetadataBuilderOpaque; +typedef struct nativeRefundMaybeWithDerivedMetadataBuilderOpaque LDKnativeRefundMaybeWithDerivedMetadataBuilder; struct nativeRefundOpaque; typedef struct nativeRefundOpaque LDKnativeRefund; struct nativeRecipientOnionFieldsOpaque; typedef struct nativeRecipientOnionFieldsOpaque LDKnativeRecipientOnionFields; +struct nativeInvoiceWithExplicitSigningPubkeyBuilderOpaque; +typedef struct nativeInvoiceWithExplicitSigningPubkeyBuilderOpaque LDKnativeInvoiceWithExplicitSigningPubkeyBuilder; +struct nativeInvoiceWithDerivedSigningPubkeyBuilderOpaque; +typedef struct nativeInvoiceWithDerivedSigningPubkeyBuilderOpaque LDKnativeInvoiceWithDerivedSigningPubkeyBuilder; struct nativeUnsignedBolt12InvoiceOpaque; typedef struct nativeUnsignedBolt12InvoiceOpaque LDKnativeUnsignedBolt12Invoice; struct nativeBolt12InvoiceOpaque; typedef struct nativeBolt12InvoiceOpaque LDKnativeBolt12Invoice; -struct nativeBlindedPayInfoOpaque; -typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; struct nativeDelayedPaymentOutputDescriptorOpaque; typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor; struct nativeStaticPaymentOutputDescriptorOpaque; @@ -35,6 +39,8 @@ struct nativeKeysManagerOpaque; typedef struct nativeKeysManagerOpaque LDKnativeKeysManager; struct nativePhantomKeysManagerOpaque; typedef struct nativePhantomKeysManagerOpaque LDKnativePhantomKeysManager; +struct nativeRandomBytesOpaque; +typedef struct nativeRandomBytesOpaque LDKnativeRandomBytes; struct nativeBackgroundProcessorOpaque; typedef struct nativeBackgroundProcessorOpaque LDKnativeBackgroundProcessor; struct nativeDefaultRouterOpaque; @@ -55,10 +61,6 @@ struct nativeRouteParametersOpaque; typedef struct nativeRouteParametersOpaque LDKnativeRouteParameters; struct nativePaymentParametersOpaque; typedef struct nativePaymentParametersOpaque LDKnativePaymentParameters; -struct nativeRouteHintOpaque; -typedef struct nativeRouteHintOpaque LDKnativeRouteHint; -struct nativeRouteHintHopOpaque; -typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop; struct nativeFirstHopCandidateOpaque; typedef struct nativeFirstHopCandidateOpaque LDKnativeFirstHopCandidate; struct nativePublicHopCandidateOpaque; @@ -69,6 +71,10 @@ struct nativeBlindedPathCandidateOpaque; typedef struct nativeBlindedPathCandidateOpaque LDKnativeBlindedPathCandidate; struct nativeOneHopBlindedPathCandidateOpaque; typedef struct nativeOneHopBlindedPathCandidateOpaque LDKnativeOneHopBlindedPathCandidate; +struct nativeUntrustedStringOpaque; +typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; +struct nativePrintableStringOpaque; +typedef struct nativePrintableStringOpaque LDKnativePrintableString; struct nativeMultiThreadedLockableScoreOpaque; typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore; struct nativeMultiThreadedScoreLockReadOpaque; @@ -89,30 +95,14 @@ struct nativeBestBlockOpaque; typedef struct nativeBestBlockOpaque LDKnativeBestBlock; struct nativeWatchedOutputOpaque; typedef struct nativeWatchedOutputOpaque LDKnativeWatchedOutput; -struct nativeInitFeaturesOpaque; -typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; -struct nativeNodeFeaturesOpaque; -typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; -struct nativeChannelFeaturesOpaque; -typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; -struct nativeBolt11InvoiceFeaturesOpaque; -typedef struct nativeBolt11InvoiceFeaturesOpaque LDKnativeBolt11InvoiceFeatures; -struct nativeOfferFeaturesOpaque; -typedef struct nativeOfferFeaturesOpaque LDKnativeOfferFeatures; -struct nativeInvoiceRequestFeaturesOpaque; -typedef struct nativeInvoiceRequestFeaturesOpaque LDKnativeInvoiceRequestFeatures; -struct nativeBolt12InvoiceFeaturesOpaque; -typedef struct nativeBolt12InvoiceFeaturesOpaque LDKnativeBolt12InvoiceFeatures; -struct nativeBlindedHopFeaturesOpaque; -typedef struct nativeBlindedHopFeaturesOpaque LDKnativeBlindedHopFeatures; -struct nativeChannelTypeFeaturesOpaque; -typedef struct nativeChannelTypeFeaturesOpaque LDKnativeChannelTypeFeatures; +struct nativeOfferIdOpaque; +typedef struct nativeOfferIdOpaque LDKnativeOfferId; +struct nativeOfferWithExplicitMetadataBuilderOpaque; +typedef struct nativeOfferWithExplicitMetadataBuilderOpaque LDKnativeOfferWithExplicitMetadataBuilder; +struct nativeOfferWithDerivedMetadataBuilderOpaque; +typedef struct nativeOfferWithDerivedMetadataBuilderOpaque LDKnativeOfferWithDerivedMetadataBuilder; struct nativeOfferOpaque; typedef struct nativeOfferOpaque LDKnativeOffer; -struct nativeAmountOpaque; -typedef struct nativeAmountOpaque LDKnativeAmount; -struct nativeQuantityOpaque; -typedef struct nativeQuantityOpaque LDKnativeQuantity; struct nativeNodeIdOpaque; typedef struct nativeNodeIdOpaque LDKnativeNodeId; struct nativeNetworkGraphOpaque; @@ -127,10 +117,8 @@ struct nativeChannelInfoOpaque; typedef struct nativeChannelInfoOpaque LDKnativeChannelInfo; struct nativeDirectedChannelInfoOpaque; typedef struct nativeDirectedChannelInfoOpaque LDKnativeDirectedChannelInfo; -struct nativeRoutingFeesOpaque; -typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees; -struct nativeNodeAnnouncementInfoOpaque; -typedef struct nativeNodeAnnouncementInfoOpaque LDKnativeNodeAnnouncementInfo; +struct nativeNodeAnnouncementDetailsOpaque; +typedef struct nativeNodeAnnouncementDetailsOpaque LDKnativeNodeAnnouncementDetails; struct nativeNodeAliasOpaque; typedef struct nativeNodeAliasOpaque LDKnativeNodeAlias; struct nativeNodeInfoOpaque; @@ -157,12 +145,6 @@ struct nativeChannelManagerOpaque; typedef struct nativeChannelManagerOpaque LDKnativeChannelManager; struct nativeChainParametersOpaque; typedef struct nativeChainParametersOpaque LDKnativeChainParameters; -struct nativeCounterpartyForwardingInfoOpaque; -typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo; -struct nativeChannelCounterpartyOpaque; -typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty; -struct nativeChannelDetailsOpaque; -typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails; struct nativePhantomRouteHintsOpaque; typedef struct nativePhantomRouteHintsOpaque LDKnativePhantomRouteHints; struct nativeChannelManagerReadArgsOpaque; @@ -193,6 +175,8 @@ struct nativeErroringMessageHandlerOpaque; typedef struct nativeErroringMessageHandlerOpaque LDKnativeErroringMessageHandler; struct nativeMessageHandlerOpaque; typedef struct nativeMessageHandlerOpaque LDKnativeMessageHandler; +struct nativePeerDetailsOpaque; +typedef struct nativePeerDetailsOpaque LDKnativePeerDetails; struct nativePeerHandleErrorOpaque; typedef struct nativePeerHandleErrorOpaque LDKnativePeerHandleError; struct nativePeerManagerOpaque; @@ -201,12 +185,18 @@ struct nativeRapidGossipSyncOpaque; typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync; struct nativeMonitorUpdatingPersisterOpaque; typedef struct nativeMonitorUpdatingPersisterOpaque LDKnativeMonitorUpdatingPersister; +struct nativeInvoiceRequestWithExplicitPayerIdBuilderOpaque; +typedef struct nativeInvoiceRequestWithExplicitPayerIdBuilderOpaque LDKnativeInvoiceRequestWithExplicitPayerIdBuilder; +struct nativeInvoiceRequestWithDerivedPayerIdBuilderOpaque; +typedef struct nativeInvoiceRequestWithDerivedPayerIdBuilderOpaque LDKnativeInvoiceRequestWithDerivedPayerIdBuilder; struct nativeUnsignedInvoiceRequestOpaque; typedef struct nativeUnsignedInvoiceRequestOpaque LDKnativeUnsignedInvoiceRequest; struct nativeInvoiceRequestOpaque; typedef struct nativeInvoiceRequestOpaque LDKnativeInvoiceRequest; struct nativeVerifiedInvoiceRequestOpaque; typedef struct nativeVerifiedInvoiceRequestOpaque LDKnativeVerifiedInvoiceRequest; +struct nativeInvoiceRequestFieldsOpaque; +typedef struct nativeInvoiceRequestFieldsOpaque LDKnativeInvoiceRequestFields; struct nativeInitOpaque; typedef struct nativeInitOpaque LDKnativeInit; struct nativeErrorMessageOpaque; @@ -217,10 +207,16 @@ struct nativePingOpaque; typedef struct nativePingOpaque LDKnativePing; struct nativePongOpaque; typedef struct nativePongOpaque LDKnativePong; +struct nativeCommonOpenChannelFieldsOpaque; +typedef struct nativeCommonOpenChannelFieldsOpaque LDKnativeCommonOpenChannelFields; +struct nativeChannelParametersOpaque; +typedef struct nativeChannelParametersOpaque LDKnativeChannelParameters; struct nativeOpenChannelOpaque; typedef struct nativeOpenChannelOpaque LDKnativeOpenChannel; struct nativeOpenChannelV2Opaque; typedef struct nativeOpenChannelV2Opaque LDKnativeOpenChannelV2; +struct nativeCommonAcceptChannelFieldsOpaque; +typedef struct nativeCommonAcceptChannelFieldsOpaque LDKnativeCommonAcceptChannelFields; struct nativeAcceptChannelOpaque; typedef struct nativeAcceptChannelOpaque LDKnativeAcceptChannel; struct nativeAcceptChannelV2Opaque; @@ -233,8 +229,8 @@ struct nativeChannelReadyOpaque; typedef struct nativeChannelReadyOpaque LDKnativeChannelReady; struct nativeStfuOpaque; typedef struct nativeStfuOpaque LDKnativeStfu; -struct nativeSpliceOpaque; -typedef struct nativeSpliceOpaque LDKnativeSplice; +struct nativeSpliceInitOpaque; +typedef struct nativeSpliceInitOpaque LDKnativeSpliceInit; struct nativeSpliceAckOpaque; typedef struct nativeSpliceAckOpaque LDKnativeSpliceAck; struct nativeSpliceLockedOpaque; @@ -273,6 +269,8 @@ struct nativeUpdateFailHTLCOpaque; typedef struct nativeUpdateFailHTLCOpaque LDKnativeUpdateFailHTLC; struct nativeUpdateFailMalformedHTLCOpaque; typedef struct nativeUpdateFailMalformedHTLCOpaque LDKnativeUpdateFailMalformedHTLC; +struct nativeCommitmentSignedBatchOpaque; +typedef struct nativeCommitmentSignedBatchOpaque LDKnativeCommitmentSignedBatch; struct nativeCommitmentSignedOpaque; typedef struct nativeCommitmentSignedOpaque LDKnativeCommitmentSigned; struct nativeRevokeAndACKOpaque; @@ -313,12 +311,28 @@ struct nativeFinalOnionHopDataOpaque; typedef struct nativeFinalOnionHopDataOpaque LDKnativeFinalOnionHopData; struct nativeOnionPacketOpaque; typedef struct nativeOnionPacketOpaque LDKnativeOnionPacket; +struct nativeTrampolineOnionPacketOpaque; +typedef struct nativeTrampolineOnionPacketOpaque LDKnativeTrampolineOnionPacket; struct nativeRecordOpaque; typedef struct nativeRecordOpaque LDKnativeRecord; +struct nativeInboundHTLCDetailsOpaque; +typedef struct nativeInboundHTLCDetailsOpaque LDKnativeInboundHTLCDetails; +struct nativeOutboundHTLCDetailsOpaque; +typedef struct nativeOutboundHTLCDetailsOpaque LDKnativeOutboundHTLCDetails; +struct nativeCounterpartyForwardingInfoOpaque; +typedef struct nativeCounterpartyForwardingInfoOpaque LDKnativeCounterpartyForwardingInfo; +struct nativeChannelCounterpartyOpaque; +typedef struct nativeChannelCounterpartyOpaque LDKnativeChannelCounterparty; +struct nativeChannelDetailsOpaque; +typedef struct nativeChannelDetailsOpaque LDKnativeChannelDetails; struct nativeFutureOpaque; typedef struct nativeFutureOpaque LDKnativeFuture; struct nativeSleeperOpaque; typedef struct nativeSleeperOpaque LDKnativeSleeper; +struct nativeHeldHtlcAvailableOpaque; +typedef struct nativeHeldHtlcAvailableOpaque LDKnativeHeldHtlcAvailable; +struct nativeReleaseHeldHtlcOpaque; +typedef struct nativeReleaseHeldHtlcOpaque LDKnativeReleaseHeldHtlc; struct nativeCounterpartyCommitmentSecretsOpaque; typedef struct nativeCounterpartyCommitmentSecretsOpaque LDKnativeCounterpartyCommitmentSecrets; struct nativeTxCreationKeysOpaque; @@ -355,6 +369,16 @@ struct nativePacketOpaque; typedef struct nativePacketOpaque LDKnativePacket; struct nativeClaimedHTLCOpaque; typedef struct nativeClaimedHTLCOpaque LDKnativeClaimedHTLC; +struct nativeReplayEventOpaque; +typedef struct nativeReplayEventOpaque LDKnativeReplayEvent; +struct nativeNonceOpaque; +typedef struct nativeNonceOpaque LDKnativeNonce; +struct nativeRoutingFeesOpaque; +typedef struct nativeRoutingFeesOpaque LDKnativeRoutingFees; +struct nativeRouteHintOpaque; +typedef struct nativeRouteHintOpaque LDKnativeRouteHint; +struct nativeRouteHintHopOpaque; +typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop; struct nativeBolt11InvoiceOpaque; typedef struct nativeBolt11InvoiceOpaque LDKnativeBolt11Invoice; struct nativeSignedRawBolt11InvoiceOpaque; @@ -387,12 +411,14 @@ struct nativeHostnameOpaque; typedef struct nativeHostnameOpaque LDKnativeHostname; struct nativeTransactionU16LenLimitedOpaque; typedef struct nativeTransactionU16LenLimitedOpaque LDKnativeTransactionU16LenLimited; -struct nativeUntrustedStringOpaque; -typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString; -struct nativePrintableStringOpaque; -typedef struct nativePrintableStringOpaque LDKnativePrintableString; -struct nativeForwardNodeOpaque; -typedef struct nativeForwardNodeOpaque LDKnativeForwardNode; +struct nativeChannelIdOpaque; +typedef struct nativeChannelIdOpaque LDKnativeChannelId; +struct nativeBlindedPayInfoOpaque; +typedef struct nativeBlindedPayInfoOpaque LDKnativeBlindedPayInfo; +struct nativeBlindedPaymentPathOpaque; +typedef struct nativeBlindedPaymentPathOpaque LDKnativeBlindedPaymentPath; +struct nativePaymentForwardNodeOpaque; +typedef struct nativePaymentForwardNodeOpaque LDKnativePaymentForwardNode; struct nativeForwardTlvsOpaque; typedef struct nativeForwardTlvsOpaque LDKnativeForwardTlvs; struct nativeReceiveTlvsOpaque; @@ -401,24 +427,56 @@ struct nativePaymentRelayOpaque; typedef struct nativePaymentRelayOpaque LDKnativePaymentRelay; struct nativePaymentConstraintsOpaque; typedef struct nativePaymentConstraintsOpaque LDKnativePaymentConstraints; +struct nativeUnknownPaymentContextOpaque; +typedef struct nativeUnknownPaymentContextOpaque LDKnativeUnknownPaymentContext; +struct nativeBolt12OfferContextOpaque; +typedef struct nativeBolt12OfferContextOpaque LDKnativeBolt12OfferContext; +struct nativeBolt12RefundContextOpaque; +typedef struct nativeBolt12RefundContextOpaque LDKnativeBolt12RefundContext; struct nativeUtxoFutureOpaque; typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture; struct nativeOnionMessengerOpaque; typedef struct nativeOnionMessengerOpaque LDKnativeOnionMessenger; +struct nativeResponderOpaque; +typedef struct nativeResponderOpaque LDKnativeResponder; +struct nativeResponseInstructionOpaque; +typedef struct nativeResponseInstructionOpaque LDKnativeResponseInstruction; struct nativeDefaultMessageRouterOpaque; typedef struct nativeDefaultMessageRouterOpaque LDKnativeDefaultMessageRouter; struct nativeOnionMessagePathOpaque; typedef struct nativeOnionMessagePathOpaque LDKnativeOnionMessagePath; struct nativeFilesystemStoreOpaque; typedef struct nativeFilesystemStoreOpaque LDKnativeFilesystemStore; -struct nativeBlindedPathOpaque; -typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath; +struct nativeInitFeaturesOpaque; +typedef struct nativeInitFeaturesOpaque LDKnativeInitFeatures; +struct nativeNodeFeaturesOpaque; +typedef struct nativeNodeFeaturesOpaque LDKnativeNodeFeatures; +struct nativeChannelFeaturesOpaque; +typedef struct nativeChannelFeaturesOpaque LDKnativeChannelFeatures; +struct nativeBolt11InvoiceFeaturesOpaque; +typedef struct nativeBolt11InvoiceFeaturesOpaque LDKnativeBolt11InvoiceFeatures; +struct nativeOfferFeaturesOpaque; +typedef struct nativeOfferFeaturesOpaque LDKnativeOfferFeatures; +struct nativeInvoiceRequestFeaturesOpaque; +typedef struct nativeInvoiceRequestFeaturesOpaque LDKnativeInvoiceRequestFeatures; +struct nativeBolt12InvoiceFeaturesOpaque; +typedef struct nativeBolt12InvoiceFeaturesOpaque LDKnativeBolt12InvoiceFeatures; +struct nativeBlindedHopFeaturesOpaque; +typedef struct nativeBlindedHopFeaturesOpaque LDKnativeBlindedHopFeatures; +struct nativeChannelTypeFeaturesOpaque; +typedef struct nativeChannelTypeFeaturesOpaque LDKnativeChannelTypeFeatures; +struct nativeEmptyNodeIdLookUpOpaque; +typedef struct nativeEmptyNodeIdLookUpOpaque LDKnativeEmptyNodeIdLookUp; struct nativeBlindedHopOpaque; typedef struct nativeBlindedHopOpaque LDKnativeBlindedHop; struct nativeInvoiceErrorOpaque; typedef struct nativeInvoiceErrorOpaque LDKnativeInvoiceError; struct nativeErroneousFieldOpaque; typedef struct nativeErroneousFieldOpaque LDKnativeErroneousField; +struct nativeTrackedSpendableOutputOpaque; +typedef struct nativeTrackedSpendableOutputOpaque LDKnativeTrackedSpendableOutput; +struct nativeOutputSweeperOpaque; +typedef struct nativeOutputSweeperOpaque LDKnativeOutputSweeper; struct nativeDelayedPaymentBasepointOpaque; typedef struct nativeDelayedPaymentBasepointOpaque LDKnativeDelayedPaymentBasepoint; struct nativeDelayedPaymentKeyOpaque; @@ -431,9 +489,11 @@ struct nativeRevocationBasepointOpaque; typedef struct nativeRevocationBasepointOpaque LDKnativeRevocationBasepoint; struct nativeRevocationKeyOpaque; typedef struct nativeRevocationKeyOpaque LDKnativeRevocationKey; -struct nativeMonitorUpdateIdOpaque; -typedef struct nativeMonitorUpdateIdOpaque LDKnativeMonitorUpdateId; struct nativeLockedChannelMonitorOpaque; typedef struct nativeLockedChannelMonitorOpaque LDKnativeLockedChannelMonitor; struct nativeChainMonitorOpaque; typedef struct nativeChainMonitorOpaque LDKnativeChainMonitor; +struct nativeBlindedMessagePathOpaque; +typedef struct nativeBlindedMessagePathOpaque LDKnativeBlindedMessagePath; +struct nativeMessageForwardNodeOpaque; +typedef struct nativeMessageForwardNodeOpaque LDKnativeMessageForwardNode; diff --git a/lightning-c-bindings/include/lightning.h b/lightning-c-bindings/include/lightning.h index e70de6f..9076f1a 100644 --- a/lightning-c-bindings/include/lightning.h +++ b/lightning-c-bindings/include/lightning.h @@ -10,6 +10,33 @@ #include #include "ldk_rust_types.h" +/** + * Indicates whether the balance is derived from a cooperative close, a force-close + * (for holder or counterparty), or whether it is for an HTLC. + */ +typedef enum LDKBalanceSource { + /** + * The channel was force closed by the holder. + */ + LDKBalanceSource_HolderForceClosed, + /** + * The channel was force closed by the counterparty. + */ + LDKBalanceSource_CounterpartyForceClosed, + /** + * The channel was cooperatively closed. + */ + LDKBalanceSource_CoopClose, + /** + * This balance is the result of an HTLC. + */ + LDKBalanceSource_Htlc, + /** + * Must be last for serialization purposes + */ + LDKBalanceSource_Sentinel, +} LDKBalanceSource; + /** * Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node, * which determines the failure message that should be used. @@ -179,6 +206,10 @@ typedef enum LDKBolt12SemanticError { * Blinded paths were expected but were missing. */ LDKBolt12SemanticError_MissingPaths, + /** + * Blinded paths were provided but were not expected. + */ + LDKBolt12SemanticError_UnexpectedPaths, /** * The blinded payinfo given does not match the number of blinded path hops. */ @@ -191,6 +222,10 @@ typedef enum LDKBolt12SemanticError { * An invoice payment hash was expected but was missing. */ LDKBolt12SemanticError_MissingPaymentHash, + /** + * An invoice payment hash was provided but was not expected. + */ + LDKBolt12SemanticError_UnexpectedPaymentHash, /** * A signature was expected but was missing. */ @@ -340,13 +375,23 @@ typedef enum LDKChannelShutdownState { * estimation. */ typedef enum LDKConfirmationTarget { + /** + * The most aggressive (i.e. highest) feerate estimate available. + * + * This is used to sanity-check our counterparty's feerates and should be as conservative as + * possible to ensure that we don't confuse a peer using a very conservative estimator for one + * trying to burn channel balance to dust. + */ + LDKConfirmationTarget_MaximumFeeEstimate, /** * We have some funds available on chain which we need to spend prior to some expiry time at - * which point our counterparty may be able to steal them. Generally we have in the high tens - * to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a - * fee - this should be a relatively high priority feerate. + * which point our counterparty may be able to steal them. + * + * Generally we have in the high tens to low hundreds of blocks to get our transaction + * on-chain (it doesn't have to happen in the next few blocks!), but we shouldn't risk too low + * a fee - this should be a relatively high priority feerate. */ - LDKConfirmationTarget_OnChainSweep, + LDKConfirmationTarget_UrgentOnChainSweep, /** * This is the lowest feerate we will allow our channel counterparty to have in an anchor * channel in order to close the channel if a channel party goes away. @@ -427,6 +472,23 @@ typedef enum LDKConfirmationTarget { * [`ChannelManager::close_channel_with_feerate_and_script`]: crate::ln::channelmanager::ChannelManager::close_channel_with_feerate_and_script */ LDKConfirmationTarget_ChannelCloseMinimum, + /** + * The feerate used to claim on-chain funds when there is no particular urgency to do so. + * + * It is used to get commitment transactions without any HTLCs confirmed in [`ChannelMonitor`] + * and by [`OutputSweeper`] on transactions spending [`SpendableOutputDescriptor`]s after a + * channel closure. + * + * Generally spending these outputs is safe as long as they eventually confirm, so a value + * (slightly above) the mempool minimum should suffice. However, as this value will influence + * how long funds will be unavailable after channel closure, [`FeeEstimator`] implementors + * might want to choose a higher feerate to regain control over funds faster. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`OutputSweeper`]: crate::util::sweep::OutputSweeper + * [`SpendableOutputDescriptor`]: crate::sign::SpendableOutputDescriptor + */ + LDKConfirmationTarget_OutputSpendingFee, /** * Must be last for serialization purposes */ @@ -454,16 +516,11 @@ typedef enum LDKCreationError { */ LDKCreationError_InvalidAmount, /** - * Route hints were required for this invoice and were missing. Applies to - * [phantom invoices]. - * - * [phantom invoices]: crate::utils::create_phantom_invoice + * Route hints were required for this invoice and were missing. */ LDKCreationError_MissingRouteHints, /** - * The provided `min_final_cltv_expiry_delta` was less than [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * The provided `min_final_cltv_expiry_delta` was less than rust-lightning's minimum. */ LDKCreationError_MinFinalCltvExpiryDeltaTooShort, /** @@ -502,6 +559,28 @@ typedef enum LDKCurrency { LDKCurrency_Sentinel, } LDKCurrency; +/** + * The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which + * nodes is which in the [`ChannelAnnouncement`] message. + * + * [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message + * [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement + */ +typedef enum LDKDirection { + /** + * The lesser node id when compared lexicographically in ascending order. + */ + LDKDirection_NodeOne, + /** + * The greater node id when compared lexicographically in ascending order. + */ + LDKDirection_NodeTwo, + /** + * Must be last for serialization purposes + */ + LDKDirection_Sentinel, +} LDKDirection; + /** * Describes the type of HTLC claim as determined by analyzing the witness. */ @@ -560,6 +639,58 @@ typedef enum LDKIOError { LDKIOError_Sentinel, } LDKIOError; +/** + * Exposes the state of pending inbound HTLCs. + * + * At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes + * through the following states in the state machine: + * - Announced for addition by the originating node through the update_add_htlc message. + * - Added to the commitment transaction of the receiving node and originating node in turn + * through the exchange of commitment_signed and revoke_and_ack messages. + * - Announced for resolution (fulfillment or failure) by the receiving node through either one of + * the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages. + * - Removed from the commitment transaction of the originating node and receiving node in turn + * through the exchange of commitment_signed and revoke_and_ack messages. + * + * This can be used to inspect what next message an HTLC is waiting for to advance its state. + */ +typedef enum LDKInboundHTLCStateDetails { + /** + * We have added this HTLC in our commitment transaction by receiving commitment_signed and + * returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + * before this HTLC is included on the remote commitment transaction. + */ + LDKInboundHTLCStateDetails_AwaitingRemoteRevokeToAdd, + /** + * This HTLC has been included in the commitment_signed and revoke_and_ack messages on both sides + * and is included in both commitment transactions. + * + * This HTLC is now safe to either forward or be claimed as a payment by us. The HTLC will + * remain in this state until the forwarded upstream HTLC has been resolved and we resolve this + * HTLC correspondingly, or until we claim it as a payment. If it is part of a multipart + * payment, it will only be claimed together with other required parts. + */ + LDKInboundHTLCStateDetails_Committed, + /** + * We have received the preimage for this HTLC and it is being removed by fulfilling it with + * update_fulfill_htlc. This HTLC is still on both commitment transactions, but we are awaiting + * the appropriate revoke_and_ack's from the remote before this HTLC is removed from the remote + * commitment transaction after update_fulfill_htlc. + */ + LDKInboundHTLCStateDetails_AwaitingRemoteRevokeToRemoveFulfill, + /** + * The HTLC is being removed by failing it with update_fail_htlc or update_fail_malformed_htlc. + * This HTLC is still on both commitment transactions, but we are awaiting the appropriate + * revoke_and_ack's from the remote before this HTLC is removed from the remote commitment + * transaction. + */ + LDKInboundHTLCStateDetails_AwaitingRemoteRevokeToRemoveFail, + /** + * Must be last for serialization purposes + */ + LDKInboundHTLCStateDetails_Sentinel, +} LDKInboundHTLCStateDetails; + /** * An enum representing the available verbosity levels of the logger. */ @@ -620,12 +751,67 @@ typedef enum LDKNetwork { LDKNetwork_Sentinel, } LDKNetwork; +/** + * Exposes the state of pending outbound HTLCs. + * + * At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes + * through the following states in the state machine: + * - Announced for addition by the originating node through the update_add_htlc message. + * - Added to the commitment transaction of the receiving node and originating node in turn + * through the exchange of commitment_signed and revoke_and_ack messages. + * - Announced for resolution (fulfillment or failure) by the receiving node through either one of + * the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages. + * - Removed from the commitment transaction of the originating node and receiving node in turn + * through the exchange of commitment_signed and revoke_and_ack messages. + * + * This can be used to inspect what next message an HTLC is waiting for to advance its state. + */ +typedef enum LDKOutboundHTLCStateDetails { + /** + * We are awaiting the appropriate revoke_and_ack's from the remote before the HTLC is added + * on the remote's commitment transaction after update_add_htlc. + */ + LDKOutboundHTLCStateDetails_AwaitingRemoteRevokeToAdd, + /** + * The HTLC has been added to the remote's commitment transaction by sending commitment_signed + * and receiving revoke_and_ack in return. + * + * The HTLC will remain in this state until the remote node resolves the HTLC, or until we + * unilaterally close the channel due to a timeout with an uncooperative remote node. + */ + LDKOutboundHTLCStateDetails_Committed, + /** + * The HTLC has been fulfilled successfully by the remote with a preimage in update_fulfill_htlc, + * and we removed the HTLC from our commitment transaction by receiving commitment_signed and + * returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + * for the removal from its commitment transaction. + */ + LDKOutboundHTLCStateDetails_AwaitingRemoteRevokeToRemoveSuccess, + /** + * The HTLC has been failed by the remote with update_fail_htlc or update_fail_malformed_htlc, + * and we removed the HTLC from our commitment transaction by receiving commitment_signed and + * returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + * for the removal from its commitment transaction. + */ + LDKOutboundHTLCStateDetails_AwaitingRemoteRevokeToRemoveFailure, + /** + * Must be last for serialization purposes + */ + LDKOutboundHTLCStateDetails_Sentinel, +} LDKOutboundHTLCStateDetails; + /** * The reason the payment failed. Used in [`Event::PaymentFailed`]. */ typedef enum LDKPaymentFailureReason { /** * The intended recipient rejected our payment. + * + * Also used for [`UnknownRequiredFeatures`] and [`InvoiceRequestRejected`] when downgrading to + * version prior to 0.0.124. + * + * [`UnknownRequiredFeatures`]: Self::UnknownRequiredFeatures + * [`InvoiceRequestRejected`]: Self::InvoiceRequestRejected */ LDKPaymentFailureReason_RecipientRejected, /** @@ -647,11 +833,18 @@ typedef enum LDKPaymentFailureReason { * The payment expired while retrying, based on the provided * [`PaymentParameters::expiry_time`]. * + * Also used for [`InvoiceRequestExpired`] when downgrading to version prior to 0.0.124. + * * [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + * [`InvoiceRequestExpired`]: Self::InvoiceRequestExpired */ LDKPaymentFailureReason_PaymentExpired, /** * We failed to find a route while retrying the payment. + * + * Note that this generally indicates that we've exhausted the available set of possible + * routes - we tried the payment over a few routes but were not able to find any further + * candidate routes beyond those. */ LDKPaymentFailureReason_RouteNotFound, /** @@ -659,6 +852,20 @@ typedef enum LDKPaymentFailureReason { * your router. */ LDKPaymentFailureReason_UnexpectedError, + /** + * An invoice was received that required unknown features. + */ + LDKPaymentFailureReason_UnknownRequiredFeatures, + /** + * A [`Bolt12Invoice`] was not received in a reasonable amount of time. + */ + LDKPaymentFailureReason_InvoiceRequestExpired, + /** + * An [`InvoiceRequest`] for the payment was rejected by the recipient. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + LDKPaymentFailureReason_InvoiceRequestRejected, /** * Must be last for serialization purposes */ @@ -718,6 +925,14 @@ typedef enum LDKRetryableSendFailure { * [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed */ LDKRetryableSendFailure_DuplicatePayment, + /** + * The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs`], or + * [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion + * packet size of 1300 bytes. + * + * [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath + */ + LDKRetryableSendFailure_OnionPacketSizeExceeded, /** * Must be last for serialization purposes */ @@ -772,12 +987,38 @@ typedef enum LDKSecp256k1Error { * The only valid parity values are 0 or 1. */ LDKSecp256k1Error_InvalidParityValue, + /** + * Invalid Elligator Swift Value + */ + LDKSecp256k1Error_InvalidEllSwift, /** * Must be last for serialization purposes */ LDKSecp256k1Error_Sentinel, } LDKSecp256k1Error; +/** + * A `short_channel_id` construction error + */ +typedef enum LDKShortChannelIdError { + /** + * Block height too high + */ + LDKShortChannelIdError_BlockOverflow, + /** + * Tx index too high + */ + LDKShortChannelIdError_TxIndexOverflow, + /** + * Vout index too high + */ + LDKShortChannelIdError_VoutIndexOverflow, + /** + * Must be last for serialization purposes + */ + LDKShortChannelIdError_Sentinel, +} LDKShortChannelIdError; + /** * SI prefixes for the human readable part */ @@ -1104,6 +1345,123 @@ typedef struct LDKTxOut { uint64_t value; } LDKTxOut; + + +/** + * Builds a [`Refund`] for the \"offer for money\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self + */ +typedef struct MUST_USE_STRUCT LDKRefundMaybeWithDerivedMetadataBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRefundMaybeWithDerivedMetadataBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRefundMaybeWithDerivedMetadataBuilder; + +/** + * The contents of CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRefundMaybeWithDerivedMetadataBuilder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr; + +/** + * A CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + /** + * The contents of this CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ; + + + +/** + * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`]. + * + * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to + * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a + * bitcoin ATM. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Offer`]: crate::offers::offer::Offer + */ +typedef struct MUST_USE_STRUCT LDKRefund { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRefund *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRefund; + +/** + * The contents of CResult_RefundBolt12SemanticErrorZ + */ +typedef union LDKCResult_RefundBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKRefund *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_RefundBolt12SemanticErrorZPtr; + +/** + * A CResult_RefundBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RefundBolt12SemanticErrorZ { + /** + * The contents of this CResult_RefundBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RefundBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_RefundBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RefundBolt12SemanticErrorZ; + /** * An enum which can either contain a u64 or not */ @@ -1134,66 +1492,137 @@ typedef struct LDKCOption_u64Z { /** - * Onion messages and payments can be sent and received to blinded paths, which serve to hide the - * identity of the recipient. + * A blinded path to be used for sending or receiving a message, hiding the identity of the + * recipient. */ -typedef struct MUST_USE_STRUCT LDKBlindedPath { +typedef struct MUST_USE_STRUCT LDKBlindedMessagePath { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBlindedPath *inner; + LDKnativeBlindedMessagePath *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBlindedPath; +} LDKBlindedMessagePath; /** - * A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. + * A dynamically-allocated array of crate::lightning::blinded_path::message::BlindedMessagePaths of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_BlindedPathZ { +typedef struct LDKCVec_BlindedMessagePathZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKBlindedPath *data; + struct LDKBlindedMessagePath *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_BlindedPathZ; +} LDKCVec_BlindedMessagePathZ; +/** + * An error in decoding a message or struct. + */ +typedef enum LDKDecodeError_Tag { + /** + * A version byte specified something we don't know how to handle. + * + * Includes unknown realm byte in an onion hop data packet. + */ + LDKDecodeError_UnknownVersion, + /** + * Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type) + */ + LDKDecodeError_UnknownRequiredFeature, + /** + * Value was invalid. + * + * For example, a byte which was supposed to be a bool was something other than a 0 + * or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was + * syntactically incorrect, etc. + */ + LDKDecodeError_InvalidValue, + /** + * The buffer to be read was too short. + */ + LDKDecodeError_ShortRead, + /** + * A length descriptor in the packet didn't describe the later data correctly. + */ + LDKDecodeError_BadLengthDescriptor, + /** + * Error from [`std::io`]. + */ + LDKDecodeError_Io, + /** + * The message included zlib-compressed values, which we don't support. + */ + LDKDecodeError_UnsupportedCompression, + /** + * Value is validly encoded but is dangerous to use. + * + * This is used for things like [`ChannelManager`] deserialization where we want to ensure + * that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`]. + * This indicates that there is a critical implementation flaw in the storage implementation + * and it's unsafe to continue. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + */ + LDKDecodeError_DangerousValue, + /** + * Must be last for serialization purposes + */ + LDKDecodeError_Sentinel, +} LDKDecodeError_Tag; +typedef struct MUST_USE_STRUCT LDKDecodeError { + LDKDecodeError_Tag tag; + union { + struct { + enum LDKIOError io; + }; + }; +} LDKDecodeError; /** - * A `Refund` is a request to send an [`Bolt12Invoice`] without a preceding [`Offer`]. - * - * Typically, after an invoice is paid, the recipient may publish a refund allowing the sender to - * recoup their funds. A refund may be used more generally as an \"offer for money\", such as with a - * bitcoin ATM. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`Offer`]: crate::offers::offer::Offer + * The contents of CResult_RefundDecodeErrorZ */ -typedef struct MUST_USE_STRUCT LDKRefund { +typedef union LDKCResult_RefundDecodeErrorZPtr { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKnativeRefund *inner; + struct LDKRefund *result; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - bool is_owned; -} LDKRefund; + struct LDKDecodeError *err; +} LDKCResult_RefundDecodeErrorZPtr; + +/** + * A CResult_RefundDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_RefundDecodeErrorZ { + /** + * The contents of this CResult_RefundDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_RefundDecodeErrorZPtr contents; + /** + * Whether this CResult_RefundDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_RefundDecodeErrorZ; @@ -1285,59 +1714,6 @@ typedef struct MUST_USE_STRUCT LDKRetry { }; } LDKRetry; -/** - * An error in decoding a message or struct. - */ -typedef enum LDKDecodeError_Tag { - /** - * A version byte specified something we don't know how to handle. - * - * Includes unknown realm byte in an onion hop data packet. - */ - LDKDecodeError_UnknownVersion, - /** - * Unknown feature mandating we fail to parse message (e.g., TLV with an even, unknown type) - */ - LDKDecodeError_UnknownRequiredFeature, - /** - * Value was invalid. - * - * For example, a byte which was supposed to be a bool was something other than a 0 - * or 1, a public key/private key/signature was invalid, text wasn't UTF-8, TLV was - * syntactically incorrect, etc. - */ - LDKDecodeError_InvalidValue, - /** - * The buffer to be read was too short. - */ - LDKDecodeError_ShortRead, - /** - * A length descriptor in the packet didn't describe the later data correctly. - */ - LDKDecodeError_BadLengthDescriptor, - /** - * Error from [`std::io`]. - */ - LDKDecodeError_Io, - /** - * The message included zlib-compressed values, which we don't support. - */ - LDKDecodeError_UnsupportedCompression, - /** - * Must be last for serialization purposes - */ - LDKDecodeError_Sentinel, -} LDKDecodeError_Tag; - -typedef struct MUST_USE_STRUCT LDKDecodeError { - LDKDecodeError_Tag tag; - union { - struct { - enum LDKIOError io; - }; - }; -} LDKDecodeError; - /** * The contents of CResult_RetryDecodeErrorZ */ @@ -1734,6 +2110,182 @@ typedef struct LDKCResult_RecipientOnionFieldsNoneZ { bool result_ok; } LDKCResult_RecipientOnionFieldsNoneZ; + + +/** + * A semantically valid [`Bolt12Invoice`] that hasn't been signed. + * + * # Serialization + * + * This is serialized as a TLV stream, which includes TLV records from the originating message. As + * such, it may include unknown, odd TLV records. + */ +typedef struct MUST_USE_STRUCT LDKUnsignedBolt12Invoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnsignedBolt12Invoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnsignedBolt12Invoice; + +/** + * The contents of CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ + */ +typedef union LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKUnsignedBolt12Invoice *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr; + +/** + * A CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::UnsignedBolt12Invoice on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + /** + * The contents of this CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ; + + + +/** + * A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`]. + * + * An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent + * directly after scanning a refund. It includes all the information needed to pay a recipient. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ +typedef struct MUST_USE_STRUCT LDKBolt12Invoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt12Invoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt12Invoice; + +/** + * The contents of CResult_Bolt12InvoiceBolt12SemanticErrorZ + */ +typedef union LDKCResult_Bolt12InvoiceBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBolt12Invoice *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_Bolt12InvoiceBolt12SemanticErrorZPtr; + +/** + * A CResult_Bolt12InvoiceBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::Bolt12Invoice on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ { + /** + * The contents of this CResult_Bolt12InvoiceBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_Bolt12InvoiceBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_Bolt12InvoiceBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ; + +/** + * Represents a secp256k1 Schnorr signature serialized as two 32-byte numbers + */ +typedef struct LDKSchnorrSignature { + /** + * The bytes of the signature as two 32-byte numbers + */ + uint8_t compact_form[64]; +} LDKSchnorrSignature; + +/** + * The contents of CResult_SchnorrSignatureNoneZ + */ +typedef union LDKCResult_SchnorrSignatureNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKSchnorrSignature *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_SchnorrSignatureNoneZPtr; + +/** + * A CResult_SchnorrSignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::SchnorrSignature on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_SchnorrSignatureNoneZ { + /** + * The contents of this CResult_SchnorrSignatureNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_SchnorrSignatureNoneZPtr contents; + /** + * Whether this CResult_SchnorrSignatureNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_SchnorrSignatureNoneZ; + +/** + * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_StrZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKStr *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_StrZ; + /** * A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. * This corresponds to std::vector in C++ @@ -1777,6 +2329,150 @@ typedef struct LDKCOption_CVec_ThirtyTwoBytesZZ { }; } LDKCOption_CVec_ThirtyTwoBytesZZ; +/** + * A 3-byte byte array. + */ +typedef struct LDKThreeBytes { + /** + * The three bytes + */ + uint8_t data[3]; +} LDKThreeBytes; + +/** + * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or + * another currency. + */ +typedef enum LDKAmount_Tag { + /** + * An amount of bitcoin. + */ + LDKAmount_Bitcoin, + /** + * An amount of currency specified using ISO 4712. + */ + LDKAmount_Currency, + /** + * Must be last for serialization purposes + */ + LDKAmount_Sentinel, +} LDKAmount_Tag; + +typedef struct LDKAmount_LDKBitcoin_Body { + /** + * The amount in millisatoshi. + */ + uint64_t amount_msats; +} LDKAmount_LDKBitcoin_Body; + +typedef struct LDKAmount_LDKCurrency_Body { + /** + * The currency that the amount is denominated in. + */ + struct LDKThreeBytes iso4217_code; + /** + * The amount in the currency unit adjusted by the ISO 4712 exponent (e.g., USD cents). + */ + uint64_t amount; +} LDKAmount_LDKCurrency_Body; + +typedef struct MUST_USE_STRUCT LDKAmount { + LDKAmount_Tag tag; + union { + LDKAmount_LDKBitcoin_Body bitcoin; + LDKAmount_LDKCurrency_Body currency; + }; +} LDKAmount; + +/** + * An enum which can either contain a crate::lightning::offers::offer::Amount or not + */ +typedef enum LDKCOption_AmountZ_Tag { + /** + * When we're in this state, this COption_AmountZ contains a crate::lightning::offers::offer::Amount + */ + LDKCOption_AmountZ_Some, + /** + * When we're in this state, this COption_AmountZ contains nothing + */ + LDKCOption_AmountZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_AmountZ_Sentinel, +} LDKCOption_AmountZ_Tag; + +typedef struct LDKCOption_AmountZ { + LDKCOption_AmountZ_Tag tag; + union { + struct { + struct LDKAmount some; + }; + }; +} LDKCOption_AmountZ; + +/** + * Quantity of items supported by an [`Offer`]. + */ +typedef enum LDKQuantity_Tag { + /** + * Up to a specific number of items (inclusive). Use when more than one item can be requested + * but is limited (e.g., because of per customer or inventory limits). + * + * May be used with `NonZeroU64::new(1)` but prefer to use [`Quantity::One`] if only one item + * is supported. + */ + LDKQuantity_Bounded, + /** + * One or more items. Use when more than one item can be requested without any limit. + */ + LDKQuantity_Unbounded, + /** + * Only one item. Use when only a single item can be requested. + */ + LDKQuantity_One, + /** + * Must be last for serialization purposes + */ + LDKQuantity_Sentinel, +} LDKQuantity_Tag; + +typedef struct MUST_USE_STRUCT LDKQuantity { + LDKQuantity_Tag tag; + union { + struct { + uint64_t bounded; + }; + }; +} LDKQuantity; + +/** + * An enum which can either contain a crate::lightning::offers::offer::Quantity or not + */ +typedef enum LDKCOption_QuantityZ_Tag { + /** + * When we're in this state, this COption_QuantityZ contains a crate::lightning::offers::offer::Quantity + */ + LDKCOption_QuantityZ_Some, + /** + * When we're in this state, this COption_QuantityZ contains nothing + */ + LDKCOption_QuantityZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_QuantityZ_Sentinel, +} LDKCOption_QuantityZ_Tag; + +typedef struct LDKCOption_QuantityZ { + LDKCOption_QuantityZ_Tag tag; + union { + struct { + struct LDKQuantity some; + }; + }; +} LDKCOption_QuantityZ; + /** * The contents of CResult_ThirtyTwoBytesNoneZ */ @@ -1809,58 +2505,38 @@ typedef struct LDKCResult_ThirtyTwoBytesNoneZ { bool result_ok; } LDKCResult_ThirtyTwoBytesNoneZ; - - -/** - * Information needed to route a payment across a [`BlindedPath`]. - */ -typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeBlindedPayInfo *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKBlindedPayInfo; - /** - * The contents of CResult_BlindedPayInfoDecodeErrorZ + * The contents of CResult_Bolt12InvoiceDecodeErrorZ */ -typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { +typedef union LDKCResult_Bolt12InvoiceDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBlindedPayInfo *result; + struct LDKBolt12Invoice *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_BlindedPayInfoDecodeErrorZPtr; +} LDKCResult_Bolt12InvoiceDecodeErrorZPtr; /** - * A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_Bolt12InvoiceDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::Bolt12Invoice on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { +typedef struct LDKCResult_Bolt12InvoiceDecodeErrorZ { /** - * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either + * The contents of this CResult_Bolt12InvoiceDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; + union LDKCResult_Bolt12InvoiceDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + * Whether this CResult_Bolt12InvoiceDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPayInfoDecodeErrorZ; +} LDKCResult_Bolt12InvoiceDecodeErrorZ; @@ -1977,7 +2653,7 @@ typedef struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ { /** * A reference to a transaction output. * - * Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 + * Differs from bitcoin::transaction::OutPoint as the index is a u16 instead of u32 * due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. */ typedef struct MUST_USE_STRUCT LDKOutPoint { @@ -2367,77 +3043,109 @@ typedef struct LDKCResult_HTLCDescriptorDecodeErrorZ { } LDKCResult_HTLCDescriptorDecodeErrorZ; /** - * The contents of CResult_NoneNoneZ + * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. */ -typedef union LDKCResult_NoneNoneZPtr { +typedef struct LDKPublicKey { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * The bytes of the public key */ - void *result; + uint8_t compressed_form[33]; +} LDKPublicKey; + +/** + * The contents of CResult_PublicKeyNoneZ + */ +typedef union LDKCResult_PublicKeyNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKPublicKey *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_NoneNoneZPtr; +} LDKCResult_PublicKeyNoneZPtr; /** - * A CResult_NoneNoneZ represents the result of a fallible operation, - * containing a () on success and a () on failure. + * A CResult_PublicKeyNoneZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneNoneZ { +typedef struct LDKCResult_PublicKeyNoneZ { /** - * The contents of this CResult_NoneNoneZ, accessible via either + * The contents of this CResult_PublicKeyNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneNoneZPtr contents; + union LDKCResult_PublicKeyNoneZPtr contents; /** - * Whether this CResult_NoneNoneZ represents a success state. + * Whether this CResult_PublicKeyNoneZ represents a success state. */ bool result_ok; -} LDKCResult_NoneNoneZ; +} LDKCResult_PublicKeyNoneZ; /** - * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. + * The contents of CResult__u832NoneZ */ -typedef struct LDKPublicKey { +typedef union LDKCResult__u832NoneZPtr { /** - * The bytes of the public key + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint8_t compressed_form[33]; -} LDKPublicKey; + struct LDKThirtyTwoBytes *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult__u832NoneZPtr; /** - * The contents of CResult_PublicKeyNoneZ + * A CResult__u832NoneZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef union LDKCResult_PublicKeyNoneZPtr { +typedef struct LDKCResult__u832NoneZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The contents of this CResult__u832NoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKPublicKey *result; + union LDKCResult__u832NoneZPtr contents; + /** + * Whether this CResult__u832NoneZ represents a success state. + */ + bool result_ok; +} LDKCResult__u832NoneZ; + +/** + * The contents of CResult_NoneNoneZ + */ +typedef union LDKCResult_NoneNoneZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_PublicKeyNoneZPtr; +} LDKCResult_NoneNoneZPtr; /** - * A CResult_PublicKeyNoneZ represents the result of a fallible operation, - * containing a crate::c_types::PublicKey on success and a () on failure. + * A CResult_NoneNoneZ represents the result of a fallible operation, + * containing a () on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PublicKeyNoneZ { +typedef struct LDKCResult_NoneNoneZ { /** - * The contents of this CResult_PublicKeyNoneZ, accessible via either + * The contents of this CResult_NoneNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PublicKeyNoneZPtr contents; + union LDKCResult_NoneNoneZPtr contents; /** - * Whether this CResult_PublicKeyNoneZ represents a success state. + * Whether this CResult_NoneNoneZ represents a success state. */ bool result_ok; -} LDKCResult_PublicKeyNoneZ; +} LDKCResult_NoneNoneZ; /** * An enum which can either contain a crate::c_types::BigEndianScalar or not @@ -2466,29 +3174,6 @@ typedef struct LDKCOption_BigEndianScalarZ { }; } LDKCOption_BigEndianScalarZ; -/** - * Integer in the range `0..32` - */ -typedef struct LDKU5 { - uint8_t _0; -} LDKU5; - -/** - * A dynamically-allocated array of crate::c_types::U5s of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_U5Z { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKU5 *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_U5Z; - /** * Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which * allows recovering the exact public key which created the signature given the message. @@ -2534,88 +3219,78 @@ typedef struct LDKCResult_RecoverableSignatureNoneZ { } LDKCResult_RecoverableSignatureNoneZ; /** - * Represents a secp256k1 Schnorr signature serialized as two 32-byte numbers + * Represents a secp256k1 ECDSA signature serialized as two 32-byte numbers */ -typedef struct LDKSchnorrSignature { +typedef struct LDKECDSASignature { /** - * The bytes of the signature as two 32-byte numbers + * The bytes of the signature in "compact" form */ uint8_t compact_form[64]; -} LDKSchnorrSignature; +} LDKECDSASignature; /** - * The contents of CResult_SchnorrSignatureNoneZ + * The contents of CResult_ECDSASignatureNoneZ */ -typedef union LDKCResult_SchnorrSignatureNoneZPtr { +typedef union LDKCResult_ECDSASignatureNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSchnorrSignature *result; + struct LDKECDSASignature *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_SchnorrSignatureNoneZPtr; +} LDKCResult_ECDSASignatureNoneZPtr; /** - * A CResult_SchnorrSignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::SchnorrSignature on success and a () on failure. + * A CResult_ECDSASignatureNoneZ represents the result of a fallible operation, + * containing a crate::c_types::ECDSASignature on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SchnorrSignatureNoneZ { +typedef struct LDKCResult_ECDSASignatureNoneZ { /** - * The contents of this CResult_SchnorrSignatureNoneZ, accessible via either + * The contents of this CResult_ECDSASignatureNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SchnorrSignatureNoneZPtr contents; + union LDKCResult_ECDSASignatureNoneZPtr contents; /** - * Whether this CResult_SchnorrSignatureNoneZ represents a success state. + * Whether this CResult_ECDSASignatureNoneZ represents a success state. */ bool result_ok; -} LDKCResult_SchnorrSignatureNoneZ; - -/** - * Represents a secp256k1 ECDSA signature serialized as two 32-byte numbers - */ -typedef struct LDKECDSASignature { - /** - * The bytes of the signature in "compact" form - */ - uint8_t compact_form[64]; -} LDKECDSASignature; +} LDKCResult_ECDSASignatureNoneZ; /** - * The contents of CResult_ECDSASignatureNoneZ + * The contents of CResult_TransactionNoneZ */ -typedef union LDKCResult_ECDSASignatureNoneZPtr { +typedef union LDKCResult_TransactionNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKECDSASignature *result; + struct LDKTransaction *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_ECDSASignatureNoneZPtr; +} LDKCResult_TransactionNoneZPtr; /** - * A CResult_ECDSASignatureNoneZ represents the result of a fallible operation, - * containing a crate::c_types::ECDSASignature on success and a () on failure. + * A CResult_TransactionNoneZ represents the result of a fallible operation, + * containing a crate::c_types::Transaction on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ECDSASignatureNoneZ { +typedef struct LDKCResult_TransactionNoneZ { /** - * The contents of this CResult_ECDSASignatureNoneZ, accessible via either + * The contents of this CResult_TransactionNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ECDSASignatureNoneZPtr contents; + union LDKCResult_TransactionNoneZPtr contents; /** - * Whether this CResult_ECDSASignatureNoneZ represents a success state. + * Whether this CResult_TransactionNoneZ represents a success state. */ bool result_ok; -} LDKCResult_ECDSASignatureNoneZ; +} LDKCResult_TransactionNoneZ; /** * A dynamically-allocated array of crate::c_types::ECDSASignatures of arbitrary size. @@ -2839,6 +3514,10 @@ typedef struct MUST_USE_STRUCT LDKChannelTransactionParameters { /** * A trait to handle Lightning channel key material without concretizing the channel type or * the signature mechanism. + * + * Several methods allow error types to be returned to support async signing. This feature + * is not yet complete, and panics may occur in certain situations when returning errors + * for these methods. */ typedef struct LDKChannelSigner { /** @@ -2850,8 +3529,13 @@ typedef struct LDKChannelSigner { * Gets the per-commitment point for a specific commitment number * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + * + * If the signer returns `Err`, then the user is responsible for either force-closing the channel + * or calling `ChannelManager::signer_unblocked` (this method is only available when the + * `async_signing` cfg flag is enabled) once the signature is ready. + * */ - struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); + struct LDKCResult_PublicKeyNoneZ (*get_per_commitment_point)(const void *this_arg, uint64_t idx); /** * Gets the commitment secret for a specific commitment number as part of the revocation process * @@ -2862,7 +3546,7 @@ typedef struct LDKChannelSigner { * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. */ - struct LDKThirtyTwoBytes (*release_commitment_secret)(const void *this_arg, uint64_t idx); + struct LDKCResult__u832NoneZ (*release_commitment_secret)(const void *this_arg, uint64_t idx); /** * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. * @@ -2963,6 +3647,13 @@ typedef struct LDKEcdsaChannelSigner { * This may be called multiple times for the same transaction. * * An external signer implementation should check that the commitment has not been revoked. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_holder_commitment)(const void *this_arg, const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** @@ -2980,6 +3671,13 @@ typedef struct LDKEcdsaChannelSigner { * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do * so). + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_justice_revoked_output)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); /** @@ -3001,6 +3699,13 @@ typedef struct LDKEcdsaChannelSigner { * * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script * (which is committed to in the BIP 143 signatures). + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_justice_revoked_htlc)(const void *this_arg, struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** @@ -3012,8 +3717,14 @@ typedef struct LDKEcdsaChannelSigner { * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) * broadcasts it before receiving the update for the latest commitment transaction. * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_holder_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, const struct LDKHTLCDescriptor *NONNULL_PTR htlc_descriptor); /** @@ -3034,6 +3745,13 @@ typedef struct LDKEcdsaChannelSigner { * detected onchain. It has been generated by our counterparty and is used to derive * channel state keys, which are then included in the witness script and committed to in the * BIP 143 signature. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_counterparty_htlc_transaction)(const void *this_arg, struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** @@ -3046,6 +3764,13 @@ typedef struct LDKEcdsaChannelSigner { /** * Computes the signature for a commitment transaction's anchor output used as an * input within `anchor_tx`, which spends the commitment transaction, at index `input`. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ struct LDKCResult_ECDSASignatureNoneZ (*sign_holder_anchor_input)(const void *this_arg, struct LDKTransaction anchor_tx, uintptr_t input); /** @@ -3067,80 +3792,50 @@ typedef struct LDKEcdsaChannelSigner { */ struct LDKChannelSigner ChannelSigner; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKEcdsaChannelSigner; - -/** - * A writeable signer. - * - * There will always be two instances of a signer per channel, one occupied by the - * [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - */ -typedef struct LDKWriteableEcdsaChannelSigner { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Implementation of EcdsaChannelSigner for this object. - */ - struct LDKEcdsaChannelSigner EcdsaChannelSigner; - /** - * Serialize the object into a byte array - */ - struct LDKCVec_u8Z (*write)(const void *this_arg); - /** - * Called, if set, after this WriteableEcdsaChannelSigner has been cloned into a duplicate object. - * The new WriteableEcdsaChannelSigner is provided, and should be mutated as needed to perform a + * Called, if set, after this EcdsaChannelSigner has been cloned into a duplicate object. + * The new EcdsaChannelSigner is provided, and should be mutated as needed to perform a * deep copy of the object pointed to by this_arg or avoid any double-freeing. */ - void (*cloned)(struct LDKWriteableEcdsaChannelSigner *NONNULL_PTR new_WriteableEcdsaChannelSigner); + void (*cloned)(struct LDKEcdsaChannelSigner *NONNULL_PTR new_EcdsaChannelSigner); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKWriteableEcdsaChannelSigner; +} LDKEcdsaChannelSigner; /** - * The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ + * The contents of CResult_EcdsaChannelSignerDecodeErrorZ */ -typedef union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +typedef union LDKCResult_EcdsaChannelSignerDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKWriteableEcdsaChannelSigner *result; + struct LDKEcdsaChannelSigner *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr; +} LDKCResult_EcdsaChannelSignerDecodeErrorZPtr; /** - * A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_EcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::sign::ecdsa::EcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ { +typedef struct LDKCResult_EcdsaChannelSignerDecodeErrorZ { /** - * The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either + * The contents of this CResult_EcdsaChannelSignerDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZPtr contents; + union LDKCResult_EcdsaChannelSignerDecodeErrorZPtr contents; /** - * Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. + * Whether this CResult_EcdsaChannelSignerDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ; +} LDKCResult_EcdsaChannelSignerDecodeErrorZ; /** * The contents of CResult_CVec_u8ZNoneZ @@ -3295,7 +3990,7 @@ typedef struct LDKCResult_WitnessNoneZ { /** - * A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. + * A simple implementation of [`EcdsaChannelSigner`] that just keeps the private keys in memory. * * This implementation performs no policy checks and is insufficient by itself as * a secure external signer. @@ -3348,38 +4043,6 @@ typedef struct LDKCResult_InMemorySignerDecodeErrorZ { bool result_ok; } LDKCResult_InMemorySignerDecodeErrorZ; -/** - * The contents of CResult_TransactionNoneZ - */ -typedef union LDKCResult_TransactionNoneZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - struct LDKTransaction *result; - /** - * Note that this value is always NULL, as there are no contents in the Err variant - */ - void *err; -} LDKCResult_TransactionNoneZPtr; - -/** - * A CResult_TransactionNoneZ represents the result of a fallible operation, - * containing a crate::c_types::Transaction on success and a () on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_TransactionNoneZ { - /** - * The contents of this CResult_TransactionNoneZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_TransactionNoneZPtr contents; - /** - * Whether this CResult_TransactionNoneZ represents a success state. - */ - bool result_ok; -} LDKCResult_TransactionNoneZ; - /** @@ -3525,6 +4188,8 @@ typedef enum LDKCandidateRouteHop_Tag { * * This primarily exists to track that we need to included a blinded path at the end of our * [`Route`], even though it doesn't actually add an additional hop in the payment. + * + * [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo */ LDKCandidateRouteHop_OneHopBlinded, /** @@ -3810,8 +4475,89 @@ typedef struct LDKCResult_NoneIOErrorZ { +/** + * Parameters needed to find a [`Route`]. + * + * Passed to [`find_route`] and [`build_route_from_hops`]. + */ +typedef struct MUST_USE_STRUCT LDKRouteParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRouteParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRouteParameters; + +/** + * A tuple of 3 elements. See the individual fields for the types contained. + */ +typedef struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + /** + * The element at position 0 + */ + struct LDKThirtyTwoBytes a; + /** + * The element at position 1 + */ + struct LDKRecipientOnionFields b; + /** + * The element at position 2 + */ + struct LDKRouteParameters c; +} LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; + +/** + * The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ + */ +typedef union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr; + +/** + * A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + /** + * The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr contents; + /** + * Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; + + + /** * Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] + * + * Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and + * [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain + * transactions. + * + * [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels + * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels + * [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances + * [`ChannelMonitor::get_claimable_balances`]: crate::chain::channelmonitor::ChannelMonitor::get_claimable_balances */ typedef struct MUST_USE_STRUCT LDKChannelDetails { /** @@ -3829,7 +4575,7 @@ typedef struct MUST_USE_STRUCT LDKChannelDetails { } LDKChannelDetails; /** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::channel_state::ChannelDetailss of arbitrary size. * This corresponds to std::vector in C++ */ typedef struct LDKCVec_ChannelDetailsZ { @@ -3918,67 +4664,74 @@ typedef struct LDKCResult_RouteLightningErrorZ { bool result_ok; } LDKCResult_RouteLightningErrorZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * A blinded path to be used for sending or receiving a payment, hiding the identity of the + * recipient. */ -typedef struct LDKC2Tuple_BlindedPayInfoBlindedPathZ { +typedef struct MUST_USE_STRUCT LDKBlindedPaymentPath { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKBlindedPayInfo a; + LDKnativeBlindedPaymentPath *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKBlindedPath b; -} LDKC2Tuple_BlindedPayInfoBlindedPathZ; + bool is_owned; +} LDKBlindedPaymentPath; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. + * A dynamically-allocated array of crate::lightning::blinded_path::payment::BlindedPaymentPaths of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ { +typedef struct LDKCVec_BlindedPaymentPathZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *data; + struct LDKBlindedPaymentPath *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ; +} LDKCVec_BlindedPaymentPathZ; /** - * The contents of CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ + * The contents of CResult_CVec_BlindedPaymentPathZNoneZ */ -typedef union LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +typedef union LDKCResult_CVec_BlindedPaymentPathZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *result; + struct LDKCVec_BlindedPaymentPathZ *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr; +} LDKCResult_CVec_BlindedPaymentPathZNoneZPtr; /** - * A CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ on success and a () on failure. + * A CResult_CVec_BlindedPaymentPathZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_BlindedPaymentPathZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +typedef struct LDKCResult_CVec_BlindedPaymentPathZNoneZ { /** - * The contents of this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, accessible via either + * The contents of this CResult_CVec_BlindedPaymentPathZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr contents; + union LDKCResult_CVec_BlindedPaymentPathZNoneZPtr contents; /** - * Whether this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents a success state. + * Whether this CResult_CVec_BlindedPaymentPathZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ; +} LDKCResult_CVec_BlindedPaymentPathZNoneZ; /** * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. @@ -4049,36 +4802,72 @@ typedef struct LDKCResult_OnionMessagePathNoneZ { } LDKCResult_OnionMessagePathNoneZ; /** - * The contents of CResult_CVec_BlindedPathZNoneZ + * The contents of CResult_CVec_BlindedMessagePathZNoneZ */ -typedef union LDKCResult_CVec_BlindedPathZNoneZPtr { +typedef union LDKCResult_CVec_BlindedMessagePathZNoneZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCVec_BlindedPathZ *result; + struct LDKCVec_BlindedMessagePathZ *result; /** * Note that this value is always NULL, as there are no contents in the Err variant */ void *err; -} LDKCResult_CVec_BlindedPathZNoneZPtr; +} LDKCResult_CVec_BlindedMessagePathZNoneZPtr; /** - * A CResult_CVec_BlindedPathZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::CVec_BlindedPathZ on success and a () on failure. + * A CResult_CVec_BlindedMessagePathZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::CVec_BlindedMessagePathZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_CVec_BlindedPathZNoneZ { +typedef struct LDKCResult_CVec_BlindedMessagePathZNoneZ { /** - * The contents of this CResult_CVec_BlindedPathZNoneZ, accessible via either + * The contents of this CResult_CVec_BlindedMessagePathZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_CVec_BlindedPathZNoneZPtr contents; + union LDKCResult_CVec_BlindedMessagePathZNoneZPtr contents; /** - * Whether this CResult_CVec_BlindedPathZNoneZ represents a success state. + * Whether this CResult_CVec_BlindedMessagePathZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_CVec_BlindedPathZNoneZ; +} LDKCResult_CVec_BlindedMessagePathZNoneZ; + + + +/** + * An intermediate node, and possibly a short channel id leading to the next node. + */ +typedef struct MUST_USE_STRUCT LDKMessageForwardNode { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeMessageForwardNode *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKMessageForwardNode; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::message::MessageForwardNodes of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_MessageForwardNodeZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKMessageForwardNode *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_MessageForwardNodeZ; @@ -4347,28 +5136,6 @@ typedef struct LDKCResult_RouteDecodeErrorZ { bool result_ok; } LDKCResult_RouteDecodeErrorZ; - - -/** - * Parameters needed to find a [`Route`]. - * - * Passed to [`find_route`] and [`build_route_from_hops`]. - */ -typedef struct MUST_USE_STRUCT LDKRouteParameters { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRouteParameters *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRouteParameters; - /** * The contents of CResult_RouteParametersDecodeErrorZ */ @@ -4492,7 +5259,7 @@ typedef struct MUST_USE_STRUCT LDKRouteHint { } LDKRouteHint; /** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. + * A dynamically-allocated array of crate::lightning_types::routing::RouteHints of arbitrary size. * This corresponds to std::vector in C++ */ typedef struct LDKCVec_RouteHintZ { @@ -4507,46 +5274,6 @@ typedef struct LDKCVec_RouteHintZ { uintptr_t datalen; } LDKCVec_RouteHintZ; - - -/** - * A channel descriptor for a hop along a payment path. - * - * While this generally comes from BOLT 11's `r` field, this struct includes more fields than are - * available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as - * fields not supported in BOLT 11 will be stripped. - */ -typedef struct MUST_USE_STRUCT LDKRouteHintHop { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRouteHintHop *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRouteHintHop; - -/** - * A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_RouteHintHopZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKRouteHintHop *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_RouteHintHopZ; - /** * The contents of CResult_RouteHintDecodeErrorZ */ @@ -4565,7 +5292,7 @@ typedef union LDKCResult_RouteHintDecodeErrorZPtr { /** * A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::routing::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_RouteHintDecodeErrorZ { @@ -4580,6 +5307,30 @@ typedef struct LDKCResult_RouteHintDecodeErrorZ { bool result_ok; } LDKCResult_RouteHintDecodeErrorZ; + + +/** + * A channel descriptor for a hop along a payment path. + * + * While this generally comes from BOLT 11's `r` field, this struct includes more fields than are + * available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as + * fields not supported in BOLT 11 will be stripped. + */ +typedef struct MUST_USE_STRUCT LDKRouteHintHop { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRouteHintHop *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRouteHintHop; + /** * The contents of CResult_RouteHintHopDecodeErrorZ */ @@ -4598,7 +5349,7 @@ typedef union LDKCResult_RouteHintHopDecodeErrorZPtr { /** * A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::routing::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_RouteHintHopDecodeErrorZ { @@ -4979,6 +5730,59 @@ typedef struct LDKCResult_ProbabilisticScorerDecodeErrorZ { bool result_ok; } LDKCResult_ProbabilisticScorerDecodeErrorZ; + + +/** + * The best known block as identified by its hash and height. + */ +typedef struct MUST_USE_STRUCT LDKBestBlock { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBestBlock *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBestBlock; + +/** + * The contents of CResult_BestBlockDecodeErrorZ + */ +typedef union LDKCResult_BestBlockDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBestBlock *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_BestBlockDecodeErrorZPtr; + +/** + * A CResult_BestBlockDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::chain::BestBlock on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BestBlockDecodeErrorZ { + /** + * The contents of this CResult_BestBlockDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BestBlockDecodeErrorZPtr contents; + /** + * Whether this CResult_BestBlockDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BestBlockDecodeErrorZ; + /** * A tuple of 2 elements. See the individual fields for the types contained. */ @@ -5097,6 +5901,217 @@ typedef struct MUST_USE_STRUCT LDKHTLCUpdate { bool is_owned; } LDKHTLCUpdate; + + +/** + * Struct to `Display` fields in a safe way using `PrintableString` + */ +typedef struct MUST_USE_STRUCT LDKUntrustedString { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUntrustedString *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUntrustedString; + +/** + * The reason the channel was closed. See individual variants for more details. + */ +typedef enum LDKClosureReason_Tag { + /** + * Closure generated from receiving a peer error message. + * + * Our counterparty may have broadcasted their latest commitment state, and we have + * as well. + */ + LDKClosureReason_CounterpartyForceClosed, + /** + * Closure generated from [`ChannelManager::force_close_channel`], called by the user. + * + * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. + */ + LDKClosureReason_HolderForceClosed, + /** + * The channel was closed after negotiating a cooperative close and we've now broadcasted + * the cooperative close transaction. Note the shutdown may have been initiated by us. + * + * This was only set in versions of LDK prior to 0.0.122. + */ + LDKClosureReason_LegacyCooperativeClosure, + /** + * The channel was closed after negotiating a cooperative close and we've now broadcasted + * the cooperative close transaction. This indicates that the shutdown was initiated by our + * counterparty. + * + * In rare cases where we initiated closure immediately prior to shutting down without + * persisting, this value may be provided for channels we initiated closure for. + */ + LDKClosureReason_CounterpartyInitiatedCooperativeClosure, + /** + * The channel was closed after negotiating a cooperative close and we've now broadcasted + * the cooperative close transaction. This indicates that the shutdown was initiated by us. + */ + LDKClosureReason_LocallyInitiatedCooperativeClosure, + /** + * A commitment transaction was confirmed on chain, closing the channel. Most likely this + * commitment transaction came from our counterparty, but it may also have come from + * a copy of our own `ChannelMonitor`. + */ + LDKClosureReason_CommitmentTxConfirmed, + /** + * The funding transaction failed to confirm in a timely manner on an inbound channel. + */ + LDKClosureReason_FundingTimedOut, + /** + * Closure generated from processing an event, likely a HTLC forward/relay/reception. + */ + LDKClosureReason_ProcessingError, + /** + * The peer disconnected prior to funding completing. In this case the spec mandates that we + * forget the channel entirely - we can attempt again if the peer reconnects. + * + * This includes cases where we restarted prior to funding completion, including prior to the + * initial [`ChannelMonitor`] persistence completing. + * + * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the + * peer because of mutual incompatibility between us and our channel counterparty. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + */ + LDKClosureReason_DisconnectedPeer, + /** + * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than + * the [`ChannelManager`] deserialized. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + */ + LDKClosureReason_OutdatedChannelManager, + /** + * The counterparty requested a cooperative close of a channel that had not been funded yet. + * The channel has been immediately closed. + */ + LDKClosureReason_CounterpartyCoopClosedUnfundedChannel, + /** + * Another channel in the same funding batch closed before the funding transaction + * was ready to be broadcast. + */ + LDKClosureReason_FundingBatchClosure, + /** + * One of our HTLCs timed out in a channel, causing us to force close the channel. + */ + LDKClosureReason_HTLCsTimedOut, + /** + * Our peer provided a feerate which violated our required minimum (fetched from our + * [`FeeEstimator`] either as [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`] or + * [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]). + * + * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + * [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedAnchorChannelRemoteFee + * [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee + */ + LDKClosureReason_PeerFeerateTooLow, + /** + * Must be last for serialization purposes + */ + LDKClosureReason_Sentinel, +} LDKClosureReason_Tag; + +typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { + /** + * The error which the peer sent us. + * + * Be careful about printing the peer_msg, a well-crafted message could exploit + * a security vulnerability in the terminal emulator or the logging subsystem. + * To be safe, use `Display` on `UntrustedString` + * + * [`UntrustedString`]: crate::util::string::UntrustedString + */ + struct LDKUntrustedString peer_msg; +} LDKClosureReason_LDKCounterpartyForceClosed_Body; + +typedef struct LDKClosureReason_LDKHolderForceClosed_Body { + /** + * Whether or not the latest transaction was broadcasted when the channel was force + * closed. + * + * Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have + * this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`] + * or force-closed prior to being funded will have this field set to false. + * + * This will be `None` for objects generated or written by LDK 0.0.123 and + * earlier. + * + * [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn. + * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn. + */ + struct LDKCOption_boolZ broadcasted_latest_txn; +} LDKClosureReason_LDKHolderForceClosed_Body; + +typedef struct LDKClosureReason_LDKProcessingError_Body { + /** + * A developer-readable error message which we generated. + */ + struct LDKStr err; +} LDKClosureReason_LDKProcessingError_Body; + +typedef struct LDKClosureReason_LDKPeerFeerateTooLow_Body { + /** + * The feerate on our channel set by our peer. + */ + uint32_t peer_feerate_sat_per_kw; + /** + * The required feerate we enforce, from our [`FeeEstimator`]. + * + * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + */ + uint32_t required_feerate_sat_per_kw; +} LDKClosureReason_LDKPeerFeerateTooLow_Body; + +typedef struct MUST_USE_STRUCT LDKClosureReason { + LDKClosureReason_Tag tag; + union { + LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; + LDKClosureReason_LDKHolderForceClosed_Body holder_force_closed; + LDKClosureReason_LDKProcessingError_Body processing_error; + LDKClosureReason_LDKPeerFeerateTooLow_Body peer_feerate_too_low; + }; +} LDKClosureReason; + + + +/** + * A unique 32-byte identifier for a channel. + * Depending on how the ID is generated, several varieties are distinguished + * (but all are stored as 32 bytes): + * _v1_ and _temporary_. + * A _v1_ channel ID is generated based on funding tx outpoint (txid & index). + * A _temporary_ ID is generated randomly. + * (Later revocation-point-based _v2_ is a possibility.) + * The variety (context) is not stored, it is relevant only at creation. + */ +typedef struct MUST_USE_STRUCT LDKChannelId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelId *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelId; + /** * An event to be processed by the ChannelManager. */ @@ -5105,6 +6120,11 @@ typedef enum LDKMonitorEvent_Tag { * A monitor event containing an HTLCUpdate. */ LDKMonitorEvent_HTLCEvent, + /** + * Indicates we broadcasted the channel's latest commitment transaction and thus closed the + * channel. Holds information about the channel and why it was closed. + */ + LDKMonitorEvent_HolderForceClosedWithInfo, /** * Indicates we broadcasted the channel's latest commitment transaction and thus closed the * channel. @@ -5123,11 +6143,30 @@ typedef enum LDKMonitorEvent_Tag { LDKMonitorEvent_Sentinel, } LDKMonitorEvent_Tag; +typedef struct LDKMonitorEvent_LDKHolderForceClosedWithInfo_Body { + /** + * The reason the channel was closed. + */ + struct LDKClosureReason reason; + /** + * The funding outpoint of the channel. + */ + struct LDKOutPoint outpoint; + /** + * The channel ID of the channel. + */ + struct LDKChannelId channel_id; +} LDKMonitorEvent_LDKHolderForceClosedWithInfo_Body; + typedef struct LDKMonitorEvent_LDKCompleted_Body { /** * The funding outpoint of the [`ChannelMonitor`] that was updated */ struct LDKOutPoint funding_txo; + /** + * The channel ID of the channel associated with the [`ChannelMonitor`] + */ + struct LDKChannelId channel_id; /** * The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or * [`ChannelMonitor::get_latest_update_id`]. @@ -5144,6 +6183,7 @@ typedef struct MUST_USE_STRUCT LDKMonitorEvent { struct { struct LDKHTLCUpdate htlc_event; }; + LDKMonitorEvent_LDKHolderForceClosedWithInfo_Body holder_force_closed_with_info; struct { struct LDKOutPoint holder_force_closed; }; @@ -5168,9 +6208,9 @@ typedef struct LDKCVec_MonitorEventZ { } LDKCVec_MonitorEventZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A tuple of 4 elements. See the individual fields for the types contained. */ -typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { +typedef struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { /** * The element at position 0 */ @@ -5178,28 +6218,32 @@ typedef struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { /** * The element at position 1 */ - struct LDKCVec_MonitorEventZ b; + struct LDKChannelId b; /** * The element at position 2 */ - struct LDKPublicKey c; -} LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; + struct LDKCVec_MonitorEventZ c; + /** + * The element at position 3 + */ + struct LDKPublicKey d; +} LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +typedef struct LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *data; + struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; +} LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ; @@ -5239,7 +6283,7 @@ typedef union LDKCResult_InitFeaturesDecodeErrorZPtr { /** * A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_InitFeaturesDecodeErrorZ { @@ -5292,7 +6336,7 @@ typedef union LDKCResult_ChannelFeaturesDecodeErrorZPtr { /** * A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_ChannelFeaturesDecodeErrorZ { @@ -5345,7 +6389,7 @@ typedef union LDKCResult_NodeFeaturesDecodeErrorZPtr { /** * A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_NodeFeaturesDecodeErrorZ { @@ -5398,7 +6442,7 @@ typedef union LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { /** * A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ { @@ -5451,7 +6495,7 @@ typedef union LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { /** * A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ { @@ -5504,7 +6548,7 @@ typedef union LDKCResult_BlindedHopFeaturesDecodeErrorZPtr { /** * A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_BlindedHopFeaturesDecodeErrorZ { @@ -5566,7 +6610,7 @@ typedef union LDKCResult_ChannelTypeFeaturesDecodeErrorZPtr { /** * A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { @@ -5583,6 +6627,91 @@ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { +/** + * An identifier for an [`Offer`] built using [`DerivedMetadata`]. + */ +typedef struct MUST_USE_STRUCT LDKOfferId { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOfferId *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOfferId; + +/** + * The contents of CResult_OfferIdDecodeErrorZ + */ +typedef union LDKCResult_OfferIdDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOfferId *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_OfferIdDecodeErrorZPtr; + +/** + * A CResult_OfferIdDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::OfferId on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OfferIdDecodeErrorZ { + /** + * The contents of this CResult_OfferIdDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferIdDecodeErrorZPtr contents; + /** + * Whether this CResult_OfferIdDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferIdDecodeErrorZ; + +/** + * The contents of CResult_NoneBolt12SemanticErrorZ + */ +typedef union LDKCResult_NoneBolt12SemanticErrorZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_NoneBolt12SemanticErrorZPtr; + +/** + * A CResult_NoneBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneBolt12SemanticErrorZ { + /** + * The contents of this CResult_NoneBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_NoneBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneBolt12SemanticErrorZ; + + + /** * An `Offer` is a potentially long-lived proposal for payment of a good or service. * @@ -5593,7 +6722,7 @@ typedef struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ { * Offers may be denominated in currency other than bitcoin but are ultimately paid using the * latter. * - * Through the use of [`BlindedPath`]s, offers provide recipient privacy. + * Through the use of [`BlindedMessagePath`]s, offers provide recipient privacy. * * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice @@ -5614,9 +6743,9 @@ typedef struct MUST_USE_STRUCT LDKOffer { } LDKOffer; /** - * The contents of CResult_OfferBolt12ParseErrorZ + * The contents of CResult_OfferBolt12SemanticErrorZ */ -typedef union LDKCResult_OfferBolt12ParseErrorZPtr { +typedef union LDKCResult_OfferBolt12SemanticErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. @@ -5626,58 +6755,205 @@ typedef union LDKCResult_OfferBolt12ParseErrorZPtr { * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKBolt12ParseError *err; -} LDKCResult_OfferBolt12ParseErrorZPtr; + enum LDKBolt12SemanticError *err; +} LDKCResult_OfferBolt12SemanticErrorZPtr; /** - * A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, - * containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. + * A CResult_OfferBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_OfferBolt12ParseErrorZ { +typedef struct LDKCResult_OfferBolt12SemanticErrorZ { /** - * The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either + * The contents of this CResult_OfferBolt12SemanticErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_OfferBolt12ParseErrorZPtr contents; + union LDKCResult_OfferBolt12SemanticErrorZPtr contents; /** - * Whether this CResult_OfferBolt12ParseErrorZ represents a success state. + * Whether this CResult_OfferBolt12SemanticErrorZ represents a success state. */ bool result_ok; -} LDKCResult_OfferBolt12ParseErrorZ; +} LDKCResult_OfferBolt12SemanticErrorZ; + + /** - * The contents of CResult_PublicKeySecp256k1ErrorZ + * Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self */ -typedef union LDKCResult_PublicKeySecp256k1ErrorZPtr { +typedef struct MUST_USE_STRUCT LDKInvoiceRequestWithDerivedPayerIdBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequestWithDerivedPayerIdBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequestWithDerivedPayerIdBuilder; + +/** + * The contents of CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKPublicKey *result; + struct LDKInvoiceRequestWithDerivedPayerIdBuilder *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSecp256k1Error *err; -} LDKCResult_PublicKeySecp256k1ErrorZPtr; + enum LDKBolt12SemanticError *err; +} LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr; /** - * A CResult_PublicKeySecp256k1ErrorZ represents the result of a fallible operation, - * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_PublicKeySecp256k1ErrorZ { +typedef struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { /** - * The contents of this CResult_PublicKeySecp256k1ErrorZ, accessible via either + * The contents of this CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_PublicKeySecp256k1ErrorZPtr contents; + union LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr contents; /** - * Whether this CResult_PublicKeySecp256k1ErrorZ represents a success state. + * Whether this CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ represents a success state. */ bool result_ok; -} LDKCResult_PublicKeySecp256k1ErrorZ; +} LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ; + + + +/** + * Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self + */ +typedef struct MUST_USE_STRUCT LDKInvoiceRequestWithExplicitPayerIdBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequestWithExplicitPayerIdBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequestWithExplicitPayerIdBuilder; + +/** + * The contents of CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoiceRequestWithExplicitPayerIdBuilder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr; + +/** + * A CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + /** + * The contents of this CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ; + +/** + * The contents of CResult_OfferDecodeErrorZ + */ +typedef union LDKCResult_OfferDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOffer *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_OfferDecodeErrorZPtr; + +/** + * A CResult_OfferDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OfferDecodeErrorZ { + /** + * The contents of this CResult_OfferDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferDecodeErrorZPtr contents; + /** + * Whether this CResult_OfferDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferDecodeErrorZ; + +/** + * The contents of CResult_OfferBolt12ParseErrorZ + */ +typedef union LDKCResult_OfferBolt12ParseErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOffer *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKBolt12ParseError *err; +} LDKCResult_OfferBolt12ParseErrorZPtr; + +/** + * A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OfferBolt12ParseErrorZ { + /** + * The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferBolt12ParseErrorZPtr contents; + /** + * Whether this CResult_OfferBolt12ParseErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferBolt12ParseErrorZ; /** * The contents of CResult_NodeIdDecodeErrorZ @@ -5712,27 +6988,38 @@ typedef struct LDKCResult_NodeIdDecodeErrorZ { bool result_ok; } LDKCResult_NodeIdDecodeErrorZ; - +/** + * The contents of CResult_PublicKeySecp256k1ErrorZ + */ +typedef union LDKCResult_PublicKeySecp256k1ErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKPublicKey *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKSecp256k1Error *err; +} LDKCResult_PublicKeySecp256k1ErrorZPtr; /** - * A [`channel_update`] message to be sent to or received from a peer. - * - * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * A CResult_PublicKeySecp256k1ErrorZ represents the result of a fallible operation, + * containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKChannelUpdate { +typedef struct LDKCResult_PublicKeySecp256k1ErrorZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The contents of this CResult_PublicKeySecp256k1ErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKnativeChannelUpdate *inner; + union LDKCResult_PublicKeySecp256k1ErrorZPtr contents; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * Whether this CResult_PublicKeySecp256k1ErrorZ represents a success state. */ - bool is_owned; -} LDKChannelUpdate; + bool result_ok; +} LDKCResult_PublicKeySecp256k1ErrorZ; /** * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion @@ -5741,11 +7028,6 @@ typedef struct MUST_USE_STRUCT LDKChannelUpdate { * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md */ typedef enum LDKNetworkUpdate_Tag { - /** - * An error indicating a `channel_update` messages should be applied via - * [`NetworkGraph::update_channel`]. - */ - LDKNetworkUpdate_ChannelUpdateMessage, /** * An error indicating that a channel failed to route a payment, which should be applied via * [`NetworkGraph::channel_failed_permanent`] if permanent. @@ -5762,13 +7044,6 @@ typedef enum LDKNetworkUpdate_Tag { LDKNetworkUpdate_Sentinel, } LDKNetworkUpdate_Tag; -typedef struct LDKNetworkUpdate_LDKChannelUpdateMessage_Body { - /** - * The update to apply via [`NetworkGraph::update_channel`]. - */ - struct LDKChannelUpdate msg; -} LDKNetworkUpdate_LDKChannelUpdateMessage_Body; - typedef struct LDKNetworkUpdate_LDKChannelFailure_Body { /** * The short channel id of the closed channel. @@ -5796,7 +7071,6 @@ typedef struct LDKNetworkUpdate_LDKNodeFailure_Body { typedef struct MUST_USE_STRUCT LDKNetworkUpdate { LDKNetworkUpdate_Tag tag; union { - LDKNetworkUpdate_LDKChannelUpdateMessage_Body channel_update_message; LDKNetworkUpdate_LDKChannelFailure_Body channel_failure; LDKNetworkUpdate_LDKNodeFailure_Body node_failure; }; @@ -6094,6 +7368,28 @@ typedef struct MUST_USE_STRUCT LDKChannelAnnouncement { bool is_owned; } LDKChannelAnnouncement; + + +/** + * A [`channel_update`] message to be sent to or received from a peer. + * + * [`channel_update`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + */ +typedef struct MUST_USE_STRUCT LDKChannelUpdate { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelUpdate *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelUpdate; + /** * A tuple of 3 elements. See the individual fields for the types contained. */ @@ -6284,7 +7580,8 @@ typedef struct MUST_USE_STRUCT LDKFundingSigned { /** - * An stfu (quiescence) message to be sent by or received from the stfu initiator. + * An `stfu` (quiescence) message to be sent by or received from the stfu initiator. + * */ typedef struct MUST_USE_STRUCT LDKStfu { /** @@ -6304,27 +7601,28 @@ typedef struct MUST_USE_STRUCT LDKStfu { /** - * A splice message to be sent by or received from the stfu initiator (splice initiator). + * A `splice_init` message to be sent by or received from the stfu initiator (splice initiator). + * */ -typedef struct MUST_USE_STRUCT LDKSplice { +typedef struct MUST_USE_STRUCT LDKSpliceInit { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeSplice *inner; + LDKnativeSpliceInit *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKSplice; +} LDKSpliceInit; /** - * A splice_ack message to be received by or sent to the splice initiator. + * A `splice_ack` message to be received by or sent to the splice initiator. * */ typedef struct MUST_USE_STRUCT LDKSpliceAck { @@ -6345,7 +7643,7 @@ typedef struct MUST_USE_STRUCT LDKSpliceAck { /** - * A splice_locked message to be sent to or received from a peer. + * A `splice_locked` message to be sent to or received from a peer. * */ typedef struct MUST_USE_STRUCT LDKSpliceLocked { @@ -7013,9 +8311,9 @@ typedef enum LDKMessageSendEvent_Tag { */ LDKMessageSendEvent_SendStfu, /** - * Used to indicate that a splice message should be sent to the peer with the given node id. + * Used to indicate that a splice_init message should be sent to the peer with the given node id. */ - LDKMessageSendEvent_SendSplice, + LDKMessageSendEvent_SendSpliceInit, /** * Used to indicate that a splice_ack message should be sent to the peer with the given node id. */ @@ -7227,7 +8525,7 @@ typedef struct LDKMessageSendEvent_LDKSendStfu_Body { struct LDKStfu msg; } LDKMessageSendEvent_LDKSendStfu_Body; -typedef struct LDKMessageSendEvent_LDKSendSplice_Body { +typedef struct LDKMessageSendEvent_LDKSendSpliceInit_Body { /** * The node_id of the node which should receive this message */ @@ -7235,8 +8533,8 @@ typedef struct LDKMessageSendEvent_LDKSendSplice_Body { /** * The message which should be sent. */ - struct LDKSplice msg; -} LDKMessageSendEvent_LDKSendSplice_Body; + struct LDKSpliceInit msg; +} LDKMessageSendEvent_LDKSendSpliceInit_Body; typedef struct LDKMessageSendEvent_LDKSendSpliceAck_Body { /** @@ -7554,7 +8852,7 @@ typedef struct MUST_USE_STRUCT LDKMessageSendEvent { LDKMessageSendEvent_LDKSendFundingCreated_Body send_funding_created; LDKMessageSendEvent_LDKSendFundingSigned_Body send_funding_signed; LDKMessageSendEvent_LDKSendStfu_Body send_stfu; - LDKMessageSendEvent_LDKSendSplice_Body send_splice; + LDKMessageSendEvent_LDKSendSpliceInit_Body send_splice_init; LDKMessageSendEvent_LDKSendSpliceAck_Body send_splice_ack; LDKMessageSendEvent_LDKSendSpliceLocked_Body send_splice_locked; LDKMessageSendEvent_LDKSendTxAddInput_Body send_tx_add_input; @@ -7747,7 +9045,7 @@ typedef union LDKCResult_RoutingFeesDecodeErrorZPtr { /** * A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::routing::gossip::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. + * containing a crate::lightning_types::routing::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ typedef struct LDKCResult_RoutingFeesDecodeErrorZ { @@ -7928,21 +9226,53 @@ typedef struct LDKCVec_SocketAddressZ { /** - * Information received in the latest node_announcement from this node. + * Non-relayable information received in the latest node_announcement from this node. */ -typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementDetails { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeNodeAnnouncementInfo *inner; + LDKnativeNodeAnnouncementDetails *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; +} LDKNodeAnnouncementDetails; + +/** + * Information received in the latest node_announcement from this node. + */ +typedef enum LDKNodeAnnouncementInfo_Tag { + /** + * An initial announcement of the node + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + */ + LDKNodeAnnouncementInfo_Relayed, + /** + * Non-relayable information received in the latest node_announcement from this node. + */ + LDKNodeAnnouncementInfo_Local, + /** + * Must be last for serialization purposes + */ + LDKNodeAnnouncementInfo_Sentinel, +} LDKNodeAnnouncementInfo_Tag; + +typedef struct MUST_USE_STRUCT LDKNodeAnnouncementInfo { + LDKNodeAnnouncementInfo_Tag tag; + union { + struct { + struct LDKNodeAnnouncement relayed; + }; + struct { + struct LDKNodeAnnouncementDetails local; + }; + }; } LDKNodeAnnouncementInfo; /** @@ -8034,6 +9364,33 @@ typedef struct LDKCResult_NodeAliasDecodeErrorZ { bool result_ok; } LDKCResult_NodeAliasDecodeErrorZ; +/** + * An enum which can either contain a crate::lightning::routing::gossip::NodeAnnouncementInfo or not + */ +typedef enum LDKCOption_NodeAnnouncementInfoZ_Tag { + /** + * When we're in this state, this COption_NodeAnnouncementInfoZ contains a crate::lightning::routing::gossip::NodeAnnouncementInfo + */ + LDKCOption_NodeAnnouncementInfoZ_Some, + /** + * When we're in this state, this COption_NodeAnnouncementInfoZ contains nothing + */ + LDKCOption_NodeAnnouncementInfoZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_NodeAnnouncementInfoZ_Sentinel, +} LDKCOption_NodeAnnouncementInfoZ_Tag; + +typedef struct LDKCOption_NodeAnnouncementInfoZ { + LDKCOption_NodeAnnouncementInfoZ_Tag tag; + union { + struct { + struct LDKNodeAnnouncementInfo some; + }; + }; +} LDKCOption_NodeAnnouncementInfoZ; + /** @@ -8147,6 +9504,39 @@ typedef struct LDKCOption_CVec_SocketAddressZZ { }; } LDKCOption_CVec_SocketAddressZZ; +/** + * The contents of CResult_u64ShortChannelIdErrorZ + */ +typedef union LDKCResult_u64ShortChannelIdErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + uint64_t *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKShortChannelIdError *err; +} LDKCResult_u64ShortChannelIdErrorZPtr; + +/** + * A CResult_u64ShortChannelIdErrorZ represents the result of a fallible operation, + * containing a u64 on success and a crate::lightning::util::scid_utils::ShortChannelIdError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_u64ShortChannelIdErrorZ { + /** + * The contents of this CResult_u64ShortChannelIdErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_u64ShortChannelIdErrorZPtr contents; + /** + * Whether this CResult_u64ShortChannelIdErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_u64ShortChannelIdErrorZ; + /** @@ -8440,6 +9830,141 @@ typedef struct LDKCResult_CVec_UtxoZNoneZ { bool result_ok; } LDKCResult_CVec_UtxoZNoneZ; + + +/** + * An unknown payment context. + */ +typedef struct MUST_USE_STRUCT LDKUnknownPaymentContext { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeUnknownPaymentContext *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKUnknownPaymentContext; + + + +/** + * The context of a payment made for an invoice requested from a BOLT 12 [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer + */ +typedef struct MUST_USE_STRUCT LDKBolt12OfferContext { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt12OfferContext *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt12OfferContext; + + + +/** + * The context of a payment made for an invoice sent for a BOLT 12 [`Refund`]. + * + * [`Refund`]: crate::offers::refund::Refund + */ +typedef struct MUST_USE_STRUCT LDKBolt12RefundContext { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt12RefundContext *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt12RefundContext; + +/** + * The context of an inbound payment, which is included in a [`BlindedPaymentPath`] via + * [`ReceiveTlvs`] and surfaced in [`PaymentPurpose`]. + * + * [`PaymentPurpose`]: crate::events::PaymentPurpose + */ +typedef enum LDKPaymentContext_Tag { + /** + * The payment context was unknown. + */ + LDKPaymentContext_Unknown, + /** + * The payment was made for an invoice requested from a BOLT 12 [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer + */ + LDKPaymentContext_Bolt12Offer, + /** + * The payment was made for an invoice sent for a BOLT 12 [`Refund`]. + * + * [`Refund`]: crate::offers::refund::Refund + */ + LDKPaymentContext_Bolt12Refund, + /** + * Must be last for serialization purposes + */ + LDKPaymentContext_Sentinel, +} LDKPaymentContext_Tag; + +typedef struct MUST_USE_STRUCT LDKPaymentContext { + LDKPaymentContext_Tag tag; + union { + struct { + struct LDKUnknownPaymentContext unknown; + }; + struct { + struct LDKBolt12OfferContext bolt12_offer; + }; + struct { + struct LDKBolt12RefundContext bolt12_refund; + }; + }; +} LDKPaymentContext; + +/** + * An enum which can either contain a crate::lightning::blinded_path::payment::PaymentContext or not + */ +typedef enum LDKCOption_PaymentContextZ_Tag { + /** + * When we're in this state, this COption_PaymentContextZ contains a crate::lightning::blinded_path::payment::PaymentContext + */ + LDKCOption_PaymentContextZ_Some, + /** + * When we're in this state, this COption_PaymentContextZ contains nothing + */ + LDKCOption_PaymentContextZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_PaymentContextZ_Sentinel, +} LDKCOption_PaymentContextZ_Tag; + +typedef struct LDKCOption_PaymentContextZ { + LDKCOption_PaymentContextZ_Tag tag; + union { + struct { + struct LDKPaymentContext some; + }; + }; +} LDKCOption_PaymentContextZ; + /** * A tuple of 2 elements. See the individual fields for the types contained. */ @@ -8482,64 +10007,37 @@ typedef struct LDKCOption_C2Tuple_u64u16ZZ { } LDKCOption_C2Tuple_u64u16ZZ; /** - * An enum which can either contain a crate::lightning::ln::channelmanager::ChannelShutdownState or not + * The contents of CResult_ChannelIdAPIErrorZ */ -typedef enum LDKCOption_ChannelShutdownStateZ_Tag { - /** - * When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channelmanager::ChannelShutdownState - */ - LDKCOption_ChannelShutdownStateZ_Some, - /** - * When we're in this state, this COption_ChannelShutdownStateZ contains nothing - */ - LDKCOption_ChannelShutdownStateZ_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_ChannelShutdownStateZ_Sentinel, -} LDKCOption_ChannelShutdownStateZ_Tag; - -typedef struct LDKCOption_ChannelShutdownStateZ { - LDKCOption_ChannelShutdownStateZ_Tag tag; - union { - struct { - enum LDKChannelShutdownState some; - }; - }; -} LDKCOption_ChannelShutdownStateZ; - -/** - * The contents of CResult_ThirtyTwoBytesAPIErrorZ - */ -typedef union LDKCResult_ThirtyTwoBytesAPIErrorZPtr { +typedef union LDKCResult_ChannelIdAPIErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes *result; + struct LDKChannelId *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKAPIError *err; -} LDKCResult_ThirtyTwoBytesAPIErrorZPtr; +} LDKCResult_ChannelIdAPIErrorZPtr; /** - * A CResult_ThirtyTwoBytesAPIErrorZ represents the result of a fallible operation, - * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. + * A CResult_ChannelIdAPIErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_ThirtyTwoBytesAPIErrorZ { +typedef struct LDKCResult_ChannelIdAPIErrorZ { /** - * The contents of this CResult_ThirtyTwoBytesAPIErrorZ, accessible via either + * The contents of this CResult_ChannelIdAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_ThirtyTwoBytesAPIErrorZPtr contents; + union LDKCResult_ChannelIdAPIErrorZPtr contents; /** - * Whether this CResult_ThirtyTwoBytesAPIErrorZ represents a success state. + * Whether this CResult_ChannelIdAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_ThirtyTwoBytesAPIErrorZ; +} LDKCResult_ChannelIdAPIErrorZ; /** * Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. @@ -9019,32 +10517,105 @@ typedef struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFa /** * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ { +typedef struct LDKC2Tuple_ChannelIdPublicKeyZ { /** * The element at position 0 */ - struct LDKThirtyTwoBytes a; + struct LDKChannelId a; /** * The element at position 1 */ struct LDKPublicKey b; -} LDKC2Tuple_ThirtyTwoBytesPublicKeyZ; +} LDKC2Tuple_ChannelIdPublicKeyZ; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesPublicKeyZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_ChannelIdPublicKeyZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { +typedef struct LDKCVec_C2Tuple_ChannelIdPublicKeyZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *data; + struct LDKC2Tuple_ChannelIdPublicKeyZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ; +} LDKCVec_C2Tuple_ChannelIdPublicKeyZZ; + +/** + * A dynamically-allocated array of crate::lightning::ln::types::ChannelIds of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_ChannelIdZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKChannelId *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_ChannelIdZ; + + + +/** + * Builds an [`Offer`] for the \"offer to be paid\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self + */ +typedef struct MUST_USE_STRUCT LDKOfferWithDerivedMetadataBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOfferWithDerivedMetadataBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOfferWithDerivedMetadataBuilder; + +/** + * The contents of CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOfferWithDerivedMetadataBuilder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr; + +/** + * A CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + /** + * The contents of this CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ; /** * An enum which can either contain a crate::c_types::Str or not @@ -9074,121 +10645,249 @@ typedef struct LDKCOption_StrZ { } LDKCOption_StrZ; /** - * The contents of CResult_NoneBolt12SemanticErrorZ + * The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ */ -typedef union LDKCResult_NoneBolt12SemanticErrorZPtr { +typedef union LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { /** - * Note that this value is always NULL, as there are no contents in the OK variant + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *result; + struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *result; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Note that this value is always NULL, as there are no contents in the Err variant */ - enum LDKBolt12SemanticError *err; -} LDKCResult_NoneBolt12SemanticErrorZPtr; + void *err; +} LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr; /** - * A CResult_NoneBolt12SemanticErrorZ represents the result of a fallible operation, - * containing a () on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a () on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_NoneBolt12SemanticErrorZ { +typedef struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { /** - * The contents of this CResult_NoneBolt12SemanticErrorZ, accessible via either + * The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_NoneBolt12SemanticErrorZPtr contents; + union LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr contents; /** - * Whether this CResult_NoneBolt12SemanticErrorZ represents a success state. + * Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents a success state. */ bool result_ok; -} LDKCResult_NoneBolt12SemanticErrorZ; +} LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ; /** - * The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ + * The contents of CResult_ThirtyTwoBytesAPIErrorZ */ -typedef union LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { +typedef union LDKCResult_ThirtyTwoBytesAPIErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *result; + struct LDKThirtyTwoBytes *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr; + struct LDKAPIError *err; +} LDKCResult_ThirtyTwoBytesAPIErrorZPtr; /** - * A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a () on failure. + * A CResult_ThirtyTwoBytesAPIErrorZ represents the result of a fallible operation, + * containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { +typedef struct LDKCResult_ThirtyTwoBytesAPIErrorZ { /** - * The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ, accessible via either + * The contents of this CResult_ThirtyTwoBytesAPIErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr contents; + union LDKCResult_ThirtyTwoBytesAPIErrorZPtr contents; /** - * Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents a success state. + * Whether this CResult_ThirtyTwoBytesAPIErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ; +} LDKCResult_ThirtyTwoBytesAPIErrorZ; /** - * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. + * A 128-bit number used only once. * - * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request - * specifies these such that its recipient can send an invoice for payment. + * Needed when constructing [`Offer::metadata`] and deriving [`Offer::signing_pubkey`] from + * [`ExpandedKey`]. Must not be reused for any other derivation without first hashing. * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -typedef struct MUST_USE_STRUCT LDKInvoiceRequest { +typedef struct MUST_USE_STRUCT LDKNonce { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceRequest *inner; + LDKnativeNonce *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceRequest; +} LDKNonce; + +/** + * Contains data specific to an [`OffersMessage`]. + * + * [`OffersMessage`]: crate::onion_message::offers::OffersMessage + */ +typedef enum LDKOffersContext_Tag { + /** + * Context used by a [`BlindedMessagePath`] within an [`Offer`]. + * + * This variant is intended to be received when handling an [`InvoiceRequest`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + LDKOffersContext_InvoiceRequest, + /** + * Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an + * [`InvoiceRequest`]. + * + * This variant is intended to be received when handling a [`Bolt12Invoice`] or an + * [`InvoiceError`]. + * + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + */ + LDKOffersContext_OutboundPayment, + /** + * Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. + * + * This variant is intended to be received when handling an [`InvoiceError`]. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + */ + LDKOffersContext_InboundPayment, + /** + * Must be last for serialization purposes + */ + LDKOffersContext_Sentinel, +} LDKOffersContext_Tag; +typedef struct LDKOffersContext_LDKInvoiceRequest_Body { + /** + * A nonce used for authenticating that an [`InvoiceRequest`] is for a valid [`Offer`] and + * for deriving the offer's signing keys. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Offer`]: crate::offers::offer::Offer + */ + struct LDKNonce nonce; +} LDKOffersContext_LDKInvoiceRequest_Body; +typedef struct LDKOffersContext_LDKOutboundPayment_Body { + /** + * Payment ID used when creating a [`Refund`] or [`InvoiceRequest`]. + * + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + struct LDKThirtyTwoBytes payment_id; + /** + * A nonce used for authenticating that a [`Bolt12Invoice`] is for a valid [`Refund`] or + * [`InvoiceRequest`] and for deriving their signing keys. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Refund`]: crate::offers::refund::Refund + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + struct LDKNonce nonce; + /** + * Authentication code for the [`PaymentId`], which should be checked when the context is + * used with an [`InvoiceError`]. + * + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKThirtyTwoBytes hmac; +} LDKOffersContext_LDKOutboundPayment_Body; + +typedef struct LDKOffersContext_LDKInboundPayment_Body { + /** + * The same payment hash as [`Bolt12Invoice::payment_hash`]. + * + * [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash + */ + struct LDKThirtyTwoBytes payment_hash; +} LDKOffersContext_LDKInboundPayment_Body; + +typedef struct MUST_USE_STRUCT LDKOffersContext { + LDKOffersContext_Tag tag; + union { + LDKOffersContext_LDKInvoiceRequest_Body invoice_request; + LDKOffersContext_LDKOutboundPayment_Body outbound_payment; + LDKOffersContext_LDKInboundPayment_Body inbound_payment; + }; +} LDKOffersContext; /** - * A `Bolt12Invoice` is a payment request, typically corresponding to an [`Offer`] or a [`Refund`]. + * An enum which can either contain a crate::lightning::blinded_path::message::OffersContext or not + */ +typedef enum LDKCOption_OffersContextZ_Tag { + /** + * When we're in this state, this COption_OffersContextZ contains a crate::lightning::blinded_path::message::OffersContext + */ + LDKCOption_OffersContextZ_Some, + /** + * When we're in this state, this COption_OffersContextZ contains nothing + */ + LDKCOption_OffersContextZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_OffersContextZ_Sentinel, +} LDKCOption_OffersContextZ_Tag; + +typedef struct LDKCOption_OffersContextZ { + LDKCOption_OffersContextZ_Tag tag; + union { + struct { + struct LDKOffersContext some; + }; + }; +} LDKCOption_OffersContextZ; + + + +/** + * An `InvoiceRequest` is a request for a [`Bolt12Invoice`] formulated from an [`Offer`]. * - * An invoice may be sent in response to an [`InvoiceRequest`] in the case of an offer or sent - * directly after scanning a refund. It includes all the information needed to pay a recipient. + * An offer may provide choices such as quantity, amount, chain, features, etc. An invoice request + * specifies these such that its recipient can send an invoice for payment. * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice * [`Offer`]: crate::offers::offer::Offer - * [`Refund`]: crate::offers::refund::Refund - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -typedef struct MUST_USE_STRUCT LDKBolt12Invoice { +typedef struct MUST_USE_STRUCT LDKInvoiceRequest { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBolt12Invoice *inner; + LDKnativeInvoiceRequest *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBolt12Invoice; +} LDKInvoiceRequest; @@ -9256,32 +10955,66 @@ typedef struct MUST_USE_STRUCT LDKOffersMessage { }; } LDKOffersMessage; + + /** - * An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not + * Instructions for how and where to send the response to an onion message. */ -typedef enum LDKCOption_OffersMessageZ_Tag { +typedef struct MUST_USE_STRUCT LDKResponseInstruction { /** - * When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKCOption_OffersMessageZ_Some, + LDKnativeResponseInstruction *inner; /** - * When we're in this state, this COption_OffersMessageZ contains nothing + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - LDKCOption_OffersMessageZ_None, + bool is_owned; +} LDKResponseInstruction; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OffersMessageResponseInstructionZ { + /** + * The element at position 0 + */ + struct LDKOffersMessage a; + /** + * The element at position 1 + */ + struct LDKResponseInstruction b; +} LDKC2Tuple_OffersMessageResponseInstructionZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ or not + */ +typedef enum LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ + */ + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains nothing + */ + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_None, /** * Must be last for serialization purposes */ - LDKCOption_OffersMessageZ_Sentinel, -} LDKCOption_OffersMessageZ_Tag; + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag; -typedef struct LDKCOption_OffersMessageZ { - LDKCOption_OffersMessageZ_Tag tag; +typedef struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ { + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ_Tag tag; union { struct { - struct LDKOffersMessage some; + struct LDKC2Tuple_OffersMessageResponseInstructionZ some; }; }; -} LDKCOption_OffersMessageZ; +} LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ; /** * The destination of an onion message. @@ -9308,15 +11041,129 @@ typedef struct MUST_USE_STRUCT LDKDestination { struct LDKPublicKey node; }; struct { - struct LDKBlindedPath blinded_path; + struct LDKBlindedMessagePath blinded_path; }; }; } LDKDestination; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * Additional data included by the recipient in a [`BlindedMessagePath`]. + * + * This data is encrypted by the recipient and will be given to the corresponding message handler + * when handling a message sent over the [`BlindedMessagePath`]. The recipient can use this data to + * authenticate the message or for further processing if needed. */ -typedef struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ { +typedef enum LDKMessageContext_Tag { + /** + * Context specific to an [`OffersMessage`]. + * + * [`OffersMessage`]: crate::onion_message::offers::OffersMessage + */ + LDKMessageContext_Offers, + /** + * Context specific to a [`CustomOnionMessageHandler::CustomMessage`]. + * + * [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage + */ + LDKMessageContext_Custom, + /** + * Must be last for serialization purposes + */ + LDKMessageContext_Sentinel, +} LDKMessageContext_Tag; + +typedef struct MUST_USE_STRUCT LDKMessageContext { + LDKMessageContext_Tag tag; + union { + struct { + struct LDKOffersContext offers; + }; + struct { + struct LDKCVec_u8Z custom; + }; + }; +} LDKMessageContext; + +/** + * Instructions for how and where to send a message. + */ +typedef enum LDKMessageSendInstructions_Tag { + /** + * Indicates that a message should be sent including the provided reply path for the recipient + * to respond. + */ + LDKMessageSendInstructions_WithSpecifiedReplyPath, + /** + * Indicates that a message should be sent including a reply path for the recipient to + * respond. + */ + LDKMessageSendInstructions_WithReplyPath, + /** + * Indicates that a message should be sent without including a reply path, preventing the + * recipient from responding. + */ + LDKMessageSendInstructions_WithoutReplyPath, + /** + * Indicates that a message is being sent as a reply to a received message. + */ + LDKMessageSendInstructions_ForReply, + /** + * Must be last for serialization purposes + */ + LDKMessageSendInstructions_Sentinel, +} LDKMessageSendInstructions_Tag; + +typedef struct LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; + /** + * The reply path which should be included in the message. + */ + struct LDKBlindedMessagePath reply_path; +} LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKWithReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; + /** + * The context to include in the reply path we'll give the recipient so they can respond + * to us. + */ + struct LDKMessageContext context; +} LDKMessageSendInstructions_LDKWithReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKWithoutReplyPath_Body { + /** + * The destination where we need to send our message. + */ + struct LDKDestination destination; +} LDKMessageSendInstructions_LDKWithoutReplyPath_Body; + +typedef struct LDKMessageSendInstructions_LDKForReply_Body { + /** + * The instructions provided by the [`Responder`]. + */ + struct LDKResponseInstruction instructions; +} LDKMessageSendInstructions_LDKForReply_Body; + +typedef struct MUST_USE_STRUCT LDKMessageSendInstructions { + LDKMessageSendInstructions_Tag tag; + union { + LDKMessageSendInstructions_LDKWithSpecifiedReplyPath_Body with_specified_reply_path; + LDKMessageSendInstructions_LDKWithReplyPath_Body with_reply_path; + LDKMessageSendInstructions_LDKWithoutReplyPath_Body without_reply_path; + LDKMessageSendInstructions_LDKForReply_Body for_reply; + }; +} LDKMessageSendInstructions; + +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ { /** * The element at position 0 */ @@ -9324,168 +11171,170 @@ typedef struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ { /** * The element at position 1 */ - struct LDKDestination b; - /** - * The element at position 2 - */ - struct LDKBlindedPath c; -} LDKC3Tuple_OffersMessageDestinationBlindedPathZ; + struct LDKMessageSendInstructions b; +} LDKC2Tuple_OffersMessageMessageSendInstructionsZ; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { +typedef struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ *data; + struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ; +} LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ; /** - * Information needed for constructing an invoice route hint for this channel. + * Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. */ -typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { +typedef struct MUST_USE_STRUCT LDKReleaseHeldHtlc { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeCounterpartyForwardingInfo *inner; + LDKnativeReleaseHeldHtlc *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKCounterpartyForwardingInfo; +} LDKReleaseHeldHtlc; /** - * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { +typedef struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKCounterpartyForwardingInfo *result; + struct LDKReleaseHeldHtlc a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKDecodeError *err; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; + struct LDKResponseInstruction b; +} LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ; /** - * A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * An enum which can either contain a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ or not */ -typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { +typedef enum LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag { /** - * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ */ - union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Some, /** - * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + * When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains nothing */ - bool result_ok; -} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ some; + }; + }; +} LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ; /** - * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] - * to better separate parameters. + * An HTLC destined for the recipient of this message is being held upstream. The reply path + * accompanying this onion message should be used to send a [`ReleaseHeldHtlc`] response, which + * will cause the upstream HTLC to be released. */ -typedef struct MUST_USE_STRUCT LDKChannelCounterparty { +typedef struct MUST_USE_STRUCT LDKHeldHtlcAvailable { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeChannelCounterparty *inner; + LDKnativeHeldHtlcAvailable *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKChannelCounterparty; +} LDKHeldHtlcAvailable; /** - * The contents of CResult_ChannelCounterpartyDecodeErrorZ + * Possible async payment messages sent and received via an [`OnionMessage`]. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage */ -typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { +typedef enum LDKAsyncPaymentsMessage_Tag { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * An HTLC is being held upstream for the often-offline recipient, to be released via + * [`ReleaseHeldHtlc`]. */ - struct LDKChannelCounterparty *result; + LDKAsyncPaymentsMessage_HeldHtlcAvailable, /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. */ - struct LDKDecodeError *err; -} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; - -/** - * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { - /** - * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; + LDKAsyncPaymentsMessage_ReleaseHeldHtlc, /** - * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + * Must be last for serialization purposes */ - bool result_ok; -} LDKCResult_ChannelCounterpartyDecodeErrorZ; + LDKAsyncPaymentsMessage_Sentinel, +} LDKAsyncPaymentsMessage_Tag; + +typedef struct MUST_USE_STRUCT LDKAsyncPaymentsMessage { + LDKAsyncPaymentsMessage_Tag tag; + union { + struct { + struct LDKHeldHtlcAvailable held_htlc_available; + }; + struct { + struct LDKReleaseHeldHtlc release_held_htlc; + }; + }; +} LDKAsyncPaymentsMessage; /** - * The contents of CResult_ChannelDetailsDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { +typedef struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. + * The element at position 0 */ - struct LDKChannelDetails *result; + struct LDKAsyncPaymentsMessage a; /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. + * The element at position 1 */ - struct LDKDecodeError *err; -} LDKCResult_ChannelDetailsDecodeErrorZPtr; + struct LDKMessageSendInstructions b; +} LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ; /** - * A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZs of arbitrary size. + * This corresponds to std::vector in C++ */ -typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { +typedef struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { /** - * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; + struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ *data; /** - * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. + * The number of elements pointed to by `data`. */ - bool result_ok; -} LDKCResult_ChannelDetailsDecodeErrorZ; + uintptr_t datalen; +} LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ; @@ -9700,6 +11549,13 @@ typedef struct LDKPendingHTLCRouting_LDKReceive_Body { * [`RecipientOnionFields::payment_metadata`]. */ struct LDKCOption_CVec_u8ZZ payment_metadata; + /** + * The context of the payment included by the recipient in a blinded path, or `None` if a + * blinded path was not used. + * + * Used in part to determine the [`events::PaymentPurpose`]. + */ + struct LDKCOption_PaymentContextZ payment_context; /** * CLTV expiry of the received HTLC. * @@ -9764,6 +11620,10 @@ typedef struct LDKPendingHTLCRouting_LDKReceiveKeysend_Body { * [`RecipientOnionFields::custom_tlvs`]. */ struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs; + /** + * Set if this HTLC is the final hop in a multi-hop blinded path. + */ + bool requires_blinded_error; } LDKPendingHTLCRouting_LDKReceiveKeysend_Body; typedef struct MUST_USE_STRUCT LDKPendingHTLCRouting { @@ -9874,39 +11734,6 @@ typedef struct LDKCResult_BlindedFailureDecodeErrorZ { bool result_ok; } LDKCResult_BlindedFailureDecodeErrorZ; -/** - * The contents of CResult_ChannelShutdownStateDecodeErrorZ - */ -typedef union LDKCResult_ChannelShutdownStateDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - enum LDKChannelShutdownState *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_ChannelShutdownStateDecodeErrorZPtr; - -/** - * A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::channelmanager::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_ChannelShutdownStateDecodeErrorZ { - /** - * The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_ChannelShutdownStateDecodeErrorZPtr contents; - /** - * Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_ChannelShutdownStateDecodeErrorZ; - /** @@ -10044,7 +11871,7 @@ typedef struct LDKWatch { * For details on asynchronous [`ChannelMonitor`] updating and returning * [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. */ - struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ (*release_pending_monitor_events)(const void *this_arg); + struct LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ (*release_pending_monitor_events)(const void *this_arg); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -10124,52 +11951,51 @@ typedef struct LDKEntropySource { /** - * A semantically valid [`InvoiceRequest`] that hasn't been signed. - * - * # Serialization + * Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network, + * but without the signature information. + * Decoding and encoding should not lead to information loss but may lead to different hashes. * - * This is serialized as a TLV stream, which includes TLV records from the originating message. As - * such, it may include unknown, odd TLV records. + * For methods without docs see the corresponding methods in [`Bolt11Invoice`]. */ -typedef struct MUST_USE_STRUCT LDKUnsignedInvoiceRequest { +typedef struct MUST_USE_STRUCT LDKRawBolt11Invoice { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedInvoiceRequest *inner; + LDKnativeRawBolt11Invoice *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUnsignedInvoiceRequest; +} LDKRawBolt11Invoice; /** - * A semantically valid [`Bolt12Invoice`] that hasn't been signed. + * A semantically valid [`InvoiceRequest`] that hasn't been signed. * * # Serialization * * This is serialized as a TLV stream, which includes TLV records from the originating message. As * such, it may include unknown, odd TLV records. */ -typedef struct MUST_USE_STRUCT LDKUnsignedBolt12Invoice { +typedef struct MUST_USE_STRUCT LDKUnsignedInvoiceRequest { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeUnsignedBolt12Invoice *inner; + LDKnativeUnsignedInvoiceRequest *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKUnsignedBolt12Invoice; +} LDKUnsignedInvoiceRequest; @@ -10306,7 +12132,7 @@ typedef struct LDKNodeSigner { * * Errors if the [`Recipient`] variant is not supported by the implementation. */ - struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); + struct LDKCResult_RecoverableSignatureNoneZ (*sign_invoice)(const void *this_arg, const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient); /** * Signs the [`TaggedHash`] of a BOLT 12 invoice request. * @@ -10377,11 +12203,11 @@ typedef struct LDKSignerProvider { * re-derived from its `channel_keys_id`, which can be obtained through its trait method * [`ChannelSigner::channel_keys_id`]. */ - struct LDKWriteableEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); + struct LDKEcdsaChannelSigner (*derive_channel_signer)(const void *this_arg, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. * This is only called during deserialization of other objects which contain - * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + * [`EcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). * The bytes are exactly those which `::write()` writes, and * contain no versioning scheme. You may wish to include your own version prefix and ensure * you've read all of the provided bytes to ensure no corruption occurred. @@ -10393,7 +12219,7 @@ typedef struct LDKSignerProvider { * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); + struct LDKCResult_EcdsaChannelSignerDecodeErrorZ (*read_chan_signer)(const void *this_arg, struct LDKu8slice reader); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -10433,6 +12259,10 @@ typedef struct LDKSignerProvider { * * Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're * called from inside the library in response to chain events, P2P events, or timer events). + * + * LDK may generate a substantial number of fee-estimation calls in some cases. You should + * pre-calculate and cache the fee estimate results to ensure you don't substantially slow HTLC + * handling. */ typedef struct LDKFeeEstimator { /** @@ -10493,10 +12323,26 @@ typedef struct LDKMessageRouter { */ struct LDKCResult_OnionMessagePathNoneZ (*find_path)(const void *this_arg, struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); /** - * Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - * direct peers with the `recipient`. + * Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + * be direct peers with the `recipient`. + */ + struct LDKCResult_CVec_BlindedMessagePathZNoneZ (*create_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers); + /** + * Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + * assumed to be direct peers with the `recipient`. + * + * Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + * which is beneficial when a QR code is used to transport the data. The SCID is passed using + * a [`MessageForwardNode`] but may be `None` for graceful degradation. + * + * Implementations using additional intermediate nodes are responsible for using a + * [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + * should call [`BlindedMessagePath::use_compact_introduction_node`]. + * + * The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + * ignoring the short channel ids. */ - struct LDKCResult_CVec_BlindedPathZNoneZ (*create_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers); + struct LDKCResult_CVec_BlindedMessagePathZNoneZ (*create_compact_blinded_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -10535,11 +12381,11 @@ typedef struct LDKRouter { */ struct LDKCResult_RouteLightningErrorZ (*find_route_with_id)(const void *this_arg, struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); /** - * Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + * Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` * are assumed to be with the `recipient`'s peers. The payment secret and any constraints are * given in `tlvs`. */ - struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ (*create_blinded_payment_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); + struct LDKCResult_CVec_BlindedPaymentPathZNoneZ (*create_blinded_payment_paths)(const void *this_arg, struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); /** * Implementation of MessageRouter for this object. */ @@ -10554,11 +12400,656 @@ typedef struct LDKRouter { /** - * Manager which keeps track of a number of channels and sends messages to the appropriate - * channel, also tracking HTLC preimages and forwarding onion packets appropriately. + * A lightning node's channel state machine and payment management logic, which facilitates + * sending, forwarding, and receiving payments through lightning channels. + * + * [`ChannelManager`] is parameterized by a number of components to achieve this. + * - [`chain::Watch`] (typically [`ChainMonitor`]) for on-chain monitoring and enforcement of each + * channel + * - [`BroadcasterInterface`] for broadcasting transactions related to opening, funding, and + * closing channels + * - [`EntropySource`] for providing random data needed for cryptographic operations + * - [`NodeSigner`] for cryptographic operations scoped to the node + * - [`SignerProvider`] for providing signers whose operations are scoped to individual channels + * - [`FeeEstimator`] to determine transaction fee rates needed to have a transaction mined in a + * timely manner + * - [`Router`] for finding payment paths when initiating and retrying payments + * - [`Logger`] for logging operational information of varying degrees + * + * Additionally, it implements the following traits: + * - [`ChannelMessageHandler`] to handle off-chain channel activity from peers + * - [`MessageSendEventsProvider`] to similarly send such messages to peers + * - [`OffersMessageHandler`] for BOLT 12 message handling and sending + * - [`EventsProvider`] to generate user-actionable [`Event`]s + * - [`chain::Listen`] and [`chain::Confirm`] for notification of on-chain activity + * + * Thus, [`ChannelManager`] is typically used to parameterize a [`MessageHandler`] and an + * [`OnionMessenger`]. The latter is required to support BOLT 12 functionality. + * + * # `ChannelManager` vs `ChannelMonitor` + * + * It's important to distinguish between the *off-chain* management and *on-chain* enforcement of + * lightning channels. [`ChannelManager`] exchanges messages with peers to manage the off-chain + * state of each channel. During this process, it generates a [`ChannelMonitor`] for each channel + * and a [`ChannelMonitorUpdate`] for each relevant change, notifying its parameterized + * [`chain::Watch`] of them. * - * Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through - * to individual Channels. + * An implementation of [`chain::Watch`], such as [`ChainMonitor`], is responsible for aggregating + * these [`ChannelMonitor`]s and applying any [`ChannelMonitorUpdate`]s to them. It then monitors + * for any pertinent on-chain activity, enforcing claims as needed. + * + * This division of off-chain management and on-chain enforcement allows for interesting node + * setups. For instance, on-chain enforcement could be moved to a separate host or have added + * redundancy, possibly as a watchtower. See [`chain::Watch`] for the relevant interface. + * + * # Initialization + * + * Use [`ChannelManager::new`] with the most recent [`BlockHash`] when creating a fresh instance. + * Otherwise, if restarting, construct [`ChannelManagerReadArgs`] with the necessary parameters and + * references to any deserialized [`ChannelMonitor`]s that were previously persisted. Use this to + * deserialize the [`ChannelManager`] and feed it any new chain data since it was last online, as + * detailed in the [`ChannelManagerReadArgs`] documentation. + * + * ``` + * use bitcoin::BlockHash; + * use bitcoin::network::Network; + * use lightning::chain::BestBlock; + * # use lightning::chain::channelmonitor::ChannelMonitor; + * use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs}; + * # use lightning::routing::gossip::NetworkGraph; + * use lightning::util::config::UserConfig; + * use lightning::util::ser::ReadableArgs; + * + * # fn read_channel_monitors() -> Vec> { vec![] } + * # fn example< + * # 'a, + * # L: lightning::util::logger::Logger, + * # ES: lightning::sign::EntropySource, + * # S: for <'b> lightning::routing::scoring::LockableScore<'b, ScoreLookUp = SL>, + * # SL: lightning::routing::scoring::ScoreLookUp, + * # SP: Sized, + * # R: lightning::io::Read, + * # >( + * # fee_estimator: &dyn lightning::chain::chaininterface::FeeEstimator, + * # chain_monitor: &dyn lightning::chain::Watch, + * # tx_broadcaster: &dyn lightning::chain::chaininterface::BroadcasterInterface, + * # router: &lightning::routing::router::DefaultRouter<&NetworkGraph<&'a L>, &'a L, &ES, &S, SP, SL>, + * # logger: &L, + * # entropy_source: &ES, + * # node_signer: &dyn lightning::sign::NodeSigner, + * # signer_provider: &lightning::sign::DynSignerProvider, + * # best_block: lightning::chain::BestBlock, + * # current_timestamp: u32, + * # mut reader: R, + * # ) -> Result<(), lightning::ln::msgs::DecodeError> { + * // Fresh start with no channels + * let params = ChainParameters { + * network: Network::Bitcoin, + * best_block, + * }; + * let default_config = UserConfig::default(); + * let channel_manager = ChannelManager::new( + * fee_estimator, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, + * signer_provider, default_config, params, current_timestamp + * ); + * + * // Restart from deserialized data + * let mut channel_monitors = read_channel_monitors(); + * let args = ChannelManagerReadArgs::new( + * entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster, + * router, logger, default_config, channel_monitors.iter_mut().collect() + * ); + * let (block_hash, channel_manager) = + * <(BlockHash, ChannelManager<_, _, _, _, _, _, _, _>)>::read(&mut reader, args)?; + * + * // Update the ChannelManager and ChannelMonitors with the latest chain data + * // ... + * + * // Move the monitors to the ChannelManager's chain::Watch parameter + * for monitor in channel_monitors { + * chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor); + * } + * # Ok(()) + * # } + * ``` + * + * # Operation + * + * The following is required for [`ChannelManager`] to function properly: + * - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically + * called by [`PeerManager::read_event`] when processing network I/O) + * - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation + * (typically initiated when [`PeerManager::process_events`] is called) + * - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation + * as documented by those traits + * - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly + * every minute + * - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a + * [`Persister`] such as a [`KVStore`] implementation + * - Handle [`Event`]s obtained via its [`EventsProvider`] implementation + * + * The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining + * when the last two requirements need to be checked. + * + * The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that + * simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits, + * respectively. The remaining requirements can be met using the [`lightning-background-processor`] + * crate. For languages other than Rust, the availability of similar utilities may vary. + * + * # Channels + * + * [`ChannelManager`]'s primary function involves managing a channel state. Without channels, + * payments can't be sent. Use [`list_channels`] or [`list_usable_channels`] for a snapshot of the + * currently open channels. + * + * ``` + * # use lightning::ln::channelmanager::AChannelManager; + * # + * # fn example(channel_manager: T) { + * # let channel_manager = channel_manager.get_cm(); + * let channels = channel_manager.list_usable_channels(); + * for details in channels { + * println!(\"{:?}\", details); + * } + * # } + * ``` + * + * Each channel is identified using a [`ChannelId`], which will change throughout the channel's + * life cycle. Additionally, channels are assigned a `user_channel_id`, which is given in + * [`Event`]s associated with the channel and serves as a fixed identifier but is otherwise unused + * by [`ChannelManager`]. + * + * ## Opening Channels + * + * To an open a channel with a peer, call [`create_channel`]. This will initiate the process of + * opening an outbound channel, which requires self-funding when handling + * [`Event::FundingGenerationReady`]. + * + * ``` + * # use bitcoin::{ScriptBuf, Transaction}; + * # use bitcoin::secp256k1::PublicKey; + * # use lightning::ln::channelmanager::AChannelManager; + * # use lightning::events::{Event, EventsProvider}; + * # + * # trait Wallet { + * # fn create_funding_transaction( + * # &self, _amount_sats: u64, _output_script: ScriptBuf + * # ) -> Transaction; + * # } + * # + * # fn example(channel_manager: T, wallet: W, peer_id: PublicKey) { + * # let channel_manager = channel_manager.get_cm(); + * let value_sats = 1_000_000; + * let push_msats = 10_000_000; + * match channel_manager.create_channel(peer_id, value_sats, push_msats, 42, None, None) { + * Ok(channel_id) => println!(\"Opening channel {}\", channel_id), + * Err(e) => println!(\"Error opening channel: {:?}\", e), + * } + * + * // On the event processing thread once the peer has responded + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::FundingGenerationReady { + * temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, + * user_channel_id, .. + * } => { + * assert_eq!(user_channel_id, 42); + * let funding_transaction = wallet.create_funding_transaction( + * channel_value_satoshis, output_script + * ); + * match channel_manager.funding_transaction_generated( + * temporary_channel_id, counterparty_node_id, funding_transaction + * ) { + * Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), + * } + * }, + * Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!( + * \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, + * former_temporary_channel_id.unwrap() + * ); + * }, + * Event::ChannelReady { channel_id, user_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!(\"Channel {} ready\", channel_id); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * ## Accepting Channels + * + * Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`] + * has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be + * either accepted or rejected when handling [`Event::OpenChannelRequest`]. + * + * ``` + * # use bitcoin::secp256k1::PublicKey; + * # use lightning::ln::channelmanager::AChannelManager; + * # use lightning::events::{Event, EventsProvider}; + * # + * # fn is_trusted(counterparty_node_id: PublicKey) -> bool { + * # // ... + * # unimplemented!() + * # } + * # + * # fn example(channel_manager: T) { + * # let channel_manager = channel_manager.get_cm(); + * # let error_message = \"Channel force-closed\"; + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { + * if !is_trusted(counterparty_node_id) { + * match channel_manager.force_close_without_broadcasting_txn( + * &temporary_channel_id, &counterparty_node_id, error_message.to_string() + * ) { + * Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), + * } + * return Ok(()); + * } + * + * let user_channel_id = 43; + * match channel_manager.accept_inbound_channel( + * &temporary_channel_id, &counterparty_node_id, user_channel_id + * ) { + * Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), + * Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), + * } + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * ## Closing Channels + * + * There are two ways to close a channel: either cooperatively using [`close_channel`] or + * unilaterally using [`force_close_broadcasting_latest_txn`]. The former is ideal as it makes for + * lower fees and immediate access to funds. However, the latter may be necessary if the + * counterparty isn't behaving properly or has gone offline. [`Event::ChannelClosed`] is generated + * once the channel has been closed successfully. + * + * ``` + * # use bitcoin::secp256k1::PublicKey; + * # use lightning::ln::types::ChannelId; + * # use lightning::ln::channelmanager::AChannelManager; + * # use lightning::events::{Event, EventsProvider}; + * # + * # fn example( + * # channel_manager: T, channel_id: ChannelId, counterparty_node_id: PublicKey + * # ) { + * # let channel_manager = channel_manager.get_cm(); + * match channel_manager.close_channel(&channel_id, &counterparty_node_id) { + * Ok(()) => println!(\"Closing channel {}\", channel_id), + * Err(e) => println!(\"Error closing channel {}: {:?}\", channel_id, e), + * } + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::ChannelClosed { channel_id, user_channel_id, .. } => { + * assert_eq!(user_channel_id, 42); + * println!(\"Channel {} closed\", channel_id); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * # Payments + * + * [`ChannelManager`] is responsible for sending, forwarding, and receiving payments through its + * channels. A payment is typically initiated from a [BOLT 11] invoice or a [BOLT 12] offer, though + * spontaneous (i.e., keysend) payments are also possible. Incoming payments don't require + * maintaining any additional state as [`ChannelManager`] can reconstruct the [`PaymentPreimage`] + * from the [`PaymentSecret`]. Sending payments, however, require tracking in order to retry failed + * HTLCs. + * + * After a payment is initiated, it will appear in [`list_recent_payments`] until a short time + * after either an [`Event::PaymentSent`] or [`Event::PaymentFailed`] is handled. Failed HTLCs + * for a payment will be retried according to the payment's [`Retry`] strategy or until + * [`abandon_payment`] is called. + * + * ## BOLT 11 Invoices + * + * The [`lightning-invoice`] crate is useful for creating BOLT 11 invoices. Specifically, use the + * functions in its `utils` module for constructing invoices that are compatible with + * [`ChannelManager`]. These functions serve as a convenience for building invoices with the + * [`PaymentHash`] and [`PaymentSecret`] returned from [`create_inbound_payment`]. To provide your + * own [`PaymentHash`], use [`create_inbound_payment_for_hash`] or the corresponding functions in + * the [`lightning-invoice`] `utils` module. + * + * [`ChannelManager`] generates an [`Event::PaymentClaimable`] once the full payment has been + * received. Call [`claim_funds`] to release the [`PaymentPreimage`], which in turn will result in + * an [`Event::PaymentClaimed`]. + * + * ``` + * # use lightning::events::{Event, EventsProvider, PaymentPurpose}; + * # use lightning::ln::channelmanager::AChannelManager; + * # + * # fn example(channel_manager: T) { + * # let channel_manager = channel_manager.get_cm(); + * // Or use utils::create_invoice_from_channelmanager + * let known_payment_hash = match channel_manager.create_inbound_payment( + * Some(10_000_000), 3600, None + * ) { + * Ok((payment_hash, _payment_secret)) => { + * println!(\"Creating inbound payment {}\", payment_hash); + * payment_hash + * }, + * Err(()) => panic!(\"Error creating inbound payment\"), + * }; + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * }, + * PaymentPurpose::SpontaneousPayment(payment_preimage) => { + * assert_ne!(payment_hash, known_payment_hash); + * println!(\"Claiming spontaneous payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * // ... + * # _ => {}, + * }, + * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claimed {} msats\", amount_msat); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * For paying an invoice, [`lightning-invoice`] provides a `payment` module with convenience + * functions for use with [`send_payment`]. + * + * ``` + * # use lightning::events::{Event, EventsProvider}; + * # use lightning::ln::types::PaymentHash; + * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry}; + * # use lightning::routing::router::RouteParameters; + * # + * # fn example( + * # channel_manager: T, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, + * # route_params: RouteParameters, retry: Retry + * # ) { + * # let channel_manager = channel_manager.get_cm(); + * // let (payment_hash, recipient_onion, route_params) = + * // payment::payment_parameters_from_invoice(&invoice); + * let payment_id = PaymentId([42; 32]); + * match channel_manager.send_payment( + * payment_hash, recipient_onion, payment_id, route_params, retry + * ) { + * Ok(()) => println!(\"Sending payment with hash {}\", payment_hash), + * Err(e) => println!(\"Failed sending payment with hash {}: {:?}\", payment_hash, e), + * } + * + * let expected_payment_id = payment_id; + * let expected_payment_hash = payment_hash; + * assert!( + * channel_manager.list_recent_payments().iter().find(|details| matches!( + * details, + * RecentPaymentDetails::Pending { + * payment_id: expected_payment_id, + * payment_hash: expected_payment_hash, + * .. + * } + * )).is_some() + * ); + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash), + * Event::PaymentFailed { payment_hash: Some(payment_hash), .. } => + * println!(\"Failed paying {}\", payment_hash), + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * ## BOLT 12 Offers + * + * The [`offers`] module is useful for creating BOLT 12 offers. An [`Offer`] is a precursor to a + * [`Bolt12Invoice`], which must first be requested by the payer. The interchange of these messages + * as defined in the specification is handled by [`ChannelManager`] and its implementation of + * [`OffersMessageHandler`]. However, this only works with an [`Offer`] created using a builder + * returned by [`create_offer_builder`]. With this approach, BOLT 12 offers and invoices are + * stateless just as BOLT 11 invoices are. + * + * ``` + * # use lightning::events::{Event, EventsProvider, PaymentPurpose}; + * # use lightning::ln::channelmanager::AChannelManager; + * # use lightning::offers::parse::Bolt12SemanticError; + * # + * # fn example(channel_manager: T) -> Result<(), Bolt12SemanticError> { + * # let channel_manager = channel_manager.get_cm(); + * # let absolute_expiry = None; + * let offer = channel_manager + * .create_offer_builder(absolute_expiry)? + * # ; + * # // Needed for compiling for c_bindings + * # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into(); + * # let offer = builder + * .description(\"coffee\".to_string()) + * .amount_msats(10_000_000) + * .build()?; + * let bech32_offer = offer.to_string(); + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * } + * # _ => {}, + * }, + * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { + * println!(\"Claimed {} msats\", amount_msat); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # Ok(()) + * # } + * ``` + * + * Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`] + * and pays the [`Bolt12Invoice`] response. + * + * ``` + * # use lightning::events::{Event, EventsProvider}; + * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; + * # use lightning::offers::offer::Offer; + * # + * # fn example( + * # channel_manager: T, offer: &Offer, quantity: Option, amount_msats: Option, + * # payer_note: Option, retry: Retry, max_total_routing_fee_msat: Option + * # ) { + * # let channel_manager = channel_manager.get_cm(); + * let payment_id = PaymentId([42; 32]); + * match channel_manager.pay_for_offer( + * offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat + * ) { + * Ok(()) => println!(\"Requesting invoice for offer\"), + * Err(e) => println!(\"Unable to request invoice for offer: {:?}\", e), + * } + * + * // First the payment will be waiting on an invoice + * let expected_payment_id = payment_id; + * assert!( + * channel_manager.list_recent_payments().iter().find(|details| matches!( + * details, + * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id } + * )).is_some() + * ); + * + * // Once the invoice is received, a payment will be sent + * assert!( + * channel_manager.list_recent_payments().iter().find(|details| matches!( + * details, + * RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. } + * )).is_some() + * ); + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), + * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * ## BOLT 12 Refunds + * + * A [`Refund`] is a request for an invoice to be paid. Like *paying* for an [`Offer`], *creating* + * a [`Refund`] involves maintaining state since it represents a future outbound payment. + * Therefore, use [`create_refund_builder`] when creating one, otherwise [`ChannelManager`] will + * refuse to pay any corresponding [`Bolt12Invoice`] that it receives. + * + * ``` + * # use core::time::Duration; + * # use lightning::events::{Event, EventsProvider}; + * # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; + * # use lightning::offers::parse::Bolt12SemanticError; + * # + * # fn example( + * # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry, + * # max_total_routing_fee_msat: Option + * # ) -> Result<(), Bolt12SemanticError> { + * # let channel_manager = channel_manager.get_cm(); + * let payment_id = PaymentId([42; 32]); + * let refund = channel_manager + * .create_refund_builder( + * amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat + * )? + * # ; + * # // Needed for compiling for c_bindings + * # let builder: lightning::offers::refund::RefundBuilder<_> = refund.into(); + * # let refund = builder + * .description(\"coffee\".to_string()) + * .payer_note(\"refund for order 1234\".to_string()) + * .build()?; + * let bech32_refund = refund.to_string(); + * + * // First the payment will be waiting on an invoice + * let expected_payment_id = payment_id; + * assert!( + * channel_manager.list_recent_payments().iter().find(|details| matches!( + * details, + * RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id } + * )).is_some() + * ); + * + * // Once the invoice is received, a payment will be sent + * assert!( + * channel_manager.list_recent_payments().iter().find(|details| matches!( + * details, + * RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. } + * )).is_some() + * ); + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), + * Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # Ok(()) + * # } + * ``` + * + * Use [`request_refund_payment`] to send a [`Bolt12Invoice`] for receiving the refund. Similar to + * *creating* an [`Offer`], this is stateless as it represents an inbound payment. + * + * ``` + * # use lightning::events::{Event, EventsProvider, PaymentPurpose}; + * # use lightning::ln::channelmanager::AChannelManager; + * # use lightning::offers::refund::Refund; + * # + * # fn example(channel_manager: T, refund: &Refund) { + * # let channel_manager = channel_manager.get_cm(); + * let known_payment_hash = match channel_manager.request_refund_payment(refund) { + * Ok(invoice) => { + * let payment_hash = invoice.payment_hash(); + * println!(\"Requesting refund payment {}\", payment_hash); + * payment_hash + * }, + * Err(e) => panic!(\"Unable to request payment for refund: {:?}\", e), + * }; + * + * // On the event processing thread + * channel_manager.process_pending_events(&|event| { + * match event { + * Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { + * PaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claiming payment {}\", payment_hash); + * channel_manager.claim_funds(payment_preimage); + * }, + * PaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { + * println!(\"Unknown payment hash: {}\", payment_hash); + * }, + * // ... + * # _ => {}, + * }, + * Event::PaymentClaimed { payment_hash, amount_msat, .. } => { + * assert_eq!(payment_hash, known_payment_hash); + * println!(\"Claimed {} msats\", amount_msat); + * }, + * // ... + * # _ => {}, + * } + * Ok(()) + * }); + * # } + * ``` + * + * # Persistence * * Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for * all peers during write/read (though does not modify this instance, only the instance being @@ -10579,12 +13070,16 @@ typedef struct LDKRouter { * tells you the last block hash which was connected. You should get the best block tip before using the manager. * See [`chain::Listen`] and [`chain::Confirm`] for more details. * + * # `ChannelUpdate` Messages + * * Note that `ChannelManager` is responsible for tracking liveness of its channels and generating * [`ChannelUpdate`] messages informing peers that the channel is temporarily disabled. To avoid * spam due to quick disconnection/reconnection, updates are not sent until the channel has been * offline for a full minute. In order to track this, you must call * [`timer_tick_occurred`] roughly once per minute, though it doesn't have to be perfect. * + * # DoS Mitigation + * * To avoid trivial DoS issues, `ChannelManager` limits the number of inbound connections and * inbound channels without confirmed funding transactions. This may result in nodes which we do * not have a channel with being unable to connect to us or open new channels with us if we have @@ -10594,19 +13089,53 @@ typedef struct LDKRouter { * exempted from the count of unfunded channels. Similarly, outbound channels and connections are * never limited. Please ensure you limit the count of such channels yourself. * + * # Type Aliases + * * Rather than using a plain `ChannelManager`, it is preferable to use either a [`SimpleArcChannelManager`] * a [`SimpleRefChannelManager`], for conciseness. See their documentation for more details, but * essentially you should default to using a [`SimpleRefChannelManager`], and use a * [`SimpleArcChannelManager`] when you require a `ChannelManager` with a static lifetime, such as when * you're using lightning-net-tokio. * + * [`ChainMonitor`]: crate::chain::chainmonitor::ChainMonitor + * [`MessageHandler`]: crate::ln::peer_handler::MessageHandler + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * [`PeerManager::read_event`]: crate::ln::peer_handler::PeerManager::read_event + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * [`timer_tick_occurred`]: Self::timer_tick_occurred + * [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence + * [`Persister`]: crate::util::persist::Persister + * [`KVStore`]: crate::util::persist::KVStore + * [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future + * [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync + * [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync + * [`lightning-background-processor`]: https://docs.rs/lightning_background_processor/lightning_background_processor + * [`list_channels`]: Self::list_channels + * [`list_usable_channels`]: Self::list_usable_channels + * [`create_channel`]: Self::create_channel + * [`close_channel`]: Self::force_close_broadcasting_latest_txn + * [`force_close_broadcasting_latest_txn`]: Self::force_close_broadcasting_latest_txn + * [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md + * [BOLT 12]: https://github.com/rustyrussell/lightning-rfc/blob/guilt/offers/12-offer-encoding.md + * [`list_recent_payments`]: Self::list_recent_payments + * [`abandon_payment`]: Self::abandon_payment + * [`lightning-invoice`]: https://docs.rs/lightning_invoice/latest/lightning_invoice + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * [`claim_funds`]: Self::claim_funds + * [`send_payment`]: Self::send_payment + * [`offers`]: crate::offers + * [`create_offer_builder`]: Self::create_offer_builder + * [`pay_for_offer`]: Self::pay_for_offer + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`create_refund_builder`]: Self::create_refund_builder + * [`request_refund_payment`]: Self::request_refund_payment * [`peer_disconnected`]: msgs::ChannelMessageHandler::peer_disconnected * [`funding_created`]: msgs::FundingCreated * [`funding_transaction_generated`]: Self::funding_transaction_generated * [`BlockHash`]: bitcoin::hash_types::BlockHash * [`update_channel`]: chain::Watch::update_channel * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`timer_tick_occurred`]: Self::timer_tick_occurred * [`read`]: ReadableArgs::read */ typedef struct MUST_USE_STRUCT LDKChannelManager { @@ -10672,7 +13201,7 @@ typedef struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { } LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ; /** - * Options for how to set the max dust HTLC exposure allowed on a channel. See + * Options for how to set the max dust exposure allowed on a channel. See * [`ChannelConfig::max_dust_htlc_exposure`] for details. */ typedef enum LDKMaxDustHTLCExposure_Tag { @@ -10689,19 +13218,17 @@ typedef enum LDKMaxDustHTLCExposure_Tag { */ LDKMaxDustHTLCExposure_FixedLimitMsat, /** - * This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from - * [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used - * then the maximum dust exposure in millisatoshis is calculated as: - * `high_priority_feerate_per_kw * value`. For example, with our default value - * `FeeRateMultiplier(5000)`: + * This sets a multiplier on the [`ConfirmationTarget::MaximumFeeEstimate`] feerate (in + * sats/KW) to determine the maximum allowed dust exposure. If this variant is used then the + * maximum dust exposure in millisatoshis is calculated as: + * `feerate_per_kw * value`. For example, with our default value + * `FeeRateMultiplier(10_000)`: * * - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum - * defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would - * be 253 * 5000 = 1,265,000 msats. + * defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + * be 253 * 10_000 = 2,530,000 msats. * - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be - * 7500 * 5000 = 37,500,000 msats. - * - * This allows the maximum dust exposure to automatically scale with fee rate changes. + * 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). * * Note, if you're using a third-party fee estimator, this may leave you more exposed to a * fee griefing attack, where your fee estimator may purposely overestimate the fee rate, @@ -10716,6 +13243,7 @@ typedef enum LDKMaxDustHTLCExposure_Tag { * by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. * * [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ LDKMaxDustHTLCExposure_FeeRateMultiplier, /** @@ -11110,6 +13638,62 @@ typedef struct LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { uintptr_t datalen; } LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ; + + +/** + * An error type that may be returned to LDK in order to safely abort event handling if it can't + * currently succeed (e.g., due to a persistence failure). + * + * Depending on the type, LDK may ensure the event is persisted and will eventually be replayed. + * Please refer to the documentation of each [`Event`] variant for more details. + */ +typedef struct MUST_USE_STRUCT LDKReplayEvent { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeReplayEvent *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKReplayEvent; + +/** + * The contents of CResult_NoneReplayEventZ + */ +typedef union LDKCResult_NoneReplayEventZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKReplayEvent *err; +} LDKCResult_NoneReplayEventZPtr; + +/** + * A CResult_NoneReplayEventZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::events::ReplayEvent on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneReplayEventZ { + /** + * The contents of this CResult_NoneReplayEventZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneReplayEventZPtr contents; + /** + * Whether this CResult_NoneReplayEventZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneReplayEventZ; + /** * A dynamically-allocated array of crate::lightning::ln::chan_utils::CommitmentTransactions of arbitrary size. * This corresponds to std::vector in C++ @@ -11246,6 +13830,59 @@ typedef struct LDKBalance_LDKClaimableOnChannelClose_Body { * required to do so. */ uint64_t amount_satoshis; + /** + * The transaction fee we pay for the closing commitment transaction. This amount is not + * included in the [`Balance::ClaimableOnChannelClose::amount_satoshis`] value. + * + * Note that if this channel is inbound (and thus our counterparty pays the commitment + * transaction fee) this value will be zero. For [`ChannelMonitor`]s created prior to LDK + * 0.0.124, the channel is always treated as outbound (and thus this value is never zero). + */ + uint64_t transaction_fee_satoshis; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + * from us and are related to a payment which was sent by us. This is the sum of the + * millisatoshis part of all HTLCs which are otherwise represented by + * [`Balance::MaybeTimeoutClaimableHTLC`] with their + * [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust + * HTLCs which would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + */ + uint64_t outbound_payment_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + * from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part + * of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`] + * with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as + * well as any dust HTLCs which would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + */ + uint64_t outbound_forwarded_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + * to us and for which we know the preimage. This is the sum of the millisatoshis part of + * all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel + * close, but whose current value is included in + * [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which + * would otherwise be represented the same. + * + * This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + * `amount_satoshis`. + */ + uint64_t inbound_claiming_htlc_rounded_msat; + /** + * The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + * to us and for which we do not know the preimage. This is the sum of the millisatoshis + * part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`] + * on channel close, as well as any dust HTLCs which would otherwise be represented the + * same. + * + * This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + * `amount_satoshis`. + */ + uint64_t inbound_htlc_rounded_msat; } LDKBalance_LDKClaimableOnChannelClose_Body; typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { @@ -11259,6 +13896,10 @@ typedef struct LDKBalance_LDKClaimableAwaitingConfirmations_Body { * amount. */ uint32_t confirmation_height; + /** + * Whether this balance is a result of cooperative close, a force-close, or an HTLC. + */ + enum LDKBalanceSource source; } LDKBalance_LDKClaimableAwaitingConfirmations_Body; typedef struct LDKBalance_LDKContentiousClaimable_Body { @@ -11297,6 +13938,12 @@ typedef struct LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body { * The payment hash whose preimage our counterparty needs to claim this HTLC. */ struct LDKThirtyTwoBytes payment_hash; + /** + * Whether this HTLC represents a payment which was sent outbound from us. Otherwise it + * represents an HTLC which was forwarded (and should, thus, have a corresponding inbound + * edge on another channel). + */ + bool outbound_payment; } LDKBalance_LDKMaybeTimeoutClaimableHTLC_Body; typedef struct LDKBalance_LDKMaybePreimageClaimableHTLC_Body { @@ -11467,36 +14114,6 @@ typedef struct LDKCVec_C2Tuple_PublicKeyTypeZZ { uintptr_t datalen; } LDKCVec_C2Tuple_PublicKeyTypeZZ; -/** - * A tuple of 2 elements. See the individual fields for the types contained. - */ -typedef struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ { - /** - * The element at position 0 - */ - struct LDKPublicKey a; - /** - * The element at position 1 - */ - struct LDKCVec_SocketAddressZ b; -} LDKC2Tuple_PublicKeyCVec_SocketAddressZZ; - -/** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ; - /** * The contents of an onion message. */ @@ -11510,6 +14127,10 @@ typedef struct LDKOnionMessageContents { * Returns the TLV type identifying the message contents. MUST be >= 64. */ uint64_t (*tlv_type)(const void *this_arg); + /** + * Returns the message type + */ + struct LDKStr (*msg_type)(const void *this_arg); /** * Serialize the object into a byte array */ @@ -11531,6 +14152,47 @@ typedef struct LDKOnionMessageContents { void (*free)(void *this_arg); } LDKOnionMessageContents; +/** + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ { + /** + * The element at position 0 + */ + struct LDKOnionMessageContents a; + /** + * The element at position 1 + */ + struct LDKResponseInstruction b; +} LDKC2Tuple_OnionMessageContentsResponseInstructionZ; + +/** + * An enum which can either contain a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ or not + */ +typedef enum LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag { + /** + * When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Some, + /** + * When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains nothing + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Sentinel, +} LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag; + +typedef struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ_Tag tag; + union { + struct { + struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ some; + }; + }; +} LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ; + /** * An enum which can either contain a crate::lightning::onion_message::packet::OnionMessageContents or not */ @@ -11592,9 +14254,9 @@ typedef struct LDKCResult_COption_OnionMessageContentsZDecodeErrorZ { } LDKCResult_COption_OnionMessageContentsZDecodeErrorZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ { +typedef struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ { /** * The element at position 0 */ @@ -11602,28 +14264,24 @@ typedef struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ { /** * The element at position 1 */ - struct LDKDestination b; - /** - * The element at position 2 - */ - struct LDKBlindedPath c; -} LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ; + struct LDKMessageSendInstructions b; +} LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ; /** - * A dynamically-allocated array of crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZs of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +typedef struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *data; + struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ; +} LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ; /** * An enum which can either contain a crate::lightning::ln::wire::Type or not @@ -11712,35 +14370,41 @@ typedef struct LDKCOption_SocketAddressZ { }; } LDKCOption_SocketAddressZ; + + /** - * A tuple of 2 elements. See the individual fields for the types contained. + * Details of a connected peer as returned by [`PeerManager::list_peers`]. */ -typedef struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ { +typedef struct MUST_USE_STRUCT LDKPeerDetails { /** - * The element at position 0 + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - struct LDKPublicKey a; + LDKnativePeerDetails *inner; /** - * The element at position 1 + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. */ - struct LDKCOption_SocketAddressZ b; -} LDKC2Tuple_PublicKeyCOption_SocketAddressZZ; + bool is_owned; +} LDKPeerDetails; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_SocketAddressZZs of arbitrary size. + * A dynamically-allocated array of crate::lightning::ln::peer_handler::PeerDetailss of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { +typedef struct LDKCVec_PeerDetailsZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *data; + struct LDKPeerDetails *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ; +} LDKCVec_PeerDetailsZ; @@ -11960,22 +14624,6 @@ typedef struct LDKCResult_CVec_u8ZIOErrorZ { bool result_ok; } LDKCResult_CVec_u8ZIOErrorZ; -/** - * A dynamically-allocated array of crate::c_types::Strs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_StrZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKStr *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_StrZ; - /** * The contents of CResult_CVec_StrZIOErrorZ */ @@ -12092,47 +14740,138 @@ typedef struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { } LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ; /** - * Represents a valid secp256k1 secret key serialized as a 32 byte array. + * The contents of CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ */ -typedef struct LDKSecretKey { +typedef union LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { /** - * The bytes of the secret key + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - uint8_t bytes[32]; -} LDKSecretKey; + struct LDKUnsignedInvoiceRequest *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr; /** - * An enum which can either contain a crate::c_types::SecretKey or not + * A CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_request::UnsignedInvoiceRequest on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef enum LDKCOption_SecretKeyZ_Tag { +typedef struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { /** - * When we're in this state, this COption_SecretKeyZ contains a crate::c_types::SecretKey + * The contents of this CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - LDKCOption_SecretKeyZ_Some, + union LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ; + +/** + * The contents of CResult_InvoiceRequestBolt12SemanticErrorZ + */ +typedef union LDKCResult_InvoiceRequestBolt12SemanticErrorZPtr { /** - * When we're in this state, this COption_SecretKeyZ contains nothing + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKCOption_SecretKeyZ_None, + struct LDKInvoiceRequest *result; /** - * Must be last for serialization purposes + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKCOption_SecretKeyZ_Sentinel, -} LDKCOption_SecretKeyZ_Tag; + enum LDKBolt12SemanticError *err; +} LDKCResult_InvoiceRequestBolt12SemanticErrorZPtr; -typedef struct LDKCOption_SecretKeyZ { - LDKCOption_SecretKeyZ_Tag tag; - union { - struct { - struct LDKSecretKey some; - }; - }; -} LDKCOption_SecretKeyZ; +/** + * A CResult_InvoiceRequestBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_request::InvoiceRequest on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ { + /** + * The contents of this CResult_InvoiceRequestBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceRequestBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_InvoiceRequestBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceRequestBolt12SemanticErrorZ; /** - * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different - * ways to respond depending on whether the signing keys were derived. + * Builds a [`Bolt12Invoice`] from either: + * - an [`InvoiceRequest`] for the \"offer to be paid\" flow or + * - a [`Refund`] for the \"offer for money\" flow. + * + * See [module-level documentation] for usage. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Refund`]: crate::offers::refund::Refund + * [module-level documentation]: self + */ +typedef struct MUST_USE_STRUCT LDKInvoiceWithExplicitSigningPubkeyBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceWithExplicitSigningPubkeyBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceWithExplicitSigningPubkeyBuilder; + +/** + * The contents of CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoiceWithExplicitSigningPubkeyBuilder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr; + +/** + * A CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + /** + * The contents of this CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ; + + + +/** + * An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending + * on whether the signing keys were derived. */ typedef struct MUST_USE_STRUCT LDKVerifiedInvoiceRequest { /** @@ -12181,6 +14920,122 @@ typedef struct LDKCResult_VerifiedInvoiceRequestNoneZ { bool result_ok; } LDKCResult_VerifiedInvoiceRequestNoneZ; + + +/** + * Builds a [`Bolt12Invoice`] from either: + * - an [`InvoiceRequest`] for the \"offer to be paid\" flow or + * - a [`Refund`] for the \"offer for money\" flow. + * + * See [module-level documentation] for usage. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Refund`]: crate::offers::refund::Refund + * [module-level documentation]: self + */ +typedef struct MUST_USE_STRUCT LDKInvoiceWithDerivedSigningPubkeyBuilder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceWithDerivedSigningPubkeyBuilder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceWithDerivedSigningPubkeyBuilder; + +/** + * The contents of CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ + */ +typedef union LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoiceWithDerivedSigningPubkeyBuilder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + enum LDKBolt12SemanticError *err; +} LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr; + +/** + * A CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + /** + * The contents of this CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr contents; + /** + * Whether this CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ; + + + +/** + * Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`]. + * + * [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer + */ +typedef struct MUST_USE_STRUCT LDKInvoiceRequestFields { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequestFields *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequestFields; + +/** + * The contents of CResult_InvoiceRequestFieldsDecodeErrorZ + */ +typedef union LDKCResult_InvoiceRequestFieldsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoiceRequestFields *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_InvoiceRequestFieldsDecodeErrorZPtr; + +/** + * A CResult_InvoiceRequestFieldsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_request::InvoiceRequestFields on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ { + /** + * The contents of this CResult_InvoiceRequestFieldsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InvoiceRequestFieldsDecodeErrorZPtr contents; + /** + * Whether this CResult_InvoiceRequestFieldsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InvoiceRequestFieldsDecodeErrorZ; + /** * A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. * This corresponds to std::vector in C++ @@ -12197,6 +15052,33 @@ typedef struct LDKCVec_WitnessZ { uintptr_t datalen; } LDKCVec_WitnessZ; +/** + * An enum which can either contain a crate::c_types::ECDSASignature or not + */ +typedef enum LDKCOption_ECDSASignatureZ_Tag { + /** + * When we're in this state, this COption_ECDSASignatureZ contains a crate::c_types::ECDSASignature + */ + LDKCOption_ECDSASignatureZ_Some, + /** + * When we're in this state, this COption_ECDSASignatureZ contains nothing + */ + LDKCOption_ECDSASignatureZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ECDSASignatureZ_Sentinel, +} LDKCOption_ECDSASignatureZ_Tag; + +typedef struct LDKCOption_ECDSASignatureZ { + LDKCOption_ECDSASignatureZ_Tag tag; + union { + struct { + struct LDKECDSASignature some; + }; + }; +} LDKCOption_ECDSASignatureZ; + /** * An enum which can either contain a i64 or not */ @@ -12542,37 +15424,37 @@ typedef struct LDKCResult_StfuDecodeErrorZ { } LDKCResult_StfuDecodeErrorZ; /** - * The contents of CResult_SpliceDecodeErrorZ + * The contents of CResult_SpliceInitDecodeErrorZ */ -typedef union LDKCResult_SpliceDecodeErrorZPtr { +typedef union LDKCResult_SpliceInitDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKSplice *result; + struct LDKSpliceInit *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_SpliceDecodeErrorZPtr; +} LDKCResult_SpliceInitDecodeErrorZPtr; /** - * A CResult_SpliceDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::ln::msgs::Splice on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_SpliceInitDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::SpliceInit on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_SpliceDecodeErrorZ { +typedef struct LDKCResult_SpliceInitDecodeErrorZ { /** - * The contents of this CResult_SpliceDecodeErrorZ, accessible via either + * The contents of this CResult_SpliceInitDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_SpliceDecodeErrorZPtr contents; + union LDKCResult_SpliceInitDecodeErrorZPtr contents; /** - * Whether this CResult_SpliceDecodeErrorZ represents a success state. + * Whether this CResult_SpliceInitDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_SpliceDecodeErrorZ; +} LDKCResult_SpliceInitDecodeErrorZ; /** * The contents of CResult_SpliceAckDecodeErrorZ @@ -13094,6 +15976,59 @@ typedef struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ { +/** + * Optional batch parameters for `commitment_signed` message. + */ +typedef struct MUST_USE_STRUCT LDKCommitmentSignedBatch { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCommitmentSignedBatch *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCommitmentSignedBatch; + +/** + * The contents of CResult_CommitmentSignedBatchDecodeErrorZ + */ +typedef union LDKCResult_CommitmentSignedBatchDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCommitmentSignedBatch *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_CommitmentSignedBatchDecodeErrorZPtr; + +/** + * A CResult_CommitmentSignedBatchDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::msgs::CommitmentSignedBatch on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CommitmentSignedBatchDecodeErrorZ { + /** + * The contents of this CResult_CommitmentSignedBatchDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CommitmentSignedBatchDecodeErrorZPtr contents; + /** + * Whether this CResult_CommitmentSignedBatchDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CommitmentSignedBatchDecodeErrorZ; + + + /** * A [`commitment_signed`] message to be sent to or received from a peer. * @@ -14305,115 +17240,467 @@ typedef struct LDKCResult_GossipTimestampFilterDecodeErrorZ { } LDKCResult_GossipTimestampFilterDecodeErrorZ; /** - * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. - * This corresponds to std::vector in C++ + * An enum which can either contain a crate::lightning::ln::channel_state::InboundHTLCStateDetails or not */ -typedef struct LDKCVec_PhantomRouteHintsZ { +typedef enum LDKCOption_InboundHTLCStateDetailsZ_Tag { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * When we're in this state, this COption_InboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::InboundHTLCStateDetails */ - struct LDKPhantomRouteHints *data; + LDKCOption_InboundHTLCStateDetailsZ_Some, /** - * The number of elements pointed to by `data`. + * When we're in this state, this COption_InboundHTLCStateDetailsZ contains nothing */ - uintptr_t datalen; -} LDKCVec_PhantomRouteHintsZ; + LDKCOption_InboundHTLCStateDetailsZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_InboundHTLCStateDetailsZ_Sentinel, +} LDKCOption_InboundHTLCStateDetailsZ_Tag; +typedef struct LDKCOption_InboundHTLCStateDetailsZ { + LDKCOption_InboundHTLCStateDetailsZ_Tag tag; + union { + struct { + enum LDKInboundHTLCStateDetails some; + }; + }; +} LDKCOption_InboundHTLCStateDetailsZ; +/** + * The contents of CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ + */ +typedef union LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_InboundHTLCStateDetailsZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr; /** - * Represents a syntactically and semantically correct lightning BOLT11 invoice. - * - * There are three ways to construct a `Bolt11Invoice`: - * 1. using [`InvoiceBuilder`] - * 2. using [`Bolt11Invoice::from_signed`] - * 3. using `str::parse::(&str)` (see [`Bolt11Invoice::from_str`]) - * - * [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr + * A CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_InboundHTLCStateDetailsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct MUST_USE_STRUCT LDKBolt11Invoice { +typedef struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + /** + * The contents of this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ; + + + +/** + * Exposes details around pending inbound HTLCs. + */ +typedef struct MUST_USE_STRUCT LDKInboundHTLCDetails { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBolt11Invoice *inner; + LDKnativeInboundHTLCDetails *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBolt11Invoice; +} LDKInboundHTLCDetails; /** - * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] - * may occur. + * The contents of CResult_InboundHTLCDetailsDecodeErrorZ */ -typedef enum LDKSignOrCreationError_Tag { +typedef union LDKCResult_InboundHTLCDetailsDecodeErrorZPtr { /** - * An error occurred during signing + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - LDKSignOrCreationError_SignError, + struct LDKInboundHTLCDetails *result; /** - * An error occurred while building the transaction + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - LDKSignOrCreationError_CreationError, + struct LDKDecodeError *err; +} LDKCResult_InboundHTLCDetailsDecodeErrorZPtr; + +/** + * A CResult_InboundHTLCDetailsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::InboundHTLCDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_InboundHTLCDetailsDecodeErrorZ { + /** + * The contents of this CResult_InboundHTLCDetailsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_InboundHTLCDetailsDecodeErrorZPtr contents; + /** + * Whether this CResult_InboundHTLCDetailsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_InboundHTLCDetailsDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::ln::channel_state::OutboundHTLCStateDetails or not + */ +typedef enum LDKCOption_OutboundHTLCStateDetailsZ_Tag { + /** + * When we're in this state, this COption_OutboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::OutboundHTLCStateDetails + */ + LDKCOption_OutboundHTLCStateDetailsZ_Some, + /** + * When we're in this state, this COption_OutboundHTLCStateDetailsZ contains nothing + */ + LDKCOption_OutboundHTLCStateDetailsZ_None, /** * Must be last for serialization purposes */ - LDKSignOrCreationError_Sentinel, -} LDKSignOrCreationError_Tag; + LDKCOption_OutboundHTLCStateDetailsZ_Sentinel, +} LDKCOption_OutboundHTLCStateDetailsZ_Tag; -typedef struct MUST_USE_STRUCT LDKSignOrCreationError { - LDKSignOrCreationError_Tag tag; +typedef struct LDKCOption_OutboundHTLCStateDetailsZ { + LDKCOption_OutboundHTLCStateDetailsZ_Tag tag; union { struct { - enum LDKCreationError creation_error; + enum LDKOutboundHTLCStateDetails some; }; }; -} LDKSignOrCreationError; +} LDKCOption_OutboundHTLCStateDetailsZ; /** - * The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ + * The contents of CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ */ -typedef union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr { +typedef union LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBolt11Invoice *result; + struct LDKCOption_OutboundHTLCStateDetailsZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKSignOrCreationError *err; -} LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr; /** - * A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, - * containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. + * A CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_OutboundHTLCStateDetailsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ { +typedef struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { /** - * The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either + * The contents of this CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr contents; + union LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr contents; /** - * Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. + * Whether this CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_Bolt11InvoiceSignOrCreationErrorZ; +} LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ; + + + +/** + * Exposes details around pending outbound HTLCs. + */ +typedef struct MUST_USE_STRUCT LDKOutboundHTLCDetails { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOutboundHTLCDetails *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOutboundHTLCDetails; + +/** + * The contents of CResult_OutboundHTLCDetailsDecodeErrorZ + */ +typedef union LDKCResult_OutboundHTLCDetailsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOutboundHTLCDetails *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_OutboundHTLCDetailsDecodeErrorZPtr; + +/** + * A CResult_OutboundHTLCDetailsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::OutboundHTLCDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ { + /** + * The contents of this CResult_OutboundHTLCDetailsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OutboundHTLCDetailsDecodeErrorZPtr contents; + /** + * Whether this CResult_OutboundHTLCDetailsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OutboundHTLCDetailsDecodeErrorZ; + + + +/** + * Information needed for constructing an invoice route hint for this channel. + */ +typedef struct MUST_USE_STRUCT LDKCounterpartyForwardingInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeCounterpartyForwardingInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCounterpartyForwardingInfo; + +/** + * The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ + */ +typedef union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCounterpartyForwardingInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr; + +/** + * A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ { + /** + * The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_CounterpartyForwardingInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_CounterpartyForwardingInfoDecodeErrorZ; + + + +/** + * Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] + * to better separate parameters. + */ +typedef struct MUST_USE_STRUCT LDKChannelCounterparty { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelCounterparty *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelCounterparty; + +/** + * The contents of CResult_ChannelCounterpartyDecodeErrorZ + */ +typedef union LDKCResult_ChannelCounterpartyDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelCounterparty *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelCounterpartyDecodeErrorZPtr; + +/** + * A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelCounterpartyDecodeErrorZ { + /** + * The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelCounterpartyDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelCounterpartyDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::ln::channel_state::ChannelShutdownState or not + */ +typedef enum LDKCOption_ChannelShutdownStateZ_Tag { + /** + * When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channel_state::ChannelShutdownState + */ + LDKCOption_ChannelShutdownStateZ_Some, + /** + * When we're in this state, this COption_ChannelShutdownStateZ contains nothing + */ + LDKCOption_ChannelShutdownStateZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_ChannelShutdownStateZ_Sentinel, +} LDKCOption_ChannelShutdownStateZ_Tag; + +typedef struct LDKCOption_ChannelShutdownStateZ { + LDKCOption_ChannelShutdownStateZ_Tag tag; + union { + struct { + enum LDKChannelShutdownState some; + }; + }; +} LDKCOption_ChannelShutdownStateZ; + +/** + * A dynamically-allocated array of crate::lightning::ln::channel_state::InboundHTLCDetailss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_InboundHTLCDetailsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKInboundHTLCDetails *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_InboundHTLCDetailsZ; + +/** + * A dynamically-allocated array of crate::lightning::ln::channel_state::OutboundHTLCDetailss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_OutboundHTLCDetailsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKOutboundHTLCDetails *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_OutboundHTLCDetailsZ; + +/** + * The contents of CResult_ChannelDetailsDecodeErrorZ + */ +typedef union LDKCResult_ChannelDetailsDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKChannelDetails *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelDetailsDecodeErrorZPtr; + +/** + * A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelDetailsDecodeErrorZ { + /** + * The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelDetailsDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelDetailsDecodeErrorZ; + +/** + * The contents of CResult_ChannelShutdownStateDecodeErrorZ + */ +typedef union LDKCResult_ChannelShutdownStateDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + enum LDKChannelShutdownState *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ChannelShutdownStateDecodeErrorZPtr; + +/** + * A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::channel_state::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ChannelShutdownStateDecodeErrorZ { + /** + * The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ChannelShutdownStateDecodeErrorZPtr contents; + /** + * Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ChannelShutdownStateDecodeErrorZ; /** * A simple future which can complete once, and calls some callback(s) when it does so. - * - * Clones can be made and all futures cloned from the same source will complete at the same time. */ typedef struct MUST_USE_STRUCT LDKFuture { /** @@ -14446,6 +17733,105 @@ typedef struct LDKCVec_FutureZ { uintptr_t datalen; } LDKCVec_FutureZ; +/** + * The contents of CResult_HeldHtlcAvailableDecodeErrorZ + */ +typedef union LDKCResult_HeldHtlcAvailableDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKHeldHtlcAvailable *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_HeldHtlcAvailableDecodeErrorZPtr; + +/** + * A CResult_HeldHtlcAvailableDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::HeldHtlcAvailable on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_HeldHtlcAvailableDecodeErrorZ { + /** + * The contents of this CResult_HeldHtlcAvailableDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_HeldHtlcAvailableDecodeErrorZPtr contents; + /** + * Whether this CResult_HeldHtlcAvailableDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_HeldHtlcAvailableDecodeErrorZ; + +/** + * The contents of CResult_ReleaseHeldHtlcDecodeErrorZ + */ +typedef union LDKCResult_ReleaseHeldHtlcDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKReleaseHeldHtlc *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ReleaseHeldHtlcDecodeErrorZPtr; + +/** + * A CResult_ReleaseHeldHtlcDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::ReleaseHeldHtlc on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ { + /** + * The contents of this CResult_ReleaseHeldHtlcDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ReleaseHeldHtlcDecodeErrorZPtr contents; + /** + * Whether this CResult_ReleaseHeldHtlcDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ReleaseHeldHtlcDecodeErrorZ; + +/** + * The contents of CResult_AsyncPaymentsMessageDecodeErrorZ + */ +typedef union LDKCResult_AsyncPaymentsMessageDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKAsyncPaymentsMessage *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_AsyncPaymentsMessageDecodeErrorZPtr; + +/** + * A CResult_AsyncPaymentsMessageDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::async_payments::AsyncPaymentsMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ { + /** + * The contents of this CResult_AsyncPaymentsMessageDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_AsyncPaymentsMessageDecodeErrorZPtr contents; + /** + * Whether this CResult_AsyncPaymentsMessageDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_AsyncPaymentsMessageDecodeErrorZ; + /** * The contents of CResult_OffersMessageDecodeErrorZ */ @@ -15156,15 +18542,107 @@ typedef struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ { bool result_ok; } LDKCResult_ShutdownScriptInvalidShutdownScriptZ; +/** + * `FundingInfo` holds information about a channel's funding transaction. + * + * When LDK is set to manual propagation of the funding transaction + * (via [`ChannelManager::unsafe_manual_funding_transaction_generated`), + * LDK does not have the full transaction data. Instead, the `OutPoint` + * for the funding is provided here. + * + * [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + */ +typedef enum LDKFundingInfo_Tag { + /** + * The full funding `Transaction`. + */ + LDKFundingInfo_Tx, + /** + * The `OutPoint` of the funding. + */ + LDKFundingInfo_OutPoint, + /** + * Must be last for serialization purposes + */ + LDKFundingInfo_Sentinel, +} LDKFundingInfo_Tag; + +typedef struct LDKFundingInfo_LDKTx_Body { + /** + * The funding transaction + */ + struct LDKTransaction transaction; +} LDKFundingInfo_LDKTx_Body; + +typedef struct LDKFundingInfo_LDKOutPoint_Body { + /** + * The outpoint of the funding + */ + struct LDKOutPoint outpoint; +} LDKFundingInfo_LDKOutPoint_Body; + +typedef struct MUST_USE_STRUCT LDKFundingInfo { + LDKFundingInfo_Tag tag; + union { + LDKFundingInfo_LDKTx_Body tx; + LDKFundingInfo_LDKOutPoint_Body out_point; + }; +} LDKFundingInfo; + +/** + * The contents of CResult_FundingInfoDecodeErrorZ + */ +typedef union LDKCResult_FundingInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKFundingInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_FundingInfoDecodeErrorZPtr; + +/** + * A CResult_FundingInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::events::FundingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_FundingInfoDecodeErrorZ { + /** + * The contents of this CResult_FundingInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_FundingInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_FundingInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_FundingInfoDecodeErrorZ; + /** * Some information provided on receipt of payment depends on whether the payment received is a * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. */ typedef enum LDKPaymentPurpose_Tag { /** - * Information for receiving a payment that we generated an invoice for. + * A payment for a BOLT 11 invoice. + */ + LDKPaymentPurpose_Bolt11InvoicePayment, + /** + * A payment for a BOLT 12 [`Offer`]. + * + * [`Offer`]: crate::offers::offer::Offer + */ + LDKPaymentPurpose_Bolt12OfferPayment, + /** + * A payment for a BOLT 12 [`Refund`]. + * + * [`Refund`]: crate::offers::refund::Refund */ - LDKPaymentPurpose_InvoicePayment, + LDKPaymentPurpose_Bolt12RefundPayment, /** * Because this is a spontaneous payment, the payer generated their own preimage rather than us * (the payee) providing a preimage. @@ -15176,11 +18654,12 @@ typedef enum LDKPaymentPurpose_Tag { LDKPaymentPurpose_Sentinel, } LDKPaymentPurpose_Tag; -typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { +typedef struct LDKPaymentPurpose_LDKBolt11InvoicePayment_Body { /** * The preimage to the payment_hash, if the payment hash (and secret) were fetched via - * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - * [`ChannelManager::claim_funds`]. + * [`ChannelManager::create_inbound_payment`]. When handling [`Event::PaymentClaimable`], + * this can be passed directly to [`ChannelManager::claim_funds`] to claim the payment. No + * action is needed when seen in [`Event::PaymentClaimed`]. * * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds @@ -15199,12 +18678,64 @@ typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash */ struct LDKThirtyTwoBytes payment_secret; -} LDKPaymentPurpose_LDKInvoicePayment_Body; +} LDKPaymentPurpose_LDKBolt11InvoicePayment_Body; + +typedef struct LDKPaymentPurpose_LDKBolt12OfferPayment_Body { + /** + * The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be + * passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed + * when seen in [`Event::PaymentClaimed`]. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + */ + struct LDKCOption_ThirtyTwoBytesZ payment_preimage; + /** + * The secret used to authenticate the sender to the recipient, preventing a number of + * de-anonymization attacks while routing a payment. + * + * See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details. + */ + struct LDKThirtyTwoBytes payment_secret; + /** + * The context of the payment such as information about the corresponding [`Offer`] and + * [`InvoiceRequest`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + */ + struct LDKBolt12OfferContext payment_context; +} LDKPaymentPurpose_LDKBolt12OfferPayment_Body; + +typedef struct LDKPaymentPurpose_LDKBolt12RefundPayment_Body { + /** + * The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be + * passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed + * when seen in [`Event::PaymentClaimed`]. + * + * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + */ + struct LDKCOption_ThirtyTwoBytesZ payment_preimage; + /** + * The secret used to authenticate the sender to the recipient, preventing a number of + * de-anonymization attacks while routing a payment. + * + * See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details. + */ + struct LDKThirtyTwoBytes payment_secret; + /** + * The context of the payment such as information about the corresponding [`Refund`]. + * + * [`Refund`]: crate::offers::refund::Refund + */ + struct LDKBolt12RefundContext payment_context; +} LDKPaymentPurpose_LDKBolt12RefundPayment_Body; typedef struct MUST_USE_STRUCT LDKPaymentPurpose { LDKPaymentPurpose_Tag tag; union { - LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; + LDKPaymentPurpose_LDKBolt11InvoicePayment_Body bolt11_invoice_payment; + LDKPaymentPurpose_LDKBolt12OfferPayment_Body bolt12_offer_payment; + LDKPaymentPurpose_LDKBolt12RefundPayment_Body bolt12_refund_payment; struct { struct LDKThirtyTwoBytes spontaneous_payment; }; @@ -15406,127 +18937,6 @@ typedef struct LDKCResult_COption_PathFailureZDecodeErrorZ { bool result_ok; } LDKCResult_COption_PathFailureZDecodeErrorZ; - - -/** - * Struct to `Display` fields in a safe way using `PrintableString` - */ -typedef struct MUST_USE_STRUCT LDKUntrustedString { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeUntrustedString *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKUntrustedString; - -/** - * The reason the channel was closed. See individual variants for more details. - */ -typedef enum LDKClosureReason_Tag { - /** - * Closure generated from receiving a peer error message. - * - * Our counterparty may have broadcasted their latest commitment state, and we have - * as well. - */ - LDKClosureReason_CounterpartyForceClosed, - /** - * Closure generated from [`ChannelManager::force_close_channel`], called by the user. - * - * [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - */ - LDKClosureReason_HolderForceClosed, - /** - * The channel was closed after negotiating a cooperative close and we've now broadcasted - * the cooperative close transaction. Note the shutdown may have been initiated by us. - */ - LDKClosureReason_CooperativeClosure, - /** - * A commitment transaction was confirmed on chain, closing the channel. Most likely this - * commitment transaction came from our counterparty, but it may also have come from - * a copy of our own `ChannelMonitor`. - */ - LDKClosureReason_CommitmentTxConfirmed, - /** - * The funding transaction failed to confirm in a timely manner on an inbound channel. - */ - LDKClosureReason_FundingTimedOut, - /** - * Closure generated from processing an event, likely a HTLC forward/relay/reception. - */ - LDKClosureReason_ProcessingError, - /** - * The peer disconnected prior to funding completing. In this case the spec mandates that we - * forget the channel entirely - we can attempt again if the peer reconnects. - * - * This includes cases where we restarted prior to funding completion, including prior to the - * initial [`ChannelMonitor`] persistence completing. - * - * In LDK versions prior to 0.0.107 this could also occur if we were unable to connect to the - * peer because of mutual incompatibility between us and our channel counterparty. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - */ - LDKClosureReason_DisconnectedPeer, - /** - * Closure generated from `ChannelManager::read` if the [`ChannelMonitor`] is newer than - * the [`ChannelManager`] deserialized. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - */ - LDKClosureReason_OutdatedChannelManager, - /** - * The counterparty requested a cooperative close of a channel that had not been funded yet. - * The channel has been immediately closed. - */ - LDKClosureReason_CounterpartyCoopClosedUnfundedChannel, - /** - * Another channel in the same funding batch closed before the funding transaction - * was ready to be broadcast. - */ - LDKClosureReason_FundingBatchClosure, - /** - * Must be last for serialization purposes - */ - LDKClosureReason_Sentinel, -} LDKClosureReason_Tag; - -typedef struct LDKClosureReason_LDKCounterpartyForceClosed_Body { - /** - * The error which the peer sent us. - * - * Be careful about printing the peer_msg, a well-crafted message could exploit - * a security vulnerability in the terminal emulator or the logging subsystem. - * To be safe, use `Display` on `UntrustedString` - * - * [`UntrustedString`]: crate::util::string::UntrustedString - */ - struct LDKUntrustedString peer_msg; -} LDKClosureReason_LDKCounterpartyForceClosed_Body; - -typedef struct LDKClosureReason_LDKProcessingError_Body { - /** - * A developer-readable error message which we generated. - */ - struct LDKStr err; -} LDKClosureReason_LDKProcessingError_Body; - -typedef struct MUST_USE_STRUCT LDKClosureReason { - LDKClosureReason_Tag tag; - union { - LDKClosureReason_LDKCounterpartyForceClosed_Body counterparty_force_closed; - LDKClosureReason_LDKProcessingError_Body processing_error; - }; -} LDKClosureReason; - /** * An enum which can either contain a crate::lightning::events::ClosureReason or not */ @@ -15605,6 +19015,10 @@ typedef enum LDKHTLCDestination_Tag { * intercept HTLC. */ LDKHTLCDestination_InvalidForward, + /** + * We couldn't decode the incoming onion to obtain the forwarding details. + */ + LDKHTLCDestination_InvalidOnion, /** * Failure scenario where an HTLC may have been forwarded to be intended for us, * but is invalid for some reason, so we reject it. @@ -15636,7 +19050,7 @@ typedef struct LDKHTLCDestination_LDKNextHopChannel_Body { /** * The outgoing `channel_id` between us and the next node. */ - struct LDKThirtyTwoBytes channel_id; + struct LDKChannelId channel_id; } LDKHTLCDestination_LDKNextHopChannel_Body; typedef struct LDKHTLCDestination_LDKUnknownNextHop_Body { @@ -15730,82 +19144,6 @@ typedef struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ { bool result_ok; } LDKCResult_COption_HTLCDestinationZDecodeErrorZ; -/** - * The contents of CResult_PaymentFailureReasonDecodeErrorZ - */ -typedef union LDKCResult_PaymentFailureReasonDecodeErrorZPtr { - /** - * A pointer to the contents in the success state. - * Reading from this pointer when `result_ok` is not set is undefined. - */ - enum LDKPaymentFailureReason *result; - /** - * A pointer to the contents in the error state. - * Reading from this pointer when `result_ok` is set is undefined. - */ - struct LDKDecodeError *err; -} LDKCResult_PaymentFailureReasonDecodeErrorZPtr; - -/** - * A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. - * `result_ok` indicates the overall state, and the contents are provided via `contents`. - */ -typedef struct LDKCResult_PaymentFailureReasonDecodeErrorZ { - /** - * The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either - * `err` or `result` depending on the state of `result_ok`. - */ - union LDKCResult_PaymentFailureReasonDecodeErrorZPtr contents; - /** - * Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. - */ - bool result_ok; -} LDKCResult_PaymentFailureReasonDecodeErrorZ; - -/** - * An enum which can either contain a crate::c_types::U128 or not - */ -typedef enum LDKCOption_U128Z_Tag { - /** - * When we're in this state, this COption_U128Z contains a crate::c_types::U128 - */ - LDKCOption_U128Z_Some, - /** - * When we're in this state, this COption_U128Z contains nothing - */ - LDKCOption_U128Z_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_U128Z_Sentinel, -} LDKCOption_U128Z_Tag; - -typedef struct LDKCOption_U128Z { - LDKCOption_U128Z_Tag tag; - union { - struct { - struct LDKU128 some; - }; - }; -} LDKCOption_U128Z; - -/** - * A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. - * This corresponds to std::vector in C++ - */ -typedef struct LDKCVec_ClaimedHTLCZ { - /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - */ - struct LDKClaimedHTLC *data; - /** - * The number of elements pointed to by `data`. - */ - uintptr_t datalen; -} LDKCVec_ClaimedHTLCZ; - /** * An enum which can either contain a crate::lightning::events::PaymentFailureReason or not */ @@ -15833,6 +19171,124 @@ typedef struct LDKCOption_PaymentFailureReasonZ { }; } LDKCOption_PaymentFailureReasonZ; +/** + * The contents of CResult_COption_PaymentFailureReasonZDecodeErrorZ + */ +typedef union LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKCOption_PaymentFailureReasonZ *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr; + +/** + * A CResult_COption_PaymentFailureReasonZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::COption_PaymentFailureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ { + /** + * The contents of this CResult_COption_PaymentFailureReasonZDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_COption_PaymentFailureReasonZDecodeErrorZPtr contents; + /** + * Whether this CResult_COption_PaymentFailureReasonZDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ; + +/** + * An enum which can either contain a crate::c_types::U128 or not + */ +typedef enum LDKCOption_U128Z_Tag { + /** + * When we're in this state, this COption_U128Z contains a crate::c_types::U128 + */ + LDKCOption_U128Z_Some, + /** + * When we're in this state, this COption_U128Z contains nothing + */ + LDKCOption_U128Z_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_U128Z_Sentinel, +} LDKCOption_U128Z_Tag; + +typedef struct LDKCOption_U128Z { + LDKCOption_U128Z_Tag tag; + union { + struct { + struct LDKU128 some; + }; + }; +} LDKCOption_U128Z; + +/** + * A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_ClaimedHTLCZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKClaimedHTLC *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_ClaimedHTLCZ; + + + +/** + * The `Responder` struct creates an appropriate [`ResponseInstruction`] for responding to a + * message. + */ +typedef struct MUST_USE_STRUCT LDKResponder { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeResponder *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKResponder; + + + +/** + * A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the + * channel initiator and which are not part of the channel funding transaction. + */ +typedef struct MUST_USE_STRUCT LDKChannelParameters { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeChannelParameters *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKChannelParameters; + /** @@ -15938,6 +19394,14 @@ typedef enum LDKBumpTransactionEvent_Tag { } LDKBumpTransactionEvent_Tag; typedef struct LDKBumpTransactionEvent_LDKChannelClose_Body { + /** + * The `channel_id` of the channel which has been closed. + */ + struct LDKChannelId channel_id; + /** + * Counterparty in the closed channel. + */ + struct LDKPublicKey counterparty_node_id; /** * The unique identifier for the claim of the anchor output in the commitment transaction. * @@ -15975,6 +19439,14 @@ typedef struct LDKBumpTransactionEvent_LDKChannelClose_Body { } LDKBumpTransactionEvent_LDKChannelClose_Body; typedef struct LDKBumpTransactionEvent_LDKHTLCResolution_Body { + /** + * The `channel_id` of the channel which has been closed. + */ + struct LDKChannelId channel_id; + /** + * Counterparty in the closed channel. + */ + struct LDKPublicKey counterparty_node_id; /** * The unique identifier for the claim of the HTLCs in the confirmed commitment * transaction. @@ -16022,10 +19494,29 @@ typedef enum LDKEvent_Tag { * Note that *all inputs* in the funding transaction must spend SegWit outputs or your * counterparty can steal your funds! * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ LDKEvent_FundingGenerationReady, + /** + * Used to indicate that the counterparty node has provided the signature(s) required to + * recover our funds in case they go offline. + * + * It is safe (and your responsibility) to broadcast the funding transaction upon receiving this + * event. + * + * This event is only emitted if you called + * [`ChannelManager::unsafe_manual_funding_transaction_generated`] instead of + * [`ChannelManager::funding_transaction_generated`]. + * + * [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + */ + LDKEvent_FundingTxBroadcastSafe, /** * Indicates that we've been offered a payment and it needs to be claimed via calling * [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. @@ -16056,6 +19547,10 @@ typedef enum LDKEvent_Tag { * # Note * This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds * [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs * [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload @@ -16077,6 +19572,10 @@ typedef enum LDKEvent_Tag { * [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get * multiple `PaymentClaimed` events. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds */ LDKEvent_PaymentClaimed, @@ -16090,6 +19589,11 @@ typedef enum LDKEvent_Tag { * This event will not be generated for onion message forwards; only for sends including * replies. Handlers should connect to the node otherwise any buffered messages may be lost. * + * # Failure Behavior and Persistence + * This event won't be replayed after failures-to-handle + * (i.e., the event handler returning `Err(ReplayEvent ())`), and also won't be persisted + * across restarts. + * * [`OnionMessage`]: msgs::OnionMessage * [`MessageRouter`]: crate::onion_message::messenger::MessageRouter * [`Destination`]: crate::onion_message::messenger::Destination @@ -16097,22 +19601,35 @@ typedef enum LDKEvent_Tag { */ LDKEvent_ConnectionNeeded, /** - * Indicates a request for an invoice failed to yield a response in a reasonable amount of time - * or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an - * [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed. + * Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was + * received. + * + * This event will only be generated if [`UserConfig::manually_handle_bolt12_invoices`] is set. + * Use [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. See those docs for + * further details. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. * - * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Offer`]: crate::offers::offer::Offer * [`Refund`]: crate::offers::refund::Refund + * [`UserConfig::manually_handle_bolt12_invoices`]: crate::util::config::UserConfig::manually_handle_bolt12_invoices + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ - LDKEvent_InvoiceRequestFailed, + LDKEvent_InvoiceReceived, /** * Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target * and we got back the payment preimage for it). * * Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` * event. In this situation, you SHOULD treat this payment as having succeeded. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentSent, /** @@ -16128,6 +19645,10 @@ typedef enum LDKEvent_Tag { * received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored, * and the payment MUST be treated as having succeeded. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`Retry`]: crate::ln::channelmanager::Retry * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ @@ -16137,6 +19658,10 @@ typedef enum LDKEvent_Tag { * * Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See * [`Event::PaymentSent`] for obtaining the payment preimage. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentPathSuccessful, /** @@ -16149,21 +19674,37 @@ typedef enum LDKEvent_Tag { * See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have * been exhausted. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment */ LDKEvent_PaymentPathFailed, /** * Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ProbeSuccessful, /** * Indicates that a probe payment we sent failed at an intermediary node on the path. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ProbeFailed, /** * Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at * a time in the future. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be regenerated after restarts. + * * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards */ LDKEvent_PendingHTLCsForwardable, @@ -16176,6 +19717,10 @@ typedef enum LDKEvent_Tag { * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See * their docs for more information. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs * [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -16185,14 +19730,28 @@ typedef enum LDKEvent_Tag { /** * Used to indicate that an output which you should know how to spend was confirmed on chain * and is now spendable. - * Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + * + * Such an output will *never* be spent directly by LDK, and are not at risk of your * counterparty spending them due to some kind of timeout. Thus, you need to store them * somewhere and spend them when you create on-chain transactions. + * + * You may hand them to the [`OutputSweeper`] utility which will store and (re-)generate spending + * transactions for you. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * + * [`OutputSweeper`]: crate::util::sweep::OutputSweeper */ LDKEvent_SpendableOutputs, /** * This event is generated when a payment has been successfully forwarded through us and a * forwarding fee earned. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_PaymentForwarded, /** @@ -16202,6 +19761,10 @@ typedef enum LDKEvent_Tag { * This event is emitted when the funding transaction has been signed and is broadcast to the * network. For 0conf channels it will be immediately followed by the corresponding * [`Event::ChannelReady`] event. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelPending, /** @@ -16209,11 +19772,15 @@ typedef enum LDKEvent_Tag { * be used. This event is emitted either when the funding transaction has been confirmed * on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel * establishment. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelReady, /** - * Used to indicate that a previously opened channel with the given `channel_id` is in the - * process of closure. + * Used to indicate that a channel that got past the initial handshake with the given `channel_id` is in the + * process of closure. This includes previously opened channels, and channels that time out from not being funded. * * Note that this event is only triggered for accepted channels: if the * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is @@ -16221,6 +19788,10 @@ typedef enum LDKEvent_Tag { * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_ChannelClosed, /** @@ -16228,6 +19799,10 @@ typedef enum LDKEvent_Tag { * inputs for another purpose. * * This event is not guaranteed to be generated for channels that are closed due to a restart. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_DiscardFunding, /** @@ -16240,6 +19815,10 @@ typedef enum LDKEvent_Tag { * The event is only triggered when a new open channel request is received and the * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. + * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels @@ -16258,6 +19837,10 @@ typedef enum LDKEvent_Tag { * * This event, however, does not get generated if an HTLC fails to meet the forwarding * requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`) and will be persisted across restarts. */ LDKEvent_HTLCHandlingFailed, /** @@ -16268,9 +19851,40 @@ typedef enum LDKEvent_Tag { * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. * It is limited to the scope of channels with anchor outputs. * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts. + * * [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx */ LDKEvent_BumpTransaction, + /** + * We received an onion message that is intended to be forwarded to a peer + * that is currently offline. This event will only be generated if the + * `OnionMessenger` was initialized with + * [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * + * [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + */ + LDKEvent_OnionMessageIntercepted, + /** + * Indicates that an onion message supporting peer has come online and it may + * be time to forward any onion messages that were previously intercepted for + * them. This event will only be generated if the `OnionMessenger` was + * initialized with + * [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + * + * # Failure Behavior and Persistence + * This event will eventually be replayed after failures-to-handle (i.e., the event handler + * returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + * + * [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + */ + LDKEvent_OnionMessagePeerConnected, /** * Must be last for serialization purposes */ @@ -16284,7 +19898,7 @@ typedef struct LDKEvent_LDKFundingGenerationReady_Body { * * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ - struct LDKThirtyTwoBytes temporary_channel_id; + struct LDKChannelId temporary_channel_id; /** * The counterparty's node_id, which you'll need to pass back into * [`ChannelManager::funding_transaction_generated`]. @@ -16314,6 +19928,31 @@ typedef struct LDKEvent_LDKFundingGenerationReady_Body { struct LDKU128 user_channel_id; } LDKEvent_LDKFundingGenerationReady_Body; +typedef struct LDKEvent_LDKFundingTxBroadcastSafe_Body { + /** + * The `channel_id` indicating which channel has reached this stage. + */ + struct LDKChannelId channel_id; + /** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`]. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + */ + struct LDKU128 user_channel_id; + /** + * The outpoint of the channel's funding transaction. + */ + struct LDKOutPoint funding_txo; + /** + * The `node_id` of the channel counterparty. + */ + struct LDKPublicKey counterparty_node_id; + /** + * The `temporary_channel_id` this channel used to be known by during channel establishment. + */ + struct LDKChannelId former_temporary_channel_id; +} LDKEvent_LDKFundingTxBroadcastSafe_Body; + typedef struct LDKEvent_LDKPaymentClaimable_Body { /** * The node that will receive the payment after it has been claimed. @@ -16370,8 +20009,10 @@ typedef struct LDKEvent_LDKPaymentClaimable_Body { struct LDKPaymentPurpose purpose; /** * The `channel_id` indicating over which channel we received the payment. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_ThirtyTwoBytesZ via_channel_id; + struct LDKChannelId via_channel_id; /** * The `user_channel_id` indicating over which channel we received the payment. */ @@ -16425,6 +20066,15 @@ typedef struct LDKEvent_LDKPaymentClaimed_Body { * serialized prior to LDK version 0.0.117. */ struct LDKCOption_u64Z sender_intended_total_msat; + /** + * The fields in the onion which were received with each HTLC. Only fields which were + * identical in each HTLC involved in the payment will be included here. + * + * Payments received on LDK versions prior to 0.0.124 will have this field unset. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKRecipientOnionFields onion_fields; } LDKEvent_LDKPaymentClaimed_Body; typedef struct LDKEvent_LDKConnectionNeeded_Body { @@ -16438,12 +20088,32 @@ typedef struct LDKEvent_LDKConnectionNeeded_Body { struct LDKCVec_SocketAddressZ addresses; } LDKEvent_LDKConnectionNeeded_Body; -typedef struct LDKEvent_LDKInvoiceRequestFailed_Body { +typedef struct LDKEvent_LDKInvoiceReceived_Body { /** - * The `payment_id` to have been associated with payment for the requested invoice. + * The `payment_id` associated with payment for the invoice. */ struct LDKThirtyTwoBytes payment_id; -} LDKEvent_LDKInvoiceRequestFailed_Body; + /** + * The invoice to pay. + */ + struct LDKBolt12Invoice invoice; + /** + * The context of the [`BlindedMessagePath`] used to send the invoice. + * + * [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath + */ + struct LDKCOption_OffersContextZ context; + /** + * A responder for replying with an [`InvoiceError`] if needed. + * + * `None` if the invoice wasn't sent with a reply path. + * + * [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKResponder responder; +} LDKEvent_LDKInvoiceReceived_Body; typedef struct LDKEvent_LDKPaymentSent_Body { /** @@ -16473,6 +20143,8 @@ typedef struct LDKEvent_LDKPaymentSent_Body { * If the recipient or an intermediate node misbehaves and gives us free money, this may * overstate the amount paid, though this is unlikely. * + * This is only `None` for payments initiated on LDK versions prior to 0.0.103. + * * [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees */ struct LDKCOption_u64Z fee_paid_msat; @@ -16486,14 +20158,17 @@ typedef struct LDKEvent_LDKPaymentFailed_Body { */ struct LDKThirtyTwoBytes payment_id; /** - * The hash that was given to [`ChannelManager::send_payment`]. + * The hash that was given to [`ChannelManager::send_payment`]. `None` if the payment failed + * before receiving an invoice when paying a BOLT12 [`Offer`]. * * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`Offer`]: crate::offers::offer::Offer */ - struct LDKThirtyTwoBytes payment_hash; + struct LDKCOption_ThirtyTwoBytesZ payment_hash; /** * The reason the payment failed. This is only `None` for events generated or serialized - * by versions prior to 0.0.115. + * by versions prior to 0.0.115, or when downgrading to a version with a reason that was + * added after. */ struct LDKCOption_PaymentFailureReasonZ reason; } LDKEvent_LDKPaymentFailed_Body; @@ -16664,23 +20339,45 @@ typedef struct LDKEvent_LDKSpendableOutputs_Body { * The `channel_id` indicating which channel the spendable outputs belong to. * * This will always be `Some` for events generated by LDK versions 0.0.117 and above. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_ThirtyTwoBytesZ channel_id; + struct LDKChannelId channel_id; } LDKEvent_LDKSpendableOutputs_Body; typedef struct LDKEvent_LDKPaymentForwarded_Body { /** - * The incoming channel between the previous node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. + * The channel id of the incoming channel between the previous node and us. + * + * This is only `None` for events generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_ThirtyTwoBytesZ prev_channel_id; + struct LDKChannelId prev_channel_id; /** - * The outgoing channel between the next node and us. This is only `None` for events - * generated or serialized by versions prior to 0.0.107. + * The channel id of the outgoing channel between the next node and us. + * + * This is only `None` for events generated or serialized by versions prior to 0.0.107. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_ThirtyTwoBytesZ next_channel_id; + struct LDKChannelId next_channel_id; /** - * The fee, in milli-satoshis, which was earned as a result of the payment. + * The `user_channel_id` of the incoming channel between the previous node and us. + * + * This is only `None` for events generated or serialized by versions prior to 0.0.122. + */ + struct LDKCOption_U128Z prev_user_channel_id; + /** + * The `user_channel_id` of the outgoing channel between the next node and us. + * + * This will be `None` if the payment was settled via an on-chain transaction. See the + * caveat described for the `total_fee_earned_msat` field. Moreover it will be `None` for + * events generated or serialized by versions prior to 0.0.122. + */ + struct LDKCOption_U128Z next_user_channel_id; + /** + * The total fee, in milli-satoshis, which was earned as a result of the payment. * * Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC * was pending, the amount the next hop claimed will have been rounded down to the nearest @@ -16691,10 +20388,26 @@ typedef struct LDKEvent_LDKPaymentForwarded_Body { * If the channel which sent us the payment has been force-closed, we will claim the funds * via an on-chain transaction. In that case we do not yet know the on-chain transaction * fees which we will spend and will instead set this to `None`. It is possible duplicate - * `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + * `PaymentForwarded` events are generated for the same payment iff `total_fee_earned_msat` is * `None`. */ - struct LDKCOption_u64Z fee_earned_msat; + struct LDKCOption_u64Z total_fee_earned_msat; + /** + * The share of the total fee, in milli-satoshis, which was withheld in addition to the + * forwarding fee. + * + * This will only be `Some` if we forwarded an intercepted HTLC with less than the + * expected amount. This means our counterparty accepted to receive less than the invoice + * amount, e.g., by claiming the payment featuring a corresponding + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]. + * + * Will also always be `None` for events serialized with LDK prior to version 0.0.122. + * + * The caveat described above the `total_fee_earned_msat` field applies here as well. + * + * [`PaymentClaimable::counterparty_skimmed_fee_msat`]: Self::PaymentClaimable::counterparty_skimmed_fee_msat + */ + struct LDKCOption_u64Z skimmed_fee_msat; /** * If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain * transaction. @@ -16703,7 +20416,7 @@ typedef struct LDKEvent_LDKPaymentForwarded_Body { /** * The final amount forwarded, in milli-satoshis, after the fee is deducted. * - * The caveat described above the `fee_earned_msat` field applies here as well. + * The caveat described above the `total_fee_earned_msat` field applies here as well. */ struct LDKCOption_u64Z outbound_amount_forwarded_msat; } LDKEvent_LDKPaymentForwarded_Body; @@ -16712,7 +20425,7 @@ typedef struct LDKEvent_LDKChannelPending_Body { /** * The `channel_id` of the channel that is pending confirmation. */ - struct LDKThirtyTwoBytes channel_id; + struct LDKChannelId channel_id; /** * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if @@ -16728,8 +20441,10 @@ typedef struct LDKEvent_LDKChannelPending_Body { * The `temporary_channel_id` this channel used to be known by during channel establishment. * * Will be `None` for channels created prior to LDK version 0.0.115. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_ThirtyTwoBytesZ former_temporary_channel_id; + struct LDKChannelId former_temporary_channel_id; /** * The `node_id` of the channel counterparty. */ @@ -16738,13 +20453,21 @@ typedef struct LDKEvent_LDKChannelPending_Body { * The outpoint of the channel's funding transaction. */ struct LDKOutPoint funding_txo; + /** + * The features that this channel will operate with. + * + * Will be `None` for channels created prior to LDK version 0.0.122. + * + * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKChannelTypeFeatures channel_type; } LDKEvent_LDKChannelPending_Body; typedef struct LDKEvent_LDKChannelReady_Body { /** * The `channel_id` of the channel that is ready. */ - struct LDKThirtyTwoBytes channel_id; + struct LDKChannelId channel_id; /** * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if @@ -16771,7 +20494,7 @@ typedef struct LDKEvent_LDKChannelClosed_Body { * The `channel_id` of the channel which has been closed. Note that on-chain transactions * resolving the channel are likely still awaiting confirmation. */ - struct LDKThirtyTwoBytes channel_id; + struct LDKChannelId channel_id; /** * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if @@ -16817,11 +20540,11 @@ typedef struct LDKEvent_LDKDiscardFunding_Body { /** * The channel_id of the channel which has been closed. */ - struct LDKThirtyTwoBytes channel_id; + struct LDKChannelId channel_id; /** * The full transaction received from the user */ - struct LDKTransaction transaction; + struct LDKFundingInfo funding_info; } LDKEvent_LDKDiscardFunding_Body; typedef struct LDKEvent_LDKOpenChannelRequest_Body { @@ -16835,7 +20558,7 @@ typedef struct LDKEvent_LDKOpenChannelRequest_Body { * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn */ - struct LDKThirtyTwoBytes temporary_channel_id; + struct LDKChannelId temporary_channel_id; /** * The node_id of the counterparty requesting to open the channel. * @@ -16874,27 +20597,55 @@ typedef struct LDKEvent_LDKOpenChannelRequest_Body { * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ struct LDKChannelTypeFeatures channel_type; + /** + * True if this channel is (or will be) publicly-announced. + */ + bool is_announced; + /** + * Channel parameters given by the counterparty. + */ + struct LDKChannelParameters params; } LDKEvent_LDKOpenChannelRequest_Body; typedef struct LDKEvent_LDKHTLCHandlingFailed_Body { /** * The channel over which the HTLC was received. */ - struct LDKThirtyTwoBytes prev_channel_id; + struct LDKChannelId prev_channel_id; /** * Destination of the HTLC that failed to be processed. */ struct LDKHTLCDestination failed_next_destination; } LDKEvent_LDKHTLCHandlingFailed_Body; +typedef struct LDKEvent_LDKOnionMessageIntercepted_Body { + /** + * The node id of the offline peer. + */ + struct LDKPublicKey peer_node_id; + /** + * The onion message intended to be forwarded to `peer_node_id`. + */ + struct LDKOnionMessage message; +} LDKEvent_LDKOnionMessageIntercepted_Body; + +typedef struct LDKEvent_LDKOnionMessagePeerConnected_Body { + /** + * The node id of the peer we just connected to, who advertises support for + * onion messages. + */ + struct LDKPublicKey peer_node_id; +} LDKEvent_LDKOnionMessagePeerConnected_Body; + typedef struct MUST_USE_STRUCT LDKEvent { LDKEvent_Tag tag; union { LDKEvent_LDKFundingGenerationReady_Body funding_generation_ready; + LDKEvent_LDKFundingTxBroadcastSafe_Body funding_tx_broadcast_safe; LDKEvent_LDKPaymentClaimable_Body payment_claimable; LDKEvent_LDKPaymentClaimed_Body payment_claimed; LDKEvent_LDKConnectionNeeded_Body connection_needed; - LDKEvent_LDKInvoiceRequestFailed_Body invoice_request_failed; + LDKEvent_LDKInvoiceReceived_Body invoice_received; LDKEvent_LDKPaymentSent_Body payment_sent; LDKEvent_LDKPaymentFailed_Body payment_failed; LDKEvent_LDKPaymentPathSuccessful_Body payment_path_successful; @@ -16914,6 +20665,8 @@ typedef struct MUST_USE_STRUCT LDKEvent { struct { struct LDKBumpTransactionEvent bump_transaction; }; + LDKEvent_LDKOnionMessageIntercepted_Body onion_message_intercepted; + LDKEvent_LDKOnionMessagePeerConnected_Body onion_message_peer_connected; }; } LDKEvent; @@ -16977,6 +20730,55 @@ typedef struct LDKCResult_COption_EventZDecodeErrorZ { bool result_ok; } LDKCResult_COption_EventZDecodeErrorZ; +/** + * The contents of CResult_NonceDecodeErrorZ + */ +typedef union LDKCResult_NonceDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKNonce *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_NonceDecodeErrorZPtr; + +/** + * A CResult_NonceDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::nonce::Nonce on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NonceDecodeErrorZ { + /** + * The contents of this CResult_NonceDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NonceDecodeErrorZPtr contents; + /** + * Whether this CResult_NonceDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NonceDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning_types::routing::RouteHintHops of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_RouteHintHopZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKRouteHintHop *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_RouteHintHopZ; + /** * Sub-errors which don't have specific information in them use this type. */ @@ -17074,6 +20876,33 @@ typedef struct LDKCResult_SiPrefixBolt11ParseErrorZ { bool result_ok; } LDKCResult_SiPrefixBolt11ParseErrorZ; + + +/** + * Represents a syntactically and semantically correct lightning BOLT11 invoice. + * + * There are three ways to construct a `Bolt11Invoice`: + * 1. using [`InvoiceBuilder`] + * 2. using [`Bolt11Invoice::from_signed`] + * 3. using `str::parse::(&str)` (see [`Bolt11Invoice::from_str`]) + * + * [`Bolt11Invoice::from_str`]: crate::Bolt11Invoice#impl-FromStr + */ +typedef struct MUST_USE_STRUCT LDKBolt11Invoice { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBolt11Invoice *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBolt11Invoice; + /** * Indicates that something went wrong while parsing or validating the invoice. Parsing errors * should be mostly seen as opaque and are only there for debugging reasons. Semantic errors @@ -17198,30 +21027,6 @@ typedef struct LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { -/** - * Represents an syntactically correct [`Bolt11Invoice`] for a payment on the lightning network, - * but without the signature information. - * Decoding and encoding should not lead to information loss but may lead to different hashes. - * - * For methods without docs see the corresponding methods in [`Bolt11Invoice`]. - */ -typedef struct MUST_USE_STRUCT LDKRawBolt11Invoice { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeRawBolt11Invoice *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKRawBolt11Invoice; - - - /** * Recoverable signature */ @@ -17655,6 +21460,39 @@ typedef struct LDKCResult_BigSizeDecodeErrorZ { bool result_ok; } LDKCResult_BigSizeDecodeErrorZ; +/** + * The contents of CResult_UntrustedStringDecodeErrorZ + */ +typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKUntrustedString *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_UntrustedStringDecodeErrorZPtr; + +/** + * A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning_types::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_UntrustedStringDecodeErrorZ { + /** + * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_UntrustedStringDecodeErrorZPtr contents; + /** + * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_UntrustedStringDecodeErrorZ; + /** * The contents of CResult_HostnameDecodeErrorZ */ @@ -17777,37 +21615,37 @@ typedef struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ { } LDKCResult_TransactionU16LenLimitedDecodeErrorZ; /** - * The contents of CResult_UntrustedStringDecodeErrorZ + * The contents of CResult_ChannelIdDecodeErrorZ */ -typedef union LDKCResult_UntrustedStringDecodeErrorZPtr { +typedef union LDKCResult_ChannelIdDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKUntrustedString *result; + struct LDKChannelId *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_UntrustedStringDecodeErrorZPtr; +} LDKCResult_ChannelIdDecodeErrorZPtr; /** - * A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_ChannelIdDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_UntrustedStringDecodeErrorZ { +typedef struct LDKCResult_ChannelIdDecodeErrorZ { /** - * The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either + * The contents of this CResult_ChannelIdDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_UntrustedStringDecodeErrorZPtr contents; + union LDKCResult_ChannelIdDecodeErrorZPtr contents; /** - * Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + * Whether this CResult_ChannelIdDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_UntrustedStringDecodeErrorZ; +} LDKCResult_ChannelIdDecodeErrorZ; /** * A tuple of 2 elements. See the individual fields for the types contained. @@ -17825,6 +21663,127 @@ typedef struct LDKC2Tuple__u832u16Z { +/** + * Information needed to route a payment across a [`BlindedPaymentPath`]. + */ +typedef struct MUST_USE_STRUCT LDKBlindedPayInfo { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeBlindedPayInfo *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKBlindedPayInfo; + +/** + * The contents of CResult_BlindedPayInfoDecodeErrorZ + */ +typedef union LDKCResult_BlindedPayInfoDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedPayInfo *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_BlindedPayInfoDecodeErrorZPtr; + +/** + * A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedPayInfoDecodeErrorZ { + /** + * The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedPayInfoDecodeErrorZPtr contents; + /** + * Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedPayInfoDecodeErrorZ; + +/** + * The contents of CResult_BlindedPaymentPathNoneZ + */ +typedef union LDKCResult_BlindedPaymentPathNoneZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBlindedPaymentPath *result; + /** + * Note that this value is always NULL, as there are no contents in the Err variant + */ + void *err; +} LDKCResult_BlindedPaymentPathNoneZPtr; + +/** + * A CResult_BlindedPaymentPathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::BlindedPaymentPath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedPaymentPathNoneZ { + /** + * The contents of this CResult_BlindedPaymentPathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_BlindedPaymentPathNoneZPtr contents; + /** + * Whether this CResult_BlindedPaymentPathNoneZ represents a success state. + */ + bool result_ok; +} LDKCResult_BlindedPaymentPathNoneZ; + + + +/** + * An intermediate node, its outbound channel, and relay parameters. + */ +typedef struct MUST_USE_STRUCT LDKPaymentForwardNode { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePaymentForwardNode *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPaymentForwardNode; + +/** + * A dynamically-allocated array of crate::lightning::blinded_path::payment::PaymentForwardNodes of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PaymentForwardNodeZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPaymentForwardNode *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PaymentForwardNodeZ; + + + /** * Parameters for relaying over a given [`BlindedHop`]. * @@ -17934,87 +21893,196 @@ typedef struct LDKCResult_PaymentConstraintsDecodeErrorZ { } LDKCResult_PaymentConstraintsDecodeErrorZ; /** - * A tuple of 3 elements. See the individual fields for the types contained. + * The contents of CResult_PaymentContextDecodeErrorZ */ -typedef struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { +typedef union LDKCResult_PaymentContextDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKThirtyTwoBytes a; + struct LDKPaymentContext *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKRecipientOnionFields b; + struct LDKDecodeError *err; +} LDKCResult_PaymentContextDecodeErrorZPtr; + +/** + * A CResult_PaymentContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::PaymentContext on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_PaymentContextDecodeErrorZ { /** - * The element at position 2 + * The contents of this CResult_PaymentContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKRouteParameters c; -} LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; + union LDKCResult_PaymentContextDecodeErrorZPtr contents; + /** + * Whether this CResult_PaymentContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_PaymentContextDecodeErrorZ; /** - * The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ + * The contents of CResult_UnknownPaymentContextDecodeErrorZ */ -typedef union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { +typedef union LDKCResult_UnknownPaymentContextDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *result; + struct LDKUnknownPaymentContext *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_UnknownPaymentContextDecodeErrorZPtr; /** - * A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. + * A CResult_UnknownPaymentContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::UnknownPaymentContext on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +typedef struct LDKCResult_UnknownPaymentContextDecodeErrorZ { /** - * The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either + * The contents of this CResult_UnknownPaymentContextDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr contents; + union LDKCResult_UnknownPaymentContextDecodeErrorZPtr contents; /** - * Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + * Whether this CResult_UnknownPaymentContextDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; +} LDKCResult_UnknownPaymentContextDecodeErrorZ; /** - * The contents of CResult_StrSecp256k1ErrorZ + * The contents of CResult_Bolt12OfferContextDecodeErrorZ */ -typedef union LDKCResult_StrSecp256k1ErrorZPtr { +typedef union LDKCResult_Bolt12OfferContextDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKStr *result; + struct LDKBolt12OfferContext *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ - enum LDKSecp256k1Error *err; -} LDKCResult_StrSecp256k1ErrorZPtr; + struct LDKDecodeError *err; +} LDKCResult_Bolt12OfferContextDecodeErrorZPtr; /** - * A CResult_StrSecp256k1ErrorZ represents the result of a fallible operation, - * containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. + * A CResult_Bolt12OfferContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::Bolt12OfferContext on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_StrSecp256k1ErrorZ { +typedef struct LDKCResult_Bolt12OfferContextDecodeErrorZ { /** - * The contents of this CResult_StrSecp256k1ErrorZ, accessible via either + * The contents of this CResult_Bolt12OfferContextDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_StrSecp256k1ErrorZPtr contents; + union LDKCResult_Bolt12OfferContextDecodeErrorZPtr contents; /** - * Whether this CResult_StrSecp256k1ErrorZ represents a success state. + * Whether this CResult_Bolt12OfferContextDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_StrSecp256k1ErrorZ; +} LDKCResult_Bolt12OfferContextDecodeErrorZ; + +/** + * The contents of CResult_Bolt12RefundContextDecodeErrorZ + */ +typedef union LDKCResult_Bolt12RefundContextDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKBolt12RefundContext *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_Bolt12RefundContextDecodeErrorZPtr; + +/** + * A CResult_Bolt12RefundContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::payment::Bolt12RefundContext on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_Bolt12RefundContextDecodeErrorZ { + /** + * The contents of this CResult_Bolt12RefundContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_Bolt12RefundContextDecodeErrorZPtr contents; + /** + * Whether this CResult_Bolt12RefundContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_Bolt12RefundContextDecodeErrorZ; + +/** + * The contents of CResult_ResponderDecodeErrorZ + */ +typedef union LDKCResult_ResponderDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKResponder *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_ResponderDecodeErrorZPtr; + +/** + * A CResult_ResponderDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::onion_message::messenger::Responder on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_ResponderDecodeErrorZ { + /** + * The contents of this CResult_ResponderDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_ResponderDecodeErrorZPtr contents; + /** + * Whether this CResult_ResponderDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_ResponderDecodeErrorZ; + +/** + * An enum which can either contain a crate::lightning::blinded_path::message::MessageContext or not + */ +typedef enum LDKCOption_MessageContextZ_Tag { + /** + * When we're in this state, this COption_MessageContextZ contains a crate::lightning::blinded_path::message::MessageContext + */ + LDKCOption_MessageContextZ_Some, + /** + * When we're in this state, this COption_MessageContextZ contains nothing + */ + LDKCOption_MessageContextZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_MessageContextZ_Sentinel, +} LDKCOption_MessageContextZ_Tag; + +typedef struct LDKCOption_MessageContextZ { + LDKCOption_MessageContextZ_Tag tag; + union { + struct { + struct LDKMessageContext some; + }; + }; +} LDKCOption_MessageContextZ; /** * A tuple of 3 elements. See the individual fields for the types contained. @@ -18050,8 +22118,8 @@ typedef enum LDKSendError_Tag { */ LDKSendError_TooBigPacket, /** - * The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded - * hops. + * The provided [`Destination`] was an invalid [`BlindedMessagePath`] due to not having any + * blinded hops. */ LDKSendError_TooFewBlindedHops, /** @@ -18059,7 +22127,11 @@ typedef enum LDKSendError_Tag { */ LDKSendError_InvalidFirstHop, /** - * A path from the sender to the destination could not be found by the [`MessageRouter`]. + * Indicates that a path could not be found by the [`MessageRouter`]. + * + * This occurs when either: + * - No path from the sender to the destination was found to send the onion message + * - No reply path to the sender could be created when responding to an onion message */ LDKSendError_PathNotFound, /** @@ -18076,6 +22148,12 @@ typedef enum LDKSendError_Tag { * [`NodeSigner`]: crate::sign::NodeSigner */ LDKSendError_GetNodeIdFailed, + /** + * The provided [`Destination`] has a blinded path with an unresolved introduction node. An + * attempt to resolve it in the [`MessageRouter`] when finding an [`OnionMessagePath`] likely + * failed. + */ + LDKSendError_UnresolvedIntroductionNode, /** * We attempted to send to a blinded path where we are the introduction node, and failed to * advance the blinded path to make the second hop the new introduction node. Either @@ -18134,6 +22212,38 @@ typedef struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddres bool result_ok; } LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; +/** + * The next hop to forward an onion message along its path. + * + * Note that payment blinded paths always specify their next hop using an explicit node id. + */ +typedef enum LDKNextMessageHop_Tag { + /** + * The node id of the next hop. + */ + LDKNextMessageHop_NodeId, + /** + * The short channel id leading to the next hop. + */ + LDKNextMessageHop_ShortChannelId, + /** + * Must be last for serialization purposes + */ + LDKNextMessageHop_Sentinel, +} LDKNextMessageHop_Tag; + +typedef struct MUST_USE_STRUCT LDKNextMessageHop { + LDKNextMessageHop_Tag tag; + union { + struct { + struct LDKPublicKey node_id; + }; + struct { + uint64_t short_channel_id; + }; + }; +} LDKNextMessageHop; + /** * The contents of an [`OnionMessage`] as read from the wire. * @@ -18176,7 +22286,7 @@ typedef enum LDKPeeledOnion_Tag { */ LDKPeeledOnion_Forward, /** - * Received onion message, with decrypted contents, path_id, and reply path + * Received onion message, with decrypted contents, context, and reply path */ LDKPeeledOnion_Receive, /** @@ -18186,22 +22296,18 @@ typedef enum LDKPeeledOnion_Tag { } LDKPeeledOnion_Tag; typedef struct LDKPeeledOnion_LDKForward_Body { - struct LDKPublicKey _0; + struct LDKNextMessageHop _0; struct LDKOnionMessage _1; } LDKPeeledOnion_LDKForward_Body; typedef struct LDKPeeledOnion_LDKReceive_Body { struct LDKParsedOnionMessageContents _0; + struct LDKCOption_MessageContextZ _1; /** * * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKThirtyTwoBytes _1; - /** - * - * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - */ - struct LDKBlindedPath _2; + struct LDKBlindedMessagePath _2; } LDKPeeledOnion_LDKReceive_Body; typedef struct MUST_USE_STRUCT LDKPeeledOnion { @@ -18309,203 +22415,725 @@ typedef struct LDKCResult_SendSuccessSendErrorZ { } LDKCResult_SendSuccessSendErrorZ; /** - * The contents of CResult_BlindedPathNoneZ + * The contents of CResult_NoneSendErrorZ + */ +typedef union LDKCResult_NoneSendErrorZPtr { + /** + * Note that this value is always NULL, as there are no contents in the OK variant + */ + void *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKSendError *err; +} LDKCResult_NoneSendErrorZPtr; + +/** + * A CResult_NoneSendErrorZ represents the result of a fallible operation, + * containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_NoneSendErrorZ { + /** + * The contents of this CResult_NoneSendErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_NoneSendErrorZPtr contents; + /** + * Whether this CResult_NoneSendErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_NoneSendErrorZ; + +/** + * The contents of CResult_BlindedHopDecodeErrorZ */ -typedef union LDKCResult_BlindedPathNoneZPtr { +typedef union LDKCResult_BlindedHopDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBlindedPath *result; + struct LDKBlindedHop *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_BlindedPathNoneZPtr; + struct LDKDecodeError *err; +} LDKCResult_BlindedHopDecodeErrorZPtr; /** - * A CResult_BlindedPathNoneZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. + * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedPathNoneZ { +typedef struct LDKCResult_BlindedHopDecodeErrorZ { /** - * The contents of this CResult_BlindedPathNoneZ, accessible via either + * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPathNoneZPtr contents; + union LDKCResult_BlindedHopDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPathNoneZ represents a success state. + * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPathNoneZ; +} LDKCResult_BlindedHopDecodeErrorZ; + +/** + * A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_PhantomRouteHintsZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKPhantomRouteHints *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_PhantomRouteHintsZ; + +/** + * When signing using a fallible method either an user-supplied `SignError` or a [`CreationError`] + * may occur. + */ +typedef enum LDKSignOrCreationError_Tag { + /** + * An error occurred during signing + */ + LDKSignOrCreationError_SignError, + /** + * An error occurred while building the transaction + */ + LDKSignOrCreationError_CreationError, + /** + * Must be last for serialization purposes + */ + LDKSignOrCreationError_Sentinel, +} LDKSignOrCreationError_Tag; + +typedef struct MUST_USE_STRUCT LDKSignOrCreationError { + LDKSignOrCreationError_Tag tag; + union { + struct { + enum LDKCreationError creation_error; + }; + }; +} LDKSignOrCreationError; /** - * The contents of CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ + * The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ */ -typedef union LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +typedef union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *result; + struct LDKBolt11Invoice *result; /** - * Note that this value is always NULL, as there are no contents in the Err variant + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void *err; -} LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr; + struct LDKSignOrCreationError *err; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr; + +/** + * A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, + * containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ { + /** + * The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_Bolt11InvoiceSignOrCreationErrorZPtr contents; + /** + * Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_Bolt11InvoiceSignOrCreationErrorZ; + +/** + * The contents of CResult_InvoiceErrorDecodeErrorZ + */ +typedef union LDKCResult_InvoiceErrorDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKInvoiceError *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_InvoiceErrorDecodeErrorZPtr; /** - * A CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents the result of a fallible operation, - * containing a crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ on success and a () on failure. + * A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { +typedef struct LDKCResult_InvoiceErrorDecodeErrorZ { /** - * The contents of this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ, accessible via either + * The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr contents; + union LDKCResult_InvoiceErrorDecodeErrorZPtr contents; /** - * Whether this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents a success state. + * Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ; +} LDKCResult_InvoiceErrorDecodeErrorZ; /** - * An intermediate node, its outbound channel, and relay parameters. + * The state of a spendable output currently tracked by an [`OutputSweeper`]. */ -typedef struct MUST_USE_STRUCT LDKForwardNode { +typedef struct MUST_USE_STRUCT LDKTrackedSpendableOutput { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeForwardNode *inner; + LDKnativeTrackedSpendableOutput *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKForwardNode; +} LDKTrackedSpendableOutput; /** - * A dynamically-allocated array of crate::lightning::blinded_path::payment::ForwardNodes of arbitrary size. - * This corresponds to std::vector in C++ + * The contents of CResult_TrackedSpendableOutputDecodeErrorZ */ -typedef struct LDKCVec_ForwardNodeZ { +typedef union LDKCResult_TrackedSpendableOutputDecodeErrorZPtr { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKForwardNode *data; + struct LDKTrackedSpendableOutput *result; /** - * The number of elements pointed to by `data`. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - uintptr_t datalen; -} LDKCVec_ForwardNodeZ; + struct LDKDecodeError *err; +} LDKCResult_TrackedSpendableOutputDecodeErrorZPtr; + +/** + * A CResult_TrackedSpendableOutputDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::sweep::TrackedSpendableOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_TrackedSpendableOutputDecodeErrorZ { + /** + * The contents of this CResult_TrackedSpendableOutputDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_TrackedSpendableOutputDecodeErrorZPtr contents; + /** + * Whether this CResult_TrackedSpendableOutputDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_TrackedSpendableOutputDecodeErrorZ; + +/** + * The current status of the output spend. + */ +typedef enum LDKOutputSpendStatus_Tag { + /** + * The output is tracked but an initial spending transaction hasn't been generated and + * broadcasted yet. + */ + LDKOutputSpendStatus_PendingInitialBroadcast, + /** + * A transaction spending the output has been broadcasted but is pending its first confirmation on-chain. + */ + LDKOutputSpendStatus_PendingFirstConfirmation, + /** + * A transaction spending the output has been confirmed on-chain but will be tracked until it + * reaches [`ANTI_REORG_DELAY`] confirmations. + */ + LDKOutputSpendStatus_PendingThresholdConfirmations, + /** + * Must be last for serialization purposes + */ + LDKOutputSpendStatus_Sentinel, +} LDKOutputSpendStatus_Tag; + +typedef struct LDKOutputSpendStatus_LDKPendingInitialBroadcast_Body { + /** + * The height at which we will first generate and broadcast a spending transaction. + */ + struct LDKCOption_u32Z delayed_until_height; +} LDKOutputSpendStatus_LDKPendingInitialBroadcast_Body; + +typedef struct LDKOutputSpendStatus_LDKPendingFirstConfirmation_Body { + /** + * The hash of the chain tip when we first broadcast a transaction spending this output. + */ + struct LDKThirtyTwoBytes first_broadcast_hash; + /** + * The best height when we last broadcast a transaction spending this output. + */ + uint32_t latest_broadcast_height; + /** + * The transaction spending this output we last broadcasted. + */ + struct LDKTransaction latest_spending_tx; +} LDKOutputSpendStatus_LDKPendingFirstConfirmation_Body; + +typedef struct LDKOutputSpendStatus_LDKPendingThresholdConfirmations_Body { + /** + * The hash of the chain tip when we first broadcast a transaction spending this output. + */ + struct LDKThirtyTwoBytes first_broadcast_hash; + /** + * The best height when we last broadcast a transaction spending this output. + */ + uint32_t latest_broadcast_height; + /** + * The transaction spending this output we saw confirmed on-chain. + */ + struct LDKTransaction latest_spending_tx; + /** + * The height at which the spending transaction was confirmed. + */ + uint32_t confirmation_height; + /** + * The hash of the block in which the spending transaction was confirmed. + */ + struct LDKThirtyTwoBytes confirmation_hash; +} LDKOutputSpendStatus_LDKPendingThresholdConfirmations_Body; + +typedef struct MUST_USE_STRUCT LDKOutputSpendStatus { + LDKOutputSpendStatus_Tag tag; + union { + LDKOutputSpendStatus_LDKPendingInitialBroadcast_Body pending_initial_broadcast; + LDKOutputSpendStatus_LDKPendingFirstConfirmation_Body pending_first_confirmation; + LDKOutputSpendStatus_LDKPendingThresholdConfirmations_Body pending_threshold_confirmations; + }; +} LDKOutputSpendStatus; /** - * The contents of CResult_BlindedPathDecodeErrorZ + * The contents of CResult_OutputSpendStatusDecodeErrorZ */ -typedef union LDKCResult_BlindedPathDecodeErrorZPtr { +typedef union LDKCResult_OutputSpendStatusDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBlindedPath *result; + struct LDKOutputSpendStatus *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_BlindedPathDecodeErrorZPtr; +} LDKCResult_OutputSpendStatusDecodeErrorZPtr; /** - * A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OutputSpendStatusDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::sweep::OutputSpendStatus on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedPathDecodeErrorZ { +typedef struct LDKCResult_OutputSpendStatusDecodeErrorZ { /** - * The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either + * The contents of this CResult_OutputSpendStatusDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedPathDecodeErrorZPtr contents; + union LDKCResult_OutputSpendStatusDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + * Whether this CResult_OutputSpendStatusDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedPathDecodeErrorZ; +} LDKCResult_OutputSpendStatusDecodeErrorZ; + + /** - * The contents of CResult_BlindedHopDecodeErrorZ + * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. + * + * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction + * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via + * [`Confirm::transactions_confirmed`]. + * + * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and + * may have been spent there. See [`Filter::register_output`] for details. + * + * Depending on your block source, you may need one or both of either [`Self::outpoint`] or + * [`Self::script_pubkey`]. + * + * [`ChannelMonitor`]: channelmonitor::ChannelMonitor + * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected */ -typedef union LDKCResult_BlindedHopDecodeErrorZPtr { +typedef struct MUST_USE_STRUCT LDKWatchedOutput { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeWatchedOutput *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKWatchedOutput; + +/** + * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to + * channels. + * + * This is useful in order to have a [`Watch`] implementation convey to a chain source which + * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in + * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If + * receiving full blocks from a chain source, any further filtering is unnecessary. + * + * After an output has been registered, subsequent block retrievals from the chain source must not + * exclude any transactions matching the new criteria nor any in-block descendants of such + * transactions. + * + * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` + * should not block on I/O. Implementations should instead queue the newly monitored data to be + * processed later. Then, in order to block until the data has been processed, any [`Watch`] + * invocation that has called the `Filter` must return [`InProgress`]. + * + * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress + * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki + * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki + */ +typedef struct LDKFilter { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as + * a spending condition. + * + * This may be used, for example, to monitor for when a funding transaction confirms. + * + * The `script_pubkey` is provided for informational purposes and may be useful for block + * sources which only support filtering on scripts. + */ + void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); + /** + * Registers interest in spends of a transaction output. + * + * Note that this method might be called during processing of a new block. You therefore need + * to ensure that also dependent output spents within an already connected block are correctly + * handled, e.g., by re-scanning the block in question whenever new outputs have been + * registered mid-processing. + * + * This may be used, for example, to monitor for when a funding output is spent (by any + * transaction). + */ + void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKFilter; + +/** + * An enum which can either contain a crate::lightning::chain::Filter or not + */ +typedef enum LDKCOption_FilterZ_Tag { + /** + * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter + */ + LDKCOption_FilterZ_Some, + /** + * When we're in this state, this COption_FilterZ contains nothing + */ + LDKCOption_FilterZ_None, + /** + * Must be last for serialization purposes + */ + LDKCOption_FilterZ_Sentinel, +} LDKCOption_FilterZ_Tag; + +typedef struct LDKCOption_FilterZ { + LDKCOption_FilterZ_Tag tag; + union { + struct { + struct LDKFilter some; + }; + }; +} LDKCOption_FilterZ; + +/** + * A dynamically-allocated array of crate::lightning::util::sweep::TrackedSpendableOutputs of arbitrary size. + * This corresponds to std::vector in C++ + */ +typedef struct LDKCVec_TrackedSpendableOutputZ { + /** + * The elements in the array. + * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + */ + struct LDKTrackedSpendableOutput *data; + /** + * The number of elements pointed to by `data`. + */ + uintptr_t datalen; +} LDKCVec_TrackedSpendableOutputZ; + +/** + * A helper trait that describes an on-chain wallet capable of returning a (change) destination + * script. + */ +typedef struct LDKChangeDestinationSource { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns a script pubkey which can be used as a change destination for + * [`OutputSpender::spend_spendable_outputs`]. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds controlled to the same user. + */ + struct LDKCResult_CVec_u8ZNoneZ (*get_change_destination_script)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKChangeDestinationSource; + +/** + * Provides an interface that allows storage and retrieval of persisted values that are associated + * with given keys. + * + * In order to avoid collisions the key space is segmented based on the given `primary_namespace`s + * and `secondary_namespace`s. Implementations of this trait are free to handle them in different + * ways, as long as per-namespace key uniqueness is asserted. + * + * Keys and namespaces are required to be valid ASCII strings in the range of + * [`KVSTORE_NAMESPACE_KEY_ALPHABET`] and no longer than [`KVSTORE_NAMESPACE_KEY_MAX_LEN`]. Empty + * primary namespaces and secondary namespaces (`\"\"`) are assumed to be a valid, however, if + * `primary_namespace` is empty, `secondary_namespace` is required to be empty, too. This means + * that concerns should always be separated by primary namespace first, before secondary + * namespaces are used. While the number of primary namespaces will be relatively small and is + * determined at compile time, there may be many secondary namespaces per primary namespace. Note + * that per-namespace uniqueness needs to also hold for keys *and* namespaces in any given + * namespace, i.e., conflicts between keys and equally named + * primary namespaces/secondary namespaces must be avoided. + * + * **Note:** Users migrating custom persistence backends from the pre-v0.0.117 `KVStorePersister` + * interface can use a concatenation of `[{primary_namespace}/[{secondary_namespace}/]]{key}` to + * recover a `key` compatible with the data model previously assumed by `KVStorePersister::persist`. + */ +typedef struct LDKKVStore { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the data stored for the given `primary_namespace`, `secondary_namespace`, and + * `key`. + * + * Returns an [`ErrorKind::NotFound`] if the given `key` could not be found in the given + * `primary_namespace` and `secondary_namespace`. + * + * [`ErrorKind::NotFound`]: io::ErrorKind::NotFound + */ + struct LDKCResult_CVec_u8ZIOErrorZ (*read)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key); + /** + * Persists the given data under the given `key`. + * + * Will create the given `primary_namespace` and `secondary_namespace` if not already present + * in the store. + */ + struct LDKCResult_NoneIOErrorZ (*write)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key, struct LDKu8slice buf); + /** + * Removes any data that had previously been persisted under the given `key`. + * + * If the `lazy` flag is set to `true`, the backend implementation might choose to lazily + * remove the given `key` at some point in time after the method returns, e.g., as part of an + * eventual batch deletion of multiple keys. As a consequence, subsequent calls to + * [`KVStore::list`] might include the removed key until the changes are actually persisted. + * + * Note that while setting the `lazy` flag reduces the I/O burden of multiple subsequent + * `remove` calls, it also influences the atomicity guarantees as lazy `remove`s could + * potentially get lost on crash after the method returns. Therefore, this flag should only be + * set for `remove` operations that can be safely replayed at a later time. + * + * Returns successfully if no data will be stored for the given `primary_namespace`, + * `secondary_namespace`, and `key`, independently of whether it was present before its + * invokation or not. + */ + struct LDKCResult_NoneIOErrorZ (*remove)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key, bool lazy); + /** + * Returns a list of keys that are stored under the given `secondary_namespace` in + * `primary_namespace`. + * + * Returns the keys in arbitrary order, so users requiring a particular order need to sort the + * returned keys. Returns an empty list if `primary_namespace` or `secondary_namespace` is unknown. + */ + struct LDKCResult_CVec_StrZIOErrorZ (*list)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKKVStore; + +/** + * A trait that describes a wallet capable of creating a spending [`Transaction`] from a set of + * [`SpendableOutputDescriptor`]s. + */ +typedef struct LDKOutputSpender { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an + * output to the given change destination (if sufficient change value remains). The + * transaction will have a feerate, at least, of the given value. + * + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. + * + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. + */ + struct LDKCResult_TransactionNoneZ (*spend_spendable_outputs)(const void *this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKOutputSpender; + + + +/** + * A utility that keeps track of [`SpendableOutputDescriptor`]s, persists them in a given + * [`KVStore`] and regularly retries sweeping them based on a callback given to the constructor + * methods. + * + * Users should call [`Self::track_spendable_outputs`] for any [`SpendableOutputDescriptor`]s received via [`Event::SpendableOutputs`]. + * + * This needs to be notified of chain state changes either via its [`Listen`] or [`Confirm`] + * implementation and hence has to be connected with the utilized chain data sources. + * + * If chain data is provided via the [`Confirm`] interface or via filtered blocks, users are + * required to give their chain data sources (i.e., [`Filter`] implementation) to the respective + * constructor. + * + * [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs + */ +typedef struct MUST_USE_STRUCT LDKOutputSweeper { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeOutputSweeper *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKOutputSweeper; + +/** + * The contents of CResult_OutputSweeperDecodeErrorZ + */ +typedef union LDKCResult_OutputSweeperDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKBlindedHop *result; + struct LDKOutputSweeper *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_BlindedHopDecodeErrorZPtr; +} LDKCResult_OutputSweeperDecodeErrorZPtr; /** - * A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_OutputSweeperDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::util::sweep::OutputSweeper on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_BlindedHopDecodeErrorZ { +typedef struct LDKCResult_OutputSweeperDecodeErrorZ { /** - * The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either + * The contents of this CResult_OutputSweeperDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_BlindedHopDecodeErrorZPtr contents; + union LDKCResult_OutputSweeperDecodeErrorZPtr contents; /** - * Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + * Whether this CResult_OutputSweeperDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_BlindedHopDecodeErrorZ; +} LDKCResult_OutputSweeperDecodeErrorZ; /** - * The contents of CResult_InvoiceErrorDecodeErrorZ + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef union LDKCResult_InvoiceErrorDecodeErrorZPtr { +typedef struct LDKC2Tuple_BestBlockOutputSweeperZ { + /** + * The element at position 0 + */ + struct LDKBestBlock a; + /** + * The element at position 1 + */ + struct LDKOutputSweeper b; +} LDKC2Tuple_BestBlockOutputSweeperZ; + +/** + * The contents of CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ + */ +typedef union LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { /** * A pointer to the contents in the success state. * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKInvoiceError *result; + struct LDKC2Tuple_BestBlockOutputSweeperZ *result; /** * A pointer to the contents in the error state. * Reading from this pointer when `result_ok` is set is undefined. */ struct LDKDecodeError *err; -} LDKCResult_InvoiceErrorDecodeErrorZPtr; +} LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr; /** - * A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, - * containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. + * A CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents the result of a fallible operation, + * containing a crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ on success and a crate::lightning::ln::msgs::DecodeError on failure. * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCResult_InvoiceErrorDecodeErrorZ { +typedef struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { /** - * The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either + * The contents of this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ, accessible via either * `err` or `result` depending on the state of `result_ok`. */ - union LDKCResult_InvoiceErrorDecodeErrorZPtr contents; + union LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr contents; /** - * Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. + * Whether this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents a success state. */ bool result_ok; -} LDKCResult_InvoiceErrorDecodeErrorZ; +} LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ; @@ -18574,7 +23202,7 @@ typedef struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ { * punish and claim all the channel funds if the state broadcasted was previously revoked. * * [See the BOLT specs] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) + * * for more information on key derivation details. */ typedef struct MUST_USE_STRUCT LDKDelayedPaymentKey { @@ -18692,7 +23320,7 @@ typedef struct LDKCResult_HtlcBasepointDecodeErrorZ { * Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script. * * [See the BOLT specs] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) + * * for more information on key derivation details. */ typedef struct MUST_USE_STRUCT LDKHtlcKey { @@ -18807,7 +23435,7 @@ typedef struct LDKCResult_RevocationBasepointDecodeErrorZ { * per_commitment_point which is used in both commitment and HTLC transactions. * * See [the BOLT spec for derivation details] - * (https://github.com/lightning/bolts/blob/master/03-transactions.md#revocationpubkey-derivation) + * */ typedef struct MUST_USE_STRUCT LDKRevocationKey { /** @@ -18860,113 +23488,7 @@ typedef struct LDKCResult_RevocationKeyDecodeErrorZ { /** - * A transaction output watched by a [`ChannelMonitor`] for spends on-chain. - * - * Used to convey to a [`Filter`] such an output with a given spending condition. Any transaction - * spending the output must be given to [`ChannelMonitor::block_connected`] either directly or via - * [`Confirm::transactions_confirmed`]. - * - * If `block_hash` is `Some`, this indicates the output was created in the corresponding block and - * may have been spent there. See [`Filter::register_output`] for details. - * - * [`ChannelMonitor`]: channelmonitor::ChannelMonitor - * [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected - */ -typedef struct MUST_USE_STRUCT LDKWatchedOutput { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeWatchedOutput *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKWatchedOutput; - -/** - * The `Filter` trait defines behavior for indicating chain activity of interest pertaining to - * channels. - * - * This is useful in order to have a [`Watch`] implementation convey to a chain source which - * transactions to be notified of. Notification may take the form of pre-filtering blocks or, in - * the case of [BIP 157]/[BIP 158], only fetching a block if the compact filter matches. If - * receiving full blocks from a chain source, any further filtering is unnecessary. - * - * After an output has been registered, subsequent block retrievals from the chain source must not - * exclude any transactions matching the new criteria nor any in-block descendants of such - * transactions. - * - * Note that use as part of a [`Watch`] implementation involves reentrancy. Therefore, the `Filter` - * should not block on I/O. Implementations should instead queue the newly monitored data to be - * processed later. Then, in order to block until the data has been processed, any [`Watch`] - * invocation that has called the `Filter` must return [`InProgress`]. - * - * [`InProgress`]: ChannelMonitorUpdateStatus::InProgress - * [BIP 157]: https://github.com/bitcoin/bips/blob/master/bip-0157.mediawiki - * [BIP 158]: https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki - */ -typedef struct LDKFilter { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as - * a spending condition. - */ - void (*register_tx)(const void *this_arg, const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); - /** - * Registers interest in spends of a transaction output. - * - * Note that this method might be called during processing of a new block. You therefore need - * to ensure that also dependent output spents within an already connected block are correctly - * handled, e.g., by re-scanning the block in question whenever new outputs have been - * registered mid-processing. - */ - void (*register_output)(const void *this_arg, struct LDKWatchedOutput output); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKFilter; - -/** - * An enum which can either contain a crate::lightning::chain::Filter or not - */ -typedef enum LDKCOption_FilterZ_Tag { - /** - * When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter - */ - LDKCOption_FilterZ_Some, - /** - * When we're in this state, this COption_FilterZ contains nothing - */ - LDKCOption_FilterZ_None, - /** - * Must be last for serialization purposes - */ - LDKCOption_FilterZ_Sentinel, -} LDKCOption_FilterZ_Tag; - -typedef struct LDKCOption_FilterZ { - LDKCOption_FilterZ_Tag tag; - union { - struct { - struct LDKFilter some; - }; - }; -} LDKCOption_FilterZ; - - - -/** - * A read-only reference to a current ChannelMonitor. + * A read-only reference to a current ChannelMonitor. * * Note that this holds a mutex in [`ChainMonitor`] and may block other events until it is * released. @@ -19019,168 +23541,200 @@ typedef struct LDKCResult_LockedChannelMonitorNoneZ { } LDKCResult_LockedChannelMonitorNoneZ; /** - * A dynamically-allocated array of crate::lightning::chain::transaction::OutPoints of arbitrary size. + * A tuple of 2 elements. See the individual fields for the types contained. + */ +typedef struct LDKC2Tuple_OutPointChannelIdZ { + /** + * The element at position 0 + */ + struct LDKOutPoint a; + /** + * The element at position 1 + */ + struct LDKChannelId b; +} LDKC2Tuple_OutPointChannelIdZ; + +/** + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointChannelIdZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_OutPointZ { +typedef struct LDKCVec_C2Tuple_OutPointChannelIdZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKOutPoint *data; + struct LDKC2Tuple_OutPointChannelIdZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_OutPointZ; - - +} LDKCVec_C2Tuple_OutPointChannelIdZZ; /** - * An opaque identifier describing a specific [`Persist`] method call. + * A tuple of 2 elements. See the individual fields for the types contained. */ -typedef struct MUST_USE_STRUCT LDKMonitorUpdateId { +typedef struct LDKC2Tuple_OutPointCVec_u64ZZ { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * The element at position 0 */ - LDKnativeMonitorUpdateId *inner; + struct LDKOutPoint a; /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * The element at position 1 */ - bool is_owned; -} LDKMonitorUpdateId; + struct LDKCVec_u64Z b; +} LDKC2Tuple_OutPointCVec_u64ZZ; /** - * A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. + * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZs of arbitrary size. * This corresponds to std::vector in C++ */ -typedef struct LDKCVec_MonitorUpdateIdZ { +typedef struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ { /** * The elements in the array. * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). */ - struct LDKMonitorUpdateId *data; + struct LDKC2Tuple_OutPointCVec_u64ZZ *data; /** * The number of elements pointed to by `data`. */ uintptr_t datalen; -} LDKCVec_MonitorUpdateIdZ; +} LDKCVec_C2Tuple_OutPointCVec_u64ZZZ; /** - * A tuple of 2 elements. See the individual fields for the types contained. + * The contents of CResult_BlindedMessagePathDecodeErrorZ */ -typedef struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ { +typedef union LDKCResult_BlindedMessagePathDecodeErrorZPtr { /** - * The element at position 0 + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKOutPoint a; + struct LDKBlindedMessagePath *result; /** - * The element at position 1 + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - struct LDKCVec_MonitorUpdateIdZ b; -} LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ; + struct LDKDecodeError *err; +} LDKCResult_BlindedMessagePathDecodeErrorZPtr; /** - * A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. - * This corresponds to std::vector in C++ + * A CResult_BlindedMessagePathDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. */ -typedef struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +typedef struct LDKCResult_BlindedMessagePathDecodeErrorZ { /** - * The elements in the array. - * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + * The contents of this CResult_BlindedMessagePathDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *data; + union LDKCResult_BlindedMessagePathDecodeErrorZPtr contents; /** - * The number of elements pointed to by `data`. + * Whether this CResult_BlindedMessagePathDecodeErrorZ represents a success state. */ - uintptr_t datalen; -} LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; + bool result_ok; +} LDKCResult_BlindedMessagePathDecodeErrorZ; /** - * Provides an interface that allows storage and retrieval of persisted values that are associated - * with given keys. - * - * In order to avoid collisions the key space is segmented based on the given `primary_namespace`s - * and `secondary_namespace`s. Implementations of this trait are free to handle them in different - * ways, as long as per-namespace key uniqueness is asserted. - * - * Keys and namespaces are required to be valid ASCII strings in the range of - * [`KVSTORE_NAMESPACE_KEY_ALPHABET`] and no longer than [`KVSTORE_NAMESPACE_KEY_MAX_LEN`]. Empty - * primary namespaces and secondary namespaces (`\"\"`) are assumed to be a valid, however, if - * `primary_namespace` is empty, `secondary_namespace` is required to be empty, too. This means - * that concerns should always be separated by primary namespace first, before secondary - * namespaces are used. While the number of primary namespaces will be relatively small and is - * determined at compile time, there may be many secondary namespaces per primary namespace. Note - * that per-namespace uniqueness needs to also hold for keys *and* namespaces in any given - * namespace, i.e., conflicts between keys and equally named - * primary namespaces/secondary namespaces must be avoided. - * - * **Note:** Users migrating custom persistence backends from the pre-v0.0.117 `KVStorePersister` - * interface can use a concatenation of `[{primary_namespace}/[{secondary_namespace}/]]{key}` to - * recover a `key` compatible with the data model previously assumed by `KVStorePersister::persist`. + * The contents of CResult_BlindedMessagePathNoneZ */ -typedef struct LDKKVStore { +typedef union LDKCResult_BlindedMessagePathNoneZPtr { /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - void *this_arg; + struct LDKBlindedMessagePath *result; /** - * Returns the data stored for the given `primary_namespace`, `secondary_namespace`, and - * `key`. - * - * Returns an [`ErrorKind::NotFound`] if the given `key` could not be found in the given - * `primary_namespace` and `secondary_namespace`. - * - * [`ErrorKind::NotFound`]: io::ErrorKind::NotFound + * Note that this value is always NULL, as there are no contents in the Err variant */ - struct LDKCResult_CVec_u8ZIOErrorZ (*read)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key); + void *err; +} LDKCResult_BlindedMessagePathNoneZPtr; + +/** + * A CResult_BlindedMessagePathNoneZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a () on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_BlindedMessagePathNoneZ { /** - * Persists the given data under the given `key`. - * - * Will create the given `primary_namespace` and `secondary_namespace` if not already present - * in the store. + * The contents of this CResult_BlindedMessagePathNoneZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. */ - struct LDKCResult_NoneIOErrorZ (*write)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key, struct LDKu8slice buf); + union LDKCResult_BlindedMessagePathNoneZPtr contents; /** - * Removes any data that had previously been persisted under the given `key`. - * - * If the `lazy` flag is set to `true`, the backend implementation might choose to lazily - * remove the given `key` at some point in time after the method returns, e.g., as part of an - * eventual batch deletion of multiple keys. As a consequence, subsequent calls to - * [`KVStore::list`] might include the removed key until the changes are actually persisted. - * - * Note that while setting the `lazy` flag reduces the I/O burden of multiple subsequent - * `remove` calls, it also influences the atomicity guarantees as lazy `remove`s could - * potentially get lost on crash after the method returns. Therefore, this flag should only be - * set for `remove` operations that can be safely replayed at a later time. - * - * Returns successfully if no data will be stored for the given `primary_namespace`, - * `secondary_namespace`, and `key`, independently of whether it was present before its - * invokation or not. + * Whether this CResult_BlindedMessagePathNoneZ represents a success state. */ - struct LDKCResult_NoneIOErrorZ (*remove)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace, struct LDKStr key, bool lazy); + bool result_ok; +} LDKCResult_BlindedMessagePathNoneZ; + +/** + * The contents of CResult_MessageContextDecodeErrorZ + */ +typedef union LDKCResult_MessageContextDecodeErrorZPtr { /** - * Returns a list of keys that are stored under the given `secondary_namespace` in - * `primary_namespace`. - * - * Returns the keys in arbitrary order, so users requiring a particular order need to sort the - * returned keys. Returns an empty list if `primary_namespace` or `secondary_namespace` is unknown. + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. */ - struct LDKCResult_CVec_StrZIOErrorZ (*list)(const void *this_arg, struct LDKStr primary_namespace, struct LDKStr secondary_namespace); + struct LDKMessageContext *result; /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. */ - void (*free)(void *this_arg); -} LDKKVStore; + struct LDKDecodeError *err; +} LDKCResult_MessageContextDecodeErrorZPtr; + +/** + * A CResult_MessageContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::MessageContext on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_MessageContextDecodeErrorZ { + /** + * The contents of this CResult_MessageContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_MessageContextDecodeErrorZPtr contents; + /** + * Whether this CResult_MessageContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_MessageContextDecodeErrorZ; + +/** + * The contents of CResult_OffersContextDecodeErrorZ + */ +typedef union LDKCResult_OffersContextDecodeErrorZPtr { + /** + * A pointer to the contents in the success state. + * Reading from this pointer when `result_ok` is not set is undefined. + */ + struct LDKOffersContext *result; + /** + * A pointer to the contents in the error state. + * Reading from this pointer when `result_ok` is set is undefined. + */ + struct LDKDecodeError *err; +} LDKCResult_OffersContextDecodeErrorZPtr; + +/** + * A CResult_OffersContextDecodeErrorZ represents the result of a fallible operation, + * containing a crate::lightning::blinded_path::message::OffersContext on success and a crate::lightning::ln::msgs::DecodeError on failure. + * `result_ok` indicates the overall state, and the contents are provided via `contents`. + */ +typedef struct LDKCResult_OffersContextDecodeErrorZ { + /** + * The contents of this CResult_OffersContextDecodeErrorZ, accessible via either + * `err` or `result` depending on the state of `result_ok`. + */ + union LDKCResult_OffersContextDecodeErrorZPtr contents; + /** + * Whether this CResult_OffersContextDecodeErrorZ represents a success state. + */ + bool result_ok; +} LDKCResult_OffersContextDecodeErrorZ; /** * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ typedef struct LDKPersister { /** @@ -19190,6 +23744,8 @@ typedef struct LDKPersister { void *this_arg; /** * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ struct LDKCResult_NoneIOErrorZ (*persist_manager)(const void *this_arg, const struct LDKChannelManager *NONNULL_PTR channel_manager); /** @@ -19342,7 +23898,7 @@ typedef struct MUST_USE_STRUCT LDKMonitorUpdatingPersister { * All calls should generally spawn a background task and immediately return * [`ChannelMonitorUpdateStatus::InProgress`]. Once the update completes, * [`ChainMonitor::channel_monitor_updated`] should be called with the corresponding - * [`MonitorUpdateId`]. + * [`ChannelMonitor::get_latest_update_id`] or [`ChannelMonitorUpdate::update_id`]. * * Note that unlike the direct [`chain::Watch`] interface, * [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. @@ -19380,8 +23936,9 @@ typedef struct LDKPersist { * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint * and the stored channel data). Note that you **must** persist every new monitor to disk. * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. @@ -19389,7 +23946,7 @@ typedef struct LDKPersist { * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`Writeable::write`]: crate::util::ser::Writeable::write */ - enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + enum LDKChannelMonitorUpdateStatus (*persist_new_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given * update. @@ -19407,7 +23964,9 @@ typedef struct LDKPersist { * If an implementer chooses to persist the updates only, they need to make * sure that all the updates are applied to the `ChannelMonitors` *before* * the set of channel monitors is given to the `ChannelManager` - * deserialization routine. See [`ChannelMonitor::update_monitor`] for + * deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + * implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + * See [`ChannelMonitor::update_monitor`] for * applying a monitor update to a monitor. If full `ChannelMonitors` are * persisted, then there is no need to persist individual updates. * @@ -19416,8 +23975,10 @@ typedef struct LDKPersist { * them in batches. The size of each monitor grows `O(number of state updates)` * whereas updates are small and `O(1)`. * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + * links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -19425,9 +23986,16 @@ typedef struct LDKPersist { * * [`Writeable::write`]: crate::util::ser::Writeable::write * - * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor); + /** + * Prevents the channel monitor from being loaded on startup. + * + * Archiving the data in a backup location (rather than deleting it fully) is useful for + * hedging against data loss in case of unexpected failure. */ - enum LDKChannelMonitorUpdateStatus (*update_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_id, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + void (*archive_persisted_channel)(const void *this_arg, struct LDKOutPoint channel_funding_outpoint); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -19435,26 +24003,196 @@ typedef struct LDKPersist { void (*free)(void *this_arg); } LDKPersist; +/** + * The `Listen` trait is used to notify when blocks have been connected or disconnected from the + * chain. + * + * Useful when needing to replay chain data upon startup or as new chain events occur. Clients + * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. + * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers + * when needed. + * + * By using [`Listen::filtered_block_connected`] this interface supports clients fetching the + * entire header chain and only blocks with matching transaction data using BIP 157 filters or + * other similar filtering. + */ +typedef struct LDKListen { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Notifies the listener that a block was added at the given height, with the transaction data + * possibly filtered. + */ + void (*filtered_block_connected)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Notifies the listener that a block was added at the given height. + */ + void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); + /** + * Notifies the listener that a block was removed at the given height. + */ + void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKListen; +/** + * The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on + * chain or unconfirmed during a chain reorganization. + * + * Clients sourcing chain data using a transaction-oriented API should prefer this interface over + * [`Listen`]. For instance, an Electrum-based transaction sync implementation may implement + * [`Filter`] to subscribe to relevant transactions and unspent outputs it should monitor for + * on-chain activity. Then, it needs to notify LDK via this interface upon observing any changes + * with reference to the confirmation status of the monitored objects. + * + * # Use + * The intended use is as follows: + * - Call [`transactions_confirmed`] to notify LDK whenever any of the registered transactions or + * outputs are, respectively, confirmed or spent on chain. + * - Call [`transaction_unconfirmed`] to notify LDK whenever any transaction returned by + * [`get_relevant_txids`] is no longer confirmed in the block with the given block hash. + * - Call [`best_block_updated`] to notify LDK whenever a new chain tip becomes available. + * + * # Order + * + * Clients must call these methods in chain order. Specifically: + * - Transactions which are confirmed in a particular block must be given before transactions + * confirmed in a later block. + * - Dependent transactions within the same block must be given in topological order, possibly in + * separate calls. + * - All unconfirmed transactions must be given after the original confirmations and before *any* + * reconfirmations, i.e., [`transactions_confirmed`] and [`transaction_unconfirmed`] calls should + * never be interleaved, but always conduced *en bloc*. + * - Any reconfirmed transactions need to be explicitly unconfirmed before they are reconfirmed + * in regard to the new block. + * + * See individual method documentation for further details. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + * [`best_block_updated`]: Self::best_block_updated + * [`get_relevant_txids`]: Self::get_relevant_txids + */ +typedef struct LDKConfirm { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Notifies LDK of transactions confirmed in a block with a given header and height. + * + * Must be called for any transactions registered by [`Filter::register_tx`] or any + * transactions spending an output registered by [`Filter::register_output`]. Such transactions + * appearing in the same block do not need to be included in the same call; instead, multiple + * calls with additional transactions may be made so long as they are made in [chain order]. + * + * May be called before or after [`best_block_updated`] for the corresponding block. However, + * in the event of a chain reorganization, it must not be called with a `header` that is no + * longer in the chain as of the last call to [`best_block_updated`]. + * + * [chain order]: Confirm#order + * [`best_block_updated`]: Self::best_block_updated + */ + void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); + /** + * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. + * + * Must be called for any transaction returned by [`get_relevant_txids`] if it has been + * reorganized out of the best chain or if it is no longer confirmed in the block with the + * given block hash. Once called, the given transaction will not be returned + * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. + * + * [`get_relevant_txids`]: Self::get_relevant_txids + * [`transactions_confirmed`]: Self::transactions_confirmed + */ + void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); + /** + * Notifies LDK of an update to the best header connected at the given height. + * + * Must be called whenever a new chain tip becomes available. May be skipped for intermediary + * blocks. + */ + void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + /** + * Returns transactions that must be monitored for reorganization out of the chain along + * with the height and the hash of the block as part of which it had been previously confirmed. + * + * Note that the returned `Option` might be `None` for channels created with LDK + * 0.0.112 and prior, in which case you need to manually track previous confirmations. + * + * Will include any transactions passed to [`transactions_confirmed`] that have insufficient + * confirmations to be safe from a chain reorganization. Will not include any transactions + * passed to [`transaction_unconfirmed`], unless later reconfirmed. + * + * Must be called to determine the subset of transactions that must be monitored for + * reorganization. Will be idempotent between calls but may change as a result of calls to the + * other interface methods. Thus, this is useful to determine which transactions must be + * given to [`transaction_unconfirmed`]. + * + * If any of the returned transactions are confirmed in a block other than the one with the + * given hash at the given height, they need to be unconfirmed and reconfirmed via + * [`transaction_unconfirmed`] and [`transactions_confirmed`], respectively. + * + * [`transactions_confirmed`]: Self::transactions_confirmed + * [`transaction_unconfirmed`]: Self::transaction_unconfirmed + */ + struct LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ (*get_relevant_txids)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKConfirm; /** - * A string that displays only printable characters, replacing control characters with - * [`core::char::REPLACEMENT_CHARACTER`]. + * A `enum` signalling to the [`OutputSweeper`] that it should delay spending an output until a + * future block height is reached. */ -typedef struct MUST_USE_STRUCT LDKPrintableString { +typedef enum LDKSpendingDelay_Tag { /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. + * A relative delay indicating we shouldn't spend the output before `cur_height + num_blocks` + * is reached. */ - LDKnativePrintableString *inner; + LDKSpendingDelay_Relative, /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. + * An absolute delay indicating we shouldn't spend the output before `height` is reached. */ - bool is_owned; -} LDKPrintableString; + LDKSpendingDelay_Absolute, + /** + * Must be last for serialization purposes + */ + LDKSpendingDelay_Sentinel, +} LDKSpendingDelay_Tag; + +typedef struct LDKSpendingDelay_LDKRelative_Body { + /** + * The number of blocks until we'll generate and broadcast the spending transaction. + */ + uint32_t num_blocks; +} LDKSpendingDelay_LDKRelative_Body; + +typedef struct LDKSpendingDelay_LDKAbsolute_Body { + /** + * The height at which we'll generate and broadcast the spending transaction. + */ + uint32_t height; +} LDKSpendingDelay_LDKAbsolute_Body; + +typedef struct MUST_USE_STRUCT LDKSpendingDelay { + LDKSpendingDelay_Tag tag; + union { + LDKSpendingDelay_LDKRelative_Body relative; + LDKSpendingDelay_LDKAbsolute_Body absolute; + }; +} LDKSpendingDelay; /** * A callback which is called when a [`Future`] completes. @@ -19509,7 +24247,7 @@ typedef struct MUST_USE_STRUCT LDKSleeper { /** * Configuration we set when applicable. * - * Default::default() provides sane defaults. + * `Default::default()` provides sane defaults. */ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { /** @@ -19533,7 +24271,7 @@ typedef struct MUST_USE_STRUCT LDKChannelHandshakeConfig { * * These limits are only applied to our counterparty's limits, not our own. * - * Use 0/`::max_value()` as appropriate to skip checking. + * Use `0` or `::max_value()` as appropriate to skip checking. * * Provides sane defaults for most configurations. * @@ -19581,8 +24319,8 @@ typedef struct MUST_USE_STRUCT LDKChannelConfigUpdate { /** * Top-level config which holds ChannelHandshakeLimits and ChannelConfig. * - * Default::default() provides sane defaults for most configurations - * (but currently with 0 relay fees!) + * `Default::default()` provides sane defaults for most configurations + * (but currently with zero relay fees!) */ typedef struct MUST_USE_STRUCT LDKUserConfig { /** @@ -19602,251 +24340,86 @@ typedef struct MUST_USE_STRUCT LDKUserConfig { /** - * The best known block as identified by its hash and height. + * An implementation of [`chain::Watch`] for monitoring channels. + * + * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by + * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally + * or used independently to monitor channels remotely. See the [module-level documentation] for + * details. + * + * Note that `ChainMonitor` should regularly trigger rebroadcasts/fee bumps of pending claims from + * a force-closed channel. This is crucial in preventing certain classes of pinning attacks, + * detecting substantial mempool feerate changes between blocks, and ensuring reliability if + * broadcasting fails. We recommend invoking this every 30 seconds, or lower if running in an + * environment with spotty connections, like on mobile. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [module-level documentation]: crate::chain::chainmonitor + * [`rebroadcast_pending_claims`]: Self::rebroadcast_pending_claims */ -typedef struct MUST_USE_STRUCT LDKBestBlock { +typedef struct MUST_USE_STRUCT LDKChainMonitor { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeBestBlock *inner; + LDKnativeChainMonitor *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKBestBlock; +} LDKChainMonitor; /** - * The `Listen` trait is used to notify when blocks have been connected or disconnected from the - * chain. - * - * Useful when needing to replay chain data upon startup or as new chain events occur. Clients - * sourcing chain data using a block-oriented API should prefer this interface over [`Confirm`]. - * Such clients fetch the entire header chain whereas clients using [`Confirm`] only fetch headers - * when needed. + * A trait implemented for objects handling events from [`EventsProvider`]. * - * By using [`Listen::filtered_block_connected`] this interface supports clients fetching the - * entire header chain and only blocks with matching transaction data using BIP 157 filters or - * other similar filtering. + * An async variation also exists for implementations of [`EventsProvider`] that support async + * event handling. The async event handler should satisfy the generic bounds: `F: + * core::future::Future>, H: Fn(Event) -> F`. */ -typedef struct LDKListen { +typedef struct LDKEventHandler { /** * An opaque pointer which is passed to your function implementations as an argument. * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; /** - * Notifies the listener that a block was added at the given height, with the transaction data - * possibly filtered. - */ - void (*filtered_block_connected)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - /** - * Notifies the listener that a block was added at the given height. - */ - void (*block_connected)(const void *this_arg, struct LDKu8slice block, uint32_t height); - /** - * Notifies the listener that a block was removed at the given height. + * Handles the given [`Event`]. + * + * See [`EventsProvider`] for details that must be considered when implementing this method. */ - void (*block_disconnected)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); + struct LDKCResult_NoneReplayEventZ (*handle_event)(const void *this_arg, struct LDKEvent event); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. */ void (*free)(void *this_arg); -} LDKListen; +} LDKEventHandler; /** - * The `Confirm` trait is used to notify LDK when relevant transactions have been confirmed on - * chain or unconfirmed during a chain reorganization. + * A trait indicating an object may generate events. * - * Clients sourcing chain data using a transaction-oriented API should prefer this interface over - * [`Listen`]. For instance, an Electrum-based transaction sync implementation may implement - * [`Filter`] to subscribe to relevant transactions and unspent outputs it should monitor for - * on-chain activity. Then, it needs to notify LDK via this interface upon observing any changes - * with reference to the confirmation status of the monitored objects. + * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. * - * # Use - * The intended use is as follows: - * - Call [`transactions_confirmed`] to notify LDK whenever any of the registered transactions or - * outputs are, respectively, confirmed or spent on chain. - * - Call [`transaction_unconfirmed`] to notify LDK whenever any transaction returned by - * [`get_relevant_txids`] is no longer confirmed in the block with the given block hash. - * - Call [`best_block_updated`] to notify LDK whenever a new chain tip becomes available. + * Implementations of this trait may also feature an async version of event handling, as shown with + * [`ChannelManager::process_pending_events_async`] and + * [`ChainMonitor::process_pending_events_async`]. * - * # Order - * - * Clients must call these methods in chain order. Specifically: - * - Transactions which are confirmed in a particular block must be given before transactions - * confirmed in a later block. - * - Dependent transactions within the same block must be given in topological order, possibly in - * separate calls. - * - All unconfirmed transactions must be given after the original confirmations and before *any* - * reconfirmations, i.e., [`transactions_confirmed`] and [`transaction_unconfirmed`] calls should - * never be interleaved, but always conduced *en bloc*. - * - Any reconfirmed transactions need to be explicitly unconfirmed before they are reconfirmed - * in regard to the new block. - * - * See individual method documentation for further details. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - * [`best_block_updated`]: Self::best_block_updated - * [`get_relevant_txids`]: Self::get_relevant_txids - */ -typedef struct LDKConfirm { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Notifies LDK of transactions confirmed in a block with a given header and height. - * - * Must be called for any transactions registered by [`Filter::register_tx`] or any - * transactions spending an output registered by [`Filter::register_output`]. Such transactions - * appearing in the same block do not need to be included in the same call; instead, multiple - * calls with additional transactions may be made so long as they are made in [chain order]. - * - * May be called before or after [`best_block_updated`] for the corresponding block. However, - * in the event of a chain reorganization, it must not be called with a `header` that is no - * longer in the chain as of the last call to [`best_block_updated`]. - * - * [chain order]: Confirm#order - * [`best_block_updated`]: Self::best_block_updated - */ - void (*transactions_confirmed)(const void *this_arg, const uint8_t (*header)[80], struct LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height); - /** - * Notifies LDK of a transaction that is no longer confirmed as result of a chain reorganization. - * - * Must be called for any transaction returned by [`get_relevant_txids`] if it has been - * reorganized out of the best chain or if it is no longer confirmed in the block with the - * given block hash. Once called, the given transaction will not be returned - * by [`get_relevant_txids`], unless it has been reconfirmed via [`transactions_confirmed`]. - * - * [`get_relevant_txids`]: Self::get_relevant_txids - * [`transactions_confirmed`]: Self::transactions_confirmed - */ - void (*transaction_unconfirmed)(const void *this_arg, const uint8_t (*txid)[32]); - /** - * Notifies LDK of an update to the best header connected at the given height. - * - * Must be called whenever a new chain tip becomes available. May be skipped for intermediary - * blocks. - */ - void (*best_block_updated)(const void *this_arg, const uint8_t (*header)[80], uint32_t height); - /** - * Returns transactions that must be monitored for reorganization out of the chain along - * with the height and the hash of the block as part of which it had been previously confirmed. - * - * Note that the returned `Option` might be `None` for channels created with LDK - * 0.0.112 and prior, in which case you need to manually track previous confirmations. - * - * Will include any transactions passed to [`transactions_confirmed`] that have insufficient - * confirmations to be safe from a chain reorganization. Will not include any transactions - * passed to [`transaction_unconfirmed`], unless later reconfirmed. - * - * Must be called to determine the subset of transactions that must be monitored for - * reorganization. Will be idempotent between calls but may change as a result of calls to the - * other interface methods. Thus, this is useful to determine which transactions must be - * given to [`transaction_unconfirmed`]. - * - * If any of the returned transactions are confirmed in a block other than the one with the - * given hash at the given height, they need to be unconfirmed and reconfirmed via - * [`transaction_unconfirmed`] and [`transactions_confirmed`], respectively. - * - * [`transactions_confirmed`]: Self::transactions_confirmed - * [`transaction_unconfirmed`]: Self::transaction_unconfirmed - */ - struct LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ (*get_relevant_txids)(const void *this_arg); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKConfirm; - - - -/** - * An implementation of [`chain::Watch`] for monitoring channels. - * - * Connected and disconnected blocks must be provided to `ChainMonitor` as documented by - * [`chain::Watch`]. May be used in conjunction with [`ChannelManager`] to monitor channels locally - * or used independently to monitor channels remotely. See the [module-level documentation] for - * details. - * - * Note that `ChainMonitor` should regularly trigger rebroadcasts/fee bumps of pending claims from - * a force-closed channel. This is crucial in preventing certain classes of pinning attacks, - * detecting substantial mempool feerate changes between blocks, and ensuring reliability if - * broadcasting fails. We recommend invoking this every 30 seconds, or lower if running in an - * environment with spotty connections, like on mobile. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - * [module-level documentation]: crate::chain::chainmonitor - * [`rebroadcast_pending_claims`]: Self::rebroadcast_pending_claims - */ -typedef struct MUST_USE_STRUCT LDKChainMonitor { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeChainMonitor *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKChainMonitor; - -/** - * A trait implemented for objects handling events from [`EventsProvider`]. - * - * An async variation also exists for implementations of [`EventsProvider`] that support async - * event handling. The async event handler should satisfy the generic bounds: `F: - * core::future::Future, H: Fn(Event) -> F`. - */ -typedef struct LDKEventHandler { - /** - * An opaque pointer which is passed to your function implementations as an argument. - * This has no meaning in the LDK, and can be NULL or any other value. - */ - void *this_arg; - /** - * Handles the given [`Event`]. - * - * See [`EventsProvider`] for details that must be considered when implementing this method. - */ - void (*handle_event)(const void *this_arg, struct LDKEvent event); - /** - * Frees any resources associated with this object given its this_arg pointer. - * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - */ - void (*free)(void *this_arg); -} LDKEventHandler; - -/** - * A trait indicating an object may generate events. - * - * Events are processed by passing an [`EventHandler`] to [`process_pending_events`]. - * - * Implementations of this trait may also feature an async version of event handling, as shown with - * [`ChannelManager::process_pending_events_async`] and - * [`ChainMonitor::process_pending_events_async`]. - * - * # Requirements + * # Requirements * * When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending * event since the last invocation. * * In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s * and replay any unhandled events on startup. An [`Event`] is considered handled when - * [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any - * relevant changes to disk *before* returning. + * [`process_pending_events`] returns `Ok(())`, thus handlers MUST fully handle [`Event`]s and + * persist any relevant changes to disk *before* returning `Ok(())`. In case of an error (e.g., + * persistence failure) implementors should return `Err(ReplayEvent())`, signalling to the + * [`EventsProvider`] to replay unhandled events on the next invocation (generally immediately). + * Note that some events might not be replayed, please refer to the documentation for + * the individual [`Event`] variants for more detail. * * Further, because an application may crash between an [`Event`] being handled and the * implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in @@ -20030,18 +24603,6 @@ typedef struct LDKChannelMessageHandler { * Handle an incoming `stfu` message from the given peer. */ void (*handle_stfu)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKStfu *NONNULL_PTR msg); - /** - * Handle an incoming `splice` message from the given peer. - */ - void (*handle_splice)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKSplice *NONNULL_PTR msg); - /** - * Handle an incoming `splice_ack` message from the given peer. - */ - void (*handle_splice_ack)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKSpliceAck *NONNULL_PTR msg); - /** - * Handle an incoming `splice_locked` message from the given peer. - */ - void (*handle_splice_locked)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKSpliceLocked *NONNULL_PTR msg); /** * Handle an incoming `tx_add_input message` from the given peer. */ @@ -20184,15 +24745,17 @@ typedef struct LDKOffersMessageHandler { * The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. * * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_OffersMessageZ (*handle_message)(const void *this_arg, struct LDKOffersMessage message); + struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ (*handle_message)(const void *this_arg, struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** * Releases any [`OffersMessage`]s that need to be sent. * * Typically, this is used for messages initiating a payment flow rather than in response to * another message. The latter should use the return value of [`Self::handle_message`]. */ - struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ (*release_pending_messages)(const void *this_arg); + struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ (*release_pending_messages)(const void *this_arg); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -20200,6 +24763,73 @@ typedef struct LDKOffersMessageHandler { void (*free)(void *this_arg); } LDKOffersMessageHandler; +/** + * A handler for an [`OnionMessage`] containing an async payments message as its payload. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage + */ +typedef struct LDKAsyncPaymentsMessageHandler { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + * the held funds. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ (*held_htlc_available)(const void *this_arg, struct LDKHeldHtlcAvailable message, struct LDKResponder responder); + /** + * Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + * should be released to the corresponding payee. + */ + void (*release_held_htlc)(const void *this_arg, struct LDKReleaseHeldHtlc message); + /** + * Release any [`AsyncPaymentsMessage`]s that need to be sent. + * + * Typically, this is used for messages initiating an async payment flow rather than in response + * to another message. + */ + struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ (*release_pending_messages)(const void *this_arg); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKAsyncPaymentsMessageHandler; + +/** + * An interface for looking up the node id of a channel counterparty for the purpose of forwarding + * an [`OnionMessage`]. + * + * [`OnionMessage`]: crate::ln::msgs::OnionMessage + */ +typedef struct LDKNodeIdLookUp { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`. + * + * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized + * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + struct LDKPublicKey (*next_node_id)(const void *this_arg, uint64_t short_channel_id); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKNodeIdLookUp; + /** @@ -20277,32 +24907,66 @@ typedef struct MUST_USE_STRUCT LDKExpandedKey { /** - * Packet of hop data for next peer + * Contains fields that are both common to [`open_channel`] and `open_channel2` messages. + * + * [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message */ -typedef struct MUST_USE_STRUCT LDKPacket { +typedef struct MUST_USE_STRUCT LDKCommonOpenChannelFields { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativePacket *inner; + LDKnativeCommonOpenChannelFields *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKPacket; +} LDKCommonOpenChannelFields; + + /** - * A 3-byte byte array. + * Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages. + * + * [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message */ -typedef struct LDKThreeBytes { +typedef struct MUST_USE_STRUCT LDKCommonAcceptChannelFields { /** - * The three bytes + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - uint8_t data[3]; -} LDKThreeBytes; + LDKnativeCommonAcceptChannelFields *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKCommonAcceptChannelFields; + + + +/** + * Packet of hop data for next peer + */ +typedef struct MUST_USE_STRUCT LDKPacket { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativePacket *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKPacket; /** * A trait to describe an object which can receive routing messages. @@ -20424,16 +25088,6 @@ typedef struct LDKOnionMessageHandler { * This has no meaning in the LDK, and can be NULL or any other value. */ void *this_arg; - /** - * Because much of the lightning network does not yet support forwarding onion messages, we - * may need to directly connect to a node which will forward a message for us. In such a case, - * this method will return the set of nodes which need connection by node_id and the - * corresponding socket addresses where they may accept incoming connections. - * - * Thus, this method should be polled regularly to detect messages await such a direct - * connection. - */ - struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ (*get_and_clear_connections_needed)(const void *this_arg); /** * Handle an incoming `onion_message` message from the given peer. */ @@ -20484,6 +25138,26 @@ typedef struct LDKOnionMessageHandler { void (*free)(void *this_arg); } LDKOnionMessageHandler; + + +/** + * BOLT 4 onion packet including hop data for the next peer. + */ +typedef struct MUST_USE_STRUCT LDKTrampolineOnionPacket { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeTrampolineOnionPacket *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKTrampolineOnionPacket; + /** * Trait to be implemented by custom message (unrelated to the channel/gossip LN layers) * decoders. @@ -20536,6 +25210,18 @@ typedef struct LDKCustomMessageHandler { * connection to the node exists, then the message is simply not sent. */ struct LDKCVec_C2Tuple_PublicKeyTypeZZ (*get_and_clear_pending_msg)(const void *this_arg); + /** + * Indicates a peer disconnected. + */ + void (*peer_disconnected)(const void *this_arg, struct LDKPublicKey their_node_id); + /** + * Handle a peer connecting. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + struct LDKCResult_NoneNoneZ (*peer_connected)(const void *this_arg, struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** * Gets the node feature flags which this handler itself supports. All available handlers are * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] @@ -20606,8 +25292,10 @@ typedef struct LDKCustomOnionMessageHandler { * Called with the custom message that was received, returning a response to send, if any. * * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - struct LDKCOption_OnionMessageContentsZ (*handle_custom_message)(const void *this_arg, struct LDKOnionMessageContents msg); + struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ (*handle_custom_message)(const void *this_arg, struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder); /** * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the * message type is unknown. @@ -20619,7 +25307,7 @@ typedef struct LDKCustomOnionMessageHandler { * Typically, this is used for messages initiating a message flow rather than in response to * another message. The latter should use the return value of [`Self::handle_custom_message`]. */ - struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ (*release_pending_custom_messages)(const void *this_arg); + struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ (*release_pending_custom_messages)(const void *this_arg); /** * Frees any resources associated with this object given its this_arg pointer. * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -20775,6 +25463,16 @@ typedef struct MUST_USE_STRUCT LDKPeerManager { bool is_owned; } LDKPeerManager; +/** + * Represents a valid secp256k1 secret key serialized as a 32 byte array. + */ +typedef struct LDKSecretKey { + /** + * The bytes of the secret key + */ + uint8_t bytes[32]; +} LDKSecretKey; + /** @@ -20802,83 +25500,152 @@ typedef struct MUST_USE_STRUCT LDKDirectedChannelTransactionParameters { /** - * Features used within an `offer`. + * SHA-256 hash */ -typedef struct MUST_USE_STRUCT LDKOfferFeatures { +typedef struct MUST_USE_STRUCT LDKSha256 { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeOfferFeatures *inner; + LDKnativeSha256 *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKOfferFeatures; +} LDKSha256; + +/** + * An error when attempting to pay a [`Bolt12Invoice`]. + */ +typedef enum LDKBolt12PaymentError_Tag { + /** + * The invoice was not requested. + */ + LDKBolt12PaymentError_UnexpectedInvoice, + /** + * Payment for an invoice with the corresponding [`PaymentId`] was already initiated. + */ + LDKBolt12PaymentError_DuplicateInvoice, + /** + * The invoice was valid for the corresponding [`PaymentId`], but required unknown features. + */ + LDKBolt12PaymentError_UnknownRequiredFeatures, + /** + * The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed. + */ + LDKBolt12PaymentError_SendingFailed, + /** + * Must be last for serialization purposes + */ + LDKBolt12PaymentError_Sentinel, +} LDKBolt12PaymentError_Tag; + +typedef struct MUST_USE_STRUCT LDKBolt12PaymentError { + LDKBolt12PaymentError_Tag tag; + union { + struct { + enum LDKRetryableSendFailure sending_failed; + }; + }; +} LDKBolt12PaymentError; /** - * Features used within an `invoice_request`. + * Builds an [`Offer`] for the \"offer to be paid\" flow. + * + * See [module-level documentation] for usage. + * + * [module-level documentation]: self */ -typedef struct MUST_USE_STRUCT LDKInvoiceRequestFeatures { +typedef struct MUST_USE_STRUCT LDKOfferWithExplicitMetadataBuilder { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeInvoiceRequestFeatures *inner; + LDKnativeOfferWithExplicitMetadataBuilder *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKInvoiceRequestFeatures; +} LDKOfferWithExplicitMetadataBuilder; /** - * The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or - * another currency. + * A string that displays only printable characters, replacing control characters with + * [`core::char::REPLACEMENT_CHARACTER`]. */ -typedef struct MUST_USE_STRUCT LDKAmount { +typedef struct MUST_USE_STRUCT LDKPrintableString { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeAmount *inner; + LDKnativePrintableString *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKAmount; +} LDKPrintableString; /** - * Quantity of items supported by an [`Offer`]. + * Features used within an `offer`. */ -typedef struct MUST_USE_STRUCT LDKQuantity { +typedef struct MUST_USE_STRUCT LDKOfferFeatures { /** * A pointer to the opaque Rust object. * Nearly everywhere, inner must be non-null, however in places where * the Rust equivalent takes an Option, it may be set to null to indicate None. */ - LDKnativeQuantity *inner; + LDKnativeOfferFeatures *inner; /** * Indicates that this is the only struct which contains the same pointer. * Rust functions which take ownership of an object provided via an argument require * this to be true and invalidate the object pointed to by inner. */ bool is_owned; -} LDKQuantity; +} LDKOfferFeatures; + +/** + * Represents a tweaked X-only public key as required for BIP 340 (Taproot). + */ +typedef struct LDKTweakedPublicKey { + /** + * The bytes of the public key X coordinate + */ + uint8_t x_coordinate[32]; +} LDKTweakedPublicKey; + +/** + * A function for signing an [`UnsignedBolt12Invoice`]. + */ +typedef struct LDKSignBolt12InvoiceFn { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + */ + struct LDKCResult_SchnorrSignatureNoneZ (*sign_invoice)(const void *this_arg, const struct LDKUnsignedBolt12Invoice *NONNULL_PTR message); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSignBolt12InvoiceFn; @@ -20906,6 +25673,26 @@ typedef struct MUST_USE_STRUCT LDKTaggedHash { +/** + * Features used within an `invoice_request`. + */ +typedef struct MUST_USE_STRUCT LDKInvoiceRequestFeatures { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeInvoiceRequestFeatures *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKInvoiceRequestFeatures; + + + /** * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. * @@ -20927,6 +25714,53 @@ typedef struct MUST_USE_STRUCT LDKErroneousField { bool is_owned; } LDKErroneousField; +/** + * A function for signing an [`UnsignedInvoiceRequest`]. + */ +typedef struct LDKSignInvoiceRequestFn { + /** + * An opaque pointer which is passed to your function implementations as an argument. + * This has no meaning in the LDK, and can be NULL or any other value. + */ + void *this_arg; + /** + * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + */ + struct LDKCResult_SchnorrSignatureNoneZ (*sign_invoice_request)(const void *this_arg, const struct LDKUnsignedInvoiceRequest *NONNULL_PTR message); + /** + * Frees any resources associated with this object given its this_arg pointer. + * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + */ + void (*free)(void *this_arg); +} LDKSignInvoiceRequestFn; + +/** + * Error when signing messages. + */ +typedef enum LDKSignError_Tag { + /** + * User-defined error when signing the message. + */ + LDKSignError_Signing, + /** + * Error when verifying the produced signature using the given pubkey. + */ + LDKSignError_Verification, + /** + * Must be last for serialization purposes + */ + LDKSignError_Sentinel, +} LDKSignError_Tag; + +typedef struct MUST_USE_STRUCT LDKSignError { + LDKSignError_Tag tag; + union { + struct { + enum LDKSecp256k1Error verification; + }; + }; +} LDKSignError; + /** @@ -21079,6 +25913,11 @@ typedef struct MUST_USE_STRUCT LDKEffectiveCapacity { /** * A [`Router`] implemented using [`find_route`]. + * + * # Privacy + * + * Implements [`MessageRouter`] by delegating to [`DefaultMessageRouter`]. See those docs for + * privacy implications. */ typedef struct MUST_USE_STRUCT LDKDefaultRouter { /** @@ -21145,7 +25984,7 @@ typedef struct LDKPayee_LDKBlinded_Body { * Aggregated routing info and blinded paths, for routing to the payee without knowing their * node id. */ - struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints; + struct LDKCVec_BlindedPaymentPathZ route_hints; /** * Features supported by the payee. * @@ -21376,6 +26215,26 @@ typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { +/** + * An implementation of [`EntropySource`] using ChaCha20. + */ +typedef struct MUST_USE_STRUCT LDKRandomBytes { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeRandomBytes *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKRandomBytes; + + + /** * A sender, receiver and forwarder of [`OnionMessage`]s. * @@ -21398,12 +26257,13 @@ typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { * ``` * # extern crate bitcoin; * # use bitcoin::hashes::_export::_core::time::Duration; - * # use bitcoin::hashes::hex::FromHex; + * # use bitcoin::hex::FromHex; * # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey, self}; - * # use lightning::blinded_path::BlindedPath; + * # use lightning::blinded_path::EmptyNodeIdLookUp; + * # use lightning::blinded_path::message::{BlindedMessagePath, MessageForwardNode, MessageContext}; * # use lightning::sign::{EntropySource, KeysManager}; * # use lightning::ln::peer_handler::IgnoringMessageHandler; - * # use lightning::onion_message::messenger::{Destination, MessageRouter, OnionMessagePath, OnionMessenger}; + * # use lightning::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions, OnionMessagePath, OnionMessenger}; * # use lightning::onion_message::packet::OnionMessageContents; * # use lightning::util::logger::{Logger, Record}; * # use lightning::util::ser::{Writeable, Writer}; @@ -21427,8 +26287,8 @@ typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { * # }) * # } * # fn create_blinded_paths( - * # &self, _recipient: PublicKey, _peers: Vec, _secp_ctx: &Secp256k1 - * # ) -> Result, ()> { + * # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1 + * # ) -> Result, ()> { * # unreachable!() * # } * # } @@ -21441,14 +26301,16 @@ typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { * # let hop_node_id1 = PublicKey::from_secret_key(&secp_ctx, &node_secret); * # let (hop_node_id3, hop_node_id4) = (hop_node_id1, hop_node_id1); * # let destination_node_id = hop_node_id1; + * # let node_id_lookup = EmptyNodeIdLookUp {}; * # let message_router = Arc::new(FakeMessageRouter {}); * # let custom_message_handler = IgnoringMessageHandler {}; * # let offers_message_handler = IgnoringMessageHandler {}; + * # let async_payments_message_handler = IgnoringMessageHandler {}; * // Create the onion messenger. This must use the same `keys_manager` as is passed to your * // ChannelManager. * let onion_messenger = OnionMessenger::new( - * &keys_manager, &keys_manager, logger, message_router, &offers_message_handler, - * &custom_message_handler + * &keys_manager, &keys_manager, logger, &node_id_lookup, message_router, + * &offers_message_handler, &async_payments_message_handler, &custom_message_handler * ); * * # #[derive(Debug, Clone)] @@ -21464,23 +26326,28 @@ typedef struct MUST_USE_STRUCT LDKPhantomKeysManager { * \t\t# let your_custom_message_type = 42; * \t\tyour_custom_message_type * \t} + * \tfn msg_type(&self) -> &'static str { \"YourCustomMessageType\" } * } * // Send a custom onion message to a node id. * let destination = Destination::Node(destination_node_id); - * let reply_path = None; + * let instructions = MessageSendInstructions::WithoutReplyPath { destination }; * # let message = YourCustomMessage {}; - * onion_messenger.send_onion_message(message, destination, reply_path); + * onion_messenger.send_onion_message(message, instructions); * * // Create a blinded path to yourself, for someone to send an onion message to. * # let your_node_id = hop_node_id1; - * let hops = [hop_node_id3, hop_node_id4, your_node_id]; - * let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap(); + * let hops = [ + * \tMessageForwardNode { node_id: hop_node_id3, short_channel_id: None }, + * \tMessageForwardNode { node_id: hop_node_id4, short_channel_id: None }, + * ]; + * let context = MessageContext::Custom(Vec::new()); + * let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); * * // Send a custom onion message to a blinded path. * let destination = Destination::BlindedPath(blinded_path); - * let reply_path = None; + * let instructions = MessageSendInstructions::WithoutReplyPath { destination }; * # let message = YourCustomMessage {}; - * onion_messenger.send_onion_message(message, destination, reply_path); + * onion_messenger.send_onion_message(message, instructions); * ``` * * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest @@ -21505,6 +26372,13 @@ typedef struct MUST_USE_STRUCT LDKOnionMessenger { /** * A [`MessageRouter`] that can only route to a directly connected [`Destination`]. + * + * # Privacy + * + * Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found, + * it will create a one-hop path using the recipient as the introduction node if it is a announced + * node. Otherwise, there is no way to find a path to the introduction node in order to send a + * message, and thus an `Err` is returned. */ typedef struct MUST_USE_STRUCT LDKDefaultMessageRouter { /** @@ -21521,6 +26395,60 @@ typedef struct MUST_USE_STRUCT LDKDefaultMessageRouter { bool is_owned; } LDKDefaultMessageRouter; +/** + * The unblinded node in a blinded path. + */ +typedef enum LDKIntroductionNode_Tag { + /** + * The node id of the introduction node. + */ + LDKIntroductionNode_NodeId, + /** + * The short channel id of the channel leading to the introduction node. The [`Direction`] + * identifies which side of the channel is the introduction node. + */ + LDKIntroductionNode_DirectedShortChannelId, + /** + * Must be last for serialization purposes + */ + LDKIntroductionNode_Sentinel, +} LDKIntroductionNode_Tag; + +typedef struct LDKIntroductionNode_LDKDirectedShortChannelId_Body { + enum LDKDirection _0; + uint64_t _1; +} LDKIntroductionNode_LDKDirectedShortChannelId_Body; + +typedef struct MUST_USE_STRUCT LDKIntroductionNode { + LDKIntroductionNode_Tag tag; + union { + struct { + struct LDKPublicKey node_id; + }; + LDKIntroductionNode_LDKDirectedShortChannelId_Body directed_short_channel_id; + }; +} LDKIntroductionNode; + + + +/** + * A [`NodeIdLookUp`] that always returns `None`. + */ +typedef struct MUST_USE_STRUCT LDKEmptyNodeIdLookUp { + /** + * A pointer to the opaque Rust object. + * Nearly everywhere, inner must be non-null, however in places where + * the Rust equivalent takes an Option, it may be set to null to indicate None. + */ + LDKnativeEmptyNodeIdLookUp *inner; + /** + * Indicates that this is the only struct which contains the same pointer. + * Rust functions which take ownership of an object provided via an argument require + * this to be true and invalidate the object pointed to by inner. + */ + bool is_owned; +} LDKEmptyNodeIdLookUp; + /** @@ -21723,6 +26651,8 @@ typedef struct MUST_USE_STRUCT LDKFilesystemStore { * However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for * unilateral chain closure fees are at risk. * + * [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager + * [`ChannelManager::timer_tick_occurred`]: lightning::ln::channelmanager::ChannelManager::timer_tick_occurred * [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor * [`Event`]: lightning::events::Event * [`PeerManager::timer_tick_occurred`]: lightning::ln::peer_handler::PeerManager::timer_tick_occurred @@ -21830,26 +26760,6 @@ typedef struct MUST_USE_STRUCT LDKRawDataPart { -/** - * SHA-256 hash - */ -typedef struct MUST_USE_STRUCT LDKSha256 { - /** - * A pointer to the opaque Rust object. - * Nearly everywhere, inner must be non-null, however in places where - * the Rust equivalent takes an Option, it may be set to null to indicate None. - */ - LDKnativeSha256 *inner; - /** - * Indicates that this is the only struct which contains the same pointer. - * Rust functions which take ownership of an object provided via an argument require - * this to be true and invalidate the object pointed to by inner. - */ - bool is_owned; -} LDKSha256; - - - /** * Positive duration that defines when (relatively to the timestamp) in the future the invoice * expires @@ -21934,6 +26844,12 @@ extern const uintptr_t MAX_BUF_SIZE; extern const uintptr_t KVSTORE_NAMESPACE_KEY_MAX_LEN; +extern const uint64_t MAX_SCID_BLOCK; + +extern const uint64_t MAX_SCID_TX_INDEX; + +extern const uint64_t MAX_SCID_VOUT_INDEX; + extern const uint64_t MIN_RELAY_FEE_SAT_PER_1000_WEIGHT; extern const uint32_t FEERATE_FLOOR_SATS_PER_KW; @@ -21964,12 +26880,16 @@ extern const uint64_t HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; extern const uintptr_t REVOKEABLE_REDEEMSCRIPT_MAX_LENGTH; +extern const uintptr_t PAYER_NOTE_LIMIT; + extern const uint64_t UNKNOWN_CHANNEL_CAPACITY_MSAT; extern const uint32_t DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA; extern const uint8_t DEFAULT_MAX_PATH_COUNT; +extern const uint8_t MAX_PATH_LENGTH_ESTIMATE; + extern const uint64_t MAX_TIMESTAMP; extern const uint64_t DEFAULT_EXPIRY_TIME; @@ -22045,6 +26965,11 @@ void WitnessProgram_free(struct LDKWitnessProgram o); */ struct LDKBigEndianScalar BigEndianScalar_new(struct LDKThirtyTwoBytes big_endian_bytes); +/** + * Creates a new BigEndianScalar which has the same data as `orig` + */ +struct LDKBigEndianScalar BigEndianScalar_clone(const struct LDKBigEndianScalar *NONNULL_PTR orig); + /** * Creates a new Bech32Error which has the same data as `orig` */ @@ -22143,6 +27068,63 @@ void Str_free(struct LDKStr _res); const void *__unmangle_inner_ptr(const void *ptr); #endif +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_u8Z_free(struct LDKCVec_u8Z _res); + +/** + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(struct LDKRefundMaybeWithDerivedMetadataBuilder o); + +/** + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ. + */ +void CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_RefundBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_ok(struct LDKRefund o); + +/** + * Creates a new CResult_RefundBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RefundBolt12SemanticErrorZ_is_ok(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RefundBolt12SemanticErrorZ. + */ +void CResult_RefundBolt12SemanticErrorZ_free(struct LDKCResult_RefundBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_RefundBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RefundBolt12SemanticErrorZ CResult_RefundBolt12SemanticErrorZ_clone(const struct LDKCResult_RefundBolt12SemanticErrorZ *NONNULL_PTR orig); + /** * Constructs a new COption_u64Z containing a u64 */ @@ -22167,7 +27149,33 @@ struct LDKCOption_u64Z COption_u64Z_clone(const struct LDKCOption_u64Z *NONNULL_ /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_BlindedPathZ_free(struct LDKCVec_BlindedPathZ _res); +void CVec_BlindedMessagePathZ_free(struct LDKCVec_BlindedMessagePathZ _res); + +/** + * Creates a new CResult_RefundDecodeErrorZ in the success state. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_ok(struct LDKRefund o); + +/** + * Creates a new CResult_RefundDecodeErrorZ in the error state. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_RefundDecodeErrorZ_is_ok(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_RefundDecodeErrorZ. + */ +void CResult_RefundDecodeErrorZ_free(struct LDKCResult_RefundDecodeErrorZ _res); + +/** + * Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_RefundDecodeErrorZ CResult_RefundDecodeErrorZ_clone(const struct LDKCResult_RefundDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_RefundBolt12ParseErrorZ in the success state. @@ -22278,11 +27286,6 @@ void COption_ThirtyTwoBytesZ_free(struct LDKCOption_ThirtyTwoBytesZ _res); */ struct LDKCOption_ThirtyTwoBytesZ COption_ThirtyTwoBytesZ_clone(const struct LDKCOption_ThirtyTwoBytesZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_u8Z_free(struct LDKCVec_u8Z _res); - /** * Constructs a new COption_CVec_u8ZZ containing a crate::c_types::derived::CVec_u8Z */ @@ -22377,6 +27380,89 @@ void CResult_RecipientOnionFieldsNoneZ_free(struct LDKCResult_RecipientOnionFiel */ struct LDKCResult_RecipientOnionFieldsNoneZ CResult_RecipientOnionFieldsNoneZ_clone(const struct LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR orig); +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKUnsignedBolt12Invoice o); + +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ. + */ +void CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_ok(struct LDKBolt12Invoice o); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_Bolt12InvoiceBolt12SemanticErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_Bolt12InvoiceBolt12SemanticErrorZ. + */ +void CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ CResult_Bolt12InvoiceBolt12SemanticErrorZ_clone(const struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ in the success state. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_ok(struct LDKSchnorrSignature o); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ in the error state. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_SchnorrSignatureNoneZ_is_ok(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_SchnorrSignatureNoneZ. + */ +void CResult_SchnorrSignatureNoneZ_free(struct LDKCResult_SchnorrSignatureNoneZ _res); + +/** + * Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_clone(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_StrZ_free(struct LDKCVec_StrZ _res); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -22403,6 +27489,48 @@ void COption_CVec_ThirtyTwoBytesZZ_free(struct LDKCOption_CVec_ThirtyTwoBytesZZ */ struct LDKCOption_CVec_ThirtyTwoBytesZZ COption_CVec_ThirtyTwoBytesZZ_clone(const struct LDKCOption_CVec_ThirtyTwoBytesZZ *NONNULL_PTR orig); +/** + * Constructs a new COption_AmountZ containing a crate::lightning::offers::offer::Amount + */ +struct LDKCOption_AmountZ COption_AmountZ_some(struct LDKAmount o); + +/** + * Constructs a new COption_AmountZ containing nothing + */ +struct LDKCOption_AmountZ COption_AmountZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::offers::offer::Amount, if we are in the Some state + */ +void COption_AmountZ_free(struct LDKCOption_AmountZ _res); + +/** + * Creates a new COption_AmountZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_AmountZ COption_AmountZ_clone(const struct LDKCOption_AmountZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_QuantityZ containing a crate::lightning::offers::offer::Quantity + */ +struct LDKCOption_QuantityZ COption_QuantityZ_some(struct LDKQuantity o); + +/** + * Constructs a new COption_QuantityZ containing nothing + */ +struct LDKCOption_QuantityZ COption_QuantityZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::offers::offer::Quantity, if we are in the Some state + */ +void COption_QuantityZ_free(struct LDKCOption_QuantityZ _res); + +/** + * Creates a new COption_QuantityZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_QuantityZ COption_QuantityZ_clone(const struct LDKCOption_QuantityZ *NONNULL_PTR orig); + /** * Creates a new CResult_ThirtyTwoBytesNoneZ in the success state. */ @@ -22430,30 +27558,30 @@ void CResult_ThirtyTwoBytesNoneZ_free(struct LDKCResult_ThirtyTwoBytesNoneZ _res struct LDKCResult_ThirtyTwoBytesNoneZ CResult_ThirtyTwoBytesNoneZ_clone(const struct LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_ok(struct LDKBolt12Invoice o); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); +bool CResult_Bolt12InvoiceDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. + * Frees any resources used by the CResult_Bolt12InvoiceDecodeErrorZ. */ -void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); +void CResult_Bolt12InvoiceDecodeErrorZ_free(struct LDKCResult_Bolt12InvoiceDecodeErrorZ _res); /** - * Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_Bolt12InvoiceDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ CResult_Bolt12InvoiceDecodeErrorZ_clone(const struct LDKCResult_Bolt12InvoiceDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. @@ -22659,56 +27787,82 @@ void CResult_HTLCDescriptorDecodeErrorZ_free(struct LDKCResult_HTLCDescriptorDec struct LDKCResult_HTLCDescriptorDecodeErrorZ CResult_HTLCDescriptorDecodeErrorZ_clone(const struct LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneNoneZ in the success state. + * Creates a new CResult_PublicKeyNoneZ in the success state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); /** - * Creates a new CResult_NoneNoneZ in the error state. + * Creates a new CResult_PublicKeyNoneZ in the error state. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); +bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneNoneZ. + * Frees any resources used by the CResult_PublicKeyNoneZ. */ -void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); +void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); /** - * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); +struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeyNoneZ in the success state. + * Creates a new CResult__u832NoneZ in the success state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_ok(struct LDKPublicKey o); +struct LDKCResult__u832NoneZ CResult__u832NoneZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_PublicKeyNoneZ in the error state. + * Creates a new CResult__u832NoneZ in the error state. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_err(void); +struct LDKCResult__u832NoneZ CResult__u832NoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_PublicKeyNoneZ_is_ok(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR o); +bool CResult__u832NoneZ_is_ok(const struct LDKCResult__u832NoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeyNoneZ. + * Frees any resources used by the CResult__u832NoneZ. */ -void CResult_PublicKeyNoneZ_free(struct LDKCResult_PublicKeyNoneZ _res); +void CResult__u832NoneZ_free(struct LDKCResult__u832NoneZ _res); /** - * Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` + * Creates a new CResult__u832NoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PublicKeyNoneZ CResult_PublicKeyNoneZ_clone(const struct LDKCResult_PublicKeyNoneZ *NONNULL_PTR orig); +struct LDKCResult__u832NoneZ CResult__u832NoneZ_clone(const struct LDKCResult__u832NoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneNoneZ in the success state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_ok(void); + +/** + * Creates a new CResult_NoneNoneZ in the error state. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneNoneZ_is_ok(const struct LDKCResult_NoneNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneNoneZ. + */ +void CResult_NoneNoneZ_free(struct LDKCResult_NoneNoneZ _res); + +/** + * Creates a new CResult_NoneNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneNoneZ CResult_NoneNoneZ_clone(const struct LDKCResult_NoneNoneZ *NONNULL_PTR orig); /** * Constructs a new COption_BigEndianScalarZ containing a crate::c_types::BigEndianScalar @@ -22731,11 +27885,6 @@ void COption_BigEndianScalarZ_free(struct LDKCOption_BigEndianScalarZ _res); */ struct LDKCOption_BigEndianScalarZ COption_BigEndianScalarZ_clone(const struct LDKCOption_BigEndianScalarZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_U5Z_free(struct LDKCVec_U5Z _res); - /** * Creates a new CResult_RecoverableSignatureNoneZ in the success state. */ @@ -22763,82 +27912,82 @@ void CResult_RecoverableSignatureNoneZ_free(struct LDKCResult_RecoverableSignatu struct LDKCResult_RecoverableSignatureNoneZ CResult_RecoverableSignatureNoneZ_clone(const struct LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_SchnorrSignatureNoneZ in the success state. + * Creates a new CResult_ECDSASignatureNoneZ in the success state. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_ok(struct LDKSchnorrSignature o); +struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_ok(struct LDKECDSASignature o); /** - * Creates a new CResult_SchnorrSignatureNoneZ in the error state. + * Creates a new CResult_ECDSASignatureNoneZ in the error state. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_err(void); +struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_SchnorrSignatureNoneZ_is_ok(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR o); +bool CResult_ECDSASignatureNoneZ_is_ok(const struct LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SchnorrSignatureNoneZ. + * Frees any resources used by the CResult_ECDSASignatureNoneZ. */ -void CResult_SchnorrSignatureNoneZ_free(struct LDKCResult_SchnorrSignatureNoneZ _res); +void CResult_ECDSASignatureNoneZ_free(struct LDKCResult_ECDSASignatureNoneZ _res); /** - * Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` + * Creates a new CResult_ECDSASignatureNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SchnorrSignatureNoneZ CResult_SchnorrSignatureNoneZ_clone(const struct LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR orig); +struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_clone(const struct LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_ECDSASignatureNoneZ in the success state. + * Creates a new CResult_TransactionNoneZ in the success state. */ -struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_ok(struct LDKECDSASignature o); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); /** - * Creates a new CResult_ECDSASignatureNoneZ in the error state. + * Creates a new CResult_TransactionNoneZ in the error state. */ -struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_err(void); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_ECDSASignatureNoneZ_is_ok(const struct LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR o); +bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ECDSASignatureNoneZ. + * Frees any resources used by the CResult_TransactionNoneZ. */ -void CResult_ECDSASignatureNoneZ_free(struct LDKCResult_ECDSASignatureNoneZ _res); +void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); /** - * Creates a new CResult_ECDSASignatureNoneZ which has the same data as `orig` + * Creates a new CResult_TransactionNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ECDSASignatureNoneZ CResult_ECDSASignatureNoneZ_clone(const struct LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR orig); +struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the success state. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(struct LDKWriteableEcdsaChannelSigner o); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_ok(struct LDKEcdsaChannelSigner o); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the error state. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR o); +bool CResult_EcdsaChannelSignerDecodeErrorZ_is_ok(const struct LDKCResult_EcdsaChannelSignerDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. + * Frees any resources used by the CResult_EcdsaChannelSignerDecodeErrorZ. */ -void CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res); +void CResult_EcdsaChannelSignerDecodeErrorZ_free(struct LDKCResult_EcdsaChannelSignerDecodeErrorZ _res); /** - * Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_EcdsaChannelSignerDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(const struct LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_EcdsaChannelSignerDecodeErrorZ CResult_EcdsaChannelSignerDecodeErrorZ_clone(const struct LDKCResult_EcdsaChannelSignerDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_CVec_u8ZNoneZ in the success state. @@ -23034,71 +28183,87 @@ void CResult_InMemorySignerDecodeErrorZ_free(struct LDKCResult_InMemorySignerDec struct LDKCResult_InMemorySignerDecodeErrorZ CResult_InMemorySignerDecodeErrorZ_clone(const struct LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TransactionNoneZ in the success state. + * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_ok(struct LDKTransaction o); +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); /** - * Creates a new CResult_TransactionNoneZ in the error state. + * Constructs a new COption_WriteableScoreZ containing nothing */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_err(void); +struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state + */ +void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); + +/** + * Creates a new CResult_NoneIOErrorZ in the success state. + */ +struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_ok(void); + +/** + * Creates a new CResult_NoneIOErrorZ in the error state. + */ +struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_err(enum LDKIOError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TransactionNoneZ_is_ok(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR o); +bool CResult_NoneIOErrorZ_is_ok(const struct LDKCResult_NoneIOErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TransactionNoneZ. + * Frees any resources used by the CResult_NoneIOErrorZ. */ -void CResult_TransactionNoneZ_free(struct LDKCResult_TransactionNoneZ _res); +void CResult_NoneIOErrorZ_free(struct LDKCResult_NoneIOErrorZ _res); /** - * Creates a new CResult_TransactionNoneZ which has the same data as `orig` + * Creates a new CResult_NoneIOErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TransactionNoneZ CResult_TransactionNoneZ_clone(const struct LDKCResult_TransactionNoneZ *NONNULL_PTR orig); +struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_clone(const struct LDKCResult_NoneIOErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_some(struct LDKWriteableScore o); +struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(const struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *NONNULL_PTR orig); /** - * Constructs a new COption_WriteableScoreZ containing nothing + * Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. */ -struct LDKCOption_WriteableScoreZ COption_WriteableScoreZ_none(void); +struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(struct LDKThirtyTwoBytes a, struct LDKRecipientOnionFields b, struct LDKRouteParameters c); /** - * Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state + * Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. */ -void COption_WriteableScoreZ_free(struct LDKCOption_WriteableScoreZ _res); +void C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ _res); /** - * Creates a new CResult_NoneIOErrorZ in the success state. + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. */ -struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_ok(void); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ o); /** - * Creates a new CResult_NoneIOErrorZ in the error state. + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. */ -struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_err(enum LDKIOError e); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneIOErrorZ_is_ok(const struct LDKCResult_NoneIOErrorZ *NONNULL_PTR o); +bool CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneIOErrorZ. + * Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. */ -void CResult_NoneIOErrorZ_free(struct LDKCResult_NoneIOErrorZ _res); +void CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ _res); /** - * Creates a new CResult_NoneIOErrorZ which has the same data as `orig` + * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneIOErrorZ CResult_NoneIOErrorZ_clone(const struct LDKCResult_NoneIOErrorZ *NONNULL_PTR orig); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. @@ -23131,52 +28296,36 @@ void CResult_RouteLightningErrorZ_free(struct LDKCResult_RouteLightningErrorZ _r */ struct LDKCResult_RouteLightningErrorZ CResult_RouteLightningErrorZ_clone(const struct LDKCResult_RouteLightningErrorZ *NONNULL_PTR orig); -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_clone(const struct LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. - */ -struct LDKC2Tuple_BlindedPayInfoBlindedPathZ C2Tuple_BlindedPayInfoBlindedPathZ_new(struct LDKBlindedPayInfo a, struct LDKBlindedPath b); - -/** - * Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. - */ -void C2Tuple_BlindedPayInfoBlindedPathZ_free(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ _res); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res); +void CVec_BlindedPaymentPathZ_free(struct LDKCVec_BlindedPaymentPathZ _res); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the success state. + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the success state. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_ok(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ o); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_ok(struct LDKCVec_BlindedPaymentPathZ o); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the error state. + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the error state. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err(void); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_is_ok(const struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ *NONNULL_PTR o); +bool CResult_CVec_BlindedPaymentPathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedPaymentPathZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ. + * Frees any resources used by the CResult_CVec_BlindedPaymentPathZNoneZ. */ -void CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ _res); +void CResult_CVec_BlindedPaymentPathZNoneZ_free(struct LDKCResult_CVec_BlindedPaymentPathZNoneZ _res); /** - * Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_BlindedPaymentPathZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_clone(const struct LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_BlindedPaymentPathZNoneZ CResult_CVec_BlindedPaymentPathZNoneZ_clone(const struct LDKCResult_CVec_BlindedPaymentPathZNoneZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. @@ -23210,30 +28359,35 @@ void CResult_OnionMessagePathNoneZ_free(struct LDKCResult_OnionMessagePathNoneZ struct LDKCResult_OnionMessagePathNoneZ CResult_OnionMessagePathNoneZ_clone(const struct LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ in the success state. + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the success state. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_ok(struct LDKCVec_BlindedPathZ o); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_ok(struct LDKCVec_BlindedMessagePathZ o); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ in the error state. + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the error state. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_err(void); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_CVec_BlindedPathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedPathZNoneZ *NONNULL_PTR o); +bool CResult_CVec_BlindedMessagePathZNoneZ_is_ok(const struct LDKCResult_CVec_BlindedMessagePathZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CVec_BlindedPathZNoneZ. + * Frees any resources used by the CResult_CVec_BlindedMessagePathZNoneZ. */ -void CResult_CVec_BlindedPathZNoneZ_free(struct LDKCResult_CVec_BlindedPathZNoneZ _res); +void CResult_CVec_BlindedMessagePathZNoneZ_free(struct LDKCResult_CVec_BlindedMessagePathZNoneZ _res); /** - * Creates a new CResult_CVec_BlindedPathZNoneZ which has the same data as `orig` + * Creates a new CResult_CVec_BlindedMessagePathZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_BlindedPathZNoneZ CResult_CVec_BlindedPathZNoneZ_clone(const struct LDKCResult_CVec_BlindedPathZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CVec_BlindedMessagePathZNoneZ CResult_CVec_BlindedMessagePathZNoneZ_clone(const struct LDKCResult_CVec_BlindedMessagePathZNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_MessageForwardNodeZ_free(struct LDKCVec_MessageForwardNodeZ _res); /** * Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. @@ -23416,11 +28570,6 @@ struct LDKCResult_PaymentParametersDecodeErrorZ CResult_PaymentParametersDecodeE */ void CVec_RouteHintZ_free(struct LDKCVec_RouteHintZ _res); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); - /** * Creates a new CResult_RouteHintDecodeErrorZ in the success state. */ @@ -23617,6 +28766,32 @@ bool CResult_ProbabilisticScorerDecodeErrorZ_is_ok(const struct LDKCResult_Proba */ void CResult_ProbabilisticScorerDecodeErrorZ_free(struct LDKCResult_ProbabilisticScorerDecodeErrorZ _res); +/** + * Creates a new CResult_BestBlockDecodeErrorZ in the success state. + */ +struct LDKCResult_BestBlockDecodeErrorZ CResult_BestBlockDecodeErrorZ_ok(struct LDKBestBlock o); + +/** + * Creates a new CResult_BestBlockDecodeErrorZ in the error state. + */ +struct LDKCResult_BestBlockDecodeErrorZ CResult_BestBlockDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BestBlockDecodeErrorZ_is_ok(const struct LDKCResult_BestBlockDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BestBlockDecodeErrorZ. + */ +void CResult_BestBlockDecodeErrorZ_free(struct LDKCResult_BestBlockDecodeErrorZ _res); + +/** + * Creates a new CResult_BestBlockDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BestBlockDecodeErrorZ CResult_BestBlockDecodeErrorZ_clone(const struct LDKCResult_BestBlockDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. @@ -23694,22 +28869,22 @@ void CVec_MonitorEventZ_free(struct LDKCVec_MonitorEventZ _res); * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(const struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR orig); +struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_clone(const struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. + * Creates a new C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ from the contained elements. */ -struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorEventZ b, struct LDKPublicKey c); +struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_new(struct LDKOutPoint a, struct LDKChannelId b, struct LDKCVec_MonitorEventZ c, struct LDKPublicKey d); /** - * Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. + * Frees any resources used by the C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ. */ -void C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(struct LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res); +void C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_free(struct LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res); +void CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ_free(struct LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ _res); /** * Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. @@ -23894,56 +29069,174 @@ void CResult_ChannelTypeFeaturesDecodeErrorZ_free(struct LDKCResult_ChannelTypeF struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ CResult_ChannelTypeFeaturesDecodeErrorZ_clone(const struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_OfferBolt12ParseErrorZ in the success state. + * Creates a new CResult_OfferIdDecodeErrorZ in the success state. */ -struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_ok(struct LDKOffer o); +struct LDKCResult_OfferIdDecodeErrorZ CResult_OfferIdDecodeErrorZ_ok(struct LDKOfferId o); /** - * Creates a new CResult_OfferBolt12ParseErrorZ in the error state. + * Creates a new CResult_OfferIdDecodeErrorZ in the error state. */ -struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); +struct LDKCResult_OfferIdDecodeErrorZ CResult_OfferIdDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_OfferBolt12ParseErrorZ_is_ok(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR o); +bool CResult_OfferIdDecodeErrorZ_is_ok(const struct LDKCResult_OfferIdDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_OfferBolt12ParseErrorZ. + * Frees any resources used by the CResult_OfferIdDecodeErrorZ. */ -void CResult_OfferBolt12ParseErrorZ_free(struct LDKCResult_OfferBolt12ParseErrorZ _res); +void CResult_OfferIdDecodeErrorZ_free(struct LDKCResult_OfferIdDecodeErrorZ _res); /** - * Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` + * Creates a new CResult_OfferIdDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_clone(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR orig); +struct LDKCResult_OfferIdDecodeErrorZ CResult_OfferIdDecodeErrorZ_clone(const struct LDKCResult_OfferIdDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PublicKeySecp256k1ErrorZ in the success state. + * Creates a new CResult_NoneBolt12SemanticErrorZ in the success state. */ -struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_ok(struct LDKPublicKey o); +struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_ok(void); /** - * Creates a new CResult_PublicKeySecp256k1ErrorZ in the error state. + * Creates a new CResult_NoneBolt12SemanticErrorZ in the error state. */ -struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PublicKeySecp256k1ErrorZ_is_ok(const struct LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR o); +bool CResult_NoneBolt12SemanticErrorZ_is_ok(const struct LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PublicKeySecp256k1ErrorZ. + * Frees any resources used by the CResult_NoneBolt12SemanticErrorZ. */ -void CResult_PublicKeySecp256k1ErrorZ_free(struct LDKCResult_PublicKeySecp256k1ErrorZ _res); +void CResult_NoneBolt12SemanticErrorZ_free(struct LDKCResult_NoneBolt12SemanticErrorZ _res); /** - * Creates a new CResult_PublicKeySecp256k1ErrorZ which has the same data as `orig` + * Creates a new CResult_NoneBolt12SemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_clone(const struct LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR orig); +struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_clone(const struct LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OfferBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_OfferBolt12SemanticErrorZ CResult_OfferBolt12SemanticErrorZ_ok(struct LDKOffer o); + +/** + * Creates a new CResult_OfferBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_OfferBolt12SemanticErrorZ CResult_OfferBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferBolt12SemanticErrorZ_is_ok(const struct LDKCResult_OfferBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferBolt12SemanticErrorZ. + */ +void CResult_OfferBolt12SemanticErrorZ_free(struct LDKCResult_OfferBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_OfferBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferBolt12SemanticErrorZ CResult_OfferBolt12SemanticErrorZ_clone(const struct LDKCResult_OfferBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_ok(struct LDKInvoiceRequestWithDerivedPayerIdBuilder o); + +/** + * Creates a new CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ. + */ +void CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_ok(struct LDKInvoiceRequestWithExplicitPayerIdBuilder o); + +/** + * Creates a new CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ. + */ +void CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_OfferDecodeErrorZ in the success state. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_ok(struct LDKOffer o); + +/** + * Creates a new CResult_OfferDecodeErrorZ in the error state. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferDecodeErrorZ_is_ok(const struct LDKCResult_OfferDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferDecodeErrorZ. + */ +void CResult_OfferDecodeErrorZ_free(struct LDKCResult_OfferDecodeErrorZ _res); + +/** + * Creates a new CResult_OfferDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferDecodeErrorZ CResult_OfferDecodeErrorZ_clone(const struct LDKCResult_OfferDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ in the success state. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_ok(struct LDKOffer o); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ in the error state. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_err(struct LDKBolt12ParseError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferBolt12ParseErrorZ_is_ok(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferBolt12ParseErrorZ. + */ +void CResult_OfferBolt12ParseErrorZ_free(struct LDKCResult_OfferBolt12ParseErrorZ _res); + +/** + * Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferBolt12ParseErrorZ CResult_OfferBolt12ParseErrorZ_clone(const struct LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_NodeIdDecodeErrorZ in the success state. @@ -23971,6 +29264,32 @@ void CResult_NodeIdDecodeErrorZ_free(struct LDKCResult_NodeIdDecodeErrorZ _res); */ struct LDKCResult_NodeIdDecodeErrorZ CResult_NodeIdDecodeErrorZ_clone(const struct LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_PublicKeySecp256k1ErrorZ in the success state. + */ +struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_ok(struct LDKPublicKey o); + +/** + * Creates a new CResult_PublicKeySecp256k1ErrorZ in the error state. + */ +struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_err(enum LDKSecp256k1Error e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PublicKeySecp256k1ErrorZ_is_ok(const struct LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PublicKeySecp256k1ErrorZ. + */ +void CResult_PublicKeySecp256k1ErrorZ_free(struct LDKCResult_PublicKeySecp256k1ErrorZ _res); + +/** + * Creates a new CResult_PublicKeySecp256k1ErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PublicKeySecp256k1ErrorZ CResult_PublicKeySecp256k1ErrorZ_clone(const struct LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR orig); + /** * Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate */ @@ -24262,6 +29581,27 @@ void CResult_NodeAliasDecodeErrorZ_free(struct LDKCResult_NodeAliasDecodeErrorZ */ struct LDKCResult_NodeAliasDecodeErrorZ CResult_NodeAliasDecodeErrorZ_clone(const struct LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR orig); +/** + * Constructs a new COption_NodeAnnouncementInfoZ containing a crate::lightning::routing::gossip::NodeAnnouncementInfo + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_some(struct LDKNodeAnnouncementInfo o); + +/** + * Constructs a new COption_NodeAnnouncementInfoZ containing nothing + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::routing::gossip::NodeAnnouncementInfo, if we are in the Some state + */ +void COption_NodeAnnouncementInfoZ_free(struct LDKCOption_NodeAnnouncementInfoZ _res); + +/** + * Creates a new COption_NodeAnnouncementInfoZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_NodeAnnouncementInfoZ COption_NodeAnnouncementInfoZ_clone(const struct LDKCOption_NodeAnnouncementInfoZ *NONNULL_PTR orig); + /** * Creates a new CResult_NodeInfoDecodeErrorZ in the success state. */ @@ -24329,6 +29669,26 @@ void COption_CVec_SocketAddressZZ_free(struct LDKCOption_CVec_SocketAddressZZ _r */ struct LDKCOption_CVec_SocketAddressZZ COption_CVec_SocketAddressZZ_clone(const struct LDKCOption_CVec_SocketAddressZZ *NONNULL_PTR orig); +/** + * Creates a new CResult_u64ShortChannelIdErrorZ in the success state. + */ +struct LDKCResult_u64ShortChannelIdErrorZ CResult_u64ShortChannelIdErrorZ_ok(uint64_t o); + +/** + * Creates a new CResult_u64ShortChannelIdErrorZ in the error state. + */ +struct LDKCResult_u64ShortChannelIdErrorZ CResult_u64ShortChannelIdErrorZ_err(enum LDKShortChannelIdError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_u64ShortChannelIdErrorZ_is_ok(const struct LDKCResult_u64ShortChannelIdErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_u64ShortChannelIdErrorZ. + */ +void CResult_u64ShortChannelIdErrorZ_free(struct LDKCResult_u64ShortChannelIdErrorZ _res); + /** * Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ in the success state. */ @@ -24349,6 +29709,12 @@ bool CResult_PendingHTLCInfoInboundHTLCErrZ_is_ok(const struct LDKCResult_Pendin */ void CResult_PendingHTLCInfoInboundHTLCErrZ_free(struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ _res); +/** + * Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ CResult_PendingHTLCInfoInboundHTLCErrZ_clone(const struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ *NONNULL_PTR orig); + /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -24442,6 +29808,27 @@ void CResult_CVec_UtxoZNoneZ_free(struct LDKCResult_CVec_UtxoZNoneZ _res); */ struct LDKCResult_CVec_UtxoZNoneZ CResult_CVec_UtxoZNoneZ_clone(const struct LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR orig); +/** + * Constructs a new COption_PaymentContextZ containing a crate::lightning::blinded_path::payment::PaymentContext + */ +struct LDKCOption_PaymentContextZ COption_PaymentContextZ_some(struct LDKPaymentContext o); + +/** + * Constructs a new COption_PaymentContextZ containing nothing + */ +struct LDKCOption_PaymentContextZ COption_PaymentContextZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::blinded_path::payment::PaymentContext, if we are in the Some state + */ +void COption_PaymentContextZ_free(struct LDKCOption_PaymentContextZ _res); + +/** + * Creates a new COption_PaymentContextZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentContextZ COption_PaymentContextZ_clone(const struct LDKCOption_PaymentContextZ *NONNULL_PTR orig); + /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. @@ -24480,51 +29867,30 @@ void COption_C2Tuple_u64u16ZZ_free(struct LDKCOption_C2Tuple_u64u16ZZ _res); struct LDKCOption_C2Tuple_u64u16ZZ COption_C2Tuple_u64u16ZZ_clone(const struct LDKCOption_C2Tuple_u64u16ZZ *NONNULL_PTR orig); /** - * Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channelmanager::ChannelShutdownState + * Creates a new CResult_ChannelIdAPIErrorZ in the success state. */ -struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_some(enum LDKChannelShutdownState o); +struct LDKCResult_ChannelIdAPIErrorZ CResult_ChannelIdAPIErrorZ_ok(struct LDKChannelId o); /** - * Constructs a new COption_ChannelShutdownStateZ containing nothing + * Creates a new CResult_ChannelIdAPIErrorZ in the error state. */ -struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::ln::channelmanager::ChannelShutdownState, if we are in the Some state - */ -void COption_ChannelShutdownStateZ_free(struct LDKCOption_ChannelShutdownStateZ _res); - -/** - * Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_clone(const struct LDKCOption_ChannelShutdownStateZ *NONNULL_PTR orig); - -/** - * Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the success state. - */ -struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_ok(struct LDKThirtyTwoBytes o); - -/** - * Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the error state. - */ -struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_err(struct LDKAPIError e); +struct LDKCResult_ChannelIdAPIErrorZ CResult_ChannelIdAPIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ThirtyTwoBytesAPIErrorZ_is_ok(const struct LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR o); +bool CResult_ChannelIdAPIErrorZ_is_ok(const struct LDKCResult_ChannelIdAPIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ThirtyTwoBytesAPIErrorZ. + * Frees any resources used by the CResult_ChannelIdAPIErrorZ. */ -void CResult_ThirtyTwoBytesAPIErrorZ_free(struct LDKCResult_ThirtyTwoBytesAPIErrorZ _res); +void CResult_ChannelIdAPIErrorZ_free(struct LDKCResult_ChannelIdAPIErrorZ _res); /** - * Creates a new CResult_ThirtyTwoBytesAPIErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelIdAPIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_clone(const struct LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelIdAPIErrorZ CResult_ChannelIdAPIErrorZ_clone(const struct LDKCResult_ChannelIdAPIErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. @@ -24712,22 +30078,53 @@ struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ C * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(const struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR orig); +struct LDKC2Tuple_ChannelIdPublicKeyZ C2Tuple_ChannelIdPublicKeyZ_clone(const struct LDKC2Tuple_ChannelIdPublicKeyZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_ChannelIdPublicKeyZ from the contained elements. + */ +struct LDKC2Tuple_ChannelIdPublicKeyZ C2Tuple_ChannelIdPublicKeyZ_new(struct LDKChannelId a, struct LDKPublicKey b); /** - * Creates a new C2Tuple_ThirtyTwoBytesPublicKeyZ from the contained elements. + * Frees any resources used by the C2Tuple_ChannelIdPublicKeyZ. */ -struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ C2Tuple_ThirtyTwoBytesPublicKeyZ_new(struct LDKThirtyTwoBytes a, struct LDKPublicKey b); +void C2Tuple_ChannelIdPublicKeyZ_free(struct LDKC2Tuple_ChannelIdPublicKeyZ _res); /** - * Frees any resources used by the C2Tuple_ThirtyTwoBytesPublicKeyZ. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void C2Tuple_ThirtyTwoBytesPublicKeyZ_free(struct LDKC2Tuple_ThirtyTwoBytesPublicKeyZ _res); +void CVec_C2Tuple_ChannelIdPublicKeyZZ_free(struct LDKCVec_C2Tuple_ChannelIdPublicKeyZZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(struct LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ _res); +void CVec_ChannelIdZ_free(struct LDKCVec_ChannelIdZ _res); + +/** + * Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(struct LDKOfferWithDerivedMetadataBuilder o); + +/** + * Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ. + */ +void CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(const struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ *NONNULL_PTR orig); /** * Constructs a new COption_StrZ containing a crate::c_types::Str @@ -24751,176 +30148,193 @@ void COption_StrZ_free(struct LDKCOption_StrZ _res); struct LDKCOption_StrZ COption_StrZ_clone(const struct LDKCOption_StrZ *NONNULL_PTR orig); /** - * Creates a new CResult_NoneBolt12SemanticErrorZ in the success state. + * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the success state. */ -struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_ok(void); +struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o); /** - * Creates a new CResult_NoneBolt12SemanticErrorZ in the error state. + * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the error state. */ -struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); +struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err(void); /** * Checks if the given object is currently in the success state */ -bool CResult_NoneBolt12SemanticErrorZ_is_ok(const struct LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR o); +bool CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(const struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_NoneBolt12SemanticErrorZ. + * Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ. */ -void CResult_NoneBolt12SemanticErrorZ_free(struct LDKCResult_NoneBolt12SemanticErrorZ _res); +void CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ _res); /** - * Creates a new CResult_NoneBolt12SemanticErrorZ which has the same data as `orig` + * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_NoneBolt12SemanticErrorZ CResult_NoneBolt12SemanticErrorZ_clone(const struct LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR orig); +struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(const struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the success state. + * Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the success state. */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o); +struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_ok(struct LDKThirtyTwoBytes o); /** - * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the error state. + * Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the error state. */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err(void); +struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_err(struct LDKAPIError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(const struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR o); +bool CResult_ThirtyTwoBytesAPIErrorZ_is_ok(const struct LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ. + * Frees any resources used by the CResult_ThirtyTwoBytesAPIErrorZ. */ -void CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ _res); +void CResult_ThirtyTwoBytesAPIErrorZ_free(struct LDKCResult_ThirtyTwoBytesAPIErrorZ _res); /** - * Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ which has the same data as `orig` + * Creates a new CResult_ThirtyTwoBytesAPIErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(const struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR orig); +struct LDKCResult_ThirtyTwoBytesAPIErrorZ CResult_ThirtyTwoBytesAPIErrorZ_clone(const struct LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage + * Constructs a new COption_OffersContextZ containing a crate::lightning::blinded_path::message::OffersContext */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_some(struct LDKOffersMessage o); +struct LDKCOption_OffersContextZ COption_OffersContextZ_some(struct LDKOffersContext o); /** - * Constructs a new COption_OffersMessageZ containing nothing + * Constructs a new COption_OffersContextZ containing nothing */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_none(void); +struct LDKCOption_OffersContextZ COption_OffersContextZ_none(void); /** - * Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state + * Frees any resources associated with the crate::lightning::blinded_path::message::OffersContext, if we are in the Some state */ -void COption_OffersMessageZ_free(struct LDKCOption_OffersMessageZ _res); +void COption_OffersContextZ_free(struct LDKCOption_OffersContextZ _res); /** - * Creates a new COption_OffersMessageZ which has the same data as `orig` + * Creates a new COption_OffersContextZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_OffersMessageZ COption_OffersMessageZ_clone(const struct LDKCOption_OffersMessageZ *NONNULL_PTR orig); +struct LDKCOption_OffersContextZ COption_OffersContextZ_clone(const struct LDKCOption_OffersContextZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ C3Tuple_OffersMessageDestinationBlindedPathZ_clone(const struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR orig); +struct LDKC2Tuple_OffersMessageResponseInstructionZ C2Tuple_OffersMessageResponseInstructionZ_clone(const struct LDKC2Tuple_OffersMessageResponseInstructionZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_OffersMessageDestinationBlindedPathZ from the contained elements. + * Creates a new C2Tuple_OffersMessageResponseInstructionZ from the contained elements. */ -struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ C3Tuple_OffersMessageDestinationBlindedPathZ_new(struct LDKOffersMessage a, struct LDKDestination b, struct LDKBlindedPath c); +struct LDKC2Tuple_OffersMessageResponseInstructionZ C2Tuple_OffersMessageResponseInstructionZ_new(struct LDKOffersMessage a, struct LDKResponseInstruction b); /** - * Frees any resources used by the C3Tuple_OffersMessageDestinationBlindedPathZ. + * Frees any resources used by the C2Tuple_OffersMessageResponseInstructionZ. */ -void C3Tuple_OffersMessageDestinationBlindedPathZ_free(struct LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res); +void C2Tuple_OffersMessageResponseInstructionZ_free(struct LDKC2Tuple_OffersMessageResponseInstructionZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ */ -void CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(struct LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ _res); +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_some(struct LDKC2Tuple_OffersMessageResponseInstructionZ o); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. + * Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing nothing */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_none(void); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. + * Frees any resources associated with the crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ, if we are in the Some state */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); +void COption_C2Tuple_OffersMessageResponseInstructionZZ_free(struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new COption_C2Tuple_OffersMessageResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); +struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ COption_C2Tuple_OffersMessageResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); +struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ C2Tuple_OffersMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new C2Tuple_OffersMessageMessageSendInstructionsZ from the contained elements. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); +struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ C2Tuple_OffersMessageMessageSendInstructionsZ_new(struct LDKOffersMessage a, struct LDKMessageSendInstructions b); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. + * Frees any resources used by the C2Tuple_OffersMessageMessageSendInstructionsZ. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); +void C2Tuple_OffersMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_OffersMessageMessageSendInstructionsZ _res); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); +void CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); +struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ C2Tuple_ReleaseHeldHtlcResponseInstructionZ_clone(const struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. + * Creates a new C2Tuple_ReleaseHeldHtlcResponseInstructionZ from the contained elements. */ -void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); +struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ C2Tuple_ReleaseHeldHtlcResponseInstructionZ_new(struct LDKReleaseHeldHtlc a, struct LDKResponseInstruction b); /** - * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees any resources used by the C2Tuple_ReleaseHeldHtlcResponseInstructionZ. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); +void C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ _res); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. + * Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_some(struct LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ o); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + * Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing nothing */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ, if we are in the Some state */ -bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); +void COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ _res); /** - * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. + * Creates a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); +struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` + * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); +struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_clone(const struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ from the contained elements. + */ +struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_new(struct LDKAsyncPaymentsMessage a, struct LDKMessageSendInstructions b); + +/** + * Frees any resources used by the C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ. + */ +void C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(struct LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ _res); /** * Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. @@ -25052,32 +30466,6 @@ void CResult_BlindedFailureDecodeErrorZ_free(struct LDKCResult_BlindedFailureDec */ struct LDKCResult_BlindedFailureDecodeErrorZ CResult_BlindedFailureDecodeErrorZ_clone(const struct LDKCResult_BlindedFailureDecodeErrorZ *NONNULL_PTR orig); -/** - * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. - */ -struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_ok(enum LDKChannelShutdownState o); - -/** - * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. - */ -struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_err(struct LDKDecodeError e); - -/** - * Checks if the given object is currently in the success state - */ -bool CResult_ChannelShutdownStateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR o); - -/** - * Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. - */ -void CResult_ChannelShutdownStateDecodeErrorZ_free(struct LDKCResult_ChannelShutdownStateDecodeErrorZ _res); - -/** - * Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_clone(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR orig); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ @@ -25391,14 +30779,35 @@ void C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(struct LDKC2Tuple_Th void CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(struct LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new CResult_NoneReplayEventZ in the success state. */ -void CVec_CommitmentTransactionZ_free(struct LDKCVec_CommitmentTransactionZ _res); +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_ok(void); + +/** + * Creates a new CResult_NoneReplayEventZ in the error state. + */ +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_err(struct LDKReplayEvent e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NoneReplayEventZ_is_ok(const struct LDKCResult_NoneReplayEventZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NoneReplayEventZ. + */ +void CResult_NoneReplayEventZ_free(struct LDKCResult_NoneReplayEventZ _res); + +/** + * Creates a new CResult_NoneReplayEventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NoneReplayEventZ CResult_NoneReplayEventZ_clone(const struct LDKCResult_NoneReplayEventZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); +void CVec_CommitmentTransactionZ_free(struct LDKCVec_CommitmentTransactionZ _res); /** * Creates a new tuple which has the same data as `orig` @@ -25514,22 +30923,38 @@ void CVec_C2Tuple_PublicKeyTypeZZ_free(struct LDKCVec_C2Tuple_PublicKeyTypeZZ _r * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ C2Tuple_PublicKeyCVec_SocketAddressZZ_clone(const struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ *NONNULL_PTR orig); +struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ C2Tuple_OnionMessageContentsResponseInstructionZ_clone(const struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_PublicKeyCVec_SocketAddressZZ from the contained elements. + * Creates a new C2Tuple_OnionMessageContentsResponseInstructionZ from the contained elements. */ -struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ C2Tuple_PublicKeyCVec_SocketAddressZZ_new(struct LDKPublicKey a, struct LDKCVec_SocketAddressZ b); +struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ C2Tuple_OnionMessageContentsResponseInstructionZ_new(struct LDKOnionMessageContents a, struct LDKResponseInstruction b); /** - * Frees any resources used by the C2Tuple_PublicKeyCVec_SocketAddressZZ. + * Frees any resources used by the C2Tuple_OnionMessageContentsResponseInstructionZ. */ -void C2Tuple_PublicKeyCVec_SocketAddressZZ_free(struct LDKC2Tuple_PublicKeyCVec_SocketAddressZZ _res); +void C2Tuple_OnionMessageContentsResponseInstructionZ_free(struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + */ +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_some(struct LDKC2Tuple_OnionMessageContentsResponseInstructionZ o); + +/** + * Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing nothing + */ +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ, if we are in the Some state + */ +void COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ _res); + +/** + * Creates a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(struct LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ _res); +struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_clone(const struct LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ *NONNULL_PTR orig); /** * Constructs a new COption_OnionMessageContentsZ containing a crate::lightning::onion_message::packet::OnionMessageContents @@ -25582,22 +31007,22 @@ struct LDKCResult_COption_OnionMessageContentsZDecodeErrorZ CResult_COption_Onio * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(const struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR orig); +struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ C2Tuple_OnionMessageContentsMessageSendInstructionsZ_clone(const struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_OnionMessageContentsDestinationBlindedPathZ from the contained elements. + * Creates a new C2Tuple_OnionMessageContentsMessageSendInstructionsZ from the contained elements. */ -struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(struct LDKOnionMessageContents a, struct LDKDestination b, struct LDKBlindedPath c); +struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ C2Tuple_OnionMessageContentsMessageSendInstructionsZ_new(struct LDKOnionMessageContents a, struct LDKMessageSendInstructions b); /** - * Frees any resources used by the C3Tuple_OnionMessageContentsDestinationBlindedPathZ. + * Frees any resources used by the C2Tuple_OnionMessageContentsMessageSendInstructionsZ. */ -void C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(struct LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res); +void C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(struct LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(struct LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ _res); +void CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(struct LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ _res); /** * Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type @@ -25667,26 +31092,10 @@ void COption_SocketAddressZ_free(struct LDKCOption_SocketAddressZ _res); */ struct LDKCOption_SocketAddressZ COption_SocketAddressZ_clone(const struct LDKCOption_SocketAddressZ *NONNULL_PTR orig); -/** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(const struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR orig); - -/** - * Creates a new C2Tuple_PublicKeyCOption_SocketAddressZZ from the contained elements. - */ -struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ C2Tuple_PublicKeyCOption_SocketAddressZZ_new(struct LDKPublicKey a, struct LDKCOption_SocketAddressZ b); - -/** - * Frees any resources used by the C2Tuple_PublicKeyCOption_SocketAddressZZ. - */ -void C2Tuple_PublicKeyCOption_SocketAddressZZ_free(struct LDKC2Tuple_PublicKeyCOption_SocketAddressZZ _res); - /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(struct LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ _res); +void CVec_PeerDetailsZ_free(struct LDKCVec_PeerDetailsZ _res); /** * Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. @@ -25812,11 +31221,6 @@ void CResult_CVec_u8ZIOErrorZ_free(struct LDKCResult_CVec_u8ZIOErrorZ _res); */ struct LDKCResult_CVec_u8ZIOErrorZ CResult_CVec_u8ZIOErrorZ_clone(const struct LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR orig); -/** - * Frees the buffer pointed to by `data` if `datalen` is non-0. - */ -void CVec_StrZ_free(struct LDKCVec_StrZ _res); - /** * Creates a new CResult_CVec_StrZIOErrorZ in the success state. */ @@ -25901,25 +31305,76 @@ void CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(struct LDKCResul struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(const struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_SecretKeyZ containing a crate::c_types::SecretKey + * Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_ok(struct LDKUnsignedInvoiceRequest o); + +/** + * Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_is_ok(const struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ. + */ +void CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_free(struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_clone(const struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ CResult_InvoiceRequestBolt12SemanticErrorZ_ok(struct LDKInvoiceRequest o); + +/** + * Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ in the error state. */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_some(struct LDKSecretKey o); +struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ CResult_InvoiceRequestBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); /** - * Constructs a new COption_SecretKeyZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_none(void); +bool CResult_InvoiceRequestBolt12SemanticErrorZ_is_ok(const struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state + * Frees any resources used by the CResult_InvoiceRequestBolt12SemanticErrorZ. */ -void COption_SecretKeyZ_free(struct LDKCOption_SecretKeyZ _res); +void CResult_InvoiceRequestBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ _res); /** - * Creates a new COption_SecretKeyZ which has the same data as `orig` + * Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_SecretKeyZ COption_SecretKeyZ_clone(const struct LDKCOption_SecretKeyZ *NONNULL_PTR orig); +struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ CResult_InvoiceRequestBolt12SemanticErrorZ_clone(const struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_ok(struct LDKInvoiceWithExplicitSigningPubkeyBuilder o); + +/** + * Creates a new CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ. + */ +void CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ _res); /** * Creates a new CResult_VerifiedInvoiceRequestNoneZ in the success state. @@ -25947,6 +31402,52 @@ void CResult_VerifiedInvoiceRequestNoneZ_free(struct LDKCResult_VerifiedInvoiceR */ struct LDKCResult_VerifiedInvoiceRequestNoneZ CResult_VerifiedInvoiceRequestNoneZ_clone(const struct LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR orig); +/** + * Creates a new CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ in the success state. + */ +struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_ok(struct LDKInvoiceWithDerivedSigningPubkeyBuilder o); + +/** + * Creates a new CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ in the error state. + */ +struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_err(enum LDKBolt12SemanticError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_is_ok(const struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ. + */ +void CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ _res); + +/** + * Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ in the success state. + */ +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ CResult_InvoiceRequestFieldsDecodeErrorZ_ok(struct LDKInvoiceRequestFields o); + +/** + * Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ in the error state. + */ +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ CResult_InvoiceRequestFieldsDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_InvoiceRequestFieldsDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_InvoiceRequestFieldsDecodeErrorZ. + */ +void CResult_InvoiceRequestFieldsDecodeErrorZ_free(struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ _res); + +/** + * Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ CResult_InvoiceRequestFieldsDecodeErrorZ_clone(const struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ *NONNULL_PTR orig); + /** * Constructs a new COption_NoneZ containing a */ @@ -25967,6 +31468,27 @@ void COption_NoneZ_free(enum LDKCOption_NoneZ _res); */ void CVec_WitnessZ_free(struct LDKCVec_WitnessZ _res); +/** + * Constructs a new COption_ECDSASignatureZ containing a crate::c_types::ECDSASignature + */ +struct LDKCOption_ECDSASignatureZ COption_ECDSASignatureZ_some(struct LDKECDSASignature o); + +/** + * Constructs a new COption_ECDSASignatureZ containing nothing + */ +struct LDKCOption_ECDSASignatureZ COption_ECDSASignatureZ_none(void); + +/** + * Frees any resources associated with the crate::c_types::ECDSASignature, if we are in the Some state + */ +void COption_ECDSASignatureZ_free(struct LDKCOption_ECDSASignatureZ _res); + +/** + * Creates a new COption_ECDSASignatureZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_ECDSASignatureZ COption_ECDSASignatureZ_clone(const struct LDKCOption_ECDSASignatureZ *NONNULL_PTR orig); + /** * Constructs a new COption_i64Z containing a i64 */ @@ -26139,30 +31661,30 @@ void CResult_StfuDecodeErrorZ_free(struct LDKCResult_StfuDecodeErrorZ _res); struct LDKCResult_StfuDecodeErrorZ CResult_StfuDecodeErrorZ_clone(const struct LDKCResult_StfuDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_SpliceDecodeErrorZ in the success state. + * Creates a new CResult_SpliceInitDecodeErrorZ in the success state. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_ok(struct LDKSplice o); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_ok(struct LDKSpliceInit o); /** - * Creates a new CResult_SpliceDecodeErrorZ in the error state. + * Creates a new CResult_SpliceInitDecodeErrorZ in the error state. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_SpliceDecodeErrorZ_is_ok(const struct LDKCResult_SpliceDecodeErrorZ *NONNULL_PTR o); +bool CResult_SpliceInitDecodeErrorZ_is_ok(const struct LDKCResult_SpliceInitDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_SpliceDecodeErrorZ. + * Frees any resources used by the CResult_SpliceInitDecodeErrorZ. */ -void CResult_SpliceDecodeErrorZ_free(struct LDKCResult_SpliceDecodeErrorZ _res); +void CResult_SpliceInitDecodeErrorZ_free(struct LDKCResult_SpliceInitDecodeErrorZ _res); /** - * Creates a new CResult_SpliceDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_SpliceInitDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_SpliceDecodeErrorZ CResult_SpliceDecodeErrorZ_clone(const struct LDKCResult_SpliceDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_SpliceInitDecodeErrorZ CResult_SpliceInitDecodeErrorZ_clone(const struct LDKCResult_SpliceInitDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_SpliceAckDecodeErrorZ in the success state. @@ -26554,6 +32076,32 @@ void CResult_ClosingSignedFeeRangeDecodeErrorZ_free(struct LDKCResult_ClosingSig */ struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(const struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the success state. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_ok(struct LDKCommitmentSignedBatch o); + +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the error state. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CommitmentSignedBatchDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentSignedBatchDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CommitmentSignedBatchDecodeErrorZ. + */ +void CResult_CommitmentSignedBatchDecodeErrorZ_free(struct LDKCResult_CommitmentSignedBatchDecodeErrorZ _res); + +/** + * Creates a new CResult_CommitmentSignedBatchDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CResult_CommitmentSignedBatchDecodeErrorZ_clone(const struct LDKCResult_CommitmentSignedBatchDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. */ @@ -27387,428 +32935,756 @@ void CResult_GossipTimestampFilterDecodeErrorZ_free(struct LDKCResult_GossipTime struct LDKCResult_GossipTimestampFilterDecodeErrorZ CResult_GossipTimestampFilterDecodeErrorZ_clone(const struct LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR orig); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Constructs a new COption_InboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::InboundHTLCStateDetails */ -void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); +struct LDKCOption_InboundHTLCStateDetailsZ COption_InboundHTLCStateDetailsZ_some(enum LDKInboundHTLCStateDetails o); /** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. + * Constructs a new COption_InboundHTLCStateDetailsZ containing nothing */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(struct LDKBolt11Invoice o); +struct LDKCOption_InboundHTLCStateDetailsZ COption_InboundHTLCStateDetailsZ_none(void); /** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. + * Frees any resources associated with the crate::lightning::ln::channel_state::InboundHTLCStateDetails, if we are in the Some state */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); +void COption_InboundHTLCStateDetailsZ_free(struct LDKCOption_InboundHTLCStateDetailsZ _res); /** - * Checks if the given object is currently in the success state + * Creates a new COption_InboundHTLCStateDetailsZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -bool CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR o); +struct LDKCOption_InboundHTLCStateDetailsZ COption_InboundHTLCStateDetailsZ_clone(const struct LDKCOption_InboundHTLCStateDetailsZ *NONNULL_PTR orig); /** - * Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. + * Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ in the success state. */ -void CResult_Bolt11InvoiceSignOrCreationErrorZ_free(struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res); +struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_ok(struct LDKCOption_InboundHTLCStateDetailsZ o); /** - * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ in the error state. */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Checks if the given object is currently in the success state */ -void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); +bool CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_OffersMessageDecodeErrorZ in the success state. + * Frees any resources used by the CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ. */ -struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_ok(struct LDKOffersMessage o); +void CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ _res); /** - * Creates a new CResult_OffersMessageDecodeErrorZ in the error state. + * Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_clone(const struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_InboundHTLCDetailsDecodeErrorZ in the success state. + */ +struct LDKCResult_InboundHTLCDetailsDecodeErrorZ CResult_InboundHTLCDetailsDecodeErrorZ_ok(struct LDKInboundHTLCDetails o); + +/** + * Creates a new CResult_InboundHTLCDetailsDecodeErrorZ in the error state. + */ +struct LDKCResult_InboundHTLCDetailsDecodeErrorZ CResult_InboundHTLCDetailsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_OffersMessageDecodeErrorZ_is_ok(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR o); +bool CResult_InboundHTLCDetailsDecodeErrorZ_is_ok(const struct LDKCResult_InboundHTLCDetailsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_OffersMessageDecodeErrorZ. + * Frees any resources used by the CResult_InboundHTLCDetailsDecodeErrorZ. */ -void CResult_OffersMessageDecodeErrorZ_free(struct LDKCResult_OffersMessageDecodeErrorZ _res); +void CResult_InboundHTLCDetailsDecodeErrorZ_free(struct LDKCResult_InboundHTLCDetailsDecodeErrorZ _res); /** - * Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_InboundHTLCDetailsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_clone(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_InboundHTLCDetailsDecodeErrorZ CResult_InboundHTLCDetailsDecodeErrorZ_clone(const struct LDKCResult_InboundHTLCDetailsDecodeErrorZ *NONNULL_PTR orig); /** - * Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim + * Constructs a new COption_OutboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::OutboundHTLCStateDetails */ -struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_some(enum LDKHTLCClaim o); +struct LDKCOption_OutboundHTLCStateDetailsZ COption_OutboundHTLCStateDetailsZ_some(enum LDKOutboundHTLCStateDetails o); /** - * Constructs a new COption_HTLCClaimZ containing nothing + * Constructs a new COption_OutboundHTLCStateDetailsZ containing nothing */ -struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_none(void); +struct LDKCOption_OutboundHTLCStateDetailsZ COption_OutboundHTLCStateDetailsZ_none(void); /** - * Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state + * Frees any resources associated with the crate::lightning::ln::channel_state::OutboundHTLCStateDetails, if we are in the Some state */ -void COption_HTLCClaimZ_free(struct LDKCOption_HTLCClaimZ _res); +void COption_OutboundHTLCStateDetailsZ_free(struct LDKCOption_OutboundHTLCStateDetailsZ _res); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. + * Creates a new COption_OutboundHTLCStateDetailsZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); +struct LDKCOption_OutboundHTLCStateDetailsZ COption_OutboundHTLCStateDetailsZ_clone(const struct LDKCOption_OutboundHTLCStateDetailsZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. + * Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ in the success state. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_ok(struct LDKCOption_OutboundHTLCStateDetailsZ o); + +/** + * Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ in the error state. + */ +struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); +bool CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_is_ok(const struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. + * Frees any resources used by the CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ. */ -void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); +void CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_free(struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ _res); /** - * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_clone(const struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. + * Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ in the success state. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); +struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ CResult_OutboundHTLCDetailsDecodeErrorZ_ok(struct LDKOutboundHTLCDetails o); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. + * Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ in the error state. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ CResult_OutboundHTLCDetailsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); +bool CResult_OutboundHTLCDetailsDecodeErrorZ_is_ok(const struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. + * Frees any resources used by the CResult_OutboundHTLCDetailsDecodeErrorZ. */ -void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); +void CResult_OutboundHTLCDetailsDecodeErrorZ_free(struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ _res); /** - * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ CResult_OutboundHTLCDetailsDecodeErrorZ_clone(const struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(struct LDKCounterpartyForwardingInfo o); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); +bool CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + * Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. */ -void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); +void CResult_CounterpartyForwardingInfoDecodeErrorZ_free(struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res); /** - * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(const struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_ok(struct LDKChannelCounterparty o); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelCounterpartyDecodeErrorZ_is_ok(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + * Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. */ -void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); +void CResult_ChannelCounterpartyDecodeErrorZ_free(struct LDKCResult_ChannelCounterpartyDecodeErrorZ _res); /** - * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelCounterpartyDecodeErrorZ CResult_ChannelCounterpartyDecodeErrorZ_clone(const struct LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + * Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channel_state::ChannelShutdownState */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_some(enum LDKChannelShutdownState o); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + * Constructs a new COption_ChannelShutdownStateZ containing nothing */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_none(void); /** - * Checks if the given object is currently in the success state + * Frees any resources associated with the crate::lightning::ln::channel_state::ChannelShutdownState, if we are in the Some state */ -bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); +void COption_ChannelShutdownStateZ_free(struct LDKCOption_ChannelShutdownStateZ _res); /** - * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. + * Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); +struct LDKCOption_ChannelShutdownStateZ COption_ChannelShutdownStateZ_clone(const struct LDKCOption_ChannelShutdownStateZ *NONNULL_PTR orig); /** - * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +void CVec_InboundHTLCDetailsZ_free(struct LDKCVec_InboundHTLCDetailsZ _res); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); +void CVec_OutboundHTLCDetailsZ_free(struct LDKCVec_OutboundHTLCDetailsZ _res); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_ok(struct LDKChannelDetails o); + +/** + * Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelDetailsDecodeErrorZ_is_ok(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + * Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. */ -void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); +void CResult_ChannelDetailsDecodeErrorZ_free(struct LDKCResult_ChannelDetailsDecodeErrorZ _res); /** - * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelDetailsDecodeErrorZ CResult_ChannelDetailsDecodeErrorZ_clone(const struct LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_ok(enum LDKChannelShutdownState o); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelShutdownStateDecodeErrorZ_is_ok(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. */ -void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); +void CResult_ChannelShutdownStateDecodeErrorZ_free(struct LDKCResult_ChannelShutdownStateDecodeErrorZ _res); /** - * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelShutdownStateDecodeErrorZ CResult_ChannelShutdownStateDecodeErrorZ_clone(const struct LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); +void CVec_FutureZ_free(struct LDKCVec_FutureZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the success state. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_ok(struct LDKHeldHtlcAvailable o); + +/** + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the error state. + */ +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult_HeldHtlcAvailableDecodeErrorZ_is_ok(const struct LDKCResult_HeldHtlcAvailableDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult_HeldHtlcAvailableDecodeErrorZ. */ -void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); +void CResult_HeldHtlcAvailableDecodeErrorZ_free(struct LDKCResult_HeldHtlcAvailableDecodeErrorZ _res); /** - * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_HeldHtlcAvailableDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ CResult_HeldHtlcAvailableDecodeErrorZ_clone(const struct LDKCResult_HeldHtlcAvailableDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the success state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_ok(struct LDKReleaseHeldHtlc o); /** - * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the error state. */ -struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o); +bool CResult_ReleaseHeldHtlcDecodeErrorZ_is_ok(const struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. + * Frees any resources used by the CResult_ReleaseHeldHtlcDecodeErrorZ. */ -void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); +void CResult_ReleaseHeldHtlcDecodeErrorZ_free(struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + * Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ CResult_ReleaseHeldHtlcDecodeErrorZ_clone(const struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the success state. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_ok(struct LDKAsyncPaymentsMessage o); + +/** + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the error state. + */ +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); +bool CResult_AsyncPaymentsMessageDecodeErrorZ_is_ok(const struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + * Frees any resources used by the CResult_AsyncPaymentsMessageDecodeErrorZ. */ -void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); +void CResult_AsyncPaymentsMessageDecodeErrorZ_free(struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ _res); /** - * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ CResult_AsyncPaymentsMessageDecodeErrorZ_clone(const struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + * Creates a new CResult_OffersMessageDecodeErrorZ in the success state. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_ok(struct LDKOffersMessage o); /** - * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + * Creates a new CResult_OffersMessageDecodeErrorZ in the error state. */ -struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); +bool CResult_OffersMessageDecodeErrorZ_is_ok(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + * Frees any resources used by the CResult_OffersMessageDecodeErrorZ. */ -void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); +void CResult_OffersMessageDecodeErrorZ_free(struct LDKCResult_OffersMessageDecodeErrorZ _res); /** - * Creates a new CResult_CVec_ECDSASignatureZNoneZ in the success state. + * Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_ok(struct LDKCVec_ECDSASignatureZ o); +struct LDKCResult_OffersMessageDecodeErrorZ CResult_OffersMessageDecodeErrorZ_clone(const struct LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_CVec_ECDSASignatureZNoneZ in the error state. + * Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim */ -struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_err(void); +struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_some(enum LDKHTLCClaim o); /** - * Checks if the given object is currently in the success state + * Constructs a new COption_HTLCClaimZ containing nothing */ -bool CResult_CVec_ECDSASignatureZNoneZ_is_ok(const struct LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR o); +struct LDKCOption_HTLCClaimZ COption_HTLCClaimZ_none(void); /** - * Frees any resources used by the CResult_CVec_ECDSASignatureZNoneZ. + * Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state */ -void CResult_CVec_ECDSASignatureZNoneZ_free(struct LDKCResult_CVec_ECDSASignatureZNoneZ _res); +void COption_HTLCClaimZ_free(struct LDKCOption_HTLCClaimZ _res); /** - * Creates a new CResult_CVec_ECDSASignatureZNoneZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. */ -struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_clone(const struct LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR orig); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(struct LDKCounterpartyCommitmentSecrets o); /** - * Constructs a new COption_usizeZ containing a usize + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. */ -struct LDKCOption_usizeZ COption_usizeZ_some(uintptr_t o); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(struct LDKDecodeError e); /** - * Constructs a new COption_usizeZ containing nothing + * Checks if the given object is currently in the success state */ -struct LDKCOption_usizeZ COption_usizeZ_none(void); +bool CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources associated with the usize, if we are in the Some state + * Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. */ -void COption_usizeZ_free(struct LDKCOption_usizeZ _res); +void CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res); /** - * Creates a new COption_usizeZ which has the same data as `orig` + * Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCOption_usizeZ COption_usizeZ_clone(const struct LDKCOption_usizeZ *NONNULL_PTR orig); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(const struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_ok(struct LDKTxCreationKeys o); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. + * Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); +bool CResult_TxCreationKeysDecodeErrorZ_is_ok(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. + * Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. */ -void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); +void CResult_TxCreationKeysDecodeErrorZ_free(struct LDKCResult_TxCreationKeysDecodeErrorZ _res); /** - * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TxCreationKeysDecodeErrorZ CResult_TxCreationKeysDecodeErrorZ_clone(const struct LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_ok(struct LDKChannelPublicKeys o); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelPublicKeysDecodeErrorZ_is_ok(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. + */ +void CResult_ChannelPublicKeysDecodeErrorZ_free(struct LDKCResult_ChannelPublicKeysDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelPublicKeysDecodeErrorZ CResult_ChannelPublicKeysDecodeErrorZ_clone(const struct LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(struct LDKHTLCOutputInCommitment o); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. + */ +void CResult_HTLCOutputInCommitmentDecodeErrorZ_free(struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res); + +/** + * Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(const struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(struct LDKCounterpartyChannelTransactionParameters o); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. + */ +void CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_ok(struct LDKChannelTransactionParameters o); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. + */ +void CResult_ChannelTransactionParametersDecodeErrorZ_free(struct LDKCResult_ChannelTransactionParametersDecodeErrorZ _res); + +/** + * Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ CResult_ChannelTransactionParametersDecodeErrorZ_clone(const struct LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_ok(struct LDKHolderCommitmentTransaction o); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. + */ +void CResult_HolderCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ CResult_HolderCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(struct LDKBuiltCommitmentTransaction o); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. + */ +void CResult_BuiltCommitmentTransactionDecodeErrorZ_free(struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. + */ +struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_ok(struct LDKTrustedClosingTransaction o); + +/** + * Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. + */ +struct LDKCResult_TrustedClosingTransactionNoneZ CResult_TrustedClosingTransactionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TrustedClosingTransactionNoneZ_is_ok(const struct LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. + */ +void CResult_TrustedClosingTransactionNoneZ_free(struct LDKCResult_TrustedClosingTransactionNoneZ _res); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_ok(struct LDKCommitmentTransaction o); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CommitmentTransactionDecodeErrorZ_is_ok(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. + */ +void CResult_CommitmentTransactionDecodeErrorZ_free(struct LDKCResult_CommitmentTransactionDecodeErrorZ _res); + +/** + * Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CommitmentTransactionDecodeErrorZ CResult_CommitmentTransactionDecodeErrorZ_clone(const struct LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. + */ +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_ok(struct LDKTrustedCommitmentTransaction o); + +/** + * Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. + */ +struct LDKCResult_TrustedCommitmentTransactionNoneZ CResult_TrustedCommitmentTransactionNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_TrustedCommitmentTransactionNoneZ_is_ok(const struct LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. + */ +void CResult_TrustedCommitmentTransactionNoneZ_free(struct LDKCResult_TrustedCommitmentTransactionNoneZ _res); + +/** + * Creates a new CResult_CVec_ECDSASignatureZNoneZ in the success state. + */ +struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_ok(struct LDKCVec_ECDSASignatureZ o); + +/** + * Creates a new CResult_CVec_ECDSASignatureZNoneZ in the error state. + */ +struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_CVec_ECDSASignatureZNoneZ_is_ok(const struct LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_CVec_ECDSASignatureZNoneZ. + */ +void CResult_CVec_ECDSASignatureZNoneZ_free(struct LDKCResult_CVec_ECDSASignatureZNoneZ _res); + +/** + * Creates a new CResult_CVec_ECDSASignatureZNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_CVec_ECDSASignatureZNoneZ CResult_CVec_ECDSASignatureZNoneZ_clone(const struct LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_usizeZ containing a usize + */ +struct LDKCOption_usizeZ COption_usizeZ_some(uintptr_t o); + +/** + * Constructs a new COption_usizeZ containing nothing + */ +struct LDKCOption_usizeZ COption_usizeZ_none(void); + +/** + * Frees any resources associated with the usize, if we are in the Some state + */ +void COption_usizeZ_free(struct LDKCOption_usizeZ _res); + +/** + * Creates a new COption_usizeZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_usizeZ COption_usizeZ_clone(const struct LDKCOption_usizeZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. + */ +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_ok(struct LDKShutdownScript o); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. + */ +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_ShutdownScriptDecodeErrorZ_is_ok(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. + */ +void CResult_ShutdownScriptDecodeErrorZ_free(struct LDKCResult_ShutdownScriptDecodeErrorZ _res); + +/** + * Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ShutdownScriptDecodeErrorZ CResult_ShutdownScriptDecodeErrorZ_clone(const struct LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. @@ -27836,6 +33712,37 @@ void CResult_ShutdownScriptInvalidShutdownScriptZ_free(struct LDKCResult_Shutdow */ struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ CResult_ShutdownScriptInvalidShutdownScriptZ_clone(const struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR orig); +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TransactionZ_free(struct LDKCVec_TransactionZ _res); + +/** + * Creates a new CResult_FundingInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_ok(struct LDKFundingInfo o); + +/** + * Creates a new CResult_FundingInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_FundingInfoDecodeErrorZ_is_ok(const struct LDKCResult_FundingInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_FundingInfoDecodeErrorZ. + */ +void CResult_FundingInfoDecodeErrorZ_free(struct LDKCResult_FundingInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_FundingInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_FundingInfoDecodeErrorZ CResult_FundingInfoDecodeErrorZ_clone(const struct LDKCResult_FundingInfoDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. */ @@ -28030,30 +33937,51 @@ void CResult_COption_HTLCDestinationZDecodeErrorZ_free(struct LDKCResult_COption struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ CResult_COption_HTLCDestinationZDecodeErrorZ_clone(const struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. + * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); + +/** + * Constructs a new COption_PaymentFailureReasonZ containing nothing + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state + */ +void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); + +/** + * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the success state. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_ok(enum LDKPaymentFailureReason o); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_ok(struct LDKCOption_PaymentFailureReasonZ o); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the error state. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_PaymentFailureReasonDecodeErrorZ_is_ok(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR o); +bool CResult_COption_PaymentFailureReasonZDecodeErrorZ_is_ok(const struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. + * Frees any resources used by the CResult_COption_PaymentFailureReasonZDecodeErrorZ. */ -void CResult_PaymentFailureReasonDecodeErrorZ_free(struct LDKCResult_PaymentFailureReasonDecodeErrorZ _res); +void CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ _res); /** - * Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ CResult_PaymentFailureReasonDecodeErrorZ_clone(const struct LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ CResult_COption_PaymentFailureReasonZDecodeErrorZ_clone(const struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ *NONNULL_PTR orig); /** * Constructs a new COption_U128Z containing a crate::c_types::U128 @@ -28081,27 +34009,6 @@ struct LDKCOption_U128Z COption_U128Z_clone(const struct LDKCOption_U128Z *NONNU */ void CVec_ClaimedHTLCZ_free(struct LDKCVec_ClaimedHTLCZ _res); -/** - * Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason - */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_some(enum LDKPaymentFailureReason o); - -/** - * Constructs a new COption_PaymentFailureReasonZ containing nothing - */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state - */ -void COption_PaymentFailureReasonZ_free(struct LDKCOption_PaymentFailureReasonZ _res); - -/** - * Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. - */ -struct LDKCOption_PaymentFailureReasonZ COption_PaymentFailureReasonZ_clone(const struct LDKCOption_PaymentFailureReasonZ *NONNULL_PTR orig); - /** * Constructs a new COption_EventZ containing a crate::lightning::events::Event */ @@ -28149,6 +34056,37 @@ void CResult_COption_EventZDecodeErrorZ_free(struct LDKCResult_COption_EventZDec */ struct LDKCResult_COption_EventZDecodeErrorZ CResult_COption_EventZDecodeErrorZ_clone(const struct LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_NonceDecodeErrorZ in the success state. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_ok(struct LDKNonce o); + +/** + * Creates a new CResult_NonceDecodeErrorZ in the error state. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_NonceDecodeErrorZ_is_ok(const struct LDKCResult_NonceDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_NonceDecodeErrorZ. + */ +void CResult_NonceDecodeErrorZ_free(struct LDKCResult_NonceDecodeErrorZ _res); + +/** + * Creates a new CResult_NonceDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_NonceDecodeErrorZ CResult_NonceDecodeErrorZ_clone(const struct LDKCResult_NonceDecodeErrorZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_RouteHintHopZ_free(struct LDKCVec_RouteHintHopZ _res); + /** * Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. */ @@ -28456,6 +34394,32 @@ void CResult_BigSizeDecodeErrorZ_free(struct LDKCResult_BigSizeDecodeErrorZ _res */ struct LDKCResult_BigSizeDecodeErrorZ CResult_BigSizeDecodeErrorZ_clone(const struct LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR orig); +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. + */ +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); + +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. + */ +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_UntrustedStringDecodeErrorZ_is_ok(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. + */ +void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); + +/** + * Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_clone(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_HostnameDecodeErrorZ in the success state. */ @@ -28535,30 +34499,30 @@ void CResult_TransactionU16LenLimitedDecodeErrorZ_free(struct LDKCResult_Transac struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ CResult_TransactionU16LenLimitedDecodeErrorZ_clone(const struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. + * Creates a new CResult_ChannelIdDecodeErrorZ in the success state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_ok(struct LDKUntrustedString o); +struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_ok(struct LDKChannelId o); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. + * Creates a new CResult_ChannelIdDecodeErrorZ in the error state. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_UntrustedStringDecodeErrorZ_is_ok(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR o); +bool CResult_ChannelIdDecodeErrorZ_is_ok(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. + * Frees any resources used by the CResult_ChannelIdDecodeErrorZ. */ -void CResult_UntrustedStringDecodeErrorZ_free(struct LDKCResult_UntrustedStringDecodeErrorZ _res); +void CResult_ChannelIdDecodeErrorZ_free(struct LDKCResult_ChannelIdDecodeErrorZ _res); /** - * Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_ChannelIdDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_UntrustedStringDecodeErrorZ CResult_UntrustedStringDecodeErrorZ_clone(const struct LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_ChannelIdDecodeErrorZ CResult_ChannelIdDecodeErrorZ_clone(const struct LDKCResult_ChannelIdDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new tuple which has the same data as `orig` @@ -28576,6 +34540,63 @@ struct LDKC2Tuple__u832u16Z C2Tuple__u832u16Z_new(struct LDKThirtyTwoBytes a, ui */ void C2Tuple__u832u16Z_free(struct LDKC2Tuple__u832u16Z _res); +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_ok(struct LDKBlindedPayInfo o); + +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedPayInfoDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. + */ +void CResult_BlindedPayInfoDecodeErrorZ_free(struct LDKCResult_BlindedPayInfoDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedPayInfoDecodeErrorZ CResult_BlindedPayInfoDecodeErrorZ_clone(const struct LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BlindedPaymentPathNoneZ in the success state. + */ +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_ok(struct LDKBlindedPaymentPath o); + +/** + * Creates a new CResult_BlindedPaymentPathNoneZ in the error state. + */ +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedPaymentPathNoneZ_is_ok(const struct LDKCResult_BlindedPaymentPathNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedPaymentPathNoneZ. + */ +void CResult_BlindedPaymentPathNoneZ_free(struct LDKCResult_BlindedPaymentPathNoneZ _res); + +/** + * Creates a new CResult_BlindedPaymentPathNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedPaymentPathNoneZ CResult_BlindedPaymentPathNoneZ_clone(const struct LDKCResult_BlindedPaymentPathNoneZ *NONNULL_PTR orig); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_PaymentForwardNodeZ_free(struct LDKCVec_PaymentForwardNodeZ _res); + /** * Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. */ @@ -28629,72 +34650,108 @@ void CResult_PaymentConstraintsDecodeErrorZ_free(struct LDKCResult_PaymentConstr struct LDKCResult_PaymentConstraintsDecodeErrorZ CResult_PaymentConstraintsDecodeErrorZ_clone(const struct LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` + * Creates a new CResult_PaymentContextDecodeErrorZ in the success state. + */ +struct LDKCResult_PaymentContextDecodeErrorZ CResult_PaymentContextDecodeErrorZ_ok(struct LDKPaymentContext o); + +/** + * Creates a new CResult_PaymentContextDecodeErrorZ in the error state. + */ +struct LDKCResult_PaymentContextDecodeErrorZ CResult_PaymentContextDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_PaymentContextDecodeErrorZ_is_ok(const struct LDKCResult_PaymentContextDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_PaymentContextDecodeErrorZ. + */ +void CResult_PaymentContextDecodeErrorZ_free(struct LDKCResult_PaymentContextDecodeErrorZ _res); + +/** + * Creates a new CResult_PaymentContextDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(const struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ *NONNULL_PTR orig); +struct LDKCResult_PaymentContextDecodeErrorZ CResult_PaymentContextDecodeErrorZ_clone(const struct LDKCResult_PaymentContextDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. + * Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the success state. */ -struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(struct LDKThirtyTwoBytes a, struct LDKRecipientOnionFields b, struct LDKRouteParameters c); +struct LDKCResult_UnknownPaymentContextDecodeErrorZ CResult_UnknownPaymentContextDecodeErrorZ_ok(struct LDKUnknownPaymentContext o); /** - * Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. + * Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the error state. */ -void C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ _res); +struct LDKCResult_UnknownPaymentContextDecodeErrorZ CResult_UnknownPaymentContextDecodeErrorZ_err(struct LDKDecodeError e); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. + * Checks if the given object is currently in the success state */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(struct LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ o); +bool CResult_UnknownPaymentContextDecodeErrorZ_is_ok(const struct LDKCResult_UnknownPaymentContextDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. + * Frees any resources used by the CResult_UnknownPaymentContextDecodeErrorZ. */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err(void); +void CResult_UnknownPaymentContextDecodeErrorZ_free(struct LDKCResult_UnknownPaymentContextDecodeErrorZ _res); + +/** + * Creates a new CResult_UnknownPaymentContextDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_UnknownPaymentContextDecodeErrorZ CResult_UnknownPaymentContextDecodeErrorZ_clone(const struct LDKCResult_UnknownPaymentContextDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the success state. + */ +struct LDKCResult_Bolt12OfferContextDecodeErrorZ CResult_Bolt12OfferContextDecodeErrorZ_ok(struct LDKBolt12OfferContext o); + +/** + * Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the error state. + */ +struct LDKCResult_Bolt12OfferContextDecodeErrorZ CResult_Bolt12OfferContextDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR o); +bool CResult_Bolt12OfferContextDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12OfferContextDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. + * Frees any resources used by the CResult_Bolt12OfferContextDecodeErrorZ. */ -void CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ _res); +void CResult_Bolt12OfferContextDecodeErrorZ_free(struct LDKCResult_Bolt12OfferContextDecodeErrorZ _res); /** - * Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` + * Creates a new CResult_Bolt12OfferContextDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(const struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ *NONNULL_PTR orig); +struct LDKCResult_Bolt12OfferContextDecodeErrorZ CResult_Bolt12OfferContextDecodeErrorZ_clone(const struct LDKCResult_Bolt12OfferContextDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_StrSecp256k1ErrorZ in the success state. + * Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the success state. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_ok(struct LDKStr o); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ CResult_Bolt12RefundContextDecodeErrorZ_ok(struct LDKBolt12RefundContext o); /** - * Creates a new CResult_StrSecp256k1ErrorZ in the error state. + * Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the error state. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_err(enum LDKSecp256k1Error e); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ CResult_Bolt12RefundContextDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_StrSecp256k1ErrorZ_is_ok(const struct LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR o); +bool CResult_Bolt12RefundContextDecodeErrorZ_is_ok(const struct LDKCResult_Bolt12RefundContextDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_StrSecp256k1ErrorZ. + * Frees any resources used by the CResult_Bolt12RefundContextDecodeErrorZ. */ -void CResult_StrSecp256k1ErrorZ_free(struct LDKCResult_StrSecp256k1ErrorZ _res); +void CResult_Bolt12RefundContextDecodeErrorZ_free(struct LDKCResult_Bolt12RefundContextDecodeErrorZ _res); /** - * Creates a new CResult_StrSecp256k1ErrorZ which has the same data as `orig` + * Creates a new CResult_Bolt12RefundContextDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_StrSecp256k1ErrorZ CResult_StrSecp256k1ErrorZ_clone(const struct LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR orig); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ CResult_Bolt12RefundContextDecodeErrorZ_clone(const struct LDKCResult_Bolt12RefundContextDecodeErrorZ *NONNULL_PTR orig); /** * Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. @@ -28723,25 +34780,72 @@ void CResult_TxOutUtxoLookupErrorZ_free(struct LDKCResult_TxOutUtxoLookupErrorZ struct LDKCResult_TxOutUtxoLookupErrorZ CResult_TxOutUtxoLookupErrorZ_clone(const struct LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR orig); /** - * Creates a new tuple which has the same data as `orig` - * but with all dynamically-allocated buffers duplicated in new buffers. + * Creates a new CResult_ResponderDecodeErrorZ in the success state. */ -struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(const struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ *NONNULL_PTR orig); +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_ok(struct LDKResponder o); /** - * Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. + * Creates a new CResult_ResponderDecodeErrorZ in the error state. */ -struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(struct LDKPublicKey a, struct LDKOnionMessage b, struct LDKCOption_CVec_SocketAddressZZ c); +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_err(struct LDKDecodeError e); /** - * Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. + * Checks if the given object is currently in the success state */ -void C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ _res); +bool CResult_ResponderDecodeErrorZ_is_ok(const struct LDKCResult_ResponderDecodeErrorZ *NONNULL_PTR o); /** - * Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. + * Frees any resources used by the CResult_ResponderDecodeErrorZ. */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ o); +void CResult_ResponderDecodeErrorZ_free(struct LDKCResult_ResponderDecodeErrorZ _res); + +/** + * Creates a new CResult_ResponderDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_ResponderDecodeErrorZ CResult_ResponderDecodeErrorZ_clone(const struct LDKCResult_ResponderDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_MessageContextZ containing a crate::lightning::blinded_path::message::MessageContext + */ +struct LDKCOption_MessageContextZ COption_MessageContextZ_some(struct LDKMessageContext o); + +/** + * Constructs a new COption_MessageContextZ containing nothing + */ +struct LDKCOption_MessageContextZ COption_MessageContextZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::blinded_path::message::MessageContext, if we are in the Some state + */ +void COption_MessageContextZ_free(struct LDKCOption_MessageContextZ _res); + +/** + * Creates a new COption_MessageContextZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCOption_MessageContextZ COption_MessageContextZ_clone(const struct LDKCOption_MessageContextZ *NONNULL_PTR orig); + +/** + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(const struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ *NONNULL_PTR orig); + +/** + * Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. + */ +struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(struct LDKPublicKey a, struct LDKOnionMessage b, struct LDKCOption_CVec_SocketAddressZZ c); + +/** + * Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. + */ +void C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ _res); + +/** + * Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. + */ +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(struct LDKC3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ o); /** * Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the error state. @@ -28758,6 +34862,12 @@ bool CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendError */ void CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_free(struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ _res); +/** + * Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_clone(const struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ *NONNULL_PTR orig); + /** * Creates a new CResult_PeeledOnionNoneZ in the success state. */ @@ -28778,6 +34888,12 @@ bool CResult_PeeledOnionNoneZ_is_ok(const struct LDKCResult_PeeledOnionNoneZ *NO */ void CResult_PeeledOnionNoneZ_free(struct LDKCResult_PeeledOnionNoneZ _res); +/** + * Creates a new CResult_PeeledOnionNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_PeeledOnionNoneZ CResult_PeeledOnionNoneZ_clone(const struct LDKCResult_PeeledOnionNoneZ *NONNULL_PTR orig); + /** * Creates a new CResult_SendSuccessSendErrorZ in the success state. */ @@ -28799,139 +34915,241 @@ bool CResult_SendSuccessSendErrorZ_is_ok(const struct LDKCResult_SendSuccessSend void CResult_SendSuccessSendErrorZ_free(struct LDKCResult_SendSuccessSendErrorZ _res); /** - * Creates a new CResult_BlindedPathNoneZ in the success state. + * Creates a new CResult_SendSuccessSendErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_SendSuccessSendErrorZ CResult_SendSuccessSendErrorZ_clone(const struct LDKCResult_SendSuccessSendErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_NoneSendErrorZ in the success state. */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_ok(struct LDKBlindedPath o); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_ok(void); /** - * Creates a new CResult_BlindedPathNoneZ in the error state. + * Creates a new CResult_NoneSendErrorZ in the error state. */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_err(void); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_err(struct LDKSendError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedPathNoneZ_is_ok(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR o); +bool CResult_NoneSendErrorZ_is_ok(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPathNoneZ. + * Frees any resources used by the CResult_NoneSendErrorZ. */ -void CResult_BlindedPathNoneZ_free(struct LDKCResult_BlindedPathNoneZ _res); +void CResult_NoneSendErrorZ_free(struct LDKCResult_NoneSendErrorZ _res); /** - * Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` + * Creates a new CResult_NoneSendErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedPathNoneZ CResult_BlindedPathNoneZ_clone(const struct LDKCResult_BlindedPathNoneZ *NONNULL_PTR orig); +struct LDKCResult_NoneSendErrorZ CResult_NoneSendErrorZ_clone(const struct LDKCResult_NoneSendErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the success state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(struct LDKC2Tuple_BlindedPayInfoBlindedPathZ o); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); /** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the error state. + * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err(void); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(const struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR o); +bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ. + * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. */ -void CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ _res); +void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); /** - * Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ which has the same data as `orig` + * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(const struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR orig); +struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_ForwardNodeZ_free(struct LDKCVec_ForwardNodeZ _res); +void CVec_PhantomRouteHintsZ_free(struct LDKCVec_PhantomRouteHintsZ _res); /** - * Creates a new CResult_BlindedPathDecodeErrorZ in the success state. + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_ok(struct LDKBlindedPath o); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(struct LDKBolt11Invoice o); /** - * Creates a new CResult_BlindedPathDecodeErrorZ in the error state. + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_err(struct LDKSignOrCreationError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedPathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR o); +bool CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedPathDecodeErrorZ. + * Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. */ -void CResult_BlindedPathDecodeErrorZ_free(struct LDKCResult_BlindedPathDecodeErrorZ _res); +void CResult_Bolt11InvoiceSignOrCreationErrorZ_free(struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res); /** - * Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedPathDecodeErrorZ CResult_BlindedPathDecodeErrorZ_clone(const struct LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(const struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. + * Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_ok(struct LDKBlindedHop o); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_ok(struct LDKInvoiceError o); /** - * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. + * Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_BlindedHopDecodeErrorZ_is_ok(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR o); +bool CResult_InvoiceErrorDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_BlindedHopDecodeErrorZ. + * Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. */ -void CResult_BlindedHopDecodeErrorZ_free(struct LDKCResult_BlindedHopDecodeErrorZ _res); +void CResult_InvoiceErrorDecodeErrorZ_free(struct LDKCResult_InvoiceErrorDecodeErrorZ _res); /** - * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_BlindedHopDecodeErrorZ CResult_BlindedHopDecodeErrorZ_clone(const struct LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_clone(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR orig); /** - * Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. + * Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the success state. */ -struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_ok(struct LDKInvoiceError o); +struct LDKCResult_TrackedSpendableOutputDecodeErrorZ CResult_TrackedSpendableOutputDecodeErrorZ_ok(struct LDKTrackedSpendableOutput o); /** - * Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. + * Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the error state. */ -struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_err(struct LDKDecodeError e); +struct LDKCResult_TrackedSpendableOutputDecodeErrorZ CResult_TrackedSpendableOutputDecodeErrorZ_err(struct LDKDecodeError e); /** * Checks if the given object is currently in the success state */ -bool CResult_InvoiceErrorDecodeErrorZ_is_ok(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR o); +bool CResult_TrackedSpendableOutputDecodeErrorZ_is_ok(const struct LDKCResult_TrackedSpendableOutputDecodeErrorZ *NONNULL_PTR o); /** - * Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. + * Frees any resources used by the CResult_TrackedSpendableOutputDecodeErrorZ. */ -void CResult_InvoiceErrorDecodeErrorZ_free(struct LDKCResult_InvoiceErrorDecodeErrorZ _res); +void CResult_TrackedSpendableOutputDecodeErrorZ_free(struct LDKCResult_TrackedSpendableOutputDecodeErrorZ _res); /** - * Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` + * Creates a new CResult_TrackedSpendableOutputDecodeErrorZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKCResult_InvoiceErrorDecodeErrorZ CResult_InvoiceErrorDecodeErrorZ_clone(const struct LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR orig); +struct LDKCResult_TrackedSpendableOutputDecodeErrorZ CResult_TrackedSpendableOutputDecodeErrorZ_clone(const struct LDKCResult_TrackedSpendableOutputDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OutputSpendStatusDecodeErrorZ in the success state. + */ +struct LDKCResult_OutputSpendStatusDecodeErrorZ CResult_OutputSpendStatusDecodeErrorZ_ok(struct LDKOutputSpendStatus o); + +/** + * Creates a new CResult_OutputSpendStatusDecodeErrorZ in the error state. + */ +struct LDKCResult_OutputSpendStatusDecodeErrorZ CResult_OutputSpendStatusDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OutputSpendStatusDecodeErrorZ_is_ok(const struct LDKCResult_OutputSpendStatusDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OutputSpendStatusDecodeErrorZ. + */ +void CResult_OutputSpendStatusDecodeErrorZ_free(struct LDKCResult_OutputSpendStatusDecodeErrorZ _res); + +/** + * Creates a new CResult_OutputSpendStatusDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OutputSpendStatusDecodeErrorZ CResult_OutputSpendStatusDecodeErrorZ_clone(const struct LDKCResult_OutputSpendStatusDecodeErrorZ *NONNULL_PTR orig); + +/** + * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter + */ +struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); + +/** + * Constructs a new COption_FilterZ containing nothing + */ +struct LDKCOption_FilterZ COption_FilterZ_none(void); + +/** + * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state + */ +void COption_FilterZ_free(struct LDKCOption_FilterZ _res); + +/** + * Frees the buffer pointed to by `data` if `datalen` is non-0. + */ +void CVec_TrackedSpendableOutputZ_free(struct LDKCVec_TrackedSpendableOutputZ _res); + +/** + * Creates a new CResult_OutputSweeperDecodeErrorZ in the success state. + */ +struct LDKCResult_OutputSweeperDecodeErrorZ CResult_OutputSweeperDecodeErrorZ_ok(struct LDKOutputSweeper o); + +/** + * Creates a new CResult_OutputSweeperDecodeErrorZ in the error state. + */ +struct LDKCResult_OutputSweeperDecodeErrorZ CResult_OutputSweeperDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OutputSweeperDecodeErrorZ_is_ok(const struct LDKCResult_OutputSweeperDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OutputSweeperDecodeErrorZ. + */ +void CResult_OutputSweeperDecodeErrorZ_free(struct LDKCResult_OutputSweeperDecodeErrorZ _res); + +/** + * Creates a new C2Tuple_BestBlockOutputSweeperZ from the contained elements. + */ +struct LDKC2Tuple_BestBlockOutputSweeperZ C2Tuple_BestBlockOutputSweeperZ_new(struct LDKBestBlock a, struct LDKOutputSweeper b); + +/** + * Frees any resources used by the C2Tuple_BestBlockOutputSweeperZ. + */ +void C2Tuple_BestBlockOutputSweeperZ_free(struct LDKC2Tuple_BestBlockOutputSweeperZ _res); + +/** + * Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the success state. + */ +struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_ok(struct LDKC2Tuple_BestBlockOutputSweeperZ o); + +/** + * Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the error state. + */ +struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_is_ok(const struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ. + */ +void CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ _res); /** * Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the success state. @@ -29089,21 +35307,6 @@ void CResult_RevocationKeyDecodeErrorZ_free(struct LDKCResult_RevocationKeyDecod */ struct LDKCResult_RevocationKeyDecodeErrorZ CResult_RevocationKeyDecodeErrorZ_clone(const struct LDKCResult_RevocationKeyDecodeErrorZ *NONNULL_PTR orig); -/** - * Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter - */ -struct LDKCOption_FilterZ COption_FilterZ_some(struct LDKFilter o); - -/** - * Constructs a new COption_FilterZ containing nothing - */ -struct LDKCOption_FilterZ COption_FilterZ_none(void); - -/** - * Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state - */ -void COption_FilterZ_free(struct LDKCOption_FilterZ _res); - /** * Creates a new CResult_LockedChannelMonitorNoneZ in the success state. */ @@ -29125,35 +35328,150 @@ bool CResult_LockedChannelMonitorNoneZ_is_ok(const struct LDKCResult_LockedChann void CResult_LockedChannelMonitorNoneZ_free(struct LDKCResult_LockedChannelMonitorNoneZ _res); /** - * Frees the buffer pointed to by `data` if `datalen` is non-0. + * Creates a new tuple which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. */ -void CVec_OutPointZ_free(struct LDKCVec_OutPointZ _res); +struct LDKC2Tuple_OutPointChannelIdZ C2Tuple_OutPointChannelIdZ_clone(const struct LDKC2Tuple_OutPointChannelIdZ *NONNULL_PTR orig); + +/** + * Creates a new C2Tuple_OutPointChannelIdZ from the contained elements. + */ +struct LDKC2Tuple_OutPointChannelIdZ C2Tuple_OutPointChannelIdZ_new(struct LDKOutPoint a, struct LDKChannelId b); + +/** + * Frees any resources used by the C2Tuple_OutPointChannelIdZ. + */ +void C2Tuple_OutPointChannelIdZ_free(struct LDKC2Tuple_OutPointChannelIdZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_MonitorUpdateIdZ_free(struct LDKCVec_MonitorUpdateIdZ _res); +void CVec_C2Tuple_OutPointChannelIdZZ_free(struct LDKCVec_C2Tuple_OutPointChannelIdZZ _res); /** * Creates a new tuple which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(const struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR orig); +struct LDKC2Tuple_OutPointCVec_u64ZZ C2Tuple_OutPointCVec_u64ZZ_clone(const struct LDKC2Tuple_OutPointCVec_u64ZZ *NONNULL_PTR orig); /** - * Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. + * Creates a new C2Tuple_OutPointCVec_u64ZZ from the contained elements. */ -struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(struct LDKOutPoint a, struct LDKCVec_MonitorUpdateIdZ b); +struct LDKC2Tuple_OutPointCVec_u64ZZ C2Tuple_OutPointCVec_u64ZZ_new(struct LDKOutPoint a, struct LDKCVec_u64Z b); /** - * Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. + * Frees any resources used by the C2Tuple_OutPointCVec_u64ZZ. */ -void C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(struct LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res); +void C2Tuple_OutPointCVec_u64ZZ_free(struct LDKC2Tuple_OutPointCVec_u64ZZ _res); /** * Frees the buffer pointed to by `data` if `datalen` is non-0. */ -void CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res); +void CVec_C2Tuple_OutPointCVec_u64ZZZ_free(struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ _res); + +/** + * Creates a new CResult_BlindedMessagePathDecodeErrorZ in the success state. + */ +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_ok(struct LDKBlindedMessagePath o); + +/** + * Creates a new CResult_BlindedMessagePathDecodeErrorZ in the error state. + */ +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedMessagePathDecodeErrorZ_is_ok(const struct LDKCResult_BlindedMessagePathDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedMessagePathDecodeErrorZ. + */ +void CResult_BlindedMessagePathDecodeErrorZ_free(struct LDKCResult_BlindedMessagePathDecodeErrorZ _res); + +/** + * Creates a new CResult_BlindedMessagePathDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedMessagePathDecodeErrorZ CResult_BlindedMessagePathDecodeErrorZ_clone(const struct LDKCResult_BlindedMessagePathDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_BlindedMessagePathNoneZ in the success state. + */ +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_ok(struct LDKBlindedMessagePath o); + +/** + * Creates a new CResult_BlindedMessagePathNoneZ in the error state. + */ +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_err(void); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_BlindedMessagePathNoneZ_is_ok(const struct LDKCResult_BlindedMessagePathNoneZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_BlindedMessagePathNoneZ. + */ +void CResult_BlindedMessagePathNoneZ_free(struct LDKCResult_BlindedMessagePathNoneZ _res); + +/** + * Creates a new CResult_BlindedMessagePathNoneZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_BlindedMessagePathNoneZ CResult_BlindedMessagePathNoneZ_clone(const struct LDKCResult_BlindedMessagePathNoneZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ in the success state. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_ok(struct LDKMessageContext o); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ in the error state. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_MessageContextDecodeErrorZ_is_ok(const struct LDKCResult_MessageContextDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_MessageContextDecodeErrorZ. + */ +void CResult_MessageContextDecodeErrorZ_free(struct LDKCResult_MessageContextDecodeErrorZ _res); + +/** + * Creates a new CResult_MessageContextDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_MessageContextDecodeErrorZ CResult_MessageContextDecodeErrorZ_clone(const struct LDKCResult_MessageContextDecodeErrorZ *NONNULL_PTR orig); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ in the success state. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_ok(struct LDKOffersContext o); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ in the error state. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_err(struct LDKDecodeError e); + +/** + * Checks if the given object is currently in the success state + */ +bool CResult_OffersContextDecodeErrorZ_is_ok(const struct LDKCResult_OffersContextDecodeErrorZ *NONNULL_PTR o); + +/** + * Frees any resources used by the CResult_OffersContextDecodeErrorZ. + */ +void CResult_OffersContextDecodeErrorZ_free(struct LDKCResult_OffersContextDecodeErrorZ _res); + +/** + * Creates a new CResult_OffersContextDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ +struct LDKCResult_OffersContextDecodeErrorZ CResult_OffersContextDecodeErrorZ_clone(const struct LDKCResult_OffersContextDecodeErrorZ *NONNULL_PTR orig); /** * Frees any resources used by the APIError @@ -29252,6 +35570,16 @@ struct LDKCVec_u8Z BigSize_write(const struct LDKBigSize *NONNULL_PTR obj); */ struct LDKCResult_BigSizeDecodeErrorZ BigSize_read(struct LDKu8slice ser); +/** + * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read + */ +struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); + +/** + * Read a UntrustedString from a byte array, created by UntrustedString_write + */ +struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); + /** * Frees any resources used by the Hostname, if is_owned is set and inner is non-NULL. */ @@ -29279,6 +35607,11 @@ bool Hostname_eq(const struct LDKHostname *NONNULL_PTR a, const struct LDKHostna */ MUST_USE_RES uint8_t Hostname_len(const struct LDKHostname *NONNULL_PTR this_arg); +/** + * Get the string representation of a Hostname object + */ +struct LDKStr Hostname_to_str(const struct LDKHostname *NONNULL_PTR o); + /** * Serialize the Hostname object into a byte array which can be read by Hostname_read */ @@ -29322,6 +35655,11 @@ MUST_USE_RES struct LDKCResult_TransactionU16LenLimitedNoneZ TransactionU16LenLi */ MUST_USE_RES struct LDKTransaction TransactionU16LenLimited_into_transaction(struct LDKTransactionU16LenLimited this_arg); +/** + * Returns a reference to the contained `Transaction` + */ +MUST_USE_RES struct LDKTransaction TransactionU16LenLimited_as_transaction(const struct LDKTransactionU16LenLimited *NONNULL_PTR this_arg); + /** * Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read */ @@ -29337,7 +35675,7 @@ struct LDKCResult_TransactionU16LenLimitedDecodeErrorZ TransactionU16LenLimited_ * A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. * Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. */ -struct LDKCResult_StrSecp256k1ErrorZ sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); +struct LDKStr sign(struct LDKu8slice msg, const uint8_t (*sk)[32]); /** * Recovers the PublicKey of the signer of the message given the message and the signature. @@ -29350,11 +35688,6 @@ struct LDKCResult_PublicKeySecp256k1ErrorZ recover_pk(struct LDKu8slice msg, str */ bool verify(struct LDKu8slice msg, struct LDKStr sig, struct LDKPublicKey pk); -/** - * Construct the invoice's HRP and signatureless data into a preimage to be hashed. - */ -struct LDKCVec_u8Z construct_invoice_preimage(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z data_without_signature); - /** * Calls the free function if one is set */ @@ -29393,7 +35726,7 @@ void MonitorUpdatingPersister_free(struct LDKMonitorUpdatingPersister this_obj); * - [`MonitorUpdatingPersister`] will potentially have more listing to do if you need to run * [`MonitorUpdatingPersister::cleanup_stale_updates`]. */ -MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(struct LDKKVStore kv_store, struct LDKLogger logger, uint64_t maximum_pending_updates, struct LDKEntropySource entropy_source, struct LDKSignerProvider signer_provider); +MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(struct LDKKVStore kv_store, struct LDKLogger logger, uint64_t maximum_pending_updates, struct LDKEntropySource entropy_source, struct LDKSignerProvider signer_provider, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator); /** * Reads all stored channel monitors, along with any stored updates for them. @@ -29402,7 +35735,7 @@ MUST_USE_RES struct LDKMonitorUpdatingPersister MonitorUpdatingPersister_new(str * [`io::ErrorKind::NotFound`] variant correctly. For more information, please see the * documentation for [`MonitorUpdatingPersister`]. */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ MonitorUpdatingPersister_read_all_channel_monitors_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ MonitorUpdatingPersister_read_all_channel_monitors_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg); /** * Read a single channel monitor, along with any stored updates for it. @@ -29423,7 +35756,7 @@ MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErro * Loading a large number of monitors will be faster if done in parallel. You can use this * function to accomplish this. Take care to limit the number of parallel readers. */ -MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ MonitorUpdatingPersister_read_channel_monitor_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, struct LDKStr monitor_key); +MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ MonitorUpdatingPersister_read_channel_monitor_with_updates(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg, struct LDKStr monitor_key); /** * Cleans up stale updates for all monitors. @@ -29442,59 +35775,256 @@ MUST_USE_RES struct LDKCResult_NoneIOErrorZ MonitorUpdatingPersister_cleanup_sta struct LDKPersist MonitorUpdatingPersister_as_Persist(const struct LDKMonitorUpdatingPersister *NONNULL_PTR this_arg); /** - * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. + * Creates a copy of the ShortChannelIdError */ -void UntrustedString_free(struct LDKUntrustedString this_obj); +enum LDKShortChannelIdError ShortChannelIdError_clone(const enum LDKShortChannelIdError *NONNULL_PTR orig); -struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); +/** + * Utility method to constructs a new BlockOverflow-variant ShortChannelIdError + */ +enum LDKShortChannelIdError ShortChannelIdError_block_overflow(void); -void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); +/** + * Utility method to constructs a new TxIndexOverflow-variant ShortChannelIdError + */ +enum LDKShortChannelIdError ShortChannelIdError_tx_index_overflow(void); /** - * Constructs a new UntrustedString given each field + * Utility method to constructs a new VoutIndexOverflow-variant ShortChannelIdError */ -MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); +enum LDKShortChannelIdError ShortChannelIdError_vout_index_overflow(void); /** - * Creates a copy of the UntrustedString + * Checks if two ShortChannelIdErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); +bool ShortChannelIdError_eq(const enum LDKShortChannelIdError *NONNULL_PTR a, const enum LDKShortChannelIdError *NONNULL_PTR b); /** - * Checks if two UntrustedStrings contain equal inner contents. + * Extracts the block height (most significant 3-bytes) from the `short_channel_id` + */ +uint32_t block_from_scid(uint64_t short_channel_id); + +/** + * Extracts the tx index (bytes [2..4]) from the `short_channel_id` + */ +uint32_t tx_index_from_scid(uint64_t short_channel_id); + +/** + * Extracts the vout (bytes [0..2]) from the `short_channel_id` + */ +uint16_t vout_from_scid(uint64_t short_channel_id); + +/** + * Constructs a `short_channel_id` using the components pieces. Results in an error + * if the block height, tx index, or vout index overflow the maximum sizes. + */ +struct LDKCResult_u64ShortChannelIdErrorZ scid_from_parts(uint64_t block, uint64_t tx_index, uint64_t vout_index); + +/** + * Frees any resources used by the TrackedSpendableOutput, if is_owned is set and inner is non-NULL. + */ +void TrackedSpendableOutput_free(struct LDKTrackedSpendableOutput this_obj); + +/** + * The tracked output descriptor. + */ +struct LDKSpendableOutputDescriptor TrackedSpendableOutput_get_descriptor(const struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr); + +/** + * The tracked output descriptor. + */ +void TrackedSpendableOutput_set_descriptor(struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr, struct LDKSpendableOutputDescriptor val); + +/** + * The channel this output belongs to. + * + * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`] + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelId TrackedSpendableOutput_get_channel_id(const struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr); + +/** + * The channel this output belongs to. + * + * Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`] + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void TrackedSpendableOutput_set_channel_id(struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The current status of the output spend. + */ +struct LDKOutputSpendStatus TrackedSpendableOutput_get_status(const struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr); + +/** + * The current status of the output spend. + */ +void TrackedSpendableOutput_set_status(struct LDKTrackedSpendableOutput *NONNULL_PTR this_ptr, struct LDKOutputSpendStatus val); + +/** + * Constructs a new TrackedSpendableOutput given each field + * + * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKTrackedSpendableOutput TrackedSpendableOutput_new(struct LDKSpendableOutputDescriptor descriptor_arg, struct LDKChannelId channel_id_arg, struct LDKOutputSpendStatus status_arg); + +/** + * Creates a copy of the TrackedSpendableOutput + */ +struct LDKTrackedSpendableOutput TrackedSpendableOutput_clone(const struct LDKTrackedSpendableOutput *NONNULL_PTR orig); + +/** + * Checks if two TrackedSpendableOutputs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); +bool TrackedSpendableOutput_eq(const struct LDKTrackedSpendableOutput *NONNULL_PTR a, const struct LDKTrackedSpendableOutput *NONNULL_PTR b); /** - * Generates a non-cryptographic 64-bit hash of the UntrustedString. + * Returns whether the output is spent in the given transaction. */ -uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); +MUST_USE_RES bool TrackedSpendableOutput_is_spent_in(const struct LDKTrackedSpendableOutput *NONNULL_PTR this_arg, struct LDKTransaction tx); /** - * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read + * Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read */ -struct LDKCVec_u8Z UntrustedString_write(const struct LDKUntrustedString *NONNULL_PTR obj); +struct LDKCVec_u8Z TrackedSpendableOutput_write(const struct LDKTrackedSpendableOutput *NONNULL_PTR obj); /** - * Read a UntrustedString from a byte array, created by UntrustedString_write + * Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write */ -struct LDKCResult_UntrustedStringDecodeErrorZ UntrustedString_read(struct LDKu8slice ser); +struct LDKCResult_TrackedSpendableOutputDecodeErrorZ TrackedSpendableOutput_read(struct LDKu8slice ser); /** - * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. + * Frees any resources used by the OutputSpendStatus */ -void PrintableString_free(struct LDKPrintableString this_obj); +void OutputSpendStatus_free(struct LDKOutputSpendStatus this_ptr); -struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); +/** + * Creates a copy of the OutputSpendStatus + */ +struct LDKOutputSpendStatus OutputSpendStatus_clone(const struct LDKOutputSpendStatus *NONNULL_PTR orig); -void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); +/** + * Utility method to constructs a new PendingInitialBroadcast-variant OutputSpendStatus + */ +struct LDKOutputSpendStatus OutputSpendStatus_pending_initial_broadcast(struct LDKCOption_u32Z delayed_until_height); /** - * Constructs a new PrintableString given each field + * Utility method to constructs a new PendingFirstConfirmation-variant OutputSpendStatus */ -MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); +struct LDKOutputSpendStatus OutputSpendStatus_pending_first_confirmation(struct LDKThirtyTwoBytes first_broadcast_hash, uint32_t latest_broadcast_height, struct LDKTransaction latest_spending_tx); + +/** + * Utility method to constructs a new PendingThresholdConfirmations-variant OutputSpendStatus + */ +struct LDKOutputSpendStatus OutputSpendStatus_pending_threshold_confirmations(struct LDKThirtyTwoBytes first_broadcast_hash, uint32_t latest_broadcast_height, struct LDKTransaction latest_spending_tx, uint32_t confirmation_height, struct LDKThirtyTwoBytes confirmation_hash); + +/** + * Checks if two OutputSpendStatuss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool OutputSpendStatus_eq(const struct LDKOutputSpendStatus *NONNULL_PTR a, const struct LDKOutputSpendStatus *NONNULL_PTR b); + +/** + * Serialize the OutputSpendStatus object into a byte array which can be read by OutputSpendStatus_read + */ +struct LDKCVec_u8Z OutputSpendStatus_write(const struct LDKOutputSpendStatus *NONNULL_PTR obj); + +/** + * Read a OutputSpendStatus from a byte array, created by OutputSpendStatus_write + */ +struct LDKCResult_OutputSpendStatusDecodeErrorZ OutputSpendStatus_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the OutputSweeper, if is_owned is set and inner is non-NULL. + */ +void OutputSweeper_free(struct LDKOutputSweeper this_obj); + +/** + * Constructs a new [`OutputSweeper`]. + * + * If chain data is provided via the [`Confirm`] interface or via filtered blocks, users also + * need to register their [`Filter`] implementation via the given `chain_data_source`. + */ +MUST_USE_RES struct LDKOutputSweeper OutputSweeper_new(struct LDKBestBlock best_block, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, struct LDKCOption_FilterZ chain_data_source, struct LDKOutputSpender output_spender, struct LDKChangeDestinationSource change_destination_source, struct LDKKVStore kv_store, struct LDKLogger logger); + +/** + * Tells the sweeper to track the given outputs descriptors. + * + * Usually, this should be called based on the values emitted by the + * [`Event::SpendableOutputs`]. + * + * The given `exclude_static_outputs` flag controls whether the sweeper will filter out + * [`SpendableOutputDescriptor::StaticOutput`]s, which may be handled directly by the on-chain + * wallet implementation. + * + * If `delay_until_height` is set, we will delay the spending until the respective block + * height is reached. This can be used to batch spends, e.g., to reduce on-chain fees. + * + * Returns `Err` on persistence failure, in which case the call may be safely retried. + * + * [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs + * + * Note that channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKCResult_NoneNoneZ OutputSweeper_track_spendable_outputs(const struct LDKOutputSweeper *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ output_descriptors, struct LDKChannelId channel_id, bool exclude_static_outputs, struct LDKCOption_u32Z delay_until_height); + +/** + * Returns a list of the currently tracked spendable outputs. + */ +MUST_USE_RES struct LDKCVec_TrackedSpendableOutputZ OutputSweeper_tracked_spendable_outputs(const struct LDKOutputSweeper *NONNULL_PTR this_arg); + +/** + * Gets the latest best block which was connected either via the [`Listen`] or + * [`Confirm`] interfaces. + */ +MUST_USE_RES struct LDKBestBlock OutputSweeper_current_best_block(const struct LDKOutputSweeper *NONNULL_PTR this_arg); + +/** + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + */ +struct LDKListen OutputSweeper_as_Listen(const struct LDKOutputSweeper *NONNULL_PTR this_arg); + +/** + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + */ +struct LDKConfirm OutputSweeper_as_Confirm(const struct LDKOutputSweeper *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the SpendingDelay + */ +void SpendingDelay_free(struct LDKSpendingDelay this_ptr); + +/** + * Creates a copy of the SpendingDelay + */ +struct LDKSpendingDelay SpendingDelay_clone(const struct LDKSpendingDelay *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Relative-variant SpendingDelay + */ +struct LDKSpendingDelay SpendingDelay_relative(uint32_t num_blocks); + +/** + * Utility method to constructs a new Absolute-variant SpendingDelay + */ +struct LDKSpendingDelay SpendingDelay_absolute(uint32_t height); + +/** + * Read a OutputSweeper from a byte array, created by OutputSweeper_write + */ +struct LDKCResult_OutputSweeperDecodeErrorZ OutputSweeper_read(struct LDKu8slice ser, struct LDKBroadcasterInterface arg_a, struct LDKFeeEstimator arg_b, struct LDKCOption_FilterZ arg_c, struct LDKOutputSpender arg_d, struct LDKChangeDestinationSource arg_e, struct LDKKVStore arg_f, struct LDKLogger arg_g); + +/** + * Read a C2Tuple_BestBlockOutputSweeperZ from a byte array, created by C2Tuple_BestBlockOutputSweeperZ_write + */ +struct LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ C2Tuple_BestBlockOutputSweeperZ_read(struct LDKu8slice ser, struct LDKBroadcasterInterface arg_a, struct LDKFeeEstimator arg_b, struct LDKCOption_FilterZ arg_c, struct LDKOutputSpender arg_d, struct LDKChangeDestinationSource arg_e, struct LDKKVStore arg_f, struct LDKLogger arg_g); /** * Calls the free function if one is set @@ -29506,11 +36036,6 @@ void FutureCallback_free(struct LDKFutureCallback this_ptr); */ void Future_free(struct LDKFuture this_obj); -/** - * Creates a copy of the Future - */ -struct LDKFuture Future_clone(const struct LDKFuture *NONNULL_PTR orig); - /** * Registers a callback to be called upon completion of this future. If the future has already * completed, the callback will be called immediately. @@ -29520,14 +36045,14 @@ void Future_register_callback_fn(const struct LDKFuture *NONNULL_PTR this_arg, s /** * Waits until this [`Future`] completes. */ -void Future_wait(struct LDKFuture this_arg); +void Future_wait(const struct LDKFuture *NONNULL_PTR this_arg); /** * Waits until this [`Future`] completes or the given amount of time has elapsed. * * Returns true if the [`Future`] completed, false if the time elapsed. */ -MUST_USE_RES bool Future_wait_timeout(struct LDKFuture this_arg, uint64_t max_wait); +MUST_USE_RES bool Future_wait_timeout(const struct LDKFuture *NONNULL_PTR this_arg, uint64_t max_wait); /** * Frees any resources used by the Sleeper, if is_owned is set and inner is non-NULL. @@ -29537,12 +36062,18 @@ void Sleeper_free(struct LDKSleeper this_obj); /** * Constructs a new sleeper from one future, allowing blocking on it. */ -MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(struct LDKFuture future); +MUST_USE_RES struct LDKSleeper Sleeper_from_single_future(const struct LDKFuture *NONNULL_PTR future); /** * Constructs a new sleeper from two futures, allowing blocking on both at once. */ -MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(struct LDKFuture fut_a, struct LDKFuture fut_b); +MUST_USE_RES struct LDKSleeper Sleeper_from_two_futures(const struct LDKFuture *NONNULL_PTR fut_a, const struct LDKFuture *NONNULL_PTR fut_b); + +/** + * Constructs a new sleeper from three futures, allowing blocking on all three at once. + * + */ +MUST_USE_RES struct LDKSleeper Sleeper_from_three_futures(const struct LDKFuture *NONNULL_PTR fut_a, const struct LDKFuture *NONNULL_PTR fut_b, const struct LDKFuture *NONNULL_PTR fut_c); /** * Constructs a new sleeper on many futures, allowing blocking on all at once. @@ -29607,6 +36138,11 @@ bool Level_eq(const enum LDKLevel *NONNULL_PTR a, const enum LDKLevel *NONNULL_P */ uint64_t Level_hash(const enum LDKLevel *NONNULL_PTR o); +/** + * Get the string representation of a Level object + */ +struct LDKStr Level_to_str(const enum LDKLevel *NONNULL_PTR o); + /** * Returns the most verbose logging level. */ @@ -29652,14 +36188,18 @@ void Record_set_peer_id(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKPublic /** * The channel id of the channel pertaining to the logged record. May be a temporary id before * the channel has been funded. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCOption_ThirtyTwoBytesZ Record_get_channel_id(const struct LDKRecord *NONNULL_PTR this_ptr); +struct LDKChannelId Record_get_channel_id(const struct LDKRecord *NONNULL_PTR this_ptr); /** * The channel id of the channel pertaining to the logged record. May be a temporary id before * the channel has been funded. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Record_set_channel_id(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +void Record_set_channel_id(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKChannelId val); /** * The message body. @@ -29701,12 +36241,29 @@ uint32_t Record_get_line(const struct LDKRecord *NONNULL_PTR this_ptr); */ void Record_set_line(struct LDKRecord *NONNULL_PTR this_ptr, uint32_t val); +/** + * The payment hash. + * + * Note that this is only filled in for logs pertaining to a specific payment, and will be + * `None` for logs which are not directly related to a payment. + */ +struct LDKCOption_ThirtyTwoBytesZ Record_get_payment_hash(const struct LDKRecord *NONNULL_PTR this_ptr); + +/** + * The payment hash. + * + * Note that this is only filled in for logs pertaining to a specific payment, and will be + * `None` for logs which are not directly related to a payment. + */ +void Record_set_payment_hash(struct LDKRecord *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); + /** * Constructs a new Record given each field * * Note that peer_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKRecord Record_new(enum LDKLevel level_arg, struct LDKPublicKey peer_id_arg, struct LDKCOption_ThirtyTwoBytesZ channel_id_arg, struct LDKStr args_arg, struct LDKStr module_path_arg, struct LDKStr file_arg, uint32_t line_arg); +MUST_USE_RES struct LDKRecord Record_new(enum LDKLevel level_arg, struct LDKPublicKey peer_id_arg, struct LDKChannelId channel_id_arg, struct LDKStr args_arg, struct LDKStr module_path_arg, struct LDKStr file_arg, uint32_t line_arg, struct LDKCOption_ThirtyTwoBytesZ payment_hash_arg); /** * Creates a copy of the Record @@ -29725,15 +36282,15 @@ void ChannelHandshakeConfig_free(struct LDKChannelHandshakeConfig this_obj); /** * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * Applied only for inbound channels (see [`ChannelHandshakeLimits::max_minimum_depth`] for the * equivalent limit applied to outbound channels). * - * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * A lower-bound of `1` is applied, requiring all channels to have a confirmed commitment * transaction before operation. If you wish to accept channels with zero confirmations, see * [`UserConfig::manually_accept_inbound_channels`] and * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. * - * Default value: 6. + * Default value: `6` * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf @@ -29742,15 +36299,15 @@ uint32_t ChannelHandshakeConfig_get_minimum_depth(const struct LDKChannelHandsha /** * Confirmations we will wait for before considering the channel locked in. - * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * Applied only for inbound channels (see [`ChannelHandshakeLimits::max_minimum_depth`] for the * equivalent limit applied to outbound channels). * - * A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment + * A lower-bound of `1` is applied, requiring all channels to have a confirmed commitment * transaction before operation. If you wish to accept channels with zero confirmations, see * [`UserConfig::manually_accept_inbound_channels`] and * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. * - * Default value: 6. + * Default value: `6` * * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel * [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf @@ -29771,8 +36328,8 @@ void ChannelHandshakeConfig_set_minimum_depth(struct LDKChannelHandshakeConfig * * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * Default value: [`BREAKDOWN_TIMEOUT`] (We enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less.) */ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -29790,8 +36347,8 @@ uint16_t ChannelHandshakeConfig_get_our_to_self_delay(const struct LDKChannelHan * case of an honest unilateral channel close, which implicitly decrease the economic value of * our channel. * - * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you - * can tweak config to ask for more security, not less. + * Default value: [`BREAKDOWN_TIMEOUT`] (We enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less.) */ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); @@ -29801,8 +36358,8 @@ void ChannelHandshakeConfig_set_our_to_self_delay(struct LDKChannelHandshakeConf * This value is sent to our counterparty on channel-open and we close the channel any time * our counterparty misbehaves by sending us an HTLC with a value smaller than this. * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is + * required by the protocol. */ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -29812,8 +36369,8 @@ uint64_t ChannelHandshakeConfig_get_our_htlc_minimum_msat(const struct LDKChanne * This value is sent to our counterparty on channel-open and we close the channel any time * our counterparty misbehaves by sending us an HTLC with a value smaller than this. * - * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required - * by the protocol. + * Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is + * required by the protocol. */ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint64_t val); @@ -29825,22 +36382,24 @@ void ChannelHandshakeConfig_set_our_htlc_minimum_msat(struct LDKChannelHandshake * channel value in whole percentages. * * Note that: - * * If configured to another value than the default value 10, any new channels created with - * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the - * `ChannelManager`. + * * If configured to another value than the default value `10`, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. * * * This caps the total value for inbound HTLCs in-flight only, and there's currently - * no way to configure the cap for the total value of outbound HTLCs in-flight. + * no way to configure the cap for the total value of outbound HTLCs in-flight. * * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds - * are different from the non-HTLC-encumbered funds. This makes this an important knob to - * restrict exposure to loss due to being offline for too long. - * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] - * for more information. + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: `10` + * + * Minimum value: `1` (Any values less will be treated as `1` instead.) * - * Default value: 10. - * Minimum value: 1, any values less than 1 will be treated as 1 instead. - * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + * Maximum value: `100` (Any values larger will be treated as `100` instead.) */ uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -29852,22 +36411,24 @@ uint8_t ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_c * channel value in whole percentages. * * Note that: - * * If configured to another value than the default value 10, any new channels created with - * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the - * `ChannelManager`. + * * If configured to another value than the default value `10`, any new channels created with + * the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the + * `ChannelManager`. * * * This caps the total value for inbound HTLCs in-flight only, and there's currently - * no way to configure the cap for the total value of outbound HTLCs in-flight. + * no way to configure the cap for the total value of outbound HTLCs in-flight. * * * The requirements for your node being online to ensure the safety of HTLC-encumbered funds - * are different from the non-HTLC-encumbered funds. This makes this an important knob to - * restrict exposure to loss due to being offline for too long. - * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] - * for more information. + * are different from the non-HTLC-encumbered funds. This makes this an important knob to + * restrict exposure to loss due to being offline for too long. + * See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] + * for more information. + * + * Default value: `10` + * + * Minimum value: `1` (Any values less will be treated as `1` instead.) * - * Default value: 10. - * Minimum value: 1, any values less than 1 will be treated as 1 instead. - * Maximum value: 100, any values larger than 100 will be treated as 100 instead. + * Maximum value: `100` (Any values larger will be treated as `100` instead.) */ void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint8_t val); @@ -29886,10 +36447,10 @@ void ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_chan * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announce_for_forwarding`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * - * Default value: false. This value is likely to change to true in the future. + * Default value: `false` (This value is likely to change to `true` in the future.) * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue @@ -29911,10 +36472,10 @@ bool ChannelHandshakeConfig_get_negotiate_scid_privacy(const struct LDKChannelHa * private channel without that option. * * Ignored if the channel is negotiated to be announced, see - * [`ChannelHandshakeConfig::announced_channel`] and + * [`ChannelHandshakeConfig::announce_for_forwarding`] and * [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. * - * Default value: false. This value is likely to change to true in the future. + * Default value: `false` (This value is likely to change to `true` in the future.) * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue @@ -29930,9 +36491,9 @@ void ChannelHandshakeConfig_set_negotiate_scid_privacy(struct LDKChannelHandshak * As the node which funds a channel picks this value this will only apply for new outbound * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. * - * Default value: false. + * Default value: `false` */ -bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); +bool ChannelHandshakeConfig_get_announce_for_forwarding(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); /** * Set to announce the channel publicly and notify all nodes that they can route via this @@ -29943,9 +36504,9 @@ bool ChannelHandshakeConfig_get_announced_channel(const struct LDKChannelHandsha * As the node which funds a channel picks this value this will only apply for new outbound * channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. * - * Default value: false. + * Default value: `false` */ -void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); +void ChannelHandshakeConfig_set_announce_for_forwarding(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, bool val); /** * When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty @@ -29958,7 +36519,7 @@ void ChannelHandshakeConfig_set_announced_channel(struct LDKChannelHandshakeConf * * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. * - * Default value: true. + * Default value: `true` * * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ @@ -29975,7 +36536,7 @@ bool ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(const struct LDKC * * The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. * - * Default value: true. + * Default value: `true` * * [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey */ @@ -29999,11 +36560,15 @@ void ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(struct LDKChannel * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve * other than the default value. * - * Default value: 1% of channel value, i.e., configured as 10,000 millionths. - * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated - * as 1000 sats instead, which is a safe implementation-specific lower bound. - * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) - * instead, although channel negotiations will fail in that case. + * Default value: `10_000` millionths (i.e., 1% of channel value) + * + * Minimum value: If the calculated proportional value is less than `1000` sats, it will be + * treated as `1000` sats instead, which is a safe implementation-specific lower + * bound. + * + * Maximum value: `1_000_000` (i.e., 100% of channel value. Any values larger than one million + * will be treated as one million instead, although channel negotiations will + * fail in that case.) */ uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -30025,11 +36590,15 @@ uint32_t ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionth * Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve * other than the default value. * - * Default value: 1% of channel value, i.e., configured as 10,000 millionths. - * Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated - * as 1000 sats instead, which is a safe implementation-specific lower bound. - * Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) - * instead, although channel negotiations will fail in that case. + * Default value: `10_000` millionths (i.e., 1% of channel value) + * + * Minimum value: If the calculated proportional value is less than `1000` sats, it will be + * treated as `1000` sats instead, which is a safe implementation-specific lower + * bound. + * + * Maximum value: `1_000_000` (i.e., 100% of channel value. Any values larger than one million + * will be treated as one million instead, although channel negotiations will + * fail in that case.) */ void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint32_t val); @@ -30056,7 +36625,7 @@ void ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(st * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee * Considered Harmful`] mailing list post. * - * Default value: false. This value is likely to change to true in the future. + * Default value: `false` (This value is likely to change to `true` in the future.) * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel @@ -30088,7 +36657,7 @@ bool ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(const struct * vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee * Considered Harmful`] mailing list post. * - * Default value: false. This value is likely to change to true in the future. + * Default value: `false` (This value is likely to change to `true` in the future.) * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel @@ -30106,9 +36675,10 @@ void ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(struct LDKCha * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration * other than the default value. * - * Default value: 50 - * Maximum value: 483, any values larger will be treated as 483. - * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + * Default value: `50` + * + * Maximum value: `483` (Any values larger will be treated as `483`. This is the BOLT #2 spec + * limit on `max_accepted_htlcs`.) */ uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr); @@ -30121,16 +36691,17 @@ uint16_t ChannelHandshakeConfig_get_our_max_accepted_htlcs(const struct LDKChann * Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration * other than the default value. * - * Default value: 50 - * Maximum value: 483, any values larger will be treated as 483. - * This is the BOLT #2 spec limit on `max_accepted_htlcs`. + * Default value: `50` + * + * Maximum value: `483` (Any values larger will be treated as `483`. This is the BOLT #2 spec + * limit on `max_accepted_htlcs`.) */ void ChannelHandshakeConfig_set_our_max_accepted_htlcs(struct LDKChannelHandshakeConfig *NONNULL_PTR this_ptr, uint16_t val); /** * Constructs a new ChannelHandshakeConfig given each field */ -MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announced_channel_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg, bool negotiate_anchors_zero_fee_htlc_tx_arg, uint16_t our_max_accepted_htlcs_arg); +MUST_USE_RES struct LDKChannelHandshakeConfig ChannelHandshakeConfig_new(uint32_t minimum_depth_arg, uint16_t our_to_self_delay_arg, uint64_t our_htlc_minimum_msat_arg, uint8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, bool negotiate_scid_privacy_arg, bool announce_for_forwarding_arg, bool commit_upfront_shutdown_pubkey_arg, uint32_t their_channel_reserve_proportional_millionths_arg, bool negotiate_anchors_zero_fee_htlc_tx_arg, uint16_t our_max_accepted_htlcs_arg); /** * Creates a copy of the ChannelHandshakeConfig @@ -30151,7 +36722,8 @@ void ChannelHandshakeLimits_free(struct LDKChannelHandshakeLimits this_obj); * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 0. + * Default value: `1000` + * (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) */ uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30159,7 +36731,8 @@ uint64_t ChannelHandshakeLimits_get_min_funding_satoshis(const struct LDKChannel * Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 0. + * Default value: `1000` + * (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) */ void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -30167,7 +36740,7 @@ void ChannelHandshakeLimits_set_min_funding_satoshis(struct LDKChannelHandshakeL * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 2^24 - 1. + * Default value: `2^24 - 1` */ uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30175,7 +36748,7 @@ uint64_t ChannelHandshakeLimits_get_max_funding_satoshis(const struct LDKChannel * Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so * only applies to inbound channels. * - * Default value: 2^24 - 1. + * Default value: `2^24 - 1` */ void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -30183,7 +36756,7 @@ void ChannelHandshakeLimits_set_max_funding_satoshis(struct LDKChannelHandshakeL * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows * you to limit the maximum minimum-size they can require. * - * Default value: u64::max_value. + * Default value: `u64::max_value` */ uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30191,7 +36764,7 @@ uint64_t ChannelHandshakeLimits_get_max_htlc_minimum_msat(const struct LDKChanne * The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows * you to limit the maximum minimum-size they can require. * - * Default value: u64::max_value. + * Default value: `u64::max_value` */ void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -30199,7 +36772,7 @@ void ChannelHandshakeLimits_set_max_htlc_minimum_msat(struct LDKChannelHandshake * The remote node sets a limit on the maximum value of pending HTLCs to them at any given * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. * - * Default value: 0. + * Default value: `0` */ uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30207,7 +36780,7 @@ uint64_t ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(const stru * The remote node sets a limit on the maximum value of pending HTLCs to them at any given * time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. * - * Default value: 0. + * Default value: `0` */ void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -30216,7 +36789,7 @@ void ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(struct LDKChan * time, ensuring that we are able to be punished if we broadcast an old state. This allows to * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). * - * Default value: u64::max_value. + * Default value: `u64::max_value`. */ uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30225,7 +36798,7 @@ uint64_t ChannelHandshakeLimits_get_max_channel_reserve_satoshis(const struct LD * time, ensuring that we are able to be punished if we broadcast an old state. This allows to * you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). * - * Default value: u64::max_value. + * Default value: `u64::max_value`. */ void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint64_t val); @@ -30233,7 +36806,7 @@ void ChannelHandshakeLimits_set_max_channel_reserve_satoshis(struct LDKChannelHa * The remote node sets a limit on the maximum number of pending HTLCs to them at any given * time. This allows you to set a minimum such value. * - * Default value: 0. + * Default value: `0` */ uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30241,7 +36814,7 @@ uint16_t ChannelHandshakeLimits_get_min_max_accepted_htlcs(const struct LDKChann * The remote node sets a limit on the maximum number of pending HTLCs to them at any given * time. This allows you to set a minimum such value. * - * Default value: 0. + * Default value: `0` */ void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); @@ -30251,7 +36824,7 @@ void ChannelHandshakeLimits_set_min_max_accepted_htlcs(struct LDKChannelHandshak * assume they aren't going to double-spend themselves). * This config allows you to set a limit on the maximum amount of time to wait. * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Default value: `144`, or roughly one day and only applies to outbound channels */ uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30261,7 +36834,7 @@ uint32_t ChannelHandshakeLimits_get_max_minimum_depth(const struct LDKChannelHan * assume they aren't going to double-spend themselves). * This config allows you to set a limit on the maximum amount of time to wait. * - * Default value: 144, or roughly one day and only applies to outbound channels. + * Default value: `144`, or roughly one day and only applies to outbound channels */ void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint32_t val); @@ -30277,12 +36850,12 @@ void ChannelHandshakeLimits_set_max_minimum_depth(struct LDKChannelHandshakeLimi * You may wish to un-set this if you allow the user to (or do in an automated fashion) * double-spend the funding transaction to RBF with an alternative channel open. * - * This only applies if our counterparty set their confirmations-required value to 0, and we - * always trust our own funding transaction at 1 confirmation irrespective of this value. + * This only applies if our counterparty set their confirmations-required value to `0`, and we + * always trust our own funding transaction at `1` confirmation irrespective of this value. * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being - * `true` (0) and `false` (1). + * `true` (`0`) and `false` (`1`). * - * Default value: true + * Default value: `true` */ bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30298,36 +36871,36 @@ bool ChannelHandshakeLimits_get_trust_own_funding_0conf(const struct LDKChannelH * You may wish to un-set this if you allow the user to (or do in an automated fashion) * double-spend the funding transaction to RBF with an alternative channel open. * - * This only applies if our counterparty set their confirmations-required value to 0, and we - * always trust our own funding transaction at 1 confirmation irrespective of this value. + * This only applies if our counterparty set their confirmations-required value to `0`, and we + * always trust our own funding transaction at `1` confirmation irrespective of this value. * Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being - * `true` (0) and `false` (1). + * `true` (`0`) and `false` (`1`). * - * Default value: true + * Default value: `true` */ void ChannelHandshakeLimits_set_trust_own_funding_0conf(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); /** * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. + * [`ChannelHandshakeConfig::announce_for_forwarding`]. * * For a node which is not online reliably, this should be set to true and - * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) * channels will ever be opened. * - * Default value: true. + * Default value: `true` */ bool ChannelHandshakeLimits_get_force_announced_channel_preference(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); /** * Set to force an incoming channel to match our announced channel preference in - * [`ChannelHandshakeConfig::announced_channel`]. + * [`ChannelHandshakeConfig::announce_for_forwarding`]. * * For a node which is not online reliably, this should be set to true and - * [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) + * [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) * channels will ever be opened. * - * Default value: true. + * Default value: `true` */ void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, bool val); @@ -30337,7 +36910,7 @@ void ChannelHandshakeLimits_set_force_announced_channel_preference(struct LDKCha * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * Default value: `2016`, which we also enforce as a maximum value so you can tweak config to * reduce the loss of having useless locked funds (if your peer accepts) */ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr); @@ -30348,7 +36921,7 @@ uint16_t ChannelHandshakeLimits_get_their_to_self_delay(const struct LDKChannelH * Not checking this value would be a security issue, as our peer would be able to set it to * max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. * - * Default value: 2016, which we also enforce as a maximum value so you can tweak config to + * Default value: `2016`, which we also enforce as a maximum value so you can tweak config to * reduce the loss of having useless locked funds (if your peer accepts) */ void ChannelHandshakeLimits_set_their_to_self_delay(struct LDKChannelHandshakeLimits *NONNULL_PTR this_ptr, uint16_t val); @@ -30415,7 +36988,7 @@ void ChannelConfig_free(struct LDKChannelConfig this_obj); * This may be allowed to change at runtime in a later update, however doing so must result in * update messages sent to notify all nodes of our updated relay fee. * - * Default value: 0. + * Default value: `0` */ uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct LDKChannelConfig *NONNULL_PTR this_ptr); @@ -30425,7 +36998,7 @@ uint32_t ChannelConfig_get_forwarding_fee_proportional_millionths(const struct L * This may be allowed to change at runtime in a later update, however doing so must result in * update messages sent to notify all nodes of our updated relay fee. * - * Default value: 0. + * Default value: `0` */ void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint32_t val); @@ -30439,7 +37012,7 @@ void ChannelConfig_set_forwarding_fee_proportional_millionths(struct LDKChannelC * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through * this node. * - * Default value: 1000. + * Default value: `1000` * * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ @@ -30455,7 +37028,7 @@ uint32_t ChannelConfig_get_forwarding_fee_base_msat(const struct LDKChannelConfi * as of July 2021. Adjusting it upwards or downwards may change whether nodes route through * this node. * - * Default value: 1000. + * Default value: `1000` * * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths */ @@ -30476,9 +37049,10 @@ void ChannelConfig_set_forwarding_fee_base_msat(struct LDKChannelConfig *NONNULL * enough time to broadcast and confirm a transaction, possibly with time in between to RBF * the spending transaction). * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * Default value: `72` (12 hours at an average of 6 blocks/hour) + * + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`] (Any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead.) * * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ @@ -30499,22 +37073,26 @@ uint16_t ChannelConfig_get_cltv_expiry_delta(const struct LDKChannelConfig *NONN * enough time to broadcast and confirm a transaction, possibly with time in between to RBF * the spending transaction). * - * Default value: 72 (12 hours at an average of 6 blocks/hour). - * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as - * [`MIN_CLTV_EXPIRY_DELTA`] instead. + * Default value: `72` (12 hours at an average of 6 blocks/hour) + * + * Minimum value: [`MIN_CLTV_EXPIRY_DELTA`] (Any values less than this will be treated as + * [`MIN_CLTV_EXPIRY_DELTA`] instead.) * * [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA */ void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR this_ptr, uint16_t val); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. + * Limit our total exposure to potential loss to on-chain fees on close, including in-flight + * HTLCs which are burned to fees as they are too small to claim on-chain and fees on + * commitment transaction(s) broadcasted by our counterparty in excess of our own fee estimate. + * + * # HTLC-based Dust Exposure * * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will * not be claimable on-chain, instead being turned into additional miner fees if either * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the + * to such payments may be substantial if there are many dust HTLCs present when the * channel is force-closed. * * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a @@ -30528,18 +37106,51 @@ void ChannelConfig_set_cltv_expiry_delta(struct LDKChannelConfig *NONNULL_PTR th * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total * exposure across all three types per-channel. * - * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. + * # Transaction Fee Dust Exposure + * + * Further, counterparties broadcasting a commitment transaction in a force-close may result + * in other balance being burned to fees, and thus all fees on commitment and HTLC + * transactions in excess of our local fee estimates are included in the dust calculation. + * + * Because of this, another way to look at this limit is to divide it by 43,000 (or 218,750 + * for non-anchor channels) and see it as the maximum feerate disagreement (in sats/vB) per + * non-dust HTLC we're allowed to have with our peers before risking a force-closure for + * inbound channels. + * + * Thus, for the default value of 10_000 * a current feerate estimate of 10 sat/vB (or 2,500 + * sat/KW), we risk force-closure if we disagree with our peer by: + * * `10_000 * 2_500 / 43_000 / (483*2)` = 0.6 sat/vB for anchor channels with 483 HTLCs in + * both directions (the maximum), + * * `10_000 * 2_500 / 43_000 / (50*2)` = 5.8 sat/vB for anchor channels with 50 HTLCs in both + * directions (the LDK default max from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) + * * `10_000 * 2_500 / 218_750 / (483*2)` = 0.1 sat/vB for non-anchor channels with 483 HTLCs + * in both directions (the maximum), + * * `10_000 * 2_500 / 218_750 / (50*2)` = 1.1 sat/vB for non-anchor channels with 50 HTLCs + * in both (the LDK default maximum from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) + * + * Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement + * will scale linearly with increases (or decreases) in the our feerate estimates. Further, + * for anchor channels we expect our counterparty to use a relatively low feerate estimate + * while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) + * and feerate disagreement force-closures should only occur when theirs is higher than ours. + * + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` + * + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ struct LDKMaxDustHTLCExposure ChannelConfig_get_max_dust_htlc_exposure(const struct LDKChannelConfig *NONNULL_PTR this_ptr); /** - * Limit our total exposure to in-flight HTLCs which are burned to fees as they are too - * small to claim on-chain. + * Limit our total exposure to potential loss to on-chain fees on close, including in-flight + * HTLCs which are burned to fees as they are too small to claim on-chain and fees on + * commitment transaction(s) broadcasted by our counterparty in excess of our own fee estimate. + * + * # HTLC-based Dust Exposure * * When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will * not be claimable on-chain, instead being turned into additional miner fees if either * party force-closes the channel. Because the threshold is per-HTLC, our total exposure - * to such payments may be sustantial if there are many dust HTLCs present when the + * to such payments may be substantial if there are many dust HTLCs present when the * channel is force-closed. * * The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a @@ -30553,7 +37164,37 @@ struct LDKMaxDustHTLCExposure ChannelConfig_get_max_dust_htlc_exposure(const str * The selected limit is applied for sent, forwarded, and received HTLCs and limits the total * exposure across all three types per-channel. * - * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. + * # Transaction Fee Dust Exposure + * + * Further, counterparties broadcasting a commitment transaction in a force-close may result + * in other balance being burned to fees, and thus all fees on commitment and HTLC + * transactions in excess of our local fee estimates are included in the dust calculation. + * + * Because of this, another way to look at this limit is to divide it by 43,000 (or 218,750 + * for non-anchor channels) and see it as the maximum feerate disagreement (in sats/vB) per + * non-dust HTLC we're allowed to have with our peers before risking a force-closure for + * inbound channels. + * + * Thus, for the default value of 10_000 * a current feerate estimate of 10 sat/vB (or 2,500 + * sat/KW), we risk force-closure if we disagree with our peer by: + * * `10_000 * 2_500 / 43_000 / (483*2)` = 0.6 sat/vB for anchor channels with 483 HTLCs in + * both directions (the maximum), + * * `10_000 * 2_500 / 43_000 / (50*2)` = 5.8 sat/vB for anchor channels with 50 HTLCs in both + * directions (the LDK default max from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) + * * `10_000 * 2_500 / 218_750 / (483*2)` = 0.1 sat/vB for non-anchor channels with 483 HTLCs + * in both directions (the maximum), + * * `10_000 * 2_500 / 218_750 / (50*2)` = 1.1 sat/vB for non-anchor channels with 50 HTLCs + * in both (the LDK default maximum from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) + * + * Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement + * will scale linearly with increases (or decreases) in the our feerate estimates. Further, + * for anchor channels we expect our counterparty to use a relatively low feerate estimate + * while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) + * and feerate disagreement force-closures should only occur when theirs is higher than ours. + * + * Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` + * + * [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate */ void ChannelConfig_set_max_dust_htlc_exposure(struct LDKChannelConfig *NONNULL_PTR this_ptr, struct LDKMaxDustHTLCExposure val); @@ -30576,7 +37217,7 @@ void ChannelConfig_set_max_dust_htlc_exposure(struct LDKChannelConfig *NONNULL_P * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like. * Thus, this value is ignored when we are not the funder. * - * Default value: 1000 satoshis. + * Default value: `1000` * * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -30602,7 +37243,7 @@ uint64_t ChannelConfig_get_force_close_avoidance_max_fee_satoshis(const struct L * [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like. * Thus, this value is ignored when we are not the funder. * - * Default value: 1000 satoshis. + * Default value: `1000` * * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -30633,7 +37274,7 @@ void ChannelConfig_set_force_close_avoidance_max_fee_satoshis(struct LDKChannelC * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. * Unsetting this flag between restarts may lead to payment receive failures. * - * Default value: false. + * Default value: `false` * * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -30668,7 +37309,7 @@ bool ChannelConfig_get_accept_underpaying_htlcs(const struct LDKChannelConfig *N * Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. * Unsetting this flag between restarts may lead to payment receive failures. * - * Default value: false. + * Default value: `false` * * [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -30750,11 +37391,6 @@ void ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(struct LDKCh */ MUST_USE_RES struct LDKChannelConfigUpdate ChannelConfigUpdate_new(struct LDKCOption_u32Z forwarding_fee_proportional_millionths_arg, struct LDKCOption_u32Z forwarding_fee_base_msat_arg, struct LDKCOption_u16Z cltv_expiry_delta_arg, struct LDKCOption_MaxDustHTLCExposureZ max_dust_htlc_exposure_msat_arg, struct LDKCOption_u64Z force_close_avoidance_max_fee_satoshis_arg); -/** - * Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. - */ -MUST_USE_RES struct LDKChannelConfigUpdate ChannelConfigUpdate_default(void); - /** * Frees any resources used by the UserConfig, if is_owned is set and inner is non-NULL. */ @@ -30791,13 +37427,13 @@ struct LDKChannelConfig UserConfig_get_channel_config(const struct LDKUserConfig void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, struct LDKChannelConfig val); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * If this is set to `false`, we will reject any HTLCs which were to be forwarded over private * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a * node which is not online reliably. * * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * (using [`ChannelHandshakeConfig::announce_for_forwarding`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to `false` to * ensure you are not exposed to any forwarding risk. * * Note that because you cannot change a channel's announced state after creation, there is no @@ -30806,18 +37442,18 @@ void UserConfig_set_channel_config(struct LDKUserConfig *NONNULL_PTR this_ptr, s * all your channels and open new ones. For privacy, you should also change your node_id * (swapping all private and public key material for new ones) at that time. * - * Default value: false. + * Default value: `false` */ bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to false, we will reject any HTLCs which were to be forwarded over private + * If this is set to `false`, we will reject any HTLCs which were to be forwarded over private * channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a * node which is not online reliably. * * For nodes which are not online reliably, you should set all channels to *not* be announced - * (using [`ChannelHandshakeConfig::announced_channel`] and - * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to + * (using [`ChannelHandshakeConfig::announce_for_forwarding`] and + * [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to `false` to * ensure you are not exposed to any forwarding risk. * * Note that because you cannot change a channel's announced state after creation, there is no @@ -30826,32 +37462,34 @@ bool UserConfig_get_accept_forwards_to_priv_channels(const struct LDKUserConfig * all your channels and open new ones. For privacy, you should also change your node_id * (swapping all private and public key material for new ones) at that time. * - * Default value: false. + * Default value: `false` */ void UserConfig_set_accept_forwards_to_priv_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * If this is set to `false`, we do not accept inbound requests to open a new channel. + * + * Default value: `true` */ bool UserConfig_get_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to false, we do not accept inbound requests to open a new channel. - * Default value: true. + * If this is set to `false`, we do not accept inbound requests to open a new channel. + * + * Default value: `true` */ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new + * If this is set to `true`, the user needs to manually accept inbound requests to open a new * channel. * - * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * When set to `true`, [`Event::OpenChannelRequest`] will be triggered once a request to open a * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the * user explicitly chooses to accept the request. * - * Default value: false. + * Default value: `false` * * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -30860,15 +37498,15 @@ void UserConfig_set_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR th bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to true, the user needs to manually accept inbound requests to open a new + * If this is set to `true`, the user needs to manually accept inbound requests to open a new * channel. * - * When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a + * When set to `true`, [`Event::OpenChannelRequest`] will be triggered once a request to open a * new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a * [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the * user explicitly chooses to accept the request. * - * Default value: false. + * Default value: `false` * * [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest * [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -30877,13 +37515,13 @@ bool UserConfig_get_manually_accept_inbound_channels(const struct LDKUserConfig void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * If this is set to `true`, LDK will intercept HTLCs that are attempting to be forwarded over * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. * - * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. * - * Default value: false. + * Default value: `false` * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -30891,13 +37529,13 @@ void UserConfig_set_manually_accept_inbound_channels(struct LDKUserConfig *NONNU bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over + * If this is set to `true`, LDK will intercept HTLCs that are attempting to be forwarded over * fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC * intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. * - * Setting this to true may break backwards compatibility with LDK versions < 0.0.113. + * Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. * - * Default value: false. + * Default value: `false` * * [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid * [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -30905,37 +37543,71 @@ bool UserConfig_get_accept_intercept_htlcs(const struct LDKUserConfig *NONNULL_P void UserConfig_set_accept_intercept_htlcs(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); /** - * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple - * parts. If this is set to true, we'll accept the payment. + * If this is set to `false`, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to `true`, we'll accept the payment. * - * Setting this to true will break backwards compatibility upon downgrading to an LDK - * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * Setting this to `true` will break backwards compatibility upon downgrading to an LDK + * version prior to 0.0.116 while receiving an MPP keysend. If we have already received an MPP * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. * - * Default value: false. + * Default value: `false` * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ bool UserConfig_get_accept_mpp_keysend(const struct LDKUserConfig *NONNULL_PTR this_ptr); /** - * If this is set to false, when receiving a keysend payment we'll fail it if it has multiple - * parts. If this is set to true, we'll accept the payment. + * If this is set to `false`, when receiving a keysend payment we'll fail it if it has multiple + * parts. If this is set to `true`, we'll accept the payment. * - * Setting this to true will break backwards compatibility upon downgrading to an LDK - * version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP + * Setting this to `true` will break backwards compatibility upon downgrading to an LDK + * version prior to 0.0.116 while receiving an MPP keysend. If we have already received an MPP * keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. * - * Default value: false. + * Default value: `false` * * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ void UserConfig_set_accept_mpp_keysend(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); +/** + * If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. + * + * When set to `true`, [`Event::InvoiceReceived`] will be generated for each received + * [`Bolt12Invoice`] instead of being automatically paid after verification. Use + * [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. + * + * Default value: `false` + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ +bool UserConfig_get_manually_handle_bolt12_invoices(const struct LDKUserConfig *NONNULL_PTR this_ptr); + +/** + * If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. + * + * When set to `true`, [`Event::InvoiceReceived`] will be generated for each received + * [`Bolt12Invoice`] instead of being automatically paid after verification. Use + * [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + * [`ChannelManager::abandon_payment`] to abandon the associated payment. + * + * Default value: `false` + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived + * [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + * [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + */ +void UserConfig_set_manually_handle_bolt12_invoices(struct LDKUserConfig *NONNULL_PTR this_ptr, bool val); + /** * Constructs a new UserConfig given each field */ -MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig channel_handshake_config_arg, struct LDKChannelHandshakeLimits channel_handshake_limits_arg, struct LDKChannelConfig channel_config_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg, bool accept_intercept_htlcs_arg, bool accept_mpp_keysend_arg); +MUST_USE_RES struct LDKUserConfig UserConfig_new(struct LDKChannelHandshakeConfig channel_handshake_config_arg, struct LDKChannelHandshakeLimits channel_handshake_limits_arg, struct LDKChannelConfig channel_config_arg, bool accept_forwards_to_priv_channels_arg, bool accept_inbound_channels_arg, bool manually_accept_inbound_channels_arg, bool accept_intercept_htlcs_arg, bool accept_mpp_keysend_arg, bool manually_handle_bolt12_invoices_arg); /** * Creates a copy of the UserConfig @@ -30952,11 +37624,41 @@ MUST_USE_RES struct LDKUserConfig UserConfig_default(void); */ void BestBlock_free(struct LDKBestBlock this_obj); +/** + * The block's hash + */ +const uint8_t (*BestBlock_get_block_hash(const struct LDKBestBlock *NONNULL_PTR this_ptr))[32]; + +/** + * The block's hash + */ +void BestBlock_set_block_hash(struct LDKBestBlock *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The height at which the block was confirmed. + */ +uint32_t BestBlock_get_height(const struct LDKBestBlock *NONNULL_PTR this_ptr); + +/** + * The height at which the block was confirmed. + */ +void BestBlock_set_height(struct LDKBestBlock *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Constructs a new BestBlock given each field + */ +MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash_arg, uint32_t height_arg); + /** * Creates a copy of the BestBlock */ struct LDKBestBlock BestBlock_clone(const struct LDKBestBlock *NONNULL_PTR orig); +/** + * Generates a non-cryptographic 64-bit hash of the BestBlock. + */ +uint64_t BestBlock_hash(const struct LDKBestBlock *NONNULL_PTR o); + /** * Checks if two BestBlocks contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. @@ -30971,19 +37673,14 @@ bool BestBlock_eq(const struct LDKBestBlock *NONNULL_PTR a, const struct LDKBest MUST_USE_RES struct LDKBestBlock BestBlock_from_network(enum LDKNetwork network); /** - * Returns a `BestBlock` as identified by the given block hash and height. - */ -MUST_USE_RES struct LDKBestBlock BestBlock_new(struct LDKThirtyTwoBytes block_hash, uint32_t height); - -/** - * Returns the best block hash. + * Serialize the BestBlock object into a byte array which can be read by BestBlock_read */ -MUST_USE_RES struct LDKThirtyTwoBytes BestBlock_block_hash(const struct LDKBestBlock *NONNULL_PTR this_arg); +struct LDKCVec_u8Z BestBlock_write(const struct LDKBestBlock *NONNULL_PTR obj); /** - * Returns the best block height. + * Read a BestBlock from a byte array, created by BestBlock_write */ -MUST_USE_RES uint32_t BestBlock_height(const struct LDKBestBlock *NONNULL_PTR this_arg); +struct LDKCResult_BestBlockDecodeErrorZ BestBlock_read(struct LDKu8slice ser); /** * Calls the free function if one is set @@ -31099,9 +37796,14 @@ void BroadcasterInterface_free(struct LDKBroadcasterInterface this_ptr); enum LDKConfirmationTarget ConfirmationTarget_clone(const enum LDKConfirmationTarget *NONNULL_PTR orig); /** - * Utility method to constructs a new OnChainSweep-variant ConfirmationTarget + * Utility method to constructs a new MaximumFeeEstimate-variant ConfirmationTarget */ -enum LDKConfirmationTarget ConfirmationTarget_on_chain_sweep(void); +enum LDKConfirmationTarget ConfirmationTarget_maximum_fee_estimate(void); + +/** + * Utility method to constructs a new UrgentOnChainSweep-variant ConfirmationTarget + */ +enum LDKConfirmationTarget ConfirmationTarget_urgent_on_chain_sweep(void); /** * Utility method to constructs a new MinAllowedAnchorChannelRemoteFee-variant ConfirmationTarget @@ -31128,6 +37830,11 @@ enum LDKConfirmationTarget ConfirmationTarget_non_anchor_channel_fee(void); */ enum LDKConfirmationTarget ConfirmationTarget_channel_close_minimum(void); +/** + * Utility method to constructs a new OutputSpendingFee-variant ConfirmationTarget + */ +enum LDKConfirmationTarget ConfirmationTarget_output_spending_fee(void); + /** * Generates a non-cryptographic 64-bit hash of the ConfirmationTarget. */ @@ -31144,28 +37851,6 @@ bool ConfirmationTarget_eq(const enum LDKConfirmationTarget *NONNULL_PTR a, cons */ void FeeEstimator_free(struct LDKFeeEstimator this_ptr); -/** - * Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. - */ -void MonitorUpdateId_free(struct LDKMonitorUpdateId this_obj); - -/** - * Creates a copy of the MonitorUpdateId - */ -struct LDKMonitorUpdateId MonitorUpdateId_clone(const struct LDKMonitorUpdateId *NONNULL_PTR orig); - -/** - * Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. - */ -uint64_t MonitorUpdateId_hash(const struct LDKMonitorUpdateId *NONNULL_PTR o); - -/** - * Checks if two MonitorUpdateIds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ -bool MonitorUpdateId_eq(const struct LDKMonitorUpdateId *NONNULL_PTR a, const struct LDKMonitorUpdateId *NONNULL_PTR b); - /** * Calls the free function if one is set */ @@ -31197,8 +37882,7 @@ MUST_USE_RES struct LDKChainMonitor ChainMonitor_new(struct LDKCOption_FilterZ c * claims which are awaiting confirmation. * * Includes the balances from each [`ChannelMonitor`] *except* those included in - * `ignored_channels`, allowing you to filter out balances from channels which are still open - * (and whose balance should likely be pulled from the [`ChannelDetails`]). + * `ignored_channels`. * * See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for * inclusion in the return value. @@ -31215,17 +37899,20 @@ MUST_USE_RES struct LDKCVec_BalanceZ ChainMonitor_get_claimable_balances(const s MUST_USE_RES struct LDKCResult_LockedChannelMonitorNoneZ ChainMonitor_get_monitor(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo); /** - * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. + * Lists the funding outpoint and channel ID of each [`ChannelMonitor`] being monitored. * * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always * monitoring for on-chain state resolutions. */ -MUST_USE_RES struct LDKCVec_OutPointZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_C2Tuple_OutPointChannelIdZZ ChainMonitor_list_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** * Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). + * Each `Vec` contains `update_id`s from [`ChannelMonitor::get_latest_update_id`] for updates + * that have not yet been fully persisted. Note that if a full monitor is persisted all the pending + * monitor updates must be individually marked completed by calling [`ChainMonitor::channel_monitor_updated`]. */ -MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_u64ZZZ ChainMonitor_list_pending_monitor_updates(const struct LDKChainMonitor *NONNULL_PTR this_arg); /** * Indicates the persistence of a [`ChannelMonitor`] has completed after @@ -31235,14 +37922,21 @@ MUST_USE_RES struct LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ChainMonitor * 1) This [`ChainMonitor`] calls [`Persist::update_persisted_channel`] which stores the * update to disk and begins updating any remote (e.g. watchtower/backup) copies, * returning [`ChannelMonitorUpdateStatus::InProgress`], - * 2) once all remote copies are updated, you call this function with the - * `completed_update_id` that completed, and once all pending updates have completed the - * channel will be re-enabled. + * 2) once all remote copies are updated, you call this function with [`ChannelMonitor::get_latest_update_id`] + * or [`ChannelMonitorUpdate::update_id`] as the `completed_update_id`, and once all pending + * updates have completed the channel will be re-enabled. + * + * It is only necessary to call [`ChainMonitor::channel_monitor_updated`] when you return [`ChannelMonitorUpdateStatus::InProgress`] + * from [`Persist`] and either: + * 1. A new [`ChannelMonitor`] was added in [`Persist::persist_new_channel`], or + * 2. A [`ChannelMonitorUpdate`] was provided as part of [`Persist::update_persisted_channel`]. + * Note that we don't care about calls to [`Persist::update_persisted_channel`] where no + * [`ChannelMonitorUpdate`] was provided. * * Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently * registered [`ChannelMonitor`]s. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, struct LDKMonitorUpdateId completed_update_id); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChainMonitor_channel_monitor_updated(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint funding_txo, uint64_t completed_update_id); /** * Gets a [`Future`] that completes when an event is available either via @@ -31265,6 +37959,29 @@ MUST_USE_RES struct LDKFuture ChainMonitor_get_update_future(const struct LDKCha */ void ChainMonitor_rebroadcast_pending_claims(const struct LDKChainMonitor *NONNULL_PTR this_arg); +/** + * Triggers rebroadcasts of pending claims from force-closed channels after a transaction + * signature generation failure. + * + * `monitor_opt` can be used as a filter to only trigger them for a specific channel monitor. + * + * Note that monitor_opt (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChainMonitor_signer_unblocked(const struct LDKChainMonitor *NONNULL_PTR this_arg, struct LDKOutPoint monitor_opt); + +/** + * Archives fully resolved channel monitors by calling [`Persist::archive_persisted_channel`]. + * + * This is useful for pruning fully resolved monitors from the monitor set and primary + * storage so they are not kept in memory and reloaded on restart. + * + * Should be called occasionally (once every handful of blocks or on startup). + * + * Depending on the implementation of [`Persist::archive_persisted_channel`] the monitor + * data could be moved to an archive location or removed entirely. + */ +void ChainMonitor_archive_fully_resolved_channel_monitors(const struct LDKChainMonitor *NONNULL_PTR this_arg); + /** * Constructs a new Listen which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is @@ -31332,6 +38049,26 @@ uint64_t ChannelMonitorUpdate_get_update_id(const struct LDKChannelMonitorUpdate */ void ChannelMonitorUpdate_set_update_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, uint64_t val); +/** + * The channel ID associated with these updates. + * + * Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and + * always `Some` otherwise. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelId ChannelMonitorUpdate_get_channel_id(const struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr); + +/** + * The channel ID associated with these updates. + * + * Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and + * always `Some` otherwise. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelMonitorUpdate_set_channel_id(struct LDKChannelMonitorUpdate *NONNULL_PTR this_ptr, struct LDKChannelId val); + /** * Creates a copy of the ChannelMonitorUpdate */ @@ -31369,6 +38106,11 @@ struct LDKMonitorEvent MonitorEvent_clone(const struct LDKMonitorEvent *NONNULL_ */ struct LDKMonitorEvent MonitorEvent_htlcevent(struct LDKHTLCUpdate a); +/** + * Utility method to constructs a new HolderForceClosedWithInfo-variant MonitorEvent + */ +struct LDKMonitorEvent MonitorEvent_holder_force_closed_with_info(struct LDKClosureReason reason, struct LDKOutPoint outpoint, struct LDKChannelId channel_id); + /** * Utility method to constructs a new HolderForceClosed-variant MonitorEvent */ @@ -31377,7 +38119,7 @@ struct LDKMonitorEvent MonitorEvent_holder_force_closed(struct LDKOutPoint a); /** * Utility method to constructs a new Completed-variant MonitorEvent */ -struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, uint64_t monitor_update_id); +struct LDKMonitorEvent MonitorEvent_completed(struct LDKOutPoint funding_txo, struct LDKChannelId channel_id, uint64_t monitor_update_id); /** * Checks if two MonitorEvents contain equal inner contents. @@ -31422,6 +38164,37 @@ struct LDKCVec_u8Z HTLCUpdate_write(const struct LDKHTLCUpdate *NONNULL_PTR obj) */ struct LDKCResult_HTLCUpdateDecodeErrorZ HTLCUpdate_read(struct LDKu8slice ser); +/** + * Creates a copy of the BalanceSource + */ +enum LDKBalanceSource BalanceSource_clone(const enum LDKBalanceSource *NONNULL_PTR orig); + +/** + * Utility method to constructs a new HolderForceClosed-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_holder_force_closed(void); + +/** + * Utility method to constructs a new CounterpartyForceClosed-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_counterparty_force_closed(void); + +/** + * Utility method to constructs a new CoopClose-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_coop_close(void); + +/** + * Utility method to constructs a new Htlc-variant BalanceSource + */ +enum LDKBalanceSource BalanceSource_htlc(void); + +/** + * Checks if two BalanceSources contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool BalanceSource_eq(const enum LDKBalanceSource *NONNULL_PTR a, const enum LDKBalanceSource *NONNULL_PTR b); + /** * Frees any resources used by the Balance */ @@ -31435,12 +38208,12 @@ struct LDKBalance Balance_clone(const struct LDKBalance *NONNULL_PTR orig); /** * Utility method to constructs a new ClaimableOnChannelClose-variant Balance */ -struct LDKBalance Balance_claimable_on_channel_close(uint64_t amount_satoshis); +struct LDKBalance Balance_claimable_on_channel_close(uint64_t amount_satoshis, uint64_t transaction_fee_satoshis, uint64_t outbound_payment_htlc_rounded_msat, uint64_t outbound_forwarded_htlc_rounded_msat, uint64_t inbound_claiming_htlc_rounded_msat, uint64_t inbound_htlc_rounded_msat); /** * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance */ -struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t amount_satoshis, uint32_t confirmation_height); +struct LDKBalance Balance_claimable_awaiting_confirmations(uint64_t amount_satoshis, uint32_t confirmation_height, enum LDKBalanceSource source); /** * Utility method to constructs a new ContentiousClaimable-variant Balance @@ -31450,7 +38223,7 @@ struct LDKBalance Balance_contentious_claimable(uint64_t amount_satoshis, uint32 /** * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance */ -struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t amount_satoshis, uint32_t claimable_height, struct LDKThirtyTwoBytes payment_hash); +struct LDKBalance Balance_maybe_timeout_claimable_htlc(uint64_t amount_satoshis, uint32_t claimable_height, struct LDKThirtyTwoBytes payment_hash, bool outbound_payment); /** * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance @@ -31469,9 +38242,15 @@ struct LDKBalance Balance_counterparty_revoked_output_claimable(uint64_t amount_ bool Balance_eq(const struct LDKBalance *NONNULL_PTR a, const struct LDKBalance *NONNULL_PTR b); /** - * The amount claimable, in satoshis. This excludes balances that we are unsure if we are able - * to claim, this is because we are waiting for a preimage or for a timeout to expire. For more - * information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and + * The amount claimable, in satoshis. + * + * For outbound payments, this excludes the balance from the possible HTLC timeout. + * + * For forwarded payments, this includes the balance from the possible HTLC timeout as + * (to be conservative) that balance does not include routing fees we'd earn if we'd claim + * the balance from a preimage in a successful forward. + * + * For more information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and * [`Balance::MaybePreimageClaimableHTLC`]. * * On-chain fees required to claim the balance are not included in this amount. @@ -31512,6 +38291,11 @@ MUST_USE_RES uint64_t ChannelMonitor_get_latest_update_id(const struct LDKChanne */ MUST_USE_RES struct LDKC2Tuple_OutPointCVec_u8ZZ ChannelMonitor_get_funding_txo(const struct LDKChannelMonitor *NONNULL_PTR this_arg); +/** + * Gets the channel_id of the channel this ChannelMonitor is monitoring for. + */ +MUST_USE_RES struct LDKChannelId ChannelMonitor_channel_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + /** * Gets a list of txids, with their output scripts (in the order they appear in the * transaction), which we must learn about spends of via block_connected(). @@ -31543,10 +38327,12 @@ MUST_USE_RES struct LDKCVec_MonitorEventZ ChannelMonitor_get_and_clear_pending_m * An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in * order to handle these events. * + * Will return a [`ReplayEvent`] error if event handling failed and should eventually be retried. + * * [`SpendableOutputs`]: crate::events::Event::SpendableOutputs * [`BumpTransaction`]: crate::events::Event::BumpTransaction */ -void ChannelMonitor_process_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKEventHandler *NONNULL_PTR handler); +MUST_USE_RES struct LDKCResult_NoneReplayEventZ ChannelMonitor_process_pending_events(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKEventHandler *NONNULL_PTR handler); /** * Gets the counterparty's initial commitment transaction. The returned commitment @@ -31622,22 +38408,17 @@ MUST_USE_RES struct LDKCResult_TransactionNoneZ ChannelMonitor_sign_to_local_jus MUST_USE_RES struct LDKPublicKey ChannelMonitor_get_counterparty_node_id(const struct LDKChannelMonitor *NONNULL_PTR this_arg); /** - * Used by [`ChannelManager`] deserialization to broadcast the latest holder state if its copy - * of the channel state was out-of-date. - * - * You may also use this to broadcast the latest local commitment transaction, either because + * You may use this to broadcast the latest local commitment transaction, either because * a monitor update failed or because we've fallen behind (i.e. we've received proof that our * counterparty side knows a revocation secret we gave them that they shouldn't know). * - * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty + * Broadcasting these transactions in this manner is UNSAFE, as they allow counterparty * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't * close channel with their commitment transaction after a substantial amount of time. Best * may be to contact the other node operator out-of-band to coordinate other options available * to you. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -MUST_USE_RES struct LDKCVec_TransactionZ ChannelMonitor_get_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); +void ChannelMonitor_broadcast_latest_holder_commitment_txn(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKBroadcasterInterface *NONNULL_PTR broadcaster, const struct LDKFeeEstimator *NONNULL_PTR fee_estimator, const struct LDKLogger *NONNULL_PTR logger); /** * Processes transactions in a newly connected block, which may result in any of the following: @@ -31712,6 +38493,17 @@ MUST_USE_RES struct LDKBestBlock ChannelMonitor_current_best_block(const struct */ void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); +/** + * Returns true if the monitor has pending claim requests that are not fully confirmed yet. + */ +MUST_USE_RES bool ChannelMonitor_has_pending_claims(const struct LDKChannelMonitor *NONNULL_PTR this_arg); + +/** + * Triggers rebroadcasts of pending claims from a force-closed channel after a transaction + * signature generation failure. + */ +void ChannelMonitor_signer_unblocked(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKBroadcasterInterface broadcaster, struct LDKFeeEstimator fee_estimator, const struct LDKLogger *NONNULL_PTR logger); + /** * Returns the descriptors for relevant outputs (i.e., those that we can spend) within the * transaction if they exist and the transaction has at least [`ANTI_REORG_DELAY`] @@ -31734,6 +38526,15 @@ void ChannelMonitor_rebroadcast_pending_claims(const struct LDKChannelMonitor *N */ MUST_USE_RES struct LDKCVec_SpendableOutputDescriptorZ ChannelMonitor_get_spendable_outputs(const struct LDKChannelMonitor *NONNULL_PTR this_arg, struct LDKTransaction tx, uint32_t confirmation_height); +/** + * Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of + * its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set). + * + * This function returns true only if [`Self::get_claimable_balances`] has been empty for at least + * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + */ +MUST_USE_RES bool ChannelMonitor_is_fully_resolved(const struct LDKChannelMonitor *NONNULL_PTR this_arg, const struct LDKLogger *NONNULL_PTR logger); + /** * Gets the balances in this channel which are either claimable by us if we were to * force-close the channel now or which are claimable on-chain (possibly awaiting @@ -31805,9 +38606,9 @@ bool OutPoint_eq(const struct LDKOutPoint *NONNULL_PTR a, const struct LDKOutPoi uint64_t OutPoint_hash(const struct LDKOutPoint *NONNULL_PTR o); /** - * Convert an `OutPoint` to a lightning channel id. + * Get the string representation of a OutPoint object */ -MUST_USE_RES struct LDKThirtyTwoBytes OutPoint_to_channel_id(const struct LDKOutPoint *NONNULL_PTR this_arg); +struct LDKStr OutPoint_to_str(const struct LDKOutPoint *NONNULL_PTR o); /** * Serialize the OutPoint object into a byte array which can be read by OutPoint_read @@ -31861,6 +38662,23 @@ void InboundHTLCErr_set_msg(struct LDKInboundHTLCErr *NONNULL_PTR this_ptr, stru */ MUST_USE_RES struct LDKInboundHTLCErr InboundHTLCErr_new(uint16_t err_code_arg, struct LDKCVec_u8Z err_data_arg, struct LDKStr msg_arg); +/** + * Creates a copy of the InboundHTLCErr + */ +struct LDKInboundHTLCErr InboundHTLCErr_clone(const struct LDKInboundHTLCErr *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the InboundHTLCErr. + */ +uint64_t InboundHTLCErr_hash(const struct LDKInboundHTLCErr *NONNULL_PTR o); + +/** + * Checks if two InboundHTLCErrs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool InboundHTLCErr_eq(const struct LDKInboundHTLCErr *NONNULL_PTR a, const struct LDKInboundHTLCErr *NONNULL_PTR b); + /** * Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information * about the intended next-hop for the HTLC. @@ -31872,7 +38690,7 @@ MUST_USE_RES struct LDKInboundHTLCErr InboundHTLCErr_new(uint16_t err_code_arg, * * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable */ -struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ peel_payment_onion(const struct LDKUpdateAddHTLC *NONNULL_PTR msg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKLogger *NONNULL_PTR logger, uint32_t cur_height, bool accept_mpp_keysend, bool allow_skimmed_fees); +struct LDKCResult_PendingHTLCInfoInboundHTLCErrZ peel_payment_onion(const struct LDKUpdateAddHTLC *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, uint32_t cur_height, bool accept_mpp_keysend, bool allow_skimmed_fees); /** * Frees any resources used by the PendingHTLCRouting @@ -31892,12 +38710,12 @@ struct LDKPendingHTLCRouting PendingHTLCRouting_forward(struct LDKOnionPacket on /** * Utility method to constructs a new Receive-variant PendingHTLCRouting */ -struct LDKPendingHTLCRouting PendingHTLCRouting_receive(struct LDKFinalOnionHopData payment_data, struct LDKCOption_CVec_u8ZZ payment_metadata, uint32_t incoming_cltv_expiry, struct LDKThirtyTwoBytes phantom_shared_secret, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); +struct LDKPendingHTLCRouting PendingHTLCRouting_receive(struct LDKFinalOnionHopData payment_data, struct LDKCOption_CVec_u8ZZ payment_metadata, struct LDKCOption_PaymentContextZ payment_context, uint32_t incoming_cltv_expiry, struct LDKThirtyTwoBytes phantom_shared_secret, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); /** * Utility method to constructs a new ReceiveKeysend-variant PendingHTLCRouting */ -struct LDKPendingHTLCRouting PendingHTLCRouting_receive_keysend(struct LDKFinalOnionHopData payment_data, struct LDKThirtyTwoBytes payment_preimage, struct LDKCOption_CVec_u8ZZ payment_metadata, uint32_t incoming_cltv_expiry, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); +struct LDKPendingHTLCRouting PendingHTLCRouting_receive_keysend(struct LDKFinalOnionHopData payment_data, struct LDKThirtyTwoBytes payment_preimage, struct LDKCOption_CVec_u8ZZ payment_metadata, uint32_t incoming_cltv_expiry, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs, bool requires_blinded_error); /** * Frees any resources used by the BlindedForward, if is_owned is set and inner is non-NULL. @@ -31930,10 +38748,30 @@ enum LDKBlindedFailure BlindedForward_get_failure(const struct LDKBlindedForward */ void BlindedForward_set_failure(struct LDKBlindedForward *NONNULL_PTR this_ptr, enum LDKBlindedFailure val); +/** + * Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being + * forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that + * starts at the next hop. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKPublicKey BlindedForward_get_next_blinding_override(const struct LDKBlindedForward *NONNULL_PTR this_ptr); + +/** + * Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being + * forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that + * starts at the next hop. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void BlindedForward_set_next_blinding_override(struct LDKBlindedForward *NONNULL_PTR this_ptr, struct LDKPublicKey val); + /** * Constructs a new BlindedForward given each field + * + * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKBlindedForward BlindedForward_new(struct LDKPublicKey inbound_blinding_point_arg, enum LDKBlindedFailure failure_arg); +MUST_USE_RES struct LDKBlindedForward BlindedForward_new(struct LDKPublicKey inbound_blinding_point_arg, enum LDKBlindedFailure failure_arg, struct LDKPublicKey next_blinding_override_arg); /** * Creates a copy of the BlindedForward @@ -32186,17713 +39024,21097 @@ MUST_USE_RES struct LDKChainParameters ChainParameters_new(enum LDKNetwork netwo struct LDKChainParameters ChainParameters_clone(const struct LDKChainParameters *NONNULL_PTR orig); /** - * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RecentPaymentDetails */ -void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); +void RecentPaymentDetails_free(struct LDKRecentPaymentDetails this_ptr); /** - * Base routing fee in millisatoshis. + * Creates a copy of the RecentPaymentDetails */ -uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +struct LDKRecentPaymentDetails RecentPaymentDetails_clone(const struct LDKRecentPaymentDetails *NONNULL_PTR orig); /** - * Base routing fee in millisatoshis. + * Utility method to constructs a new AwaitingInvoice-variant RecentPaymentDetails */ -void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRecentPaymentDetails RecentPaymentDetails_awaiting_invoice(struct LDKThirtyTwoBytes payment_id); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Utility method to constructs a new Pending-variant RecentPaymentDetails */ -uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +struct LDKRecentPaymentDetails RecentPaymentDetails_pending(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, uint64_t total_msat); /** - * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails */ -void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKRecentPaymentDetails RecentPaymentDetails_fulfilled(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * Utility method to constructs a new Abandoned-variant RecentPaymentDetails */ -uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); +struct LDKRecentPaymentDetails RecentPaymentDetails_abandoned(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); /** - * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, - * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s - * `cltv_expiry_delta` for more details. + * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. */ -void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); +void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); /** - * Constructs a new CounterpartyForwardingInfo given each field + * The list of channels to be included in the invoice route hints. */ -MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); +struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * Creates a copy of the CounterpartyForwardingInfo + * The list of channels to be included in the invoice route hints. */ -struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); +void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); /** - * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); +uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * The node_id of our counterparty + * A fake scid used for representing the phantom node's fake channel in generating the invoice + * route hints. */ -struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); /** - * The node_id of our counterparty + * The pubkey of the real backing node that would ultimately receive the payment. */ -void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * The pubkey of the real backing node that would ultimately receive the payment. */ -struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The Features the channel counterparty provided upon last connection. - * Useful for routing as it is the most up-to-date copy of the counterparty's features and - * many routing-relevant features are present in the init context. + * Constructs a new PhantomRouteHints given each field */ -void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. - * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. - * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + * Creates a copy of the PhantomRouteHints */ -uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); /** - * The value, in satoshis, that must always be held in the channel for our counterparty. This - * value ensures that if our counterparty broadcasts a revoked state, we can punish them by - * claiming at least this value on chain. + * Constructs a new `ChannelManager` to hold several channels and route between them. * - * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * The current time or latest block header time can be provided as the `current_timestamp`. * - * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat - */ -void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); - -/** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. + * This is the main \"logic hub\" for all channel-related actions, and implements + * [`ChannelMessageHandler`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Non-proportional fees are fixed according to our risk using the provided fee estimator. + * + * Users need to notify the new `ChannelManager` when a new block is connected or + * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting + * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for + * more details. + * + * [`block_connected`]: chain::Listen::block_connected + * [`block_disconnected`]: chain::Listen::block_disconnected + * [`params.best_block.block_hash`]: chain::BestBlock::block_hash */ -struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKUserConfig config, struct LDKChainParameters params, uint32_t current_timestamp); /** - * Information on the fees and requirements that the counterparty requires when forwarding - * payments to us through this channel. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Gets the current configuration applied to all new channels. */ -void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); +MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Creates a new outbound channel to the given remote node and with the given value. + * + * `user_channel_id` will be provided back as in + * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events + * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a + * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it + * is simply copied to events and otherwise ignored. + * + * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is + * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`]. + * + * Note that we do not check if you are currently connected to the given peer. If no + * connection is available, the outbound `open_channel` message may fail to send, resulting in + * the channel eventually being silently forgotten (dropped on reload). + * + * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the + * channel. Otherwise, a random one will be generated for you. + * + * Returns the new Channel's temporary `channel_id`. This ID will appear as + * [`Event::FundingGenerationReady::temporary_channel_id`] and in + * [`ChannelDetails::channel_id`] until after + * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for + * one derived from the funding transaction's TXID. If the counterparty rejects the channel + * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. + * + * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id + * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id + * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id + * + * Note that temporary_channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_ChannelIdAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, struct LDKU128 user_channel_id, struct LDKChannelId temporary_channel_id, struct LDKUserConfig override_config); /** - * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field - * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message - * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for + * more information. */ -void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * Gets the list of usable channels, in random order. Useful as an argument to + * [`Router::find_route`] to ensure non-announced channels are used. + * + * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the + * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria + * are. */ -struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + * Gets the list of channels we have with a given counterparty, in random order. */ -void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels_with_counterparty(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); /** - * Constructs a new ChannelCounterparty given each field + * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a + * successful path, or have unresolved HTLCs. * - * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * This can be useful for payments that may have been prepared, but ultimately not sent, as a + * result of a crash. If such a payment exists, is not listed here, and an + * [`Event::PaymentSent`] has not been received, you may consider resending the payment. + * + * [`Event::PaymentSent`]: events::Event::PaymentSent */ -MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); +MUST_USE_RES struct LDKCVec_RecentPaymentDetailsZ ChannelManager_list_recent_payments(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelCounterparty + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`] + * fee estimate. + * * If our counterparty is the channel initiator, we will require a channel closing + * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which + * would appear on a force-closure transaction, whichever is lower. We will allow our + * counterparty to pay as much fee as they'd like, however. + * + * May generate a [`SendShutdown`] message event on success, which should be relayed. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the + * channel. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum + * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown */ -struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id); /** - * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs + * will be accepted on the given channel, and after additional timeout/the closing of all + * pending HTLCs, the channel will be closed on chain. + * + * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated + * the channel being closed or not: + * * If we are the channel initiator, we will pay at least this feerate on the closing + * transaction. The upper-bound is set by + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`] + * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). + * * If our counterparty is the channel initiator, we will refuse to accept a channel closure + * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which + * will appear on a force-closure transaction, whichever is lower). + * + * The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction. + * Will fail if a shutdown script has already been set for this channel by + * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must + * also be compatible with our and the counterparty's features. + * + * May generate a [`SendShutdown`] message event on success, which should be relayed. + * + * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to + * generate a shutdown scriptpubkey or destination script set by + * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the + * channel. + * + * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis + * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee + * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * + * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelDetails_free(struct LDKChannelDetails this_obj); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_feerate_and_script(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u32Z target_feerate_sats_per_1000_weight, struct LDKShutdownScript shutdown_script); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * Force closes a channel, immediately broadcasting the latest local transaction(s), + * rejecting new HTLCs. + * + * The provided `error_message` is sent to connected peers for closing + * channels and should be a human-readable description of what went wrong. + * + * Fails if `channel_id` is unknown to the manager, or if the `counterparty_node_id` + * isn't the counterparty of the corresponding channel. */ -const uint8_t (*ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKStr error_message); /** - * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, - * thereafter this is the txid of the funding transaction xor the funding transaction output). - * Note that this means this value is *not* persistent - it can change once during the - * lifetime of the channel. + * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting + * the latest local transaction(s). + * + * The provided `error_message` is sent to connected peers for closing channels and should + * be a human-readable description of what went wrong. + * + * Fails if `channel_id` is unknown to the manager, or if the + * `counterparty_node_id` isn't the counterparty of the corresponding channel. + * You can always broadcast the latest local transaction(s) via + * [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]. */ -void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR channel_id, struct LDKPublicKey counterparty_node_id, struct LDKStr error_message); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * Force close all channels, immediately broadcasting the latest local commitment transaction + * for each to the chain and rejecting new HTLCs on each. + * + * The provided `error_message` is sent to connected peers for closing channels and should + * be a human-readable description of what went wrong. */ -struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); /** - * Parameters which apply to our counterparty. See individual fields for more information. + * Force close all channels rejecting new HTLCs on each but without broadcasting the latest + * local transaction(s). + * + * The provided `error_message` is sent to connected peers for closing channels and + * should be a human-readable description of what went wrong. */ -void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); +void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKStr error_message); /** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. + * Sends a payment along a given route. * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. + * This method is *DEPRECATED*, use [`Self::send_payment`] instead. If you wish to fix the + * route for a payment, do so by matching the [`PaymentId`] passed to + * [`Router::find_route_with_id`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The Channel's funding transaction output, if we've negotiated the funding transaction with - * our counterparty already. + * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] + * fields for more info. + * + * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via + * [`PeerManager::process_events`]). * - * Note that, if this has been set, `channel_id` will be equivalent to - * `funding_txo.unwrap().to_channel_id()`. + * # Avoiding Duplicate Payments * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); - -/** - * The features which this channel operates with. See individual features for more info. + * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this + * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment + * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an + * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a + * second payment with the same [`PaymentId`]. * - * `None` until negotiation completes and the channel type is finalized. + * Thus, in order to ensure duplicate payments are not sent, you should implement your own + * tracking of payments, including state to indicate once a payment has completed. Because you + * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should + * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the + * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Additionally, in the scenario where we begin the process of sending a payment, but crash + * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're + * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See + * [`ChannelManager::list_recent_payments`] for more information. + * + * # Possible Error States on [`PaymentSendFailure`] + * + * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with + * each entry matching the corresponding-index entry in the route paths, see + * [`PaymentSendFailure`] for more info. + * + * In general, a path may raise: + * * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee, + * node public key) is specified. + * * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been + * closed, doesn't exist, or the peer is currently disconnected. + * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the + * relevant updates. + * + * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been + * irrevocably committed to on our end. In such a case, do NOT retry the payment with a + * different route unless you intend to pay twice! + * + * [`RouteHop`]: crate::routing::router::RouteHop + * [`Event::PaymentSent`]: events::Event::PaymentSent + * [`Event::PaymentFailed`]: events::Event::PaymentFailed + * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress */ -struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRoute route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** - * The features which this channel operates with. See individual features for more info. - * - * `None` until negotiation completes and the channel type is finalized. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on + * `route_params` and retry failed payment paths based on `retry_strategy`. */ -void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. + * Signals that no further attempts for the given payment should occur. Useful if you have a + * pending outbound payment with retries remaining, but wish to stop retrying the payment before + * retries are exhausted. * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. + * # Event Generation * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon + * as there are no remaining pending HTLCs for this payment. * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required - */ -struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The position of the funding transaction in the chain. None if the funding transaction has - * not yet been confirmed and the channel fully opened. + * Note that calling this method does *not* prevent a payment from succeeding. You must still + * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to + * determine the ultimate status of a payment. * - * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound - * payments instead of this. See [`get_inbound_payment_scid`]. + * # Requested Invoices * - * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may - * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning + * the payment prior to receiving the invoice will result in an [`Event::PaymentFailed`] and + * prevent any attempts at paying it once received. * - * [`inbound_scid_alias`]: Self::inbound_scid_alias - * [`outbound_scid_alias`]: Self::outbound_scid_alias - * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid - * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid - * [`confirmations_required`]: Self::confirmations_required - */ -void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); - -/** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). + * # Restart Behavior * - * This will be `None` as long as the channel is not available for routing outbound payments. + * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the + * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated. * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by us and - * usable in place of [`short_channel_id`] to reference the channel in outbound routes when - * the channel has not yet been confirmed (as long as [`confirmations_required`] is - * `Some(0)`). + * Send a spontaneous payment, which is a payment that does not require the recipient to have + * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify + * the preimage, it must be a cryptographically secure random value that no intermediate node + * would be able to guess -- otherwise, an intermediate node may claim the payment and it will + * never reach the recipient. * - * This will be `None` as long as the channel is not available for routing outbound payments. + * See [`send_payment`] documentation for more details on the return value of this function + * and idempotency guarantees provided by the [`PaymentId`] key. * - * [`short_channel_id`]: Self::short_channel_id - * [`confirmations_required`]: Self::confirmations_required + * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See + * [`send_payment`] for more information about the risks of duplicate preimage usage. + * + * [`send_payment`]: Self::send_payment */ -void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. + * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route + * based on `route_params` and retry failed payment paths based on `retry_strategy`. * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. + * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous + * payments. * - * [`short_channel_id`]: Self::short_channel_id + * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); /** - * An optional [`short_channel_id`] alias for this channel, randomly generated by our - * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our - * counterparty will recognize the alias provided here in place of the [`short_channel_id`] - * when they see a payment to be routed to us. - * - * Our counterparty may choose to rotate this value at any time, though will always recognize - * previous values for inbound payment forwarding. - * - * [`short_channel_id`]: Self::short_channel_id + * Send a payment that is probing the given route for liquidity. We calculate the + * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows + * us to easily discern them from real payments. */ -void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPath path); /** - * The value, in satoshis, of this channel as appears in the funding output + * Sends payment probes over all paths of a route that would be used to pay the given + * amount to the given `node_id`. + * + * See [`ChannelManager::send_preflight_probes`] for more information. */ -uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ChannelManager_send_spontaneous_preflight_probes(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, uint64_t amount_msat, uint32_t final_cltv_expiry_delta, struct LDKCOption_u64Z liquidity_limit_multiplier); /** - * The value, in satoshis, of this channel as appears in the funding output + * Sends payment probes over all paths of a route that would be used to pay a route found + * according to the given [`RouteParameters`]. + * + * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting + * the actual payment. Note this is only useful if there likely is sufficient time for the + * probe to settle before sending out the actual payment, e.g., when waiting for user + * confirmation in a wallet UI. + * + * Otherwise, there is a chance the probe could take up some liquidity needed to complete the + * actual payment. Users should therefore be cautious and might avoid sending probes if + * liquidity is scarce and/or they don't expect the probe to return before they send the + * payment. To mitigate this issue, channels with available liquidity less than the required + * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight + * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`. */ -void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ChannelManager_send_preflight_probes(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRouteParameters route_params, struct LDKCOption_u64Z liquidity_limit_multiplier); /** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. + * Call this upon creation of a funding transaction for the given channel. * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs + * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation + * across the p2p network. * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat - */ -struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The value, in satoshis, that must always be held in the channel for us. This value ensures - * that if we broadcast a revoked state, our counterparty can punish us by claiming at least - * this value on chain. + * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided + * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. * - * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * May panic if the output found in the funding transaction is duplicative with some other + * channel (note that this should be trivially prevented by using unique funding transaction + * keys per-channel). * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Do NOT broadcast the funding transaction yourself. When we have safely received our + * counterparty's signature the funding transaction will automatically be broadcast via the + * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. * - * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat - */ -void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); - -/** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects - * serialized with LDK versions prior to 0.0.113. + * Note that this includes RBF or similar transaction replacement strategies - lightning does + * not currently support replacing a funding transaction on an existing channel. Instead, + * create a new channel with a conflicting funding transaction. * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels - */ -struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound - * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects - * serialized with LDK versions prior to 0.0.113. + * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend + * the wallet software generating the funding transaction to apply anti-fee sniping as + * implemented by Bitcoin Core wallet. See + * for more details. * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady + * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed */ -void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); /** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. + * **Unsafe**: This method does not validate the spent output. It is the caller's + * responsibility to ensure the spent outputs are SegWit, as well as making sure the funding + * transaction has a final absolute locktime, i.e., its locktime is lower than the next block height. * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. - */ -struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The currently negotiated fee rate denominated in satoshi per 1000 weight units, - * which is applied to commitment and HTLC transactions. + * For a safer method, please refer to [`ChannelManager::funding_transaction_generated`]. * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. - */ -void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); - -/** - * Our total balance. This is the amount we would get if we close the channel. - * This value is not exact. Due to various in-flight changes and feerate changes, exactly this - * amount is not likely to be recoverable on close. + * Call this in response to a [`Event::FundingGenerationReady`] event. * - * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose - * balance is not available for inclusion in new outbound HTLCs). This further does not include - * any pending outgoing HTLCs which are awaiting some other resolution to be sent. - * This does not consider any on-chain fees. + * Note that if this method is called successfully, the funding transaction won't be + * broadcasted and you are expected to broadcast it manually when receiving the + * [`Event::FundingTxBroadcastSafe`] event. * - * See also [`ChannelDetails::outbound_capacity_msat`] - */ -uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * Our total balance. This is the amount we would get if we close the channel. - * This value is not exact. Due to various in-flight changes and feerate changes, exactly this - * amount is not likely to be recoverable on close. + * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided + * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. * - * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose - * balance is not available for inclusion in new outbound HTLCs). This further does not include - * any pending outgoing HTLCs which are awaiting some other resolution to be sent. - * This does not consider any on-chain fees. + * May panic if the funding output is duplicative with some other channel (note that this + * should be trivially prevented by using unique funding transaction keys per-channel). * - * See also [`ChannelDetails::outbound_capacity_msat`] + * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend + * the wallet software generating the funding transaction to apply anti-fee sniping as + * implemented by Bitcoin Core wallet. See for + * more details. + * + * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady + * [`Event::FundingTxBroadcastSafe`]: crate::events::Event::FundingTxBroadcastSafe + * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed + * [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated */ -void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_unsafe_manual_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. + * Call this upon creation of a batch funding transaction for the given channels. * - * See also [`ChannelDetails::balance_msat`] + * Return values are identical to [`Self::funding_transaction_generated`], respective to + * each individual channel and transaction output. * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. + * Do NOT broadcast the funding transaction yourself. This batch funding transaction + * will only be broadcast when we have safely received and persisted the counterparty's + * signature for each channel. + * + * If there is an error, all channels in the batch are to be considered closed. */ -uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_batch_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_ChannelIdPublicKeyZZ temporary_channels, struct LDKTransaction funding_transaction); /** - * The available outbound capacity for sending HTLCs to the remote peer. This does not include - * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new outbound HTLCs). This further does not include any pending - * outgoing HTLCs which are awaiting some other resolution to be sent. + * Atomically applies partial updates to the [`ChannelConfig`] of the given channels. * - * See also [`ChannelDetails::balance_msat`] + * Once the updates are applied, each eligible channel (advertised with a known short channel + * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], + * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated + * containing the new [`ChannelUpdate`] message which should be broadcast to the network. * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we - * should be able to spend nearly this amount. - */ -void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); - -/** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. + * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect + * `counterparty_node_id` is provided. * - * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], - * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. - */ -uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The available outbound capacity for sending a single HTLC to the remote peer. This is - * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by - * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us - * to use a limit as close as possible to the HTLC limit we can currently send. + * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value + * below [`MIN_CLTV_EXPIRY_DELTA`]. * - * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], - * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. - */ -void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); - -/** - * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of - * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than - * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a - * route which is valid. - */ -uint64_t ChannelDetails_get_next_outbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of - * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than - * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a - * route which is valid. - */ -void ChannelDetails_set_next_outbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); - -/** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. + * If an error is returned, none of the updates should be considered applied. * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat + * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta + * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelUnavailable`]: APIError::ChannelUnavailable + * [`APIMisuseError`]: APIError::APIMisuseError */ -uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_partial_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ChannelIdZ channel_ids, const struct LDKChannelConfigUpdate *NONNULL_PTR config_update); /** - * The available inbound capacity for the remote peer to send HTLCs to us. This does not - * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not - * available for inclusion in new inbound HTLCs). - * Note that there are some corner cases not fully handled here, so the actual available - * inbound capacity may be slightly higher than this. + * Atomically updates the [`ChannelConfig`] for the given channels. * - * This value is not exact. Due to various in-flight changes, feerate changes, and our - * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. - * However, our counterparty should be able to spend nearly this amount. - */ -void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); - -/** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. + * Once the updates are applied, each eligible channel (advertised with a known short channel + * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], + * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated + * containing the new [`ChannelUpdate`] message which should be broadcast to the network. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect + * `counterparty_node_id` is provided. * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth - */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The number of required confirmations on the funding transaction before the funding will be - * considered \"locked\". This number is selected by the channel fundee (i.e. us if - * [`is_outbound`] is *not* set), and can be selected for inbound channels with - * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with - * [`ChannelHandshakeLimits::max_minimum_depth`]. + * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value + * below [`MIN_CLTV_EXPIRY_DELTA`]. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * If an error is returned, none of the updates should be considered applied. * - * [`is_outbound`]: ChannelDetails::is_outbound - * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth - * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths + * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat + * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta + * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelUnavailable`]: APIError::ChannelUnavailable + * [`APIMisuseError`]: APIError::APIMisuseError */ -void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ChannelIdZ channel_ids, const struct LDKChannelConfig *NONNULL_PTR config); /** - * The current number of confirmations on the funding transaction. + * Attempts to forward an intercepted HTLC over the provided channel id and with the provided + * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event. * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. - */ -struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); - -/** - * The current number of confirmations on the funding transaction. + * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time + * channel to a receiving node if the node lacks sufficient inbound liquidity. * - * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use + * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the + * receiver's invoice route hints. These route hints will signal to LDK to generate an + * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or + * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. + * + * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop + * you from forwarding more than you received. See + * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount + * than expected. + * + * Errors if the event was not handled in time, in which case the HTLC was automatically failed + * backwards. + * + * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs + * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat */ -void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_forward_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id, const struct LDKChannelId *NONNULL_PTR next_hop_channel_id, struct LDKPublicKey next_node_id, uint64_t amt_to_forward_msat); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. + * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to + * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`]. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Errors if the event was not handled in time, in which case the HTLC was automatically failed + * backwards. + * + * [`HTLCIntercepted`]: events::Event::HTLCIntercepted */ -struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_fail_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id); /** - * The number of blocks (after our commitment transaction confirms) that we will need to wait - * until we can claim our funds after we force-close the channel. During this time our - * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty - * force-closes the channel and broadcasts a commitment transaction we do not have to wait any - * time to claim our non-HTLC-encumbered funds. + * Processes HTLCs which are pending waiting on random forward delay. * - * This value will be `None` for outbound channels until the counterparty accepts the channel. + * Should only really ever be called in response to a PendingHTLCsForwardable event. + * Will likely generate further events. */ -void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); +void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * True if the channel was initiated (and thus funded) by us. + * Performs actions which should happen on startup and roughly once per minute thereafter. + * + * This currently includes: + * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, + * * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more + * than a minute, informing the network that they should no longer attempt to route over + * the channel. + * * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs + * with the current [`ChannelConfig`]. + * * Removing peers which have disconnected but and no longer have any channels. + * * Force-closing and removing channels which have not completed establishment in a timely manner. + * * Forgetting about stale outbound payments, either those that have already been fulfilled + * or those awaiting an invoice that hasn't been delivered in the necessary amount of time. + * The latter is determined using the system clock in `std` and the highest seen block time + * minus two hours in `no-std`. + * + * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate + * estimate fetches. + * + * [`ChannelUpdate`]: msgs::ChannelUpdate + * [`ChannelConfig`]: crate::util::config::ChannelConfig */ -bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * True if the channel was initiated (and thus funded) by us. + * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect + * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources + * along the path (including in our own channel on which we received it). + * + * Note that in some cases around unclean shutdown, it is possible the payment may have + * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a + * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment + * may have already been failed automatically by LDK if it was nearing its expiration time. + * + * While LDK will never claim a payment automatically on your behalf (i.e. without you calling + * [`ChannelManager::claim_funds`]), you should still monitor for + * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on + * startup during which time claims that were in-progress at shutdown may be replayed. */ -void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. + * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the + * reason for the failure. * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * See [`FailureCode`] for valid failure codes. */ -bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void ChannelManager_fail_htlc_backwards_with_reason(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32], struct LDKFailureCode failure_code); /** - * True if the channel is confirmed, channel_ready messages have been exchanged, and the - * channel is not currently being shut down. `channel_ready` message exchange implies the - * required confirmation count has been reached (and we were connected to the peer at some - * point after the funding transaction received enough confirmations). The required - * confirmation count is provided in [`confirmations_required`]. + * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any + * [`MessageSendEvent`]s needed to claim the payment. * - * [`confirmations_required`]: ChannelDetails::confirmations_required + * This method is guaranteed to ensure the payment has been claimed but only if the current + * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race + * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment + * successful. It will generally be available in the next [`process_pending_events`] call. + * + * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or + * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` + * event matches your expectation. If you fail to do so and call this method, you may provide + * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. + * + * This function will fail the payment if it has custom TLVs with even type numbers, as we + * will assume they are unknown. If you intend to accept even custom TLVs, you should use + * [`claim_funds_with_known_custom_tlvs`]. + * + * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable + * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline + * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed + * [`process_pending_events`]: EventsProvider::process_pending_events + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs */ -void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +void ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); /** - * The stage of the channel's shutdown. - * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with + * even type numbers. * - * Returns a copy of the field. + * # Note + * + * You MUST check you've understood all even TLVs before using this to + * claim, otherwise you may unintentionally agree to some protocol you do not understand. + * + * [`claim_funds`]: Self::claim_funds */ -struct LDKCOption_ChannelShutdownStateZ ChannelDetails_get_channel_shutdown_state(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +void ChannelManager_claim_funds_with_known_custom_tlvs(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); /** - * The stage of the channel's shutdown. - * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * Gets the node_id held by this ChannelManager */ -void ChannelDetails_set_channel_shutdown_state(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_ChannelShutdownStateZ val); +MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * Accepts a request to open a channel after a [`Event::OpenChannelRequest`]. * - * This is a strict superset of `is_channel_ready`. + * The `temporary_channel_id` parameter indicates which inbound channel should be accepted, + * and the `counterparty_node_id` parameter is the id of the peer which has requested to open + * the channel. + * + * The `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. + * + * Note that this method will return an error and reject the channel, if it requires support + * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be + * used to accept such channels. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); /** - * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) - * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating + * it as confirmed immediately. * - * This is a strict superset of `is_channel_ready`. + * The `user_channel_id` parameter will be provided back in + * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond + * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. + * + * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel + * and (if the counterparty agrees), enables forwarding of payments immediately. + * + * This fully trusts that the counterparty has honestly and correctly constructed the funding + * transaction and blindly assumes that it will eventually confirm. + * + * If it does not confirm before we decide to close the channel, or if the funding transaction + * does not pay to the correct script the correct amount, *you will lose funds*. + * + * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest + * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id */ -void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKChannelId *NONNULL_PTR temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); /** - * True if this channel is (or will be) publicly-announced. + * Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the + * [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer's + * expiration will be `absolute_expiry` if `Some`, otherwise it will not expire. + * + * # Privacy + * + * Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given + * `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for + * privacy implications as well as those of the parameterized [`Router`], which implements + * [`MessageRouter`]. + * + * Also, uses a derived signing pubkey in the offer for recipient privacy. + * + * # Limitations + * + * Requires a direct connection to the introduction node in the responding [`InvoiceRequest`]'s + * reply path. + * + * # Errors + * + * Errors if the parameterized [`Router`] is unable to create a blinded path for the offer. + * + * [`Offer`]: crate::offers::offer::Offer + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -bool ChannelDetails_get_is_public(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ ChannelManager_create_offer_builder(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z absolute_expiry); /** - * True if this channel is (or will be) publicly-announced. + * Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the + * [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. + * + * # Payment + * + * The provided `payment_id` is used to ensure that only one invoice is paid for the refund. + * See [Avoiding Duplicate Payments] for other requirements once the payment has been sent. + * + * The builder will have the provided expiration set. Any changes to the expiration on the + * returned builder will not be honored by [`ChannelManager`]. For `no-std`, the highest seen + * block time minus two hours is used for the current time when determining if the refund has + * expired. + * + * To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the + * invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail + * with an [`Event::PaymentFailed`]. + * + * If `max_total_routing_fee_msat` is not specified, The default from + * [`RouteParameters::from_payment_params_and_value`] is applied. + * + * # Privacy + * + * Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given + * `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for + * privacy implications as well as those of the parameterized [`Router`], which implements + * [`MessageRouter`]. + * + * Also, uses a derived payer id in the refund for payer privacy. + * + * # Limitations + * + * Requires a direct connection to an introduction node in the responding + * [`Bolt12Invoice::payment_paths`]. + * + * # Errors + * + * Errors if: + * - a duplicate `payment_id` is provided given the caveats in the aforementioned link, + * - `amount_msats` is invalid, or + * - the parameterized [`Router`] is unable to create a blinded path for the refund. + * + * [`Refund`]: crate::offers::refund::Refund + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths + * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments */ -void ChannelDetails_set_is_public(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ ChannelManager_create_refund_builder(const struct LDKChannelManager *NONNULL_PTR this_arg, uint64_t amount_msats, uint64_t absolute_expiry, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, struct LDKCOption_u64Z max_total_routing_fee_msat); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 - */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and + * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual + * [`Bolt12Invoice`] once it is received. + * + * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by + * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request. + * The optional parameters are used in the builder, if `Some`: + * - `quantity` for [`InvoiceRequest::quantity`] which must be set if + * [`Offer::expects_quantity`] is `true`. + * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and + * - `payer_note` for [`InvoiceRequest::payer_note`]. + * + * If `max_total_routing_fee_msat` is not specified, The default from + * [`RouteParameters::from_payment_params_and_value`] is applied. + * + * # Payment + * + * The provided `payment_id` is used to ensure that only one invoice is paid for the request + * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has + * been sent. + * + * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the + * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the + * payment will fail with an [`Event::PaymentFailed`]. + * + * # Privacy + * + * For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`] + * to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the + * docs of the parameterized [`Router`], which implements [`MessageRouter`]. + * + * # Limitations + * + * Requires a direct connection to an introduction node in [`Offer::paths`] or to + * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding + * [`Bolt12Invoice::payment_paths`]. + * + * # Errors + * + * Errors if: + * - a duplicate `payment_id` is provided given the caveats in the aforementioned link, + * - the provided parameters are invalid for the offer, + * - the offer is for an unsupported chain, or + * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice + * request. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity + * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note + * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths + * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments + */ +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ ChannelManager_pay_for_offer(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOffer *NONNULL_PTR offer, struct LDKCOption_u64Z quantity, struct LDKCOption_u64Z amount_msats, struct LDKCOption_StrZ payer_note, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, struct LDKCOption_u64Z max_total_routing_fee_msat); /** - * The smallest value HTLC (in msat) we will accept, for this channel. This field - * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion + * message. + * + * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a + * [`BlindedPaymentPath`] containing the [`PaymentSecret`] needed to reconstruct the + * corresponding [`PaymentPreimage`]. It is returned purely for informational purposes. + * + * # Limitations + * + * Requires a direct connection to an introduction node in [`Refund::paths`] or to + * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each + * node meeting the aforementioned criteria, but there's no guarantee that they will be + * received and no retries will be made. + * + * # Errors + * + * Errors if: + * - the refund is for an unsupported chain, or + * - the parameterized [`Router`] is unable to create a blinded payment path or reply path for + * the invoice. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ ChannelManager_request_refund_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRefund *NONNULL_PTR refund); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Gets a payment secret and payment hash for use in an invoice given to a third party wishing + * to pay us. + * + * This differs from [`create_inbound_payment_for_hash`] only in that it generates the + * [`PaymentHash`] and [`PaymentPreimage`] for you. + * + * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`] event, which + * will have the [`PaymentClaimable::purpose`] return `Some` for [`PaymentPurpose::preimage`]. That + * should then be passed directly to [`claim_funds`]. + * + * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. + * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * + * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [`claim_funds`]: Self::claim_funds + * [`PaymentClaimable`]: events::Event::PaymentClaimable + * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose + * [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage + * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash */ -struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * The largest value HTLC (in msat) we currently will accept, for this channel. + * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is + * stored external to LDK. + * + * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a + * payment secret fetched via this method or [`create_inbound_payment`], and which is at least + * the `min_value_msat` provided here, if one is provided. + * + * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though + * note that LDK will not stop you from registering duplicate payment hashes for inbound + * payments. + * + * `min_value_msat` should be set if the invoice being generated contains a value. Any payment + * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` + * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the + * sender \"proof-of-payment\" unless they have paid the required amount. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. This should roughly match the expiry time set in the invoice. + * After this many seconds, we will remove the inbound payment, resulting in any attempts to + * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for + * invoices when no timeout is set. + * + * Note that we use block header time to time-out pending inbound payments (with some margin + * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will + * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. + * If you need exact expiry semantics, you should enforce them upon receipt of + * [`PaymentClaimable`]. + * + * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` + * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * + * Note that a malicious eavesdropper can intuit whether an inbound payment was created by + * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. + * + * # Note + * + * If you register an inbound payment with this method, then serialize the `ChannelManager`, then + * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. + * + * Errors if `min_value_msat` is greater than total bitcoin supply. + * + * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [`create_inbound_payment`]: Self::create_inbound_payment + * [`PaymentClaimable`]: events::Event::PaymentClaimable */ -void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry); /** - * Set of configurable parameters that affect channel operation. - * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * Gets an LDK-generated payment preimage from a payment hash and payment secret that were + * previously returned from [`create_inbound_payment`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`create_inbound_payment`]: Self::create_inbound_payment */ -struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); /** - * Set of configurable parameters that affect channel operation. + * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids + * are used when constructing the phantom invoice's route hints. * - * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * [phantom node payments]: crate::sign::PhantomKeysManager + */ +MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets route hints for use in receiving [phantom node payments]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [phantom node payments]: crate::sign::PhantomKeysManager */ -void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); +MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Constructs a new ChannelDetails given each field + * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are + * used when constructing the route hints for HTLCs intended to be intercepted. See + * [`ChannelManager::forward_intercepted_htlc`]. * - * Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that this method is not guaranteed to return unique values, you may need to call it a few + * times to get a unique scid. */ -MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t next_outbound_htlc_minimum_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, struct LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg, bool is_usable_arg, bool is_public_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg); +MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelDetails + * Gets inflight HTLC information by processing pending outbound payments that are in + * our channels. May be used during pathfinding to account for in-use channel liquidity. */ -struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); +MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Gets the current SCID which should be used to identify this channel for inbound payments. - * This should be used for providing invoice hints or in any other context where our - * counterparty will forward a payment to us. + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + */ +struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + */ +struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new Listen which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + */ +struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Constructs a new Confirm which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + */ +struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); + +/** + * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or + * may have events that need processing. * - * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the - * [`ChannelDetails::short_channel_id`]. See those for more information. + * In order to check if this [`ChannelManager`] needs persisting, call + * [`Self::get_and_clear_needs_persistence`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`ChannelManager`] and should instead register actions to be taken later. */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKFuture ChannelManager_get_event_or_persistence_needed_future(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Gets the current SCID which should be used to identify this channel for outbound payments. - * This should be used in [`Route`]s to describe the first hop or in other contexts where - * we're sending or forwarding a payment outbound over this channel. + * Returns true if this [`ChannelManager`] needs to be persisted. * - * This is either the [`ChannelDetails::short_channel_id`], if set, or the - * [`ChannelDetails::outbound_scid_alias`]. See those for more information. + * See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that + * indicates this should be checked. */ -MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelManager_get_and_clear_needs_persistence(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelShutdownState + * Gets the latest best block which was connected either via the [`chain::Listen`] or + * [`chain::Confirm`] interfaces. */ -enum LDKChannelShutdownState ChannelShutdownState_clone(const enum LDKChannelShutdownState *NONNULL_PTR orig); +MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState + * Fetches the set of [`NodeFeatures`] flags that are provided by or required by + * [`ChannelManager`]. */ -enum LDKChannelShutdownState ChannelShutdownState_not_shutting_down(void); +MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState + * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by + * [`ChannelManager`]. */ -enum LDKChannelShutdownState ChannelShutdownState_shutdown_initiated(void); +MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState + * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by + * [`ChannelManager`]. */ -enum LDKChannelShutdownState ChannelShutdownState_resolving_htlcs(void); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState + * Fetches the set of [`InitFeatures`] flags that are provided by or required by + * [`ChannelManager`]. */ -enum LDKChannelShutdownState ChannelShutdownState_negotiating_closing_fee(void); +MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -enum LDKChannelShutdownState ChannelShutdownState_shutdown_complete(void); +struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Checks if two ChannelShutdownStates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is */ -bool ChannelShutdownState_eq(const enum LDKChannelShutdownState *NONNULL_PTR a, const enum LDKChannelShutdownState *NONNULL_PTR b); +struct LDKOffersMessageHandler ChannelManager_as_OffersMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Frees any resources used by the RecentPaymentDetails + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is */ -void RecentPaymentDetails_free(struct LDKRecentPaymentDetails this_ptr); +struct LDKAsyncPaymentsMessageHandler ChannelManager_as_AsyncPaymentsMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Creates a copy of the RecentPaymentDetails + * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is */ -struct LDKRecentPaymentDetails RecentPaymentDetails_clone(const struct LDKRecentPaymentDetails *NONNULL_PTR orig); +struct LDKNodeIdLookUp ChannelManager_as_NodeIdLookUp(const struct LDKChannelManager *NONNULL_PTR this_arg); /** - * Utility method to constructs a new AwaitingInvoice-variant RecentPaymentDetails + * Fetches the set of [`InitFeatures`] flags that are provided by or required by + * [`ChannelManager`]. */ -struct LDKRecentPaymentDetails RecentPaymentDetails_awaiting_invoice(struct LDKThirtyTwoBytes payment_id); +struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR config); /** - * Utility method to constructs a new Pending-variant RecentPaymentDetails + * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read */ -struct LDKRecentPaymentDetails RecentPaymentDetails_pending(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, uint64_t total_msat); +struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); /** - * Utility method to constructs a new Fulfilled-variant RecentPaymentDetails + * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write */ -struct LDKRecentPaymentDetails RecentPaymentDetails_fulfilled(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash); +struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); /** - * Utility method to constructs a new Abandoned-variant RecentPaymentDetails + * Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read */ -struct LDKRecentPaymentDetails RecentPaymentDetails_abandoned(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash); +struct LDKCVec_u8Z BlindedForward_write(const struct LDKBlindedForward *NONNULL_PTR obj); /** - * Frees any resources used by the PhantomRouteHints, if is_owned is set and inner is non-NULL. + * Read a BlindedForward from a byte array, created by BlindedForward_write */ -void PhantomRouteHints_free(struct LDKPhantomRouteHints this_obj); +struct LDKCResult_BlindedForwardDecodeErrorZ BlindedForward_read(struct LDKu8slice ser); /** - * The list of channels to be included in the invoice route hints. + * Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read */ -struct LDKCVec_ChannelDetailsZ PhantomRouteHints_get_channels(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PendingHTLCRouting_write(const struct LDKPendingHTLCRouting *NONNULL_PTR obj); /** - * The list of channels to be included in the invoice route hints. + * Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write */ -void PhantomRouteHints_set_channels(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKCVec_ChannelDetailsZ val); +struct LDKCResult_PendingHTLCRoutingDecodeErrorZ PendingHTLCRouting_read(struct LDKu8slice ser); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read */ -uint64_t PhantomRouteHints_get_phantom_scid(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PendingHTLCInfo_write(const struct LDKPendingHTLCInfo *NONNULL_PTR obj); /** - * A fake scid used for representing the phantom node's fake channel in generating the invoice - * route hints. + * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write */ -void PhantomRouteHints_set_phantom_scid(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_PendingHTLCInfoDecodeErrorZ PendingHTLCInfo_read(struct LDKu8slice ser); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Serialize the BlindedFailure object into a byte array which can be read by BlindedFailure_read */ -struct LDKPublicKey PhantomRouteHints_get_real_node_pubkey(const struct LDKPhantomRouteHints *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z BlindedFailure_write(const enum LDKBlindedFailure *NONNULL_PTR obj); /** - * The pubkey of the real backing node that would ultimately receive the payment. + * Read a BlindedFailure from a byte array, created by BlindedFailure_write */ -void PhantomRouteHints_set_real_node_pubkey(struct LDKPhantomRouteHints *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_BlindedFailureDecodeErrorZ BlindedFailure_read(struct LDKu8slice ser); /** - * Constructs a new PhantomRouteHints given each field + * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read */ -MUST_USE_RES struct LDKPhantomRouteHints PhantomRouteHints_new(struct LDKCVec_ChannelDetailsZ channels_arg, uint64_t phantom_scid_arg, struct LDKPublicKey real_node_pubkey_arg); +struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); /** - * Creates a copy of the PhantomRouteHints + * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. */ -struct LDKPhantomRouteHints PhantomRouteHints_clone(const struct LDKPhantomRouteHints *NONNULL_PTR orig); +void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); /** - * Constructs a new `ChannelManager` to hold several channels and route between them. - * - * The current time or latest block header time can be provided as the `current_timestamp`. - * - * This is the main \"logic hub\" for all channel-related actions, and implements - * [`ChannelMessageHandler`]. - * - * Non-proportional fees are fixed according to our risk using the provided fee estimator. - * - * Users need to notify the new `ChannelManager` when a new block is connected or - * disconnected using its [`block_connected`] and [`block_disconnected`] methods, starting - * from after [`params.best_block.block_hash`]. See [`chain::Listen`] and [`chain::Confirm`] for - * more details. - * - * [`block_connected`]: chain::Listen::block_connected - * [`block_disconnected`]: chain::Listen::block_disconnected - * [`params.best_block.block_hash`]: chain::BestBlock::block_hash + * A cryptographically secure source of entropy. */ -MUST_USE_RES struct LDKChannelManager ChannelManager_new(struct LDKFeeEstimator fee_est, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKUserConfig config, struct LDKChainParameters params, uint32_t current_timestamp); +const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Gets the current configuration applied to all new channels. + * A cryptographically secure source of entropy. */ -MUST_USE_RES struct LDKUserConfig ChannelManager_get_current_default_configuration(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); /** - * Creates a new outbound channel to the given remote node and with the given value. - * - * `user_channel_id` will be provided back as in - * [`Event::FundingGenerationReady::user_channel_id`] to allow tracking of which events - * correspond with which `create_channel` call. Note that the `user_channel_id` defaults to a - * randomized value for inbound channels. `user_channel_id` has no meaning inside of LDK, it - * is simply copied to events and otherwise ignored. - * - * Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is - * greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`. - * - * Raises [`APIError::ChannelUnavailable`] if the channel cannot be opened due to failing to - * generate a shutdown scriptpubkey or destination script set by - * [`SignerProvider::get_shutdown_scriptpubkey`] or [`SignerProvider::get_destination_script`]. - * - * Note that we do not check if you are currently connected to the given peer. If no - * connection is available, the outbound `open_channel` message may fail to send, resulting in - * the channel eventually being silently forgotten (dropped on reload). - * - * If `temporary_channel_id` is specified, it will be used as the temporary channel ID of the - * channel. Otherwise, a random one will be generated for you. - * - * Returns the new Channel's temporary `channel_id`. This ID will appear as - * [`Event::FundingGenerationReady::temporary_channel_id`] and in - * [`ChannelDetails::channel_id`] until after - * [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for - * one derived from the funding transaction's TXID. If the counterparty rejects the channel - * immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`]. - * - * [`Event::FundingGenerationReady::user_channel_id`]: events::Event::FundingGenerationReady::user_channel_id - * [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id - * [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id - * - * Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None + * A signer that is able to perform node-scoped cryptographic operations. */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesAPIErrorZ ChannelManager_create_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey their_network_key, uint64_t channel_value_satoshis, uint64_t push_msat, struct LDKU128 user_channel_id, struct LDKCOption_ThirtyTwoBytesZ temporary_channel_id, struct LDKUserConfig override_config); +const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Gets the list of open channels, in random order. See [`ChannelDetails`] field documentation for - * more information. + * A signer that is able to perform node-scoped cryptographic operations. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); /** - * Gets the list of usable channels, in random order. Useful as an argument to - * [`Router::find_route`] to ensure non-announced channels are used. - * - * These are guaranteed to have their [`ChannelDetails::is_usable`] value set to true, see the - * documentation for [`ChannelDetails::is_usable`] for more info on exactly what the criteria - * are. + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_usable_channels(const struct LDKChannelManager *NONNULL_PTR this_arg); +const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Gets the list of channels we have with a given counterparty, in random order. + * The keys provider which will give us relevant keys. Some keys will be loaded during + * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel + * signing data. */ -MUST_USE_RES struct LDKCVec_ChannelDetailsZ ChannelManager_list_channels_with_counterparty(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id); +void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); /** - * Returns in an undefined order recent payments that -- if not fulfilled -- have yet to find a - * successful path, or have unresolved HTLCs. - * - * This can be useful for payments that may have been prepared, but ultimately not sent, as a - * result of a crash. If such a payment exists, is not listed here, and an - * [`Event::PaymentSent`] has not been received, you may consider resending the payment. + * The fee_estimator for use in the ChannelManager in the future. * - * [`Event::PaymentSent`]: events::Event::PaymentSent + * No calls to the FeeEstimator will be made during deserialization. */ -MUST_USE_RES struct LDKCVec_RecentPaymentDetailsZ ChannelManager_list_recent_payments(const struct LDKChannelManager *NONNULL_PTR this_arg); +const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * * If we are the channel initiator, we will pay between our [`ChannelCloseMinimum`] and - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`] - * fee estimate. - * * If our counterparty is the channel initiator, we will require a channel closing - * transaction feerate of at least our [`ChannelCloseMinimum`] feerate or the feerate which - * would appear on a force-closure transaction, whichever is lower. We will allow our - * counterparty to pay as much fee as they'd like, however. - * - * May generate a [`SendShutdown`] message event on success, which should be relayed. - * - * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to - * generate a shutdown scriptpubkey or destination script set by - * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the - * channel. + * The fee_estimator for use in the ChannelManager in the future. * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum - * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee - * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * No calls to the FeeEstimator will be made during deserialization. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); /** - * Begins the process of closing a channel. After this call (plus some timeout), no new HTLCs - * will be accepted on the given channel, and after additional timeout/the closing of all - * pending HTLCs, the channel will be closed on chain. - * - * `target_feerate_sat_per_1000_weight` has different meanings depending on if we initiated - * the channel being closed or not: - * * If we are the channel initiator, we will pay at least this feerate on the closing - * transaction. The upper-bound is set by - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`] plus our [`NonAnchorChannelFee`] - * fee estimate (or `target_feerate_sat_per_1000_weight`, if it is greater). - * * If our counterparty is the channel initiator, we will refuse to accept a channel closure - * transaction feerate below `target_feerate_sat_per_1000_weight` (or the feerate which - * will appear on a force-closure transaction, whichever is lower). - * - * The `shutdown_script` provided will be used as the `scriptPubKey` for the closing transaction. - * Will fail if a shutdown script has already been set for this channel by - * ['ChannelHandshakeConfig::commit_upfront_shutdown_pubkey`]. The given shutdown script must - * also be compatible with our and the counterparty's features. - * - * May generate a [`SendShutdown`] message event on success, which should be relayed. - * - * Raises [`APIError::ChannelUnavailable`] if the channel cannot be closed due to failing to - * generate a shutdown scriptpubkey or destination script set by - * [`SignerProvider::get_shutdown_scriptpubkey`]. A force-closure may be needed to close the - * channel. - * - * [`ChannelConfig::force_close_avoidance_max_fee_satoshis`]: crate::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis - * [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee - * [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown + * The chain::Watch for use in the ChannelManager in the future. * - * Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_close_channel_with_feerate_and_script(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKCOption_u32Z target_feerate_sats_per_1000_weight, struct LDKShutdownScript shutdown_script); +const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Force closes a channel, immediately broadcasting the latest local transaction(s) and - * rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to - * the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding - * channel. + * The chain::Watch for use in the ChannelManager in the future. + * + * No calls to the chain::Watch will be made during deserialization. It is assumed that + * you have deserialized ChannelMonitors separately and will add them to your + * chain::Watch after deserializing this ChannelManager. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); /** - * Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting - * the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the - * `counterparty_node_id` isn't the counterparty of the corresponding channel. - * - * You can always get the latest local transaction(s) to broadcast from - * [`ChannelMonitor::get_latest_holder_commitment_txn`]. + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_force_close_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*channel_id)[32], struct LDKPublicKey counterparty_node_id); +const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Force close all channels, immediately broadcasting the latest local commitment transaction - * for each to the chain and rejecting new HTLCs on each. + * The BroadcasterInterface which will be used in the ChannelManager in the future and may be + * used to broadcast the latest local commitment transactions of channels which must be + * force-closed during deserialization. */ -void ChannelManager_force_close_all_channels_broadcasting_latest_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); /** - * Force close all channels rejecting new HTLCs on each but without broadcasting the latest - * local transaction(s). + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. + * + * No calls to the router will be made during deserialization. */ -void ChannelManager_force_close_all_channels_without_broadcasting_txn(const struct LDKChannelManager *NONNULL_PTR this_arg); +const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); /** - * Sends a payment along a given route. + * The router which will be used in the ChannelManager in the future for finding routes + * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. * - * Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] - * fields for more info. + * No calls to the router will be made during deserialization. + */ +void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); + +/** + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. + */ +const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * The Logger for use in the ChannelManager and which may be used to log information during + * deserialization. + */ +void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); + +/** + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. + */ +struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); + +/** + * Default settings used for new channels. Any existing channels will continue to use the + * runtime settings which were stored when the ChannelManager was serialized. + */ +void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); + +/** + * Simple utility function to create a ChannelManagerReadArgs which creates the monitor + * HashMap for you. This is primarily useful for C bindings where it is not practical to + * populate a HashMap directly from C. + */ +MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); + +/** + * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write + */ +struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); + +/** + * Frees any resources used by the DelayedPaymentBasepoint, if is_owned is set and inner is non-NULL. + */ +void DelayedPaymentBasepoint_free(struct LDKDelayedPaymentBasepoint this_obj); + +struct LDKPublicKey DelayedPaymentBasepoint_get_a(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr); + +void DelayedPaymentBasepoint_set_a(struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new DelayedPaymentBasepoint given each field + */ +MUST_USE_RES struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two DelayedPaymentBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool DelayedPaymentBasepoint_eq(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR a, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the DelayedPaymentBasepoint + */ +struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_clone(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the DelayedPaymentBasepoint. + */ +uint64_t DelayedPaymentBasepoint_hash(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey DelayedPaymentBasepoint_to_public_key(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg); + +/** + *Derives the \"tweak\" used in calculate [`DelayedPaymentKey::from_basepoint`].\n\n[`DelayedPaymentKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + */ +MUST_USE_RES struct LDKThirtyTwoBytes DelayedPaymentBasepoint_derive_add_tweak(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); + +/** + * Serialize the DelayedPaymentBasepoint object into a byte array which can be read by DelayedPaymentBasepoint_read + */ +struct LDKCVec_u8Z DelayedPaymentBasepoint_write(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR obj); + +/** + * Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write + */ +struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ DelayedPaymentBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the DelayedPaymentKey, if is_owned is set and inner is non-NULL. + */ +void DelayedPaymentKey_free(struct LDKDelayedPaymentKey this_obj); + +struct LDKPublicKey DelayedPaymentKey_get_a(const struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr); + +void DelayedPaymentKey_set_a(struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new DelayedPaymentKey given each field + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two DelayedPaymentKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool DelayedPaymentKey_eq(const struct LDKDelayedPaymentKey *NONNULL_PTR a, const struct LDKDelayedPaymentKey *NONNULL_PTR b); + +/** + * Creates a copy of the DelayedPaymentKey + */ +struct LDKDelayedPaymentKey DelayedPaymentKey_clone(const struct LDKDelayedPaymentKey *NONNULL_PTR orig); + +/** + *Derive a public delayedpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_basepoint(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + *Build a delayedpubkey directly from an already-derived private key + */ +MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_secret_key(const uint8_t (*sk)[32]); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey DelayedPaymentKey_to_public_key(const struct LDKDelayedPaymentKey *NONNULL_PTR this_arg); + +/** + * Serialize the DelayedPaymentKey object into a byte array which can be read by DelayedPaymentKey_read + */ +struct LDKCVec_u8Z DelayedPaymentKey_write(const struct LDKDelayedPaymentKey *NONNULL_PTR obj); + +/** + * Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write + */ +struct LDKCResult_DelayedPaymentKeyDecodeErrorZ DelayedPaymentKey_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the HtlcBasepoint, if is_owned is set and inner is non-NULL. + */ +void HtlcBasepoint_free(struct LDKHtlcBasepoint this_obj); + +struct LDKPublicKey HtlcBasepoint_get_a(const struct LDKHtlcBasepoint *NONNULL_PTR this_ptr); + +void HtlcBasepoint_set_a(struct LDKHtlcBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new HtlcBasepoint given each field + */ +MUST_USE_RES struct LDKHtlcBasepoint HtlcBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two HtlcBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool HtlcBasepoint_eq(const struct LDKHtlcBasepoint *NONNULL_PTR a, const struct LDKHtlcBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the HtlcBasepoint + */ +struct LDKHtlcBasepoint HtlcBasepoint_clone(const struct LDKHtlcBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the HtlcBasepoint. + */ +uint64_t HtlcBasepoint_hash(const struct LDKHtlcBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey HtlcBasepoint_to_public_key(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg); + +/** + *Derives the \"tweak\" used in calculate [`HtlcKey::from_basepoint`].\n\n[`HtlcKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. + */ +MUST_USE_RES struct LDKThirtyTwoBytes HtlcBasepoint_derive_add_tweak(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg, struct LDKPublicKey per_commitment_point); + +/** + * Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read + */ +struct LDKCVec_u8Z HtlcBasepoint_write(const struct LDKHtlcBasepoint *NONNULL_PTR obj); + +/** + * Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write + */ +struct LDKCResult_HtlcBasepointDecodeErrorZ HtlcBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the HtlcKey, if is_owned is set and inner is non-NULL. + */ +void HtlcKey_free(struct LDKHtlcKey this_obj); + +struct LDKPublicKey HtlcKey_get_a(const struct LDKHtlcKey *NONNULL_PTR this_ptr); + +void HtlcKey_set_a(struct LDKHtlcKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new HtlcKey given each field + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two HtlcKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool HtlcKey_eq(const struct LDKHtlcKey *NONNULL_PTR a, const struct LDKHtlcKey *NONNULL_PTR b); + +/** + * Creates a copy of the HtlcKey + */ +struct LDKHtlcKey HtlcKey_clone(const struct LDKHtlcKey *NONNULL_PTR orig); + +/** + *Derive a public htlcpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_from_basepoint(const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + *Build a htlcpubkey directly from an already-derived private key + */ +MUST_USE_RES struct LDKHtlcKey HtlcKey_from_secret_key(const uint8_t (*sk)[32]); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey HtlcKey_to_public_key(const struct LDKHtlcKey *NONNULL_PTR this_arg); + +/** + * Serialize the HtlcKey object into a byte array which can be read by HtlcKey_read + */ +struct LDKCVec_u8Z HtlcKey_write(const struct LDKHtlcKey *NONNULL_PTR obj); + +/** + * Read a HtlcKey from a byte array, created by HtlcKey_write + */ +struct LDKCResult_HtlcKeyDecodeErrorZ HtlcKey_read(struct LDKu8slice ser); + +/** + * Adds a tweak to a public key to derive a new public key. * - * May generate [`UpdateHTLCs`] message(s) event on success, which should be relayed (e.g. via - * [`PeerManager::process_events`]). + * May panic if `tweak` is not the output of a SHA-256 hash. + */ +struct LDKPublicKey add_public_key_tweak(struct LDKPublicKey base_point, const uint8_t (*tweak)[32]); + +/** + * Frees any resources used by the RevocationBasepoint, if is_owned is set and inner is non-NULL. + */ +void RevocationBasepoint_free(struct LDKRevocationBasepoint this_obj); + +struct LDKPublicKey RevocationBasepoint_get_a(const struct LDKRevocationBasepoint *NONNULL_PTR this_ptr); + +void RevocationBasepoint_set_a(struct LDKRevocationBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new RevocationBasepoint given each field + */ +MUST_USE_RES struct LDKRevocationBasepoint RevocationBasepoint_new(struct LDKPublicKey a_arg); + +/** + * Checks if two RevocationBasepoints contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool RevocationBasepoint_eq(const struct LDKRevocationBasepoint *NONNULL_PTR a, const struct LDKRevocationBasepoint *NONNULL_PTR b); + +/** + * Creates a copy of the RevocationBasepoint + */ +struct LDKRevocationBasepoint RevocationBasepoint_clone(const struct LDKRevocationBasepoint *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RevocationBasepoint. + */ +uint64_t RevocationBasepoint_hash(const struct LDKRevocationBasepoint *NONNULL_PTR o); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey RevocationBasepoint_to_public_key(const struct LDKRevocationBasepoint *NONNULL_PTR this_arg); + +/** + * Serialize the RevocationBasepoint object into a byte array which can be read by RevocationBasepoint_read + */ +struct LDKCVec_u8Z RevocationBasepoint_write(const struct LDKRevocationBasepoint *NONNULL_PTR obj); + +/** + * Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write + */ +struct LDKCResult_RevocationBasepointDecodeErrorZ RevocationBasepoint_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the RevocationKey, if is_owned is set and inner is non-NULL. + */ +void RevocationKey_free(struct LDKRevocationKey this_obj); + +struct LDKPublicKey RevocationKey_get_a(const struct LDKRevocationKey *NONNULL_PTR this_ptr); + +void RevocationKey_set_a(struct LDKRevocationKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Constructs a new RevocationKey given each field + */ +MUST_USE_RES struct LDKRevocationKey RevocationKey_new(struct LDKPublicKey a_arg); + +/** + * Checks if two RevocationKeys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool RevocationKey_eq(const struct LDKRevocationKey *NONNULL_PTR a, const struct LDKRevocationKey *NONNULL_PTR b); + +/** + * Creates a copy of the RevocationKey + */ +struct LDKRevocationKey RevocationKey_clone(const struct LDKRevocationKey *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the RevocationKey. + */ +uint64_t RevocationKey_hash(const struct LDKRevocationKey *NONNULL_PTR o); + +/** + * Derives a per-commitment-transaction revocation public key from one party's per-commitment + * point and the other party's [`RevocationBasepoint`]. This is the public equivalent of + * [`chan_utils::derive_private_revocation_key`] - using only public keys to derive a public + * key instead of private keys. * - * # Avoiding Duplicate Payments + * Note that this is infallible iff we trust that at least one of the two input keys are randomly + * generated (ie our own). * - * If a pending payment is currently in-flight with the same [`PaymentId`] provided, this - * method will error with an [`APIError::InvalidRoute`]. Note, however, that once a payment - * is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an - * [`Event::PaymentSent`] or [`Event::PaymentFailed`]) LDK will not stop you from sending a - * second payment with the same [`PaymentId`]. + * [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key + */ +MUST_USE_RES struct LDKRevocationKey RevocationKey_from_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); + +/** + * Get inner Public Key + */ +MUST_USE_RES struct LDKPublicKey RevocationKey_to_public_key(const struct LDKRevocationKey *NONNULL_PTR this_arg); + +/** + * Serialize the RevocationKey object into a byte array which can be read by RevocationKey_read + */ +struct LDKCVec_u8Z RevocationKey_write(const struct LDKRevocationKey *NONNULL_PTR obj); + +/** + * Read a RevocationKey from a byte array, created by RevocationKey_write + */ +struct LDKCResult_RevocationKeyDecodeErrorZ RevocationKey_read(struct LDKu8slice ser); + +/** + * Creates a copy of the InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_clone(const enum LDKInboundHTLCStateDetails *NONNULL_PTR orig); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); + +/** + * Utility method to constructs a new Committed-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_committed(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFulfill-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fulfill(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFail-variant InboundHTLCStateDetails + */ +enum LDKInboundHTLCStateDetails InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fail(void); + +/** + * Serialize the InboundHTLCStateDetails object into a byte array which can be read by InboundHTLCStateDetails_read + */ +struct LDKCVec_u8Z InboundHTLCStateDetails_write(const enum LDKInboundHTLCStateDetails *NONNULL_PTR obj); + +/** + * Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write + */ +struct LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ InboundHTLCStateDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL. + */ +void InboundHTLCDetails_free(struct LDKInboundHTLCDetails this_obj); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + */ +uint64_t InboundHTLCDetails_get_htlc_id(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + */ +void InboundHTLCDetails_set_htlc_id(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The amount in msat. + */ +uint64_t InboundHTLCDetails_get_amount_msat(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The amount in msat. + */ +void InboundHTLCDetails_set_amount_msat(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The block height at which this HTLC expires. + */ +uint32_t InboundHTLCDetails_get_cltv_expiry(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The block height at which this HTLC expires. + */ +void InboundHTLCDetails_set_cltv_expiry(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The payment hash. + */ +const uint8_t (*InboundHTLCDetails_get_payment_hash(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr))[32]; + +/** + * The payment hash. + */ +void InboundHTLCDetails_set_payment_hash(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The state of the HTLC in the state machine. * - * Thus, in order to ensure duplicate payments are not sent, you should implement your own - * tracking of payments, including state to indicate once a payment has completed. Because you - * should also ensure that [`PaymentHash`]es are not re-used, for simplicity, you should - * consider using the [`PaymentHash`] as the key for tracking payments. In that case, the - * [`PaymentId`] should be a copy of the [`PaymentHash`] bytes. + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. * - * Additionally, in the scenario where we begin the process of sending a payment, but crash - * before `send_payment` returns (or prior to [`ChannelMonitorUpdate`] persistence if you're - * using [`ChannelMonitorUpdateStatus::InProgress`]), the payment may be lost on restart. See - * [`ChannelManager::list_recent_payments`] for more information. + * See [`InboundHTLCStateDetails`] for information on the specific states. * - * # Possible Error States on [`PaymentSendFailure`] + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +struct LDKCOption_InboundHTLCStateDetailsZ InboundHTLCDetails_get_state(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The state of the HTLC in the state machine. * - * Each path may have a different return value, and [`PaymentSendFailure`] may return a `Vec` with - * each entry matching the corresponding-index entry in the route paths, see - * [`PaymentSendFailure`] for more info. + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. * - * In general, a path may raise: - * * [`APIError::InvalidRoute`] when an invalid route or forwarding parameter (cltv_delta, fee, - * node public key) is specified. - * * [`APIError::ChannelUnavailable`] if the next-hop channel is not available as it has been - * closed, doesn't exist, or the peer is currently disconnected. - * * [`APIError::MonitorUpdateInProgress`] if a new monitor update failure prevented sending the - * relevant updates. + * See [`InboundHTLCStateDetails`] for information on the specific states. * - * Note that depending on the type of the [`PaymentSendFailure`] the HTLC may have been - * irrevocably committed to on our end. In such a case, do NOT retry the payment with a - * different route unless you intend to pay twice! + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +void InboundHTLCDetails_set_state(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_InboundHTLCStateDetailsZ val); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. * - * [`RouteHop`]: crate::routing::router::RouteHop - * [`Event::PaymentSent`]: events::Event::PaymentSent - * [`Event::PaymentFailed`]: events::Event::PaymentFailed - * [`UpdateHTLCs`]: events::MessageSendEvent::UpdateHTLCs - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events - * [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +bool InboundHTLCDetails_get_is_dust(const struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +void InboundHTLCDetails_set_is_dust(struct LDKInboundHTLCDetails *NONNULL_PTR this_ptr, bool val); + +/** + * Constructs a new InboundHTLCDetails given each field + */ +MUST_USE_RES struct LDKInboundHTLCDetails InboundHTLCDetails_new(uint64_t htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_InboundHTLCStateDetailsZ state_arg, bool is_dust_arg); + +/** + * Creates a copy of the InboundHTLCDetails + */ +struct LDKInboundHTLCDetails InboundHTLCDetails_clone(const struct LDKInboundHTLCDetails *NONNULL_PTR orig); + +/** + * Serialize the InboundHTLCDetails object into a byte array which can be read by InboundHTLCDetails_read + */ +struct LDKCVec_u8Z InboundHTLCDetails_write(const struct LDKInboundHTLCDetails *NONNULL_PTR obj); + +/** + * Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write + */ +struct LDKCResult_InboundHTLCDetailsDecodeErrorZ InboundHTLCDetails_read(struct LDKu8slice ser); + +/** + * Creates a copy of the OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_clone(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR orig); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_add(void); + +/** + * Utility method to constructs a new Committed-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_committed(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveSuccess-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_success(void); + +/** + * Utility method to constructs a new AwaitingRemoteRevokeToRemoveFailure-variant OutboundHTLCStateDetails + */ +enum LDKOutboundHTLCStateDetails OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_failure(void); + +/** + * Serialize the OutboundHTLCStateDetails object into a byte array which can be read by OutboundHTLCStateDetails_read + */ +struct LDKCVec_u8Z OutboundHTLCStateDetails_write(const enum LDKOutboundHTLCStateDetails *NONNULL_PTR obj); + +/** + * Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write + */ +struct LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ OutboundHTLCStateDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL. + */ +void OutboundHTLCDetails_free(struct LDKOutboundHTLCDetails this_obj); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + * + * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + */ +struct LDKCOption_u64Z OutboundHTLCDetails_get_htlc_id(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The HTLC ID. + * The IDs are incremented by 1 starting from 0 for each offered HTLC. + * They are unique per channel and inbound/outbound direction, unless an HTLC was only announced + * and not part of any commitment transaction. + * + * Not present when we are awaiting a remote revocation and the HTLC is not added yet. + */ +void OutboundHTLCDetails_set_htlc_id(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The amount in msat. + */ +uint64_t OutboundHTLCDetails_get_amount_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The amount in msat. + */ +void OutboundHTLCDetails_set_amount_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The block height at which this HTLC expires. + */ +uint32_t OutboundHTLCDetails_get_cltv_expiry(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The block height at which this HTLC expires. + */ +void OutboundHTLCDetails_set_cltv_expiry(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The payment hash. + */ +const uint8_t (*OutboundHTLCDetails_get_payment_hash(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr))[32]; + +/** + * The payment hash. + */ +void OutboundHTLCDetails_set_payment_hash(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`OutboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +struct LDKCOption_OutboundHTLCStateDetailsZ OutboundHTLCDetails_get_state(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The state of the HTLC in the state machine. + * + * Determines on which commitment transactions the HTLC is included and what message the HTLC is + * waiting for to advance to the next state. + * + * See [`OutboundHTLCStateDetails`] for information on the specific states. + * + * LDK will always fill this field in, but when downgrading to prior versions of LDK, new + * states may result in `None` here. + */ +void OutboundHTLCDetails_set_state(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_OutboundHTLCStateDetailsZ val); + +/** + * The extra fee being skimmed off the top of this HTLC. + */ +struct LDKCOption_u64Z OutboundHTLCDetails_get_skimmed_fee_msat(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * The extra fee being skimmed off the top of this HTLC. + */ +void OutboundHTLCDetails_set_skimmed_fee_msat(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +bool OutboundHTLCDetails_get_is_dust(const struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr); + +/** + * Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed + * from the local commitment transaction and added to the commitment transaction fee. + * For non-anchor channels, this takes into account the cost of the second-stage HTLC + * transactions as well. + * + * When the local commitment transaction is broadcasted as part of a unilateral closure, + * the value of this HTLC will therefore not be claimable but instead burned as a transaction + * fee. + * + * Note that dust limits are specific to each party. An HTLC can be dust for the local + * commitment transaction but not for the counterparty's commitment transaction and vice versa. + */ +void OutboundHTLCDetails_set_is_dust(struct LDKOutboundHTLCDetails *NONNULL_PTR this_ptr, bool val); + +/** + * Constructs a new OutboundHTLCDetails given each field + */ +MUST_USE_RES struct LDKOutboundHTLCDetails OutboundHTLCDetails_new(struct LDKCOption_u64Z htlc_id_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_OutboundHTLCStateDetailsZ state_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, bool is_dust_arg); + +/** + * Creates a copy of the OutboundHTLCDetails + */ +struct LDKOutboundHTLCDetails OutboundHTLCDetails_clone(const struct LDKOutboundHTLCDetails *NONNULL_PTR orig); + +/** + * Serialize the OutboundHTLCDetails object into a byte array which can be read by OutboundHTLCDetails_read + */ +struct LDKCVec_u8Z OutboundHTLCDetails_write(const struct LDKOutboundHTLCDetails *NONNULL_PTR obj); + +/** + * Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write + */ +struct LDKCResult_OutboundHTLCDetailsDecodeErrorZ OutboundHTLCDetails_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. + */ +void CounterpartyForwardingInfo_free(struct LDKCounterpartyForwardingInfo this_obj); + +/** + * Base routing fee in millisatoshis. + */ +uint32_t CounterpartyForwardingInfo_get_fee_base_msat(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * Base routing fee in millisatoshis. + */ +void CounterpartyForwardingInfo_set_fee_base_msat(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ +uint32_t CounterpartyForwardingInfo_get_fee_proportional_millionths(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * Amount in millionths of a satoshi the channel will charge per transferred satoshi. + */ +void CounterpartyForwardingInfo_set_fee_proportional_millionths(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ +uint16_t CounterpartyForwardingInfo_get_cltv_expiry_delta(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr); + +/** + * The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, + * such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s + * `cltv_expiry_delta` for more details. + */ +void CounterpartyForwardingInfo_set_cltv_expiry_delta(struct LDKCounterpartyForwardingInfo *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new CounterpartyForwardingInfo given each field + */ +MUST_USE_RES struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg); + +/** + * Creates a copy of the CounterpartyForwardingInfo + */ +struct LDKCounterpartyForwardingInfo CounterpartyForwardingInfo_clone(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR orig); + +/** + * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + */ +struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); + +/** + * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + */ +struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. + */ +void ChannelCounterparty_free(struct LDKChannelCounterparty this_obj); + +/** + * The node_id of our counterparty + */ +struct LDKPublicKey ChannelCounterparty_get_node_id(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The node_id of our counterparty + */ +void ChannelCounterparty_set_node_id(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ +struct LDKInitFeatures ChannelCounterparty_get_features(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The Features the channel counterparty provided upon last connection. + * Useful for routing as it is the most up-to-date copy of the counterparty's features and + * many routing-relevant features are present in the init context. + */ +void ChannelCounterparty_set_features(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + +/** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ +uint64_t ChannelCounterparty_get_unspendable_punishment_reserve(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, that must always be held in the channel for our counterparty. This + * value ensures that if our counterparty broadcasts a revoked state, we can punish them by + * claiming at least this value on chain. + * + * This value is not included in [`inbound_capacity_msat`] as it can never be spent. + * + * [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat + */ +void ChannelCounterparty_set_unspendable_punishment_reserve(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKCounterpartyForwardingInfo ChannelCounterparty_get_forwarding_info(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * Information on the fees and requirements that the counterparty requires when forwarding + * payments to us through this channel. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelCounterparty_set_forwarding_info(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCounterpartyForwardingInfo val); + +/** + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + */ +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_minimum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field + * is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message + * from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. + */ +void ChannelCounterparty_set_outbound_htlc_minimum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + */ +struct LDKCOption_u64Z ChannelCounterparty_get_outbound_htlc_maximum_msat(const struct LDKChannelCounterparty *NONNULL_PTR this_ptr); + +/** + * The largest value HTLC (in msat) the remote peer currently will accept, for this channel. + */ +void ChannelCounterparty_set_outbound_htlc_maximum_msat(struct LDKChannelCounterparty *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Constructs a new ChannelCounterparty given each field + * + * Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelCounterparty ChannelCounterparty_new(struct LDKPublicKey node_id_arg, struct LDKInitFeatures features_arg, uint64_t unspendable_punishment_reserve_arg, struct LDKCounterpartyForwardingInfo forwarding_info_arg, struct LDKCOption_u64Z outbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z outbound_htlc_maximum_msat_arg); + +/** + * Creates a copy of the ChannelCounterparty + */ +struct LDKChannelCounterparty ChannelCounterparty_clone(const struct LDKChannelCounterparty *NONNULL_PTR orig); + +/** + * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + */ +struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); + +/** + * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + */ +struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. + */ +void ChannelDetails_free(struct LDKChannelDetails this_obj); + +/** + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. + */ +struct LDKChannelId ChannelDetails_get_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The channel's ID (prior to funding transaction generation, this is a random 32 bytes, + * thereafter this is the txid of the funding transaction xor the funding transaction output). + * Note that this means this value is *not* persistent - it can change once during the + * lifetime of the channel. + */ +void ChannelDetails_set_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * Parameters which apply to our counterparty. See individual fields for more information. + */ +struct LDKChannelCounterparty ChannelDetails_get_counterparty(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Parameters which apply to our counterparty. See individual fields for more information. + */ +void ChannelDetails_set_counterparty(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelCounterparty val); + +/** + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKOutPoint ChannelDetails_get_funding_txo(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The Channel's funding transaction output, if we've negotiated the funding transaction with + * our counterparty already. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_funding_txo(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKOutPoint val); + +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures ChannelDetails_get_channel_type(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The features which this channel operates with. See individual features for more info. + * + * `None` until negotiation completes and the channel type is finalized. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_channel_type(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + +/** + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required + */ +struct LDKCOption_u64Z ChannelDetails_get_short_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The position of the funding transaction in the chain. None if the funding transaction has + * not yet been confirmed and the channel fully opened. + * + * Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound + * payments instead of this. See [`get_inbound_payment_scid`]. + * + * For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may + * be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. + * + * [`inbound_scid_alias`]: Self::inbound_scid_alias + * [`outbound_scid_alias`]: Self::outbound_scid_alias + * [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid + * [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid + * [`confirmations_required`]: Self::confirmations_required + */ +void ChannelDetails_set_short_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required + */ +struct LDKCOption_u64Z ChannelDetails_get_outbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by us and + * usable in place of [`short_channel_id`] to reference the channel in outbound routes when + * the channel has not yet been confirmed (as long as [`confirmations_required`] is + * `Some(0)`). + * + * This will be `None` as long as the channel is not available for routing outbound payments. + * + * [`short_channel_id`]: Self::short_channel_id + * [`confirmations_required`]: Self::confirmations_required + */ +void ChannelDetails_set_outbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_scid_alias(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * An optional [`short_channel_id`] alias for this channel, randomly generated by our + * counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our + * counterparty will recognize the alias provided here in place of the [`short_channel_id`] + * when they see a payment to be routed to us. + * + * Our counterparty may choose to rotate this value at any time, though will always recognize + * previous values for inbound payment forwarding. + * + * [`short_channel_id`]: Self::short_channel_id + */ +void ChannelDetails_set_inbound_scid_alias(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The value, in satoshis, of this channel as appears in the funding output + */ +uint64_t ChannelDetails_get_channel_value_satoshis(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, of this channel as appears in the funding output + */ +void ChannelDetails_set_channel_value_satoshis(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + */ +struct LDKCOption_u64Z ChannelDetails_get_unspendable_punishment_reserve(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The value, in satoshis, that must always be held in the channel for us. This value ensures + * that if we broadcast a revoked state, our counterparty can punish us by claiming at least + * this value on chain. + * + * This value is not included in [`outbound_capacity_msat`] as it can never be spent. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat + */ +void ChannelDetails_set_unspendable_punishment_reserve(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects + * serialized with LDK versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ +struct LDKU128 ChannelDetails_get_user_channel_id(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound + * channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. This may be zero for objects + * serialized with LDK versions prior to 0.0.113. + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + */ +void ChannelDetails_set_user_channel_id(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKU128 val); + +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +struct LDKCOption_u32Z ChannelDetails_get_feerate_sat_per_1000_weight(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The currently negotiated fee rate denominated in satoshi per 1000 weight units, + * which is applied to commitment and HTLC transactions. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.115. + */ +void ChannelDetails_set_feerate_sat_per_1000_weight(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] + */ +uint64_t ChannelDetails_get_balance_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Our total balance. This is the amount we would get if we close the channel. + * This value is not exact. Due to various in-flight changes and feerate changes, exactly this + * amount is not likely to be recoverable on close. + * + * This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose + * balance is not available for inclusion in new outbound HTLCs). This further does not include + * any pending outgoing HTLCs which are awaiting some other resolution to be sent. + * This does not consider any on-chain fees. + * + * See also [`ChannelDetails::outbound_capacity_msat`] + */ +void ChannelDetails_set_balance_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * See also [`ChannelDetails::balance_msat`] + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. + */ +uint64_t ChannelDetails_get_outbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available outbound capacity for sending HTLCs to the remote peer. This does not include + * any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new outbound HTLCs). This further does not include any pending + * outgoing HTLCs which are awaiting some other resolution to be sent. + * + * See also [`ChannelDetails::balance_msat`] + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we + * should be able to spend nearly this amount. + */ +void ChannelDetails_set_outbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], + * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. + */ +uint64_t ChannelDetails_get_next_outbound_htlc_limit_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available outbound capacity for sending a single HTLC to the remote peer. This is + * similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by + * the current state and per-HTLC limit(s). This is intended for use when routing, allowing us + * to use a limit as close as possible to the HTLC limit we can currently send. + * + * See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], + * [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. + */ +void ChannelDetails_set_next_outbound_htlc_limit_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. + */ +uint64_t ChannelDetails_get_next_outbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The minimum value for sending a single HTLC to the remote peer. This is the equivalent of + * [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than + * an upper-bound. This is intended for use when routing, allowing us to ensure we pick a + * route which is valid. + */ +void ChannelDetails_set_next_outbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. + */ +uint64_t ChannelDetails_get_inbound_capacity_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The available inbound capacity for the remote peer to send HTLCs to us. This does not + * include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not + * available for inclusion in new inbound HTLCs). + * Note that there are some corner cases not fully handled here, so the actual available + * inbound capacity may be slightly higher than this. + * + * This value is not exact. Due to various in-flight changes, feerate changes, and our + * counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. + * However, our counterparty should be able to spend nearly this amount. + */ +void ChannelDetails_set_inbound_capacity_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ +struct LDKCOption_u32Z ChannelDetails_get_confirmations_required(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The number of required confirmations on the funding transaction before the funding will be + * considered \"locked\". This number is selected by the channel fundee (i.e. us if + * [`is_outbound`] is *not* set), and can be selected for inbound channels with + * [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with + * [`ChannelHandshakeLimits::max_minimum_depth`]. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + * + * [`is_outbound`]: ChannelDetails::is_outbound + * [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth + * [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth + */ +void ChannelDetails_set_confirmations_required(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + */ +struct LDKCOption_u32Z ChannelDetails_get_confirmations(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The current number of confirmations on the funding transaction. + * + * This value will be `None` for objects serialized with LDK versions prior to 0.0.113. + */ +void ChannelDetails_set_confirmations(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); + +/** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ +struct LDKCOption_u16Z ChannelDetails_get_force_close_spend_delay(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The number of blocks (after our commitment transaction confirms) that we will need to wait + * until we can claim our funds after we force-close the channel. During this time our + * counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty + * force-closes the channel and broadcasts a commitment transaction we do not have to wait any + * time to claim our non-HTLC-encumbered funds. + * + * This value will be `None` for outbound channels until the counterparty accepts the channel. + */ +void ChannelDetails_set_force_close_spend_delay(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u16Z val); + +/** + * True if the channel was initiated (and thus funded) by us. + */ +bool ChannelDetails_get_is_outbound(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel was initiated (and thus funded) by us. + */ +void ChannelDetails_set_is_outbound(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required + */ +bool ChannelDetails_get_is_channel_ready(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel is confirmed, channel_ready messages have been exchanged, and the + * channel is not currently being shut down. `channel_ready` message exchange implies the + * required confirmation count has been reached (and we were connected to the peer at some + * point after the funding transaction received enough confirmations). The required + * confirmation count is provided in [`confirmations_required`]. + * + * [`confirmations_required`]: ChannelDetails::confirmations_required + */ +void ChannelDetails_set_is_channel_ready(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + * + * Returns a copy of the field. + */ +struct LDKCOption_ChannelShutdownStateZ ChannelDetails_get_channel_shutdown_state(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The stage of the channel's shutdown. + * `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. + */ +void ChannelDetails_set_channel_shutdown_state(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_ChannelShutdownStateZ val); + +/** + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. + */ +bool ChannelDetails_get_is_usable(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) + * the peer is connected, and (c) the channel is not currently negotiating a shutdown. + * + * This is a strict superset of `is_channel_ready`. + */ +void ChannelDetails_set_is_usable(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * True if this channel is (or will be) publicly-announced. + */ +bool ChannelDetails_get_is_announced(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * True if this channel is (or will be) publicly-announced. + */ +void ChannelDetails_set_is_announced(struct LDKChannelDetails *NONNULL_PTR this_ptr, bool val); + +/** + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_minimum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The smallest value HTLC (in msat) we will accept, for this channel. This field + * is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 + */ +void ChannelDetails_set_inbound_htlc_minimum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * The largest value HTLC (in msat) we currently will accept, for this channel. + */ +struct LDKCOption_u64Z ChannelDetails_get_inbound_htlc_maximum_msat(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * The largest value HTLC (in msat) we currently will accept, for this channel. + */ +void ChannelDetails_set_inbound_htlc_maximum_msat(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelConfig ChannelDetails_get_config(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Set of configurable parameters that affect channel operation. + * + * This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ChannelDetails_set_config(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKChannelConfig val); + +/** + * Pending inbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +struct LDKCVec_InboundHTLCDetailsZ ChannelDetails_get_pending_inbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Pending inbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +void ChannelDetails_set_pending_inbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_InboundHTLCDetailsZ val); + +/** + * Pending outbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +struct LDKCVec_OutboundHTLCDetailsZ ChannelDetails_get_pending_outbound_htlcs(const struct LDKChannelDetails *NONNULL_PTR this_ptr); + +/** + * Pending outbound HTLCs. + * + * This field is empty for objects serialized with LDK versions prior to 0.0.122. + */ +void ChannelDetails_set_pending_outbound_htlcs(struct LDKChannelDetails *NONNULL_PTR this_ptr, struct LDKCVec_OutboundHTLCDetailsZ val); + +/** + * Constructs a new ChannelDetails given each field + * + * Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKChannelDetails ChannelDetails_new(struct LDKChannelId channel_id_arg, struct LDKChannelCounterparty counterparty_arg, struct LDKOutPoint funding_txo_arg, struct LDKChannelTypeFeatures channel_type_arg, struct LDKCOption_u64Z short_channel_id_arg, struct LDKCOption_u64Z outbound_scid_alias_arg, struct LDKCOption_u64Z inbound_scid_alias_arg, uint64_t channel_value_satoshis_arg, struct LDKCOption_u64Z unspendable_punishment_reserve_arg, struct LDKU128 user_channel_id_arg, struct LDKCOption_u32Z feerate_sat_per_1000_weight_arg, uint64_t balance_msat_arg, uint64_t outbound_capacity_msat_arg, uint64_t next_outbound_htlc_limit_msat_arg, uint64_t next_outbound_htlc_minimum_msat_arg, uint64_t inbound_capacity_msat_arg, struct LDKCOption_u32Z confirmations_required_arg, struct LDKCOption_u32Z confirmations_arg, struct LDKCOption_u16Z force_close_spend_delay_arg, bool is_outbound_arg, bool is_channel_ready_arg, struct LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg, bool is_usable_arg, bool is_announced_arg, struct LDKCOption_u64Z inbound_htlc_minimum_msat_arg, struct LDKCOption_u64Z inbound_htlc_maximum_msat_arg, struct LDKChannelConfig config_arg, struct LDKCVec_InboundHTLCDetailsZ pending_inbound_htlcs_arg, struct LDKCVec_OutboundHTLCDetailsZ pending_outbound_htlcs_arg); + +/** + * Creates a copy of the ChannelDetails + */ +struct LDKChannelDetails ChannelDetails_clone(const struct LDKChannelDetails *NONNULL_PTR orig); + +/** + * Gets the current SCID which should be used to identify this channel for inbound payments. + * This should be used for providing invoice hints or in any other context where our + * counterparty will forward a payment to us. + * + * This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the + * [`ChannelDetails::short_channel_id`]. See those for more information. + */ +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_inbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); + +/** + * Gets the current SCID which should be used to identify this channel for outbound payments. + * This should be used in [`Route`]s to describe the first hop or in other contexts where + * we're sending or forwarding a payment outbound over this channel. + * + * This is either the [`ChannelDetails::short_channel_id`], if set, or the + * [`ChannelDetails::outbound_scid_alias`]. See those for more information. + * + * [`Route`]: crate::routing::router::Route + */ +MUST_USE_RES struct LDKCOption_u64Z ChannelDetails_get_outbound_payment_scid(const struct LDKChannelDetails *NONNULL_PTR this_arg); + +/** + * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + */ +struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); + +/** + * Read a ChannelDetails from a byte array, created by ChannelDetails_write + */ +struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); + +/** + * Creates a copy of the ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_clone(const enum LDKChannelShutdownState *NONNULL_PTR orig); + +/** + * Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_not_shutting_down(void); + +/** + * Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_shutdown_initiated(void); + +/** + * Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_resolving_htlcs(void); + +/** + * Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_negotiating_closing_fee(void); + +/** + * Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState + */ +enum LDKChannelShutdownState ChannelShutdownState_shutdown_complete(void); + +/** + * Checks if two ChannelShutdownStates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool ChannelShutdownState_eq(const enum LDKChannelShutdownState *NONNULL_PTR a, const enum LDKChannelShutdownState *NONNULL_PTR b); + +/** + * Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read + */ +struct LDKCVec_u8Z ChannelShutdownState_write(const enum LDKChannelShutdownState *NONNULL_PTR obj); + +/** + * Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write + */ +struct LDKCResult_ChannelShutdownStateDecodeErrorZ ChannelShutdownState_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. + */ +void ExpandedKey_free(struct LDKExpandedKey this_obj); + +/** + * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. + * + * It is recommended to cache this value and not regenerate it for each new inbound payment. + */ +MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(const uint8_t (*key_material)[32]); + +/** + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no + * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without + * a `ChannelManager`. + * + * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then + * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not + * regenerate it for each new inbound payment. + * + * `current_time` is a Unix timestamp representing the current time. + * + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material + */ +struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); + +/** + * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], + * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] + * without a `ChannelManager`. + * + * See [`create`] for information on the `keys` and `current_time` parameters. + * + * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable + * on versions of LDK prior to 0.0.114. + * + * [phantom node payments]: crate::sign::PhantomKeysManager + */ +struct LDKCResult_ThirtyTwoBytesNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); + +/** + * Frees any resources used by the DecodeError + */ +void DecodeError_free(struct LDKDecodeError this_ptr); + +/** + * Creates a copy of the DecodeError + */ +struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); + +/** + * Utility method to constructs a new UnknownVersion-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_version(void); + +/** + * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + */ +struct LDKDecodeError DecodeError_unknown_required_feature(void); + +/** + * Utility method to constructs a new InvalidValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_invalid_value(void); + +/** + * Utility method to constructs a new ShortRead-variant DecodeError + */ +struct LDKDecodeError DecodeError_short_read(void); + +/** + * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + */ +struct LDKDecodeError DecodeError_bad_length_descriptor(void); + +/** + * Utility method to constructs a new Io-variant DecodeError + */ +struct LDKDecodeError DecodeError_io(enum LDKIOError a); + +/** + * Utility method to constructs a new UnsupportedCompression-variant DecodeError + */ +struct LDKDecodeError DecodeError_unsupported_compression(void); + +/** + * Utility method to constructs a new DangerousValue-variant DecodeError + */ +struct LDKDecodeError DecodeError_dangerous_value(void); + +/** + * Generates a non-cryptographic 64-bit hash of the DecodeError. + */ +uint64_t DecodeError_hash(const struct LDKDecodeError *NONNULL_PTR o); + +/** + * Checks if two DecodeErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ +bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); + +/** + * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + */ +void Init_free(struct LDKInit this_obj); + +/** + * The relevant features which the sender supports. + */ +struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The relevant features which the sender supports. + */ +void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); + +/** + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. + * + * Returns a copy of the field. + */ +struct LDKCOption_CVec_ThirtyTwoBytesZZ Init_get_networks(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * Indicates chains the sender is interested in. + * + * If there are no common chains, the connection will be closed. + */ +void Init_set_networks(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_CVec_ThirtyTwoBytesZZ val); + +/** + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. + */ +struct LDKCOption_SocketAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); + +/** + * The receipient's network address. + * + * This adds the option to report a remote IP address back to a connecting peer using the init + * message. A node can decide to use that information to discover a potential update to its + * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing + * the new address. + */ +void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); + +/** + * Constructs a new Init given each field + */ +MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg, struct LDKCOption_SocketAddressZ remote_network_address_arg); + +/** + * Creates a copy of the Init + */ +struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Init. + */ +uint64_t Init_hash(const struct LDKInit *NONNULL_PTR o); + +/** + * Checks if two Inits contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); + +/** + * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + */ +void ErrorMessage_free(struct LDKErrorMessage this_obj); + +/** + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. + */ +struct LDKChannelId ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr); + +/** + * The channel ID involved in the error. + * + * All-0s indicates a general error unrelated to a specific channel, after which all channels + * with the sending peer should be closed. + */ +void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); + +/** + * A possibly human-readable error description. + * + * The string should be sanitized before it is used (e.g., emitted to logs or printed to + * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * Constructs a new ErrorMessage given each field + */ +MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); + +/** + * Creates a copy of the ErrorMessage + */ +struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ErrorMessage. + */ +uint64_t ErrorMessage_hash(const struct LDKErrorMessage *NONNULL_PTR o); + +/** + * Checks if two ErrorMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); + +/** + * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + */ +void WarningMessage_free(struct LDKWarningMessage this_obj); + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +struct LDKChannelId WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr); + +/** + * The channel ID involved in the warning. + * + * All-0s indicates a warning unrelated to a specific channel. + */ +void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); + +/** + * A possibly human-readable warning description. + * + * The string should be sanitized before it is used (e.g. emitted to logs or printed to + * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in + * the terminal emulator or the logging subsystem. + */ +void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); + +/** + * Constructs a new WarningMessage given each field + */ +MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKChannelId channel_id_arg, struct LDKStr data_arg); + +/** + * Creates a copy of the WarningMessage + */ +struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the WarningMessage. + */ +uint64_t WarningMessage_hash(const struct LDKWarningMessage *NONNULL_PTR o); + +/** + * Checks if two WarningMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); + +/** + * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + */ +void Ping_free(struct LDKPing this_obj); + +/** + * The desired response length. + */ +uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); + +/** + * The desired response length. + */ +void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); + +/** + * The ping packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new Ping given each field + */ +MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); + +/** + * Creates a copy of the Ping + */ +struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Ping. + */ +uint64_t Ping_hash(const struct LDKPing *NONNULL_PTR o); + +/** + * Checks if two Pings contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); + +/** + * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + */ +void Pong_free(struct LDKPong this_obj); + +/** + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); + +/** + * The pong packet size. + * + * This field is not sent on the wire. byteslen zeros are sent. + */ +void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new Pong given each field + */ +MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); + +/** + * Creates a copy of the Pong + */ +struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the Pong. + */ +uint64_t Pong_hash(const struct LDKPong *NONNULL_PTR o); + +/** + * Checks if two Pongs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); + +/** + * Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL. + */ +void CommonOpenChannelFields_free(struct LDKCommonOpenChannelFields this_obj); + +/** + * The genesis hash of the blockchain where the channel is to be opened + */ +const uint8_t (*CommonOpenChannelFields_get_chain_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr))[32]; + +/** + * The genesis hash of the blockchain where the channel is to be opened + */ +void CommonOpenChannelFields_set_chain_hash(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * A temporary channel ID + * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint + * For V1 channels: a temporary channel ID, until the funding outpoint is announced + */ +struct LDKChannelId CommonOpenChannelFields_get_temporary_channel_id(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * A temporary channel ID + * For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint + * For V1 channels: a temporary channel ID, until the funding outpoint is announced + */ +void CommonOpenChannelFields_set_temporary_channel_id(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * For V1 channels: The channel value + * For V2 channels: Part of the channel value contributed by the channel initiator + */ +uint64_t CommonOpenChannelFields_get_funding_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * For V1 channels: The channel value + * For V2 channels: Part of the channel value contributed by the channel initiator + */ +void CommonOpenChannelFields_set_funding_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted + */ +uint64_t CommonOpenChannelFields_get_dust_limit_satoshis(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted + */ +void CommonOpenChannelFields_set_dust_limit_satoshis(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +uint64_t CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +void CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum HTLC size incoming to channel initiator, in milli-satoshi + */ +uint64_t CommonOpenChannelFields_get_htlc_minimum_msat(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The minimum HTLC size incoming to channel initiator, in milli-satoshi + */ +void CommonOpenChannelFields_set_htlc_minimum_msat(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +uint32_t CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +void CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction + */ +uint16_t CommonOpenChannelFields_get_to_self_delay(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction + */ +void CommonOpenChannelFields_set_to_self_delay(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The maximum number of inbound HTLCs towards channel initiator + */ +uint16_t CommonOpenChannelFields_get_max_accepted_htlcs(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The maximum number of inbound HTLCs towards channel initiator + */ +void CommonOpenChannelFields_set_max_accepted_htlcs(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The channel initiator's key controlling the funding transaction + */ +struct LDKPublicKey CommonOpenChannelFields_get_funding_pubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The channel initiator's key controlling the funding transaction + */ +void CommonOpenChannelFields_set_funding_pubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive a revocation key for transactions broadcast by counterparty + */ +struct LDKPublicKey CommonOpenChannelFields_get_revocation_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive a revocation key for transactions broadcast by counterparty + */ +void CommonOpenChannelFields_set_revocation_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * A payment key to channel initiator for transactions broadcast by counterparty + */ +struct LDKPublicKey CommonOpenChannelFields_get_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * A payment key to channel initiator for transactions broadcast by counterparty + */ +void CommonOpenChannelFields_set_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator + */ +struct LDKPublicKey CommonOpenChannelFields_get_delayed_payment_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive a payment key to channel initiator for transactions broadcast by channel + * initiator + */ +void CommonOpenChannelFields_set_delayed_payment_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive an HTLC payment key to channel initiator + */ +struct LDKPublicKey CommonOpenChannelFields_get_htlc_basepoint(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive an HTLC payment key to channel initiator + */ +void CommonOpenChannelFields_set_htlc_basepoint(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +struct LDKPublicKey CommonOpenChannelFields_get_first_per_commitment_point(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +void CommonOpenChannelFields_set_first_per_commitment_point(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The channel flags to be used + */ +uint8_t CommonOpenChannelFields_get_channel_flags(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The channel flags to be used + */ +void CommonOpenChannelFields_set_channel_flags(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, uint8_t val); + +/** + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close + */ +struct LDKCOption_CVec_u8ZZ CommonOpenChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we + * collaboratively close + */ +void CommonOpenChannelFields_set_shutdown_scriptpubkey(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); + +/** + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures CommonOpenChannelFields_get_channel_type(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr); + +/** + * The channel type that this channel will represent + * + * If this is `None`, we derive the channel type from the intersection of our + * feature bits with our counterparty's feature bits from the [`Init`] message. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void CommonOpenChannelFields_set_channel_type(struct LDKCommonOpenChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + +/** + * Constructs a new CommonOpenChannelFields given each field + * + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKCommonOpenChannelFields CommonOpenChannelFields_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKChannelId temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); + +/** + * Creates a copy of the CommonOpenChannelFields + */ +struct LDKCommonOpenChannelFields CommonOpenChannelFields_clone(const struct LDKCommonOpenChannelFields *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields. + */ +uint64_t CommonOpenChannelFields_hash(const struct LDKCommonOpenChannelFields *NONNULL_PTR o); + +/** + * Checks if two CommonOpenChannelFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool CommonOpenChannelFields_eq(const struct LDKCommonOpenChannelFields *NONNULL_PTR a, const struct LDKCommonOpenChannelFields *NONNULL_PTR b); + +/** + * The [`ChannelParameters`] for this channel. + */ +MUST_USE_RES struct LDKChannelParameters CommonOpenChannelFields_channel_parameters(const struct LDKCommonOpenChannelFields *NONNULL_PTR this_arg); + +/** + * Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. + */ +void ChannelParameters_free(struct LDKChannelParameters this_obj); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. + */ +uint64_t ChannelParameters_get_dust_limit_satoshis(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The threshold below which outputs on transactions broadcast by the channel initiator will be + * omitted. + */ +void ChannelParameters_set_dust_limit_satoshis(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +uint64_t ChannelParameters_get_max_htlc_value_in_flight_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + */ +void ChannelParameters_set_max_htlc_value_in_flight_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + */ +uint64_t ChannelParameters_get_htlc_minimum_msat(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi + */ +void ChannelParameters_set_htlc_minimum_msat(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +uint32_t ChannelParameters_get_commitment_feerate_sat_per_1000_weight(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The feerate for the commitment transaction set by the channel initiator until updated by + * [`UpdateFee`] + */ +void ChannelParameters_set_commitment_feerate_sat_per_1000_weight(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. + */ +uint16_t ChannelParameters_get_to_self_delay(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The number of blocks which the non-channel-initator will have to wait to claim on-chain + * funds if they broadcast a commitment transaction. + */ +void ChannelParameters_set_to_self_delay(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The maximum number of pending HTLCs towards the channel initiator. + */ +uint16_t ChannelParameters_get_max_accepted_htlcs(const struct LDKChannelParameters *NONNULL_PTR this_ptr); + +/** + * The maximum number of pending HTLCs towards the channel initiator. + */ +void ChannelParameters_set_max_accepted_htlcs(struct LDKChannelParameters *NONNULL_PTR this_ptr, uint16_t val); + +/** + * Constructs a new ChannelParameters given each field + */ +MUST_USE_RES struct LDKChannelParameters ChannelParameters_new(uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg); + +/** + * Creates a copy of the ChannelParameters + */ +struct LDKChannelParameters ChannelParameters_clone(const struct LDKChannelParameters *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ChannelParameters. + */ +uint64_t ChannelParameters_hash(const struct LDKChannelParameters *NONNULL_PTR o); + +/** + * Checks if two ChannelParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelParameters_eq(const struct LDKChannelParameters *NONNULL_PTR a, const struct LDKChannelParameters *NONNULL_PTR b); + +/** + * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + */ +void OpenChannel_free(struct LDKOpenChannel this_obj); + +/** + * Common fields of `open_channel(2)`-like messages + */ +struct LDKCommonOpenChannelFields OpenChannel_get_common_fields(const struct LDKOpenChannel *NONNULL_PTR this_ptr); + +/** + * Common fields of `open_channel(2)`-like messages + */ +void OpenChannel_set_common_fields(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); + +/** + * The amount to push to the counterparty as part of the open, in milli-satoshi + */ +uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); + +/** + * The amount to push to the counterparty as part of the open, in milli-satoshi + */ +void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); + +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new OpenChannel given each field + */ +MUST_USE_RES struct LDKOpenChannel OpenChannel_new(struct LDKCommonOpenChannelFields common_fields_arg, uint64_t push_msat_arg, uint64_t channel_reserve_satoshis_arg); + +/** + * Creates a copy of the OpenChannel + */ +struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the OpenChannel. + */ +uint64_t OpenChannel_hash(const struct LDKOpenChannel *NONNULL_PTR o); + +/** + * Checks if two OpenChannels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); + +/** + * Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. + */ +void OpenChannelV2_free(struct LDKOpenChannelV2 this_obj); + +/** + * Common fields of `open_channel(2)`-like messages + */ +struct LDKCommonOpenChannelFields OpenChannelV2_get_common_fields(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); + +/** + * Common fields of `open_channel(2)`-like messages + */ +void OpenChannelV2_set_common_fields(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonOpenChannelFields val); + +/** + * The feerate for the funding transaction set by the channel initiator + */ +uint32_t OpenChannelV2_get_funding_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); + +/** + * The feerate for the funding transaction set by the channel initiator + */ +void OpenChannelV2_set_funding_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The locktime for the funding transaction + */ +uint32_t OpenChannelV2_get_locktime(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); + +/** + * The locktime for the funding transaction + */ +void OpenChannelV2_set_locktime(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +struct LDKPublicKey OpenChannelV2_get_second_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); + +/** + * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + */ +void OpenChannelV2_set_second_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Optionally, a requirement that only confirmed inputs can be added + */ +enum LDKCOption_NoneZ OpenChannelV2_get_require_confirmed_inputs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); + +/** + * Optionally, a requirement that only confirmed inputs can be added + */ +void OpenChannelV2_set_require_confirmed_inputs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + +/** + * Constructs a new OpenChannelV2 given each field + */ +MUST_USE_RES struct LDKOpenChannelV2 OpenChannelV2_new(struct LDKCommonOpenChannelFields common_fields_arg, uint32_t funding_feerate_sat_per_1000_weight_arg, uint32_t locktime_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); + +/** + * Creates a copy of the OpenChannelV2 + */ +struct LDKOpenChannelV2 OpenChannelV2_clone(const struct LDKOpenChannelV2 *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the OpenChannelV2. + */ +uint64_t OpenChannelV2_hash(const struct LDKOpenChannelV2 *NONNULL_PTR o); + +/** + * Checks if two OpenChannelV2s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool OpenChannelV2_eq(const struct LDKOpenChannelV2 *NONNULL_PTR a, const struct LDKOpenChannelV2 *NONNULL_PTR b); + +/** + * Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL. + */ +void CommonAcceptChannelFields_free(struct LDKCommonAcceptChannelFields this_obj); + +/** + * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + */ +struct LDKChannelId CommonAcceptChannelFields_get_temporary_channel_id(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. + */ +void CommonAcceptChannelFields_set_temporary_channel_id(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted + */ +uint64_t CommonAcceptChannelFields_get_dust_limit_satoshis(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The threshold below which outputs on transactions broadcast by the channel acceptor will be + * omitted + */ +void CommonAcceptChannelFields_set_dust_limit_satoshis(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + */ +uint64_t CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + */ +void CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + */ +uint64_t CommonAcceptChannelFields_get_htlc_minimum_msat(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + */ +void CommonAcceptChannelFields_set_htlc_minimum_msat(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Minimum depth of the funding transaction before the channel is considered open + */ +uint32_t CommonAcceptChannelFields_get_minimum_depth(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * Minimum depth of the funding transaction before the channel is considered open + */ +void CommonAcceptChannelFields_set_minimum_depth(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction + */ +uint16_t CommonAcceptChannelFields_get_to_self_delay(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The number of blocks which the counterparty will have to wait to claim on-chain funds if they + * broadcast a commitment transaction + */ +void CommonAcceptChannelFields_set_to_self_delay(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The maximum number of inbound HTLCs towards channel acceptor + */ +uint16_t CommonAcceptChannelFields_get_max_accepted_htlcs(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The maximum number of inbound HTLCs towards channel acceptor + */ +void CommonAcceptChannelFields_set_max_accepted_htlcs(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The channel acceptor's key controlling the funding transaction + */ +struct LDKPublicKey CommonAcceptChannelFields_get_funding_pubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The channel acceptor's key controlling the funding transaction + */ +void CommonAcceptChannelFields_set_funding_pubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive a revocation key for transactions broadcast by counterparty + */ +struct LDKPublicKey CommonAcceptChannelFields_get_revocation_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive a revocation key for transactions broadcast by counterparty + */ +void CommonAcceptChannelFields_set_revocation_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * A payment key to channel acceptor for transactions broadcast by counterparty + */ +struct LDKPublicKey CommonAcceptChannelFields_get_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * A payment key to channel acceptor for transactions broadcast by counterparty + */ +void CommonAcceptChannelFields_set_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor + */ +struct LDKPublicKey CommonAcceptChannelFields_get_delayed_payment_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive a payment key to channel acceptor for transactions broadcast by channel + * acceptor + */ +void CommonAcceptChannelFields_set_delayed_payment_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + */ +struct LDKPublicKey CommonAcceptChannelFields_get_htlc_basepoint(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + */ +void CommonAcceptChannelFields_set_htlc_basepoint(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + */ +struct LDKPublicKey CommonAcceptChannelFields_get_first_per_commitment_point(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + */ +void CommonAcceptChannelFields_set_first_per_commitment_point(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close + */ +struct LDKCOption_CVec_u8ZZ CommonAcceptChannelFields_get_shutdown_scriptpubkey(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we + * collaboratively close + */ +void CommonAcceptChannelFields_set_shutdown_scriptpubkey(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); + +/** + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s + * [`CommonOpenChannelFields::channel_type`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKChannelTypeFeatures CommonAcceptChannelFields_get_channel_type(const struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr); + +/** + * The channel type that this channel will represent. If none is set, we derive the channel + * type from the intersection of our feature bits with our counterparty's feature bits from + * the Init message. + * + * This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s + * [`CommonOpenChannelFields::channel_type`]. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void CommonAcceptChannelFields_set_channel_type(struct LDKCommonAcceptChannelFields *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); + +/** + * Constructs a new CommonAcceptChannelFields given each field + * + * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_new(struct LDKChannelId temporary_channel_id_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); + +/** + * Creates a copy of the CommonAcceptChannelFields + */ +struct LDKCommonAcceptChannelFields CommonAcceptChannelFields_clone(const struct LDKCommonAcceptChannelFields *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields. + */ +uint64_t CommonAcceptChannelFields_hash(const struct LDKCommonAcceptChannelFields *NONNULL_PTR o); + +/** + * Checks if two CommonAcceptChannelFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool CommonAcceptChannelFields_eq(const struct LDKCommonAcceptChannelFields *NONNULL_PTR a, const struct LDKCommonAcceptChannelFields *NONNULL_PTR b); + +/** + * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + */ +void AcceptChannel_free(struct LDKAcceptChannel this_obj); + +/** + * Common fields of `accept_channel(2)`-like messages + */ +struct LDKCommonAcceptChannelFields AcceptChannel_get_common_fields(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); + +/** + * Common fields of `accept_channel(2)`-like messages + */ +void AcceptChannel_set_common_fields(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); + +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); + +/** + * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + */ +void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); + +/** + * Constructs a new AcceptChannel given each field + */ +MUST_USE_RES struct LDKAcceptChannel AcceptChannel_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t channel_reserve_satoshis_arg); + +/** + * Creates a copy of the AcceptChannel + */ +struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the AcceptChannel. + */ +uint64_t AcceptChannel_hash(const struct LDKAcceptChannel *NONNULL_PTR o); + +/** + * Checks if two AcceptChannels contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); + +/** + * Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. + */ +void AcceptChannelV2_free(struct LDKAcceptChannelV2 this_obj); + +/** + * Common fields of `accept_channel(2)`-like messages + */ +struct LDKCommonAcceptChannelFields AcceptChannelV2_get_common_fields(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); + +/** + * Common fields of `accept_channel(2)`-like messages + */ +void AcceptChannelV2_set_common_fields(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKCommonAcceptChannelFields val); + +/** + * Part of the channel value contributed by the channel acceptor + */ +uint64_t AcceptChannelV2_get_funding_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); + +/** + * Part of the channel value contributed by the channel acceptor + */ +void AcceptChannelV2_set_funding_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + */ +struct LDKPublicKey AcceptChannelV2_get_second_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); + +/** + * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + */ +void AcceptChannelV2_set_second_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * Optionally, a requirement that only confirmed inputs can be added + */ +enum LDKCOption_NoneZ AcceptChannelV2_get_require_confirmed_inputs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); + +/** + * Optionally, a requirement that only confirmed inputs can be added + */ +void AcceptChannelV2_set_require_confirmed_inputs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + +/** + * Constructs a new AcceptChannelV2 given each field + */ +MUST_USE_RES struct LDKAcceptChannelV2 AcceptChannelV2_new(struct LDKCommonAcceptChannelFields common_fields_arg, uint64_t funding_satoshis_arg, struct LDKPublicKey second_per_commitment_point_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); + +/** + * Creates a copy of the AcceptChannelV2 + */ +struct LDKAcceptChannelV2 AcceptChannelV2_clone(const struct LDKAcceptChannelV2 *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2. + */ +uint64_t AcceptChannelV2_hash(const struct LDKAcceptChannelV2 *NONNULL_PTR o); + +/** + * Checks if two AcceptChannelV2s contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool AcceptChannelV2_eq(const struct LDKAcceptChannelV2 *NONNULL_PTR a, const struct LDKAcceptChannelV2 *NONNULL_PTR b); + +/** + * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + */ +void FundingCreated_free(struct LDKFundingCreated this_obj); + +/** + * A temporary channel ID, until the funding is established + */ +struct LDKChannelId FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr); + +/** + * A temporary channel ID, until the funding is established + */ +void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The funding transaction ID + */ +const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; + +/** + * The funding transaction ID + */ +void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); + +/** + * The specific output index funding this channel + */ +uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); + +/** + * The specific output index funding this channel + */ +void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); + +/** + * The signature of the channel initiator (funder) on the initial commitment transaction + */ +struct LDKECDSASignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); + +/** + * The signature of the channel initiator (funder) on the initial commitment transaction + */ +void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKECDSASignature val); + +/** + * Constructs a new FundingCreated given each field + */ +MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKChannelId temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKECDSASignature signature_arg); + +/** + * Creates a copy of the FundingCreated + */ +struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the FundingCreated. + */ +uint64_t FundingCreated_hash(const struct LDKFundingCreated *NONNULL_PTR o); + +/** + * Checks if two FundingCreateds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); + +/** + * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + */ +void FundingSigned_free(struct LDKFundingSigned this_obj); + +/** + * The channel ID + */ +struct LDKChannelId FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr); + +/** + * The channel ID + */ +void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The signature of the channel acceptor (fundee) on the initial commitment transaction + */ +struct LDKECDSASignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); + +/** + * The signature of the channel acceptor (fundee) on the initial commitment transaction + */ +void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); + +/** + * Constructs a new FundingSigned given each field + */ +MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg); + +/** + * Creates a copy of the FundingSigned + */ +struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the FundingSigned. + */ +uint64_t FundingSigned_hash(const struct LDKFundingSigned *NONNULL_PTR o); + +/** + * Checks if two FundingSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); + +/** + * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. + */ +void ChannelReady_free(struct LDKChannelReady this_obj); + +/** + * The channel ID + */ +struct LDKChannelId ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr); + +/** + * The channel ID + */ +void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The per-commitment point of the second commitment transaction + */ +struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); + +/** + * The per-commitment point of the second commitment transaction + */ +void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. + */ +struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); + +/** + * If set, provides a `short_channel_id` alias for this channel. + * + * The sender will accept payments to be forwarded over this SCID and forward them to this + * messages' recipient. + */ +void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); + +/** + * Constructs a new ChannelReady given each field + */ +MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKChannelId channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); + +/** + * Creates a copy of the ChannelReady + */ +struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ChannelReady. + */ +uint64_t ChannelReady_hash(const struct LDKChannelReady *NONNULL_PTR o); + +/** + * Checks if two ChannelReadys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); + +/** + * Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL. + */ +void Stfu_free(struct LDKStfu this_obj); + +/** + * The channel ID where quiescence is intended + */ +struct LDKChannelId Stfu_get_channel_id(const struct LDKStfu *NONNULL_PTR this_ptr); + +/** + * The channel ID where quiescence is intended + */ +void Stfu_set_channel_id(struct LDKStfu *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * Initiator flag, 1 if initiating, 0 if replying to an stfu. + */ +uint8_t Stfu_get_initiator(const struct LDKStfu *NONNULL_PTR this_ptr); + +/** + * Initiator flag, 1 if initiating, 0 if replying to an stfu. + */ +void Stfu_set_initiator(struct LDKStfu *NONNULL_PTR this_ptr, uint8_t val); + +/** + * Constructs a new Stfu given each field + */ +MUST_USE_RES struct LDKStfu Stfu_new(struct LDKChannelId channel_id_arg, uint8_t initiator_arg); + +/** + * Creates a copy of the Stfu + */ +struct LDKStfu Stfu_clone(const struct LDKStfu *NONNULL_PTR orig); + +/** + * Checks if two Stfus contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Stfu_eq(const struct LDKStfu *NONNULL_PTR a, const struct LDKStfu *NONNULL_PTR b); + +/** + * Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. + */ +void SpliceInit_free(struct LDKSpliceInit this_obj); + +/** + * The channel ID where splicing is intended + */ +struct LDKChannelId SpliceInit_get_channel_id(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * The channel ID where splicing is intended + */ +void SpliceInit_set_channel_id(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). + */ +int64_t SpliceInit_get_funding_contribution_satoshis(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * The amount the splice initiator is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). + */ +void SpliceInit_set_funding_contribution_satoshis(struct LDKSpliceInit *NONNULL_PTR this_ptr, int64_t val); + +/** + * The feerate for the new funding transaction, set by the splice initiator + */ +uint32_t SpliceInit_get_funding_feerate_perkw(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * The feerate for the new funding transaction, set by the splice initiator + */ +void SpliceInit_set_funding_feerate_perkw(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The locktime for the new funding transaction + */ +uint32_t SpliceInit_get_locktime(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * The locktime for the new funding transaction + */ +void SpliceInit_set_locktime(struct LDKSpliceInit *NONNULL_PTR this_ptr, uint32_t val); + +/** + * The key of the sender (splice initiator) controlling the new funding transaction + */ +struct LDKPublicKey SpliceInit_get_funding_pubkey(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * The key of the sender (splice initiator) controlling the new funding transaction + */ +void SpliceInit_set_funding_pubkey(struct LDKSpliceInit *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * If set, only confirmed inputs added (by the splice acceptor) will be accepted + */ +enum LDKCOption_NoneZ SpliceInit_get_require_confirmed_inputs(const struct LDKSpliceInit *NONNULL_PTR this_ptr); + +/** + * If set, only confirmed inputs added (by the splice acceptor) will be accepted + */ +void SpliceInit_set_require_confirmed_inputs(struct LDKSpliceInit *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + +/** + * Constructs a new SpliceInit given each field + */ +MUST_USE_RES struct LDKSpliceInit SpliceInit_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); + +/** + * Creates a copy of the SpliceInit + */ +struct LDKSpliceInit SpliceInit_clone(const struct LDKSpliceInit *NONNULL_PTR orig); + +/** + * Checks if two SpliceInits contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool SpliceInit_eq(const struct LDKSpliceInit *NONNULL_PTR a, const struct LDKSpliceInit *NONNULL_PTR b); + +/** + * Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL. + */ +void SpliceAck_free(struct LDKSpliceAck this_obj); + +/** + * The channel ID where splicing is intended + */ +struct LDKChannelId SpliceAck_get_channel_id(const struct LDKSpliceAck *NONNULL_PTR this_ptr); + +/** + * The channel ID where splicing is intended + */ +void SpliceAck_set_channel_id(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). + */ +int64_t SpliceAck_get_funding_contribution_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); + +/** + * The amount the splice acceptor is intending to add to its channel balance (splice-in) + * or remove from its channel balance (splice-out). + */ +void SpliceAck_set_funding_contribution_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); + +/** + * The key of the sender (splice acceptor) controlling the new funding transaction + */ +struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); + +/** + * The key of the sender (splice acceptor) controlling the new funding transaction + */ +void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); + +/** + * If set, only confirmed inputs added (by the splice initiator) will be accepted + */ +enum LDKCOption_NoneZ SpliceAck_get_require_confirmed_inputs(const struct LDKSpliceAck *NONNULL_PTR this_ptr); + +/** + * If set, only confirmed inputs added (by the splice initiator) will be accepted + */ +void SpliceAck_set_require_confirmed_inputs(struct LDKSpliceAck *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); + +/** + * Constructs a new SpliceAck given each field + */ +MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKChannelId channel_id_arg, int64_t funding_contribution_satoshis_arg, struct LDKPublicKey funding_pubkey_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); + +/** + * Creates a copy of the SpliceAck + */ +struct LDKSpliceAck SpliceAck_clone(const struct LDKSpliceAck *NONNULL_PTR orig); + +/** + * Checks if two SpliceAcks contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool SpliceAck_eq(const struct LDKSpliceAck *NONNULL_PTR a, const struct LDKSpliceAck *NONNULL_PTR b); + +/** + * Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NonePaymentSendFailureZ ChannelManager_send_payment_with_route(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); +void SpliceLocked_free(struct LDKSpliceLocked this_obj); /** - * Similar to [`ChannelManager::send_payment_with_route`], but will automatically find a route based on - * `route_params` and retry failed payment paths based on `retry_strategy`. + * The channel ID */ -MUST_USE_RES struct LDKCResult_NoneRetryableSendFailureZ ChannelManager_send_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +struct LDKChannelId SpliceLocked_get_channel_id(const struct LDKSpliceLocked *NONNULL_PTR this_ptr); /** - * Signals that no further attempts for the given payment should occur. Useful if you have a - * pending outbound payment with retries remaining, but wish to stop retrying the payment before - * retries are exhausted. - * - * # Event Generation - * - * If no [`Event::PaymentFailed`] event had been generated before, one will be generated as soon - * as there are no remaining pending HTLCs for this payment. - * - * Note that calling this method does *not* prevent a payment from succeeding. You must still - * wait until you receive either a [`Event::PaymentFailed`] or [`Event::PaymentSent`] event to - * determine the ultimate status of a payment. - * - * # Requested Invoices - * - * In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning - * the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`] - * and prevent any attempts at paying it once received. The other events may only be generated - * once the invoice has been received. - * - * # Restart Behavior - * - * If an [`Event::PaymentFailed`] is generated and we restart without first persisting the - * [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for - * [`Event::InvoiceRequestFailed`]. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * The channel ID */ -void ChannelManager_abandon_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id); +void SpliceLocked_set_channel_id(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Send a spontaneous payment, which is a payment that does not require the recipient to have - * generated an invoice. Optionally, you may specify the preimage. If you do choose to specify - * the preimage, it must be a cryptographically secure random value that no intermediate node - * would be able to guess -- otherwise, an intermediate node may claim the payment and it will - * never reach the recipient. - * - * See [`send_payment`] documentation for more details on the return value of this function - * and idempotency guarantees provided by the [`PaymentId`] key. - * - * Similar to regular payments, you MUST NOT reuse a `payment_preimage` value. See - * [`send_payment`] for more information about the risks of duplicate preimage usage. - * - * [`send_payment`]: Self::send_payment + * The ID of the new funding transaction that has been locked */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesPaymentSendFailureZ ChannelManager_send_spontaneous_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRoute *NONNULL_PTR route, struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id); +const uint8_t (*SpliceLocked_get_splice_txid(const struct LDKSpliceLocked *NONNULL_PTR this_ptr))[32]; /** - * Similar to [`ChannelManager::send_spontaneous_payment`], but will automatically find a route - * based on `route_params` and retry failed payment paths based on `retry_strategy`. - * - * See [`PaymentParameters::for_keysend`] for help in constructing `route_params` for spontaneous - * payments. - * - * [`PaymentParameters::for_keysend`]: crate::routing::router::PaymentParameters::for_keysend + * The ID of the new funding transaction that has been locked */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesRetryableSendFailureZ ChannelManager_send_spontaneous_payment_with_retry(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKRecipientOnionFields recipient_onion, struct LDKThirtyTwoBytes payment_id, struct LDKRouteParameters route_params, struct LDKRetry retry_strategy); +void SpliceLocked_set_splice_txid(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Send a payment that is probing the given route for liquidity. We calculate the - * [`PaymentHash`] of probes based on a static secret and a random [`PaymentId`], which allows - * us to easily discern them from real payments. + * Constructs a new SpliceLocked given each field */ -MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ ChannelManager_send_probe(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPath path); +MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes splice_txid_arg); /** - * Sends payment probes over all paths of a route that would be used to pay the given - * amount to the given `node_id`. - * - * See [`ChannelManager::send_preflight_probes`] for more information. + * Creates a copy of the SpliceLocked */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ChannelManager_send_spontaneous_preflight_probes(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id, uint64_t amount_msat, uint32_t final_cltv_expiry_delta, struct LDKCOption_u64Z liquidity_limit_multiplier); +struct LDKSpliceLocked SpliceLocked_clone(const struct LDKSpliceLocked *NONNULL_PTR orig); /** - * Sends payment probes over all paths of a route that would be used to pay a route found - * according to the given [`RouteParameters`]. - * - * This may be used to send \"pre-flight\" probes, i.e., to train our scorer before conducting - * the actual payment. Note this is only useful if there likely is sufficient time for the - * probe to settle before sending out the actual payment, e.g., when waiting for user - * confirmation in a wallet UI. - * - * Otherwise, there is a chance the probe could take up some liquidity needed to complete the - * actual payment. Users should therefore be cautious and might avoid sending probes if - * liquidity is scarce and/or they don't expect the probe to return before they send the - * payment. To mitigate this issue, channels with available liquidity less than the required - * amount times the given `liquidity_limit_multiplier` won't be used to send pre-flight - * probes. If `None` is given as `liquidity_limit_multiplier`, it defaults to `3`. + * Checks if two SpliceLockeds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ ChannelManager_send_preflight_probes(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKRouteParameters route_params, struct LDKCOption_u64Z liquidity_limit_multiplier); +bool SpliceLocked_eq(const struct LDKSpliceLocked *NONNULL_PTR a, const struct LDKSpliceLocked *NONNULL_PTR b); /** - * Call this upon creation of a funding transaction for the given channel. - * - * Returns an [`APIError::APIMisuseError`] if the funding_transaction spent non-SegWit outputs - * or if no output was found which matches the parameters in [`Event::FundingGenerationReady`]. - * - * Returns [`APIError::APIMisuseError`] if the funding transaction is not final for propagation - * across the p2p network. - * - * Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided - * for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. - * - * May panic if the output found in the funding transaction is duplicative with some other - * channel (note that this should be trivially prevented by using unique funding transaction - * keys per-channel). - * - * Do NOT broadcast the funding transaction yourself. When we have safely received our - * counterparty's signature the funding transaction will automatically be broadcast via the - * [`BroadcasterInterface`] provided when this `ChannelManager` was constructed. - * - * Note that this includes RBF or similar transaction replacement strategies - lightning does - * not currently support replacing a funding transaction on an existing channel. Instead, - * create a new channel with a conflicting funding transaction. - * - * Note to keep the miner incentives aligned in moving the blockchain forward, we recommend - * the wallet software generating the funding transaction to apply anti-fee sniping as - * implemented by Bitcoin Core wallet. See - * for more details. - * - * [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady - * [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed + * Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKTransaction funding_transaction); +void TxAddInput_free(struct LDKTxAddInput this_obj); /** - * Call this upon creation of a batch funding transaction for the given channels. - * - * Return values are identical to [`Self::funding_transaction_generated`], respective to - * each individual channel and transaction output. - * - * Do NOT broadcast the funding transaction yourself. This batch funding transaction - * will only be broadcast when we have safely received and persisted the counterparty's - * signature for each channel. - * - * If there is an error, all channels in the batch are to be considered closed. + * The channel ID */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_batch_funding_transaction_generated(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ temporary_channels, struct LDKTransaction funding_transaction); +struct LDKChannelId TxAddInput_get_channel_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Atomically applies partial updates to the [`ChannelConfig`] of the given channels. - * - * Once the updates are applied, each eligible channel (advertised with a known short channel - * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], - * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated - * containing the new [`ChannelUpdate`] message which should be broadcast to the network. - * - * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect - * `counterparty_node_id` is provided. - * - * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value - * below [`MIN_CLTV_EXPIRY_DELTA`]. - * - * If an error is returned, none of the updates should be considered applied. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths - * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat - * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta - * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`ChannelUnavailable`]: APIError::ChannelUnavailable - * [`APIMisuseError`]: APIError::APIMisuseError + * The channel ID */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_partial_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfigUpdate *NONNULL_PTR config_update); +void TxAddInput_set_channel_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Atomically updates the [`ChannelConfig`] for the given channels. - * - * Once the updates are applied, each eligible channel (advertised with a known short channel - * ID and a change in [`forwarding_fee_proportional_millionths`], [`forwarding_fee_base_msat`], - * or [`cltv_expiry_delta`]) has a [`BroadcastChannelUpdate`] event message generated - * containing the new [`ChannelUpdate`] message which should be broadcast to the network. - * - * Returns [`ChannelUnavailable`] when a channel is not found or an incorrect - * `counterparty_node_id` is provided. - * - * Returns [`APIMisuseError`] when a [`cltv_expiry_delta`] update is to be applied with a value - * below [`MIN_CLTV_EXPIRY_DELTA`]. - * - * If an error is returned, none of the updates should be considered applied. - * - * [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths - * [`forwarding_fee_base_msat`]: ChannelConfig::forwarding_fee_base_msat - * [`cltv_expiry_delta`]: ChannelConfig::cltv_expiry_delta - * [`BroadcastChannelUpdate`]: events::MessageSendEvent::BroadcastChannelUpdate - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`ChannelUnavailable`]: APIError::ChannelUnavailable - * [`APIMisuseError`]: APIError::APIMisuseError + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_update_channel_config(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKPublicKey counterparty_node_id, struct LDKCVec_ThirtyTwoBytesZ channel_ids, const struct LDKChannelConfig *NONNULL_PTR config); +uint64_t TxAddInput_get_serial_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Attempts to forward an intercepted HTLC over the provided channel id and with the provided - * amount to forward. Should only be called in response to an [`HTLCIntercepted`] event. - * - * Intercepted HTLCs can be useful for Lightning Service Providers (LSPs) to open a just-in-time - * channel to a receiving node if the node lacks sufficient inbound liquidity. - * - * To make use of intercepted HTLCs, set [`UserConfig::accept_intercept_htlcs`] and use - * [`ChannelManager::get_intercept_scid`] to generate short channel id(s) to put in the - * receiver's invoice route hints. These route hints will signal to LDK to generate an - * [`HTLCIntercepted`] event when it receives the forwarded HTLC, and this method or - * [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to the event. - * - * Note that LDK does not enforce fee requirements in `amt_to_forward_msat`, and will not stop - * you from forwarding more than you received. See - * [`HTLCIntercepted::expected_outbound_amount_msat`] for more on forwarding a different amount - * than expected. - * - * Errors if the event was not handled in time, in which case the HTLC was automatically failed - * backwards. - * - * [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs - * [`HTLCIntercepted`]: events::Event::HTLCIntercepted - * [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat + * A randomly chosen unique identifier for this input, which is even for initiators and odd for + * non-initiators. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_forward_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id, const uint8_t (*next_hop_channel_id)[32], struct LDKPublicKey next_node_id, uint64_t amt_to_forward_msat); +void TxAddInput_set_serial_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint64_t val); /** - * Fails the intercepted HTLC indicated by intercept_id. Should only be called in response to - * an [`HTLCIntercepted`] event. See [`ChannelManager::forward_intercepted_htlc`]. - * - * Errors if the event was not handled in time, in which case the HTLC was automatically failed - * backwards. - * - * [`HTLCIntercepted`]: events::Event::HTLCIntercepted + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_fail_intercepted_htlc(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes intercept_id); +struct LDKTransactionU16LenLimited TxAddInput_get_prevtx(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Processes HTLCs which are pending waiting on random forward delay. - * - * Should only really ever be called in response to a PendingHTLCsForwardable event. - * Will likely generate further events. + * Serialized transaction that contains the output this input spends to verify that it is non + * malleable. */ -void ChannelManager_process_pending_htlc_forwards(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxAddInput_set_prevtx(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKTransactionU16LenLimited val); /** - * Performs actions which should happen on startup and roughly once per minute thereafter. - * - * This currently includes: - * * Increasing or decreasing the on-chain feerate estimates for our outbound channels, - * * Broadcasting [`ChannelUpdate`] messages if we've been disconnected from our peer for more - * than a minute, informing the network that they should no longer attempt to route over - * the channel. - * * Expiring a channel's previous [`ChannelConfig`] if necessary to only allow forwarding HTLCs - * with the current [`ChannelConfig`]. - * * Removing peers which have disconnected but and no longer have any channels. - * * Force-closing and removing channels which have not completed establishment in a timely manner. - * * Forgetting about stale outbound payments, either those that have already been fulfilled - * or those awaiting an invoice that hasn't been delivered in the necessary amount of time. - * The latter is determined using the system clock in `std` and the highest seen block time - * minus two hours in `no-std`. - * - * Note that this may cause reentrancy through [`chain::Watch::update_channel`] calls or feerate - * estimate fetches. - * - * [`ChannelUpdate`]: msgs::ChannelUpdate - * [`ChannelConfig`]: crate::util::config::ChannelConfig + * The index of the output being spent */ -void ChannelManager_timer_tick_occurred(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint32_t TxAddInput_get_prevtx_out(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Indicates that the preimage for payment_hash is unknown or the received amount is incorrect - * after a PaymentClaimable event, failing the HTLC back to its origin and freeing resources - * along the path (including in our own channel on which we received it). - * - * Note that in some cases around unclean shutdown, it is possible the payment may have - * already been claimed by you via [`ChannelManager::claim_funds`] prior to you seeing (a - * second copy of) the [`events::Event::PaymentClaimable`] event. Alternatively, the payment - * may have already been failed automatically by LDK if it was nearing its expiration time. - * - * While LDK will never claim a payment automatically on your behalf (i.e. without you calling - * [`ChannelManager::claim_funds`]), you should still monitor for - * [`events::Event::PaymentClaimed`] events even for payments you intend to fail, especially on - * startup during which time claims that were in-progress at shutdown may be replayed. + * The index of the output being spent */ -void ChannelManager_fail_htlc_backwards(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32]); +void TxAddInput_set_prevtx_out(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the - * reason for the failure. - * - * See [`FailureCode`] for valid failure codes. + * The sequence number of this input */ -void ChannelManager_fail_htlc_backwards_with_reason(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*payment_hash)[32], struct LDKFailureCode failure_code); +uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any - * [`MessageSendEvent`]s needed to claim the payment. - * - * This method is guaranteed to ensure the payment has been claimed but only if the current - * height is strictly below [`Event::PaymentClaimable::claim_deadline`]. To avoid race - * conditions, you should wait for an [`Event::PaymentClaimed`] before considering the payment - * successful. It will generally be available in the next [`process_pending_events`] call. - * - * Note that if you did not set an `amount_msat` when calling [`create_inbound_payment`] or - * [`create_inbound_payment_for_hash`] you must check that the amount in the `PaymentClaimable` - * event matches your expectation. If you fail to do so and call this method, you may provide - * the sender \"proof-of-payment\" when they did not fulfill the full expected payment. - * - * This function will fail the payment if it has custom TLVs with even type numbers, as we - * will assume they are unknown. If you intend to accept even custom TLVs, you should use - * [`claim_funds_with_known_custom_tlvs`]. - * - * [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable - * [`Event::PaymentClaimable::claim_deadline`]: crate::events::Event::PaymentClaimable::claim_deadline - * [`Event::PaymentClaimed`]: crate::events::Event::PaymentClaimed - * [`process_pending_events`]: EventsProvider::process_pending_events - * [`create_inbound_payment`]: Self::create_inbound_payment - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash - * [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs + * The sequence number of this input */ -void ChannelManager_claim_funds(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); +void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); /** - * This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with - * even type numbers. - * - * # Note - * - * You MUST check you've understood all even TLVs before using this to - * claim, otherwise you may unintentionally agree to some protocol you do not understand. - * - * [`claim_funds`]: Self::claim_funds + * The ID of the previous funding transaction, when it is being added as an input during splicing */ -void ChannelManager_claim_funds_with_known_custom_tlvs(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_preimage); +struct LDKCOption_ThirtyTwoBytesZ TxAddInput_get_shared_input_txid(const struct LDKTxAddInput *NONNULL_PTR this_ptr); /** - * Gets the node_id held by this ChannelManager + * The ID of the previous funding transaction, when it is being added as an input during splicing */ -MUST_USE_RES struct LDKPublicKey ChannelManager_get_our_node_id(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxAddInput_set_shared_input_txid(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Accepts a request to open a channel after a [`Event::OpenChannelRequest`]. - * - * The `temporary_channel_id` parameter indicates which inbound channel should be accepted, - * and the `counterparty_node_id` parameter is the id of the peer which has requested to open - * the channel. - * - * The `user_channel_id` parameter will be provided back in - * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond - * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. - * - * Note that this method will return an error and reject the channel, if it requires support - * for zero confirmations. Instead, `accept_inbound_channel_from_trusted_peer_0conf` must be - * used to accept such channels. - * - * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest - * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + * Constructs a new TxAddInput given each field */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); +MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg, struct LDKCOption_ThirtyTwoBytesZ shared_input_txid_arg); /** - * Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating - * it as confirmed immediately. - * - * The `user_channel_id` parameter will be provided back in - * [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond - * with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call. - * - * Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel - * and (if the counterparty agrees), enables forwarding of payments immediately. - * - * This fully trusts that the counterparty has honestly and correctly constructed the funding - * transaction and blindly assumes that it will eventually confirm. - * - * If it does not confirm before we decide to close the channel, or if the funding transaction - * does not pay to the correct script the correct amount, *you will lose funds*. - * - * [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest - * [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id + * Creates a copy of the TxAddInput */ -MUST_USE_RES struct LDKCResult_NoneAPIErrorZ ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(const struct LDKChannelManager *NONNULL_PTR this_arg, const uint8_t (*temporary_channel_id)[32], struct LDKPublicKey counterparty_node_id, struct LDKU128 user_channel_id); +struct LDKTxAddInput TxAddInput_clone(const struct LDKTxAddInput *NONNULL_PTR orig); /** - * Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and - * enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual - * [`Bolt12Invoice`] once it is received. - * - * Uses [`InvoiceRequestBuilder`] such that the [`InvoiceRequest`] it builds is recognized by - * the [`ChannelManager`] when handling a [`Bolt12Invoice`] message in response to the request. - * The optional parameters are used in the builder, if `Some`: - * - `quantity` for [`InvoiceRequest::quantity`] which must be set if - * [`Offer::expects_quantity`] is `true`. - * - `amount_msats` if overpaying what is required for the given `quantity` is desired, and - * - `payer_note` for [`InvoiceRequest::payer_note`]. - * - * If `max_total_routing_fee_msat` is not specified, The default from - * [`RouteParameters::from_payment_params_and_value`] is applied. - * - * # Payment - * - * The provided `payment_id` is used to ensure that only one invoice is paid for the request - * when received. See [Avoiding Duplicate Payments] for other requirements once the payment has - * been sent. - * - * To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the - * invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the - * payment will fail with an [`Event::InvoiceRequestFailed`]. - * - * # Privacy - * - * Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`] - * as the introduction node and a derived payer id for payer privacy. As such, currently, the - * node must be announced. Otherwise, there is no way to find a path to the introduction node - * in order to send the [`Bolt12Invoice`]. - * - * # Limitations - * - * Requires a direct connection to an introduction node in [`Offer::paths`] or to - * [`Offer::signing_pubkey`], if empty. A similar restriction applies to the responding - * [`Bolt12Invoice::payment_paths`]. - * - * # Errors - * - * Errors if: - * - a duplicate `payment_id` is provided given the caveats in the aforementioned link, - * - the provided parameters are invalid for the offer, - * - the parameterized [`Router`] is unable to create a blinded reply path for the invoice - * request. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity - * [`InvoiceRequest::payer_note`]: crate::offers::invoice_request::InvoiceRequest::payer_note - * [`InvoiceRequestBuilder`]: crate::offers::invoice_request::InvoiceRequestBuilder - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths - * [Avoiding Duplicate Payments]: #avoiding-duplicate-payments + * Generates a non-cryptographic 64-bit hash of the TxAddInput. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ ChannelManager_pay_for_offer(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKOffer *NONNULL_PTR offer, struct LDKCOption_u64Z quantity, struct LDKCOption_u64Z amount_msats, struct LDKCOption_StrZ payer_note, struct LDKThirtyTwoBytes payment_id, struct LDKRetry retry_strategy, struct LDKCOption_u64Z max_total_routing_fee_msat); +uint64_t TxAddInput_hash(const struct LDKTxAddInput *NONNULL_PTR o); /** - * Creates a [`Bolt12Invoice`] for a [`Refund`] and enqueues it to be sent via an onion - * message. - * - * The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a - * [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding - * [`PaymentPreimage`]. - * - * # Limitations - * - * Requires a direct connection to an introduction node in [`Refund::paths`] or to - * [`Refund::payer_id`], if empty. This request is best effort; an invoice will be sent to each - * node meeting the aforementioned criteria, but there's no guarantee that they will be - * received and no retries will be made. - * - * # Errors - * - * Errors if the parameterized [`Router`] is unable to create a blinded payment path or reply - * path for the invoice. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Checks if two TxAddInputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ ChannelManager_request_refund_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, const struct LDKRefund *NONNULL_PTR refund); +bool TxAddInput_eq(const struct LDKTxAddInput *NONNULL_PTR a, const struct LDKTxAddInput *NONNULL_PTR b); /** - * Gets a payment secret and payment hash for use in an invoice given to a third party wishing - * to pay us. - * - * This differs from [`create_inbound_payment_for_hash`] only in that it generates the - * [`PaymentHash`] and [`PaymentPreimage`] for you. - * - * The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which - * will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with - * its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be - * passed directly to [`claim_funds`]. - * - * See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. - * - * Note that a malicious eavesdropper can intuit whether an inbound payment was created by - * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. - * - * # Note - * - * If you register an inbound payment with this method, then serialize the `ChannelManager`, then - * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. - * - * Errors if `min_value_msat` is greater than total bitcoin supply. - * - * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [`claim_funds`]: Self::claim_funds - * [`PaymentClaimable`]: events::Event::PaymentClaimable - * [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose - * [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment - * [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage - * [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash + * Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. + */ +void TxAddOutput_free(struct LDKTxAddOutput this_obj); + +/** + * The channel ID + */ +struct LDKChannelId TxAddOutput_get_channel_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); + +/** + * The channel ID + */ +void TxAddOutput_set_channel_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. + */ +uint64_t TxAddOutput_get_serial_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); + +/** + * A randomly chosen unique identifier for this output, which is even for initiators and odd for + * non-initiators. + */ +void TxAddOutput_set_serial_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The satoshi value of the output + */ +uint64_t TxAddOutput_get_sats(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); + +/** + * The satoshi value of the output + */ +void TxAddOutput_set_sats(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The scriptPubKey for the output + */ +struct LDKCVec_u8Z TxAddOutput_get_script(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); + +/** + * The scriptPubKey for the output + */ +void TxAddOutput_set_script(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); + +/** + * Constructs a new TxAddOutput given each field + */ +MUST_USE_RES struct LDKTxAddOutput TxAddOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg, uint64_t sats_arg, struct LDKCVec_u8Z script_arg); + +/** + * Creates a copy of the TxAddOutput + */ +struct LDKTxAddOutput TxAddOutput_clone(const struct LDKTxAddOutput *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the TxAddOutput. + */ +uint64_t TxAddOutput_hash(const struct LDKTxAddOutput *NONNULL_PTR o); + +/** + * Checks if two TxAddOutputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool TxAddOutput_eq(const struct LDKTxAddOutput *NONNULL_PTR a, const struct LDKTxAddOutput *NONNULL_PTR b); + +/** + * Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. + */ +void TxRemoveInput_free(struct LDKTxRemoveInput this_obj); + +/** + * The channel ID */ -MUST_USE_RES struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ ChannelManager_create_inbound_payment(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +struct LDKChannelId TxRemoveInput_get_channel_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); /** - * Gets a [`PaymentSecret`] for a given [`PaymentHash`], for which the payment preimage is - * stored external to LDK. - * - * A [`PaymentClaimable`] event will only be generated if the [`PaymentSecret`] matches a - * payment secret fetched via this method or [`create_inbound_payment`], and which is at least - * the `min_value_msat` provided here, if one is provided. - * - * The [`PaymentHash`] (and corresponding [`PaymentPreimage`]) should be globally unique, though - * note that LDK will not stop you from registering duplicate payment hashes for inbound - * payments. - * - * `min_value_msat` should be set if the invoice being generated contains a value. Any payment - * received for the returned [`PaymentHash`] will be required to be at least `min_value_msat` - * before a [`PaymentClaimable`] event will be generated, ensuring that we do not provide the - * sender \"proof-of-payment\" unless they have paid the required amount. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. This should roughly match the expiry time set in the invoice. - * After this many seconds, we will remove the inbound payment, resulting in any attempts to - * pay the invoice failing. The BOLT spec suggests 3,600 secs as a default validity time for - * invoices when no timeout is set. - * - * Note that we use block header time to time-out pending inbound payments (with some margin - * to compensate for the inaccuracy of block header timestamps). Thus, in practice we will - * accept a payment and generate a [`PaymentClaimable`] event for some time after the expiry. - * If you need exact expiry semantics, you should enforce them upon receipt of - * [`PaymentClaimable`]. - * - * Note that invoices generated for inbound payments should have their `min_final_cltv_expiry_delta` - * set to at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * - * Note that a malicious eavesdropper can intuit whether an inbound payment was created by - * `create_inbound_payment` or `create_inbound_payment_for_hash` based on runtime. - * - * # Note - * - * If you register an inbound payment with this method, then serialize the `ChannelManager`, then - * deserialize it with a node running 0.0.103 and earlier, the payment will fail to be received. - * - * Errors if `min_value_msat` is greater than total bitcoin supply. - * - * If `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [`create_inbound_payment`]: Self::create_inbound_payment - * [`PaymentClaimable`]: events::Event::PaymentClaimable + * The channel ID */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ ChannelManager_create_inbound_payment_for_hash(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry); +void TxRemoveInput_set_channel_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Gets an LDK-generated payment preimage from a payment hash and payment secret that were - * previously returned from [`create_inbound_payment`]. - * - * [`create_inbound_payment`]: Self::create_inbound_payment + * The serial ID of the input to be removed */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesAPIErrorZ ChannelManager_get_payment_preimage(const struct LDKChannelManager *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_hash, struct LDKThirtyTwoBytes payment_secret); +uint64_t TxRemoveInput_get_serial_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); /** - * Gets a fake short channel id for use in receiving [phantom node payments]. These fake scids - * are used when constructing the phantom invoice's route hints. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * The serial ID of the input to be removed */ -MUST_USE_RES uint64_t ChannelManager_get_phantom_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxRemoveInput_set_serial_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets route hints for use in receiving [phantom node payments]. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * Constructs a new TxRemoveInput given each field */ -MUST_USE_RES struct LDKPhantomRouteHints ChannelManager_get_phantom_route_hints(const struct LDKChannelManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTxRemoveInput TxRemoveInput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); /** - * Gets a fake short channel id for use in receiving intercepted payments. These fake scids are - * used when constructing the route hints for HTLCs intended to be intercepted. See - * [`ChannelManager::forward_intercepted_htlc`]. - * - * Note that this method is not guaranteed to return unique values, you may need to call it a few - * times to get a unique scid. + * Creates a copy of the TxRemoveInput */ -MUST_USE_RES uint64_t ChannelManager_get_intercept_scid(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKTxRemoveInput TxRemoveInput_clone(const struct LDKTxRemoveInput *NONNULL_PTR orig); /** - * Gets inflight HTLC information by processing pending outbound payments that are in - * our channels. May be used during pathfinding to account for in-use channel liquidity. + * Generates a non-cryptographic 64-bit hash of the TxRemoveInput. */ -MUST_USE_RES struct LDKInFlightHtlcs ChannelManager_compute_inflight_htlcs(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t TxRemoveInput_hash(const struct LDKTxRemoveInput *NONNULL_PTR o); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Checks if two TxRemoveInputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKMessageSendEventsProvider ChannelManager_as_MessageSendEventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool TxRemoveInput_eq(const struct LDKTxRemoveInput *NONNULL_PTR a, const struct LDKTxRemoveInput *NONNULL_PTR b); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. */ -struct LDKEventsProvider ChannelManager_as_EventsProvider(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxRemoveOutput_free(struct LDKTxRemoveOutput this_obj); /** - * Constructs a new Listen which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is + * The channel ID */ -struct LDKListen ChannelManager_as_Listen(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKChannelId TxRemoveOutput_get_channel_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); /** - * Constructs a new Confirm which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is + * The channel ID */ -struct LDKConfirm ChannelManager_as_Confirm(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxRemoveOutput_set_channel_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Gets a [`Future`] that completes when this [`ChannelManager`] may need to be persisted or - * may have events that need processing. - * - * In order to check if this [`ChannelManager`] needs persisting, call - * [`Self::get_and_clear_needs_persistence`]. - * - * Note that callbacks registered on the [`Future`] MUST NOT call back into this - * [`ChannelManager`] and should instead register actions to be taken later. + * The serial ID of the output to be removed */ -MUST_USE_RES struct LDKFuture ChannelManager_get_event_or_persistence_needed_future(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t TxRemoveOutput_get_serial_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); /** - * Returns true if this [`ChannelManager`] needs to be persisted. + * The serial ID of the output to be removed */ -MUST_USE_RES bool ChannelManager_get_and_clear_needs_persistence(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxRemoveOutput_set_serial_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, uint64_t val); /** - * Gets the latest best block which was connected either via the [`chain::Listen`] or - * [`chain::Confirm`] interfaces. + * Constructs a new TxRemoveOutput given each field */ -MUST_USE_RES struct LDKBestBlock ChannelManager_current_best_block(const struct LDKChannelManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTxRemoveOutput TxRemoveOutput_new(struct LDKChannelId channel_id_arg, uint64_t serial_id_arg); /** - * Fetches the set of [`NodeFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Creates a copy of the TxRemoveOutput */ -MUST_USE_RES struct LDKNodeFeatures ChannelManager_node_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKTxRemoveOutput TxRemoveOutput_clone(const struct LDKTxRemoveOutput *NONNULL_PTR orig); /** - * Fetches the set of [`ChannelFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Generates a non-cryptographic 64-bit hash of the TxRemoveOutput. */ -MUST_USE_RES struct LDKChannelFeatures ChannelManager_channel_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +uint64_t TxRemoveOutput_hash(const struct LDKTxRemoveOutput *NONNULL_PTR o); /** - * Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Checks if two TxRemoveOutputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelManager_channel_type_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +bool TxRemoveOutput_eq(const struct LDKTxRemoveOutput *NONNULL_PTR a, const struct LDKTxRemoveOutput *NONNULL_PTR b); /** - * Fetches the set of [`InitFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKInitFeatures ChannelManager_init_features(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxComplete_free(struct LDKTxComplete this_obj); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * The channel ID */ -struct LDKChannelMessageHandler ChannelManager_as_ChannelMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +struct LDKChannelId TxComplete_get_channel_id(const struct LDKTxComplete *NONNULL_PTR this_ptr); /** - * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is + * The channel ID */ -struct LDKOffersMessageHandler ChannelManager_as_OffersMessageHandler(const struct LDKChannelManager *NONNULL_PTR this_arg); +void TxComplete_set_channel_id(struct LDKTxComplete *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Fetches the set of [`InitFeatures`] flags that are provided by or required by - * [`ChannelManager`]. + * Constructs a new TxComplete given each field */ -struct LDKInitFeatures provided_init_features(const struct LDKUserConfig *NONNULL_PTR config); +MUST_USE_RES struct LDKTxComplete TxComplete_new(struct LDKChannelId channel_id_arg); /** - * Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read + * Creates a copy of the TxComplete */ -struct LDKCVec_u8Z CounterpartyForwardingInfo_write(const struct LDKCounterpartyForwardingInfo *NONNULL_PTR obj); +struct LDKTxComplete TxComplete_clone(const struct LDKTxComplete *NONNULL_PTR orig); /** - * Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write + * Generates a non-cryptographic 64-bit hash of the TxComplete. */ -struct LDKCResult_CounterpartyForwardingInfoDecodeErrorZ CounterpartyForwardingInfo_read(struct LDKu8slice ser); +uint64_t TxComplete_hash(const struct LDKTxComplete *NONNULL_PTR o); /** - * Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read + * Checks if two TxCompletes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z ChannelCounterparty_write(const struct LDKChannelCounterparty *NONNULL_PTR obj); +bool TxComplete_eq(const struct LDKTxComplete *NONNULL_PTR a, const struct LDKTxComplete *NONNULL_PTR b); /** - * Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write + * Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelCounterpartyDecodeErrorZ ChannelCounterparty_read(struct LDKu8slice ser); +void TxSignatures_free(struct LDKTxSignatures this_obj); /** - * Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read + * The channel ID */ -struct LDKCVec_u8Z ChannelDetails_write(const struct LDKChannelDetails *NONNULL_PTR obj); +struct LDKChannelId TxSignatures_get_channel_id(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Read a ChannelDetails from a byte array, created by ChannelDetails_write + * The channel ID */ -struct LDKCResult_ChannelDetailsDecodeErrorZ ChannelDetails_read(struct LDKu8slice ser); +void TxSignatures_set_channel_id(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read + * The TXID */ -struct LDKCVec_u8Z PhantomRouteHints_write(const struct LDKPhantomRouteHints *NONNULL_PTR obj); +const uint8_t (*TxSignatures_get_tx_hash(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; /** - * Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write + * The TXID */ -struct LDKCResult_PhantomRouteHintsDecodeErrorZ PhantomRouteHints_read(struct LDKu8slice ser); +void TxSignatures_set_tx_hash(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the BlindedForward object into a byte array which can be read by BlindedForward_read + * The list of witnesses + * + * Returns a copy of the field. */ -struct LDKCVec_u8Z BlindedForward_write(const struct LDKBlindedForward *NONNULL_PTR obj); +struct LDKCVec_WitnessZ TxSignatures_get_witnesses(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Read a BlindedForward from a byte array, created by BlindedForward_write + * The list of witnesses */ -struct LDKCResult_BlindedForwardDecodeErrorZ BlindedForward_read(struct LDKu8slice ser); +void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCVec_WitnessZ val); /** - * Serialize the PendingHTLCRouting object into a byte array which can be read by PendingHTLCRouting_read + * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -struct LDKCVec_u8Z PendingHTLCRouting_write(const struct LDKPendingHTLCRouting *NONNULL_PTR obj); +struct LDKCOption_ECDSASignatureZ TxSignatures_get_shared_input_signature(const struct LDKTxSignatures *NONNULL_PTR this_ptr); /** - * Read a PendingHTLCRouting from a byte array, created by PendingHTLCRouting_write + * Optional signature for the shared input -- the previous funding outpoint -- signed by both peers */ -struct LDKCResult_PendingHTLCRoutingDecodeErrorZ PendingHTLCRouting_read(struct LDKu8slice ser); +void TxSignatures_set_shared_input_signature(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCOption_ECDSASignatureZ val); /** - * Serialize the PendingHTLCInfo object into a byte array which can be read by PendingHTLCInfo_read + * Constructs a new TxSignatures given each field */ -struct LDKCVec_u8Z PendingHTLCInfo_write(const struct LDKPendingHTLCInfo *NONNULL_PTR obj); +MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg, struct LDKCOption_ECDSASignatureZ shared_input_signature_arg); /** - * Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write + * Creates a copy of the TxSignatures */ -struct LDKCResult_PendingHTLCInfoDecodeErrorZ PendingHTLCInfo_read(struct LDKu8slice ser); +struct LDKTxSignatures TxSignatures_clone(const struct LDKTxSignatures *NONNULL_PTR orig); /** - * Serialize the BlindedFailure object into a byte array which can be read by BlindedFailure_read + * Generates a non-cryptographic 64-bit hash of the TxSignatures. */ -struct LDKCVec_u8Z BlindedFailure_write(const enum LDKBlindedFailure *NONNULL_PTR obj); +uint64_t TxSignatures_hash(const struct LDKTxSignatures *NONNULL_PTR o); /** - * Read a BlindedFailure from a byte array, created by BlindedFailure_write + * Checks if two TxSignaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_BlindedFailureDecodeErrorZ BlindedFailure_read(struct LDKu8slice ser); +bool TxSignatures_eq(const struct LDKTxSignatures *NONNULL_PTR a, const struct LDKTxSignatures *NONNULL_PTR b); /** - * Serialize the ChannelManager object into a byte array which can be read by ChannelManager_read + * Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ChannelManager_write(const struct LDKChannelManager *NONNULL_PTR obj); +void TxInitRbf_free(struct LDKTxInitRbf this_obj); /** - * Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read + * The channel ID */ -struct LDKCVec_u8Z ChannelShutdownState_write(const enum LDKChannelShutdownState *NONNULL_PTR obj); +struct LDKChannelId TxInitRbf_get_channel_id(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write + * The channel ID */ -struct LDKCResult_ChannelShutdownStateDecodeErrorZ ChannelShutdownState_read(struct LDKu8slice ser); +void TxInitRbf_set_channel_id(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Frees any resources used by the ChannelManagerReadArgs, if is_owned is set and inner is non-NULL. + * The locktime of the transaction */ -void ChannelManagerReadArgs_free(struct LDKChannelManagerReadArgs this_obj); +uint32_t TxInitRbf_get_locktime(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * A cryptographically secure source of entropy. + * The locktime of the transaction */ -const struct LDKEntropySource *ChannelManagerReadArgs_get_entropy_source(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void TxInitRbf_set_locktime(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * A cryptographically secure source of entropy. + * The feerate of the transaction */ -void ChannelManagerReadArgs_set_entropy_source(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKEntropySource val); +uint32_t TxInitRbf_get_feerate_sat_per_1000_weight(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * A signer that is able to perform node-scoped cryptographic operations. + * The feerate of the transaction */ -const struct LDKNodeSigner *ChannelManagerReadArgs_get_node_signer(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void TxInitRbf_set_feerate_sat_per_1000_weight(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); /** - * A signer that is able to perform node-scoped cryptographic operations. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -void ChannelManagerReadArgs_set_node_signer(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKNodeSigner val); +struct LDKCOption_i64Z TxInitRbf_get_funding_output_contribution(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -const struct LDKSignerProvider *ChannelManagerReadArgs_get_signer_provider(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +void TxInitRbf_set_funding_output_contribution(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * The keys provider which will give us relevant keys. Some keys will be loaded during - * deserialization and KeysInterface::read_chan_signer will be used to read per-Channel - * signing data. + * Constructs a new TxInitRbf given each field */ -void ChannelManagerReadArgs_set_signer_provider(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKSignerProvider val); +MUST_USE_RES struct LDKTxInitRbf TxInitRbf_new(struct LDKChannelId channel_id_arg, uint32_t locktime_arg, uint32_t feerate_sat_per_1000_weight_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * Creates a copy of the TxInitRbf */ -const struct LDKFeeEstimator *ChannelManagerReadArgs_get_fee_estimator(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKTxInitRbf TxInitRbf_clone(const struct LDKTxInitRbf *NONNULL_PTR orig); /** - * The fee_estimator for use in the ChannelManager in the future. - * - * No calls to the FeeEstimator will be made during deserialization. + * Generates a non-cryptographic 64-bit hash of the TxInitRbf. */ -void ChannelManagerReadArgs_set_fee_estimator(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKFeeEstimator val); +uint64_t TxInitRbf_hash(const struct LDKTxInitRbf *NONNULL_PTR o); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Checks if two TxInitRbfs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const struct LDKWatch *ChannelManagerReadArgs_get_chain_monitor(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +bool TxInitRbf_eq(const struct LDKTxInitRbf *NONNULL_PTR a, const struct LDKTxInitRbf *NONNULL_PTR b); /** - * The chain::Watch for use in the ChannelManager in the future. - * - * No calls to the chain::Watch will be made during deserialization. It is assumed that - * you have deserialized ChannelMonitors separately and will add them to your - * chain::Watch after deserializing this ChannelManager. + * Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. */ -void ChannelManagerReadArgs_set_chain_monitor(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKWatch val); +void TxAckRbf_free(struct LDKTxAckRbf this_obj); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The channel ID */ -const struct LDKBroadcasterInterface *ChannelManagerReadArgs_get_tx_broadcaster(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKChannelId TxAckRbf_get_channel_id(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); /** - * The BroadcasterInterface which will be used in the ChannelManager in the future and may be - * used to broadcast the latest local commitment transactions of channels which must be - * force-closed during deserialization. + * The channel ID */ -void ChannelManagerReadArgs_set_tx_broadcaster(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKBroadcasterInterface val); +void TxAckRbf_set_channel_id(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. - * - * No calls to the router will be made during deserialization. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -const struct LDKRouter *ChannelManagerReadArgs_get_router(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +struct LDKCOption_i64Z TxAckRbf_get_funding_output_contribution(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); /** - * The router which will be used in the ChannelManager in the future for finding routes - * on-the-fly for trampoline payments. Absent in private nodes that don't support forwarding. - * - * No calls to the router will be made during deserialization. + * The number of satoshis the sender will contribute to or, if negative, remove from + * (e.g. splice-out) the funding output of the transaction */ -void ChannelManagerReadArgs_set_router(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKRouter val); +void TxAckRbf_set_funding_output_contribution(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Constructs a new TxAckRbf given each field */ -const struct LDKLogger *ChannelManagerReadArgs_get_logger(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxAckRbf TxAckRbf_new(struct LDKChannelId channel_id_arg, struct LDKCOption_i64Z funding_output_contribution_arg); /** - * The Logger for use in the ChannelManager and which may be used to log information during - * deserialization. + * Creates a copy of the TxAckRbf */ -void ChannelManagerReadArgs_set_logger(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKLogger val); +struct LDKTxAckRbf TxAckRbf_clone(const struct LDKTxAckRbf *NONNULL_PTR orig); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Generates a non-cryptographic 64-bit hash of the TxAckRbf. */ -struct LDKUserConfig ChannelManagerReadArgs_get_default_config(const struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr); +uint64_t TxAckRbf_hash(const struct LDKTxAckRbf *NONNULL_PTR o); /** - * Default settings used for new channels. Any existing channels will continue to use the - * runtime settings which were stored when the ChannelManager was serialized. + * Checks if two TxAckRbfs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void ChannelManagerReadArgs_set_default_config(struct LDKChannelManagerReadArgs *NONNULL_PTR this_ptr, struct LDKUserConfig val); +bool TxAckRbf_eq(const struct LDKTxAckRbf *NONNULL_PTR a, const struct LDKTxAckRbf *NONNULL_PTR b); /** - * Simple utility function to create a ChannelManagerReadArgs which creates the monitor - * HashMap for you. This is primarily useful for C bindings where it is not practical to - * populate a HashMap directly from C. + * Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelManagerReadArgs ChannelManagerReadArgs_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKSignerProvider signer_provider, struct LDKFeeEstimator fee_estimator, struct LDKWatch chain_monitor, struct LDKBroadcasterInterface tx_broadcaster, struct LDKRouter router, struct LDKLogger logger, struct LDKUserConfig default_config, struct LDKCVec_ChannelMonitorZ channel_monitors); +void TxAbort_free(struct LDKTxAbort this_obj); /** - * Read a C2Tuple_ThirtyTwoBytesChannelManagerZ from a byte array, created by C2Tuple_ThirtyTwoBytesChannelManagerZ_write + * The channel ID */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ C2Tuple_ThirtyTwoBytesChannelManagerZ_read(struct LDKu8slice ser, struct LDKChannelManagerReadArgs arg); +struct LDKChannelId TxAbort_get_channel_id(const struct LDKTxAbort *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DelayedPaymentBasepoint, if is_owned is set and inner is non-NULL. + * The channel ID */ -void DelayedPaymentBasepoint_free(struct LDKDelayedPaymentBasepoint this_obj); +void TxAbort_set_channel_id(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKChannelId val); -struct LDKPublicKey DelayedPaymentBasepoint_get_a(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr); +/** + * Message data + * + * Returns a copy of the field. + */ +struct LDKCVec_u8Z TxAbort_get_data(const struct LDKTxAbort *NONNULL_PTR this_ptr); -void DelayedPaymentBasepoint_set_a(struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Message data + */ +void TxAbort_set_data(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Constructs a new DelayedPaymentBasepoint given each field + * Constructs a new TxAbort given each field */ -MUST_USE_RES struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_new(struct LDKPublicKey a_arg); +MUST_USE_RES struct LDKTxAbort TxAbort_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z data_arg); /** - * Checks if two DelayedPaymentBasepoints contain equal inner contents. + * Creates a copy of the TxAbort + */ +struct LDKTxAbort TxAbort_clone(const struct LDKTxAbort *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the TxAbort. + */ +uint64_t TxAbort_hash(const struct LDKTxAbort *NONNULL_PTR o); + +/** + * Checks if two TxAborts contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool DelayedPaymentBasepoint_eq(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR a, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR b); +bool TxAbort_eq(const struct LDKTxAbort *NONNULL_PTR a, const struct LDKTxAbort *NONNULL_PTR b); /** - * Creates a copy of the DelayedPaymentBasepoint + * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. */ -struct LDKDelayedPaymentBasepoint DelayedPaymentBasepoint_clone(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR orig); +void Shutdown_free(struct LDKShutdown this_obj); /** - * Generates a non-cryptographic 64-bit hash of the DelayedPaymentBasepoint. + * The channel ID */ -uint64_t DelayedPaymentBasepoint_hash(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR o); +struct LDKChannelId Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * Get inner Public Key + * The channel ID */ -MUST_USE_RES struct LDKPublicKey DelayedPaymentBasepoint_to_public_key(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR this_arg); +void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Serialize the DelayedPaymentBasepoint object into a byte array which can be read by DelayedPaymentBasepoint_read + * The destination of this peer's funds on closing. + * + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -struct LDKCVec_u8Z DelayedPaymentBasepoint_write(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR obj); +struct LDKCVec_u8Z Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); /** - * Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write + * The destination of this peer's funds on closing. + * + * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. */ -struct LDKCResult_DelayedPaymentBasepointDecodeErrorZ DelayedPaymentBasepoint_read(struct LDKu8slice ser); +void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Frees any resources used by the DelayedPaymentKey, if is_owned is set and inner is non-NULL. + * Constructs a new Shutdown given each field */ -void DelayedPaymentKey_free(struct LDKDelayedPaymentKey this_obj); - -struct LDKPublicKey DelayedPaymentKey_get_a(const struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKChannelId channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); -void DelayedPaymentKey_set_a(struct LDKDelayedPaymentKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the Shutdown + */ +struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); /** - * Constructs a new DelayedPaymentKey given each field + * Generates a non-cryptographic 64-bit hash of the Shutdown. */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_new(struct LDKPublicKey a_arg); +uint64_t Shutdown_hash(const struct LDKShutdown *NONNULL_PTR o); /** - * Checks if two DelayedPaymentKeys contain equal inner contents. + * Checks if two Shutdowns contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool DelayedPaymentKey_eq(const struct LDKDelayedPaymentKey *NONNULL_PTR a, const struct LDKDelayedPaymentKey *NONNULL_PTR b); +bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); /** - * Creates a copy of the DelayedPaymentKey + * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. */ -struct LDKDelayedPaymentKey DelayedPaymentKey_clone(const struct LDKDelayedPaymentKey *NONNULL_PTR orig); +void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); /** - *Derive a public delayedpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_basepoint(const struct LDKDelayedPaymentBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - *Build a delayedpubkey directly from an already-derived private key + * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKDelayedPaymentKey DelayedPaymentKey_from_secret_key(const uint8_t (*sk)[32]); +void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * Get inner Public Key + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -MUST_USE_RES struct LDKPublicKey DelayedPaymentKey_to_public_key(const struct LDKDelayedPaymentKey *NONNULL_PTR this_arg); +uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); /** - * Serialize the DelayedPaymentKey object into a byte array which can be read by DelayedPaymentKey_read + * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing + * transaction. */ -struct LDKCVec_u8Z DelayedPaymentKey_write(const struct LDKDelayedPaymentKey *NONNULL_PTR obj); +void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write + * Constructs a new ClosingSignedFeeRange given each field */ -struct LDKCResult_DelayedPaymentKeyDecodeErrorZ DelayedPaymentKey_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); /** - * Frees any resources used by the HtlcBasepoint, if is_owned is set and inner is non-NULL. + * Creates a copy of the ClosingSignedFeeRange */ -void HtlcBasepoint_free(struct LDKHtlcBasepoint this_obj); - -struct LDKPublicKey HtlcBasepoint_get_a(const struct LDKHtlcBasepoint *NONNULL_PTR this_ptr); - -void HtlcBasepoint_set_a(struct LDKHtlcBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); /** - * Constructs a new HtlcBasepoint given each field + * Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange. */ -MUST_USE_RES struct LDKHtlcBasepoint HtlcBasepoint_new(struct LDKPublicKey a_arg); +uint64_t ClosingSignedFeeRange_hash(const struct LDKClosingSignedFeeRange *NONNULL_PTR o); /** - * Checks if two HtlcBasepoints contain equal inner contents. + * Checks if two ClosingSignedFeeRanges contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool HtlcBasepoint_eq(const struct LDKHtlcBasepoint *NONNULL_PTR a, const struct LDKHtlcBasepoint *NONNULL_PTR b); +bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); /** - * Creates a copy of the HtlcBasepoint + * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. */ -struct LDKHtlcBasepoint HtlcBasepoint_clone(const struct LDKHtlcBasepoint *NONNULL_PTR orig); +void ClosingSigned_free(struct LDKClosingSigned this_obj); /** - * Generates a non-cryptographic 64-bit hash of the HtlcBasepoint. + * The channel ID */ -uint64_t HtlcBasepoint_hash(const struct LDKHtlcBasepoint *NONNULL_PTR o); +struct LDKChannelId ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Get inner Public Key + * The channel ID */ -MUST_USE_RES struct LDKPublicKey HtlcBasepoint_to_public_key(const struct LDKHtlcBasepoint *NONNULL_PTR this_arg); +void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read + * The proposed total fee for the closing transaction */ -struct LDKCVec_u8Z HtlcBasepoint_write(const struct LDKHtlcBasepoint *NONNULL_PTR obj); +uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); /** - * Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write + * The proposed total fee for the closing transaction */ -struct LDKCResult_HtlcBasepointDecodeErrorZ HtlcBasepoint_read(struct LDKu8slice ser); +void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the HtlcKey, if is_owned is set and inner is non-NULL. + * A signature on the closing transaction */ -void HtlcKey_free(struct LDKHtlcKey this_obj); +struct LDKECDSASignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); -struct LDKPublicKey HtlcKey_get_a(const struct LDKHtlcKey *NONNULL_PTR this_ptr); +/** + * A signature on the closing transaction + */ +void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); + +/** + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); + +/** + * The minimum and maximum fees which the sender is willing to accept, provided only by new + * nodes. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); + +/** + * Constructs a new ClosingSigned given each field + * + * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKChannelId channel_id_arg, uint64_t fee_satoshis_arg, struct LDKECDSASignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); -void HtlcKey_set_a(struct LDKHtlcKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +/** + * Creates a copy of the ClosingSigned + */ +struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); /** - * Constructs a new HtlcKey given each field + * Generates a non-cryptographic 64-bit hash of the ClosingSigned. */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_new(struct LDKPublicKey a_arg); +uint64_t ClosingSigned_hash(const struct LDKClosingSigned *NONNULL_PTR o); /** - * Checks if two HtlcKeys contain equal inner contents. + * Checks if two ClosingSigneds contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool HtlcKey_eq(const struct LDKHtlcKey *NONNULL_PTR a, const struct LDKHtlcKey *NONNULL_PTR b); +bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); /** - * Creates a copy of the HtlcKey + * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKHtlcKey HtlcKey_clone(const struct LDKHtlcKey *NONNULL_PTR orig); +void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); /** - *Derive a public htlcpubkey using one node\'s `per_commitment_point` and its countersignatory\'s `basepoint` + * The channel ID */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_from_basepoint(const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +struct LDKChannelId UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - *Build a htlcpubkey directly from an already-derived private key + * The channel ID */ -MUST_USE_RES struct LDKHtlcKey HtlcKey_from_secret_key(const uint8_t (*sk)[32]); +void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Get inner Public Key + * The HTLC ID */ -MUST_USE_RES struct LDKPublicKey HtlcKey_to_public_key(const struct LDKHtlcKey *NONNULL_PTR this_arg); +uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Serialize the HtlcKey object into a byte array which can be read by HtlcKey_read + * The HTLC ID */ -struct LDKCVec_u8Z HtlcKey_write(const struct LDKHtlcKey *NONNULL_PTR obj); +void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Read a HtlcKey from a byte array, created by HtlcKey_write + * The HTLC value in milli-satoshi */ -struct LDKCResult_HtlcKeyDecodeErrorZ HtlcKey_read(struct LDKu8slice ser); +uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RevocationBasepoint, if is_owned is set and inner is non-NULL. + * The HTLC value in milli-satoshi */ -void RevocationBasepoint_free(struct LDKRevocationBasepoint this_obj); - -struct LDKPublicKey RevocationBasepoint_get_a(const struct LDKRevocationBasepoint *NONNULL_PTR this_ptr); - -void RevocationBasepoint_set_a(struct LDKRevocationBasepoint *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new RevocationBasepoint given each field + * The payment hash, the pre-image of which controls HTLC redemption */ -MUST_USE_RES struct LDKRevocationBasepoint RevocationBasepoint_new(struct LDKPublicKey a_arg); +const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; /** - * Checks if two RevocationBasepoints contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The payment hash, the pre-image of which controls HTLC redemption */ -bool RevocationBasepoint_eq(const struct LDKRevocationBasepoint *NONNULL_PTR a, const struct LDKRevocationBasepoint *NONNULL_PTR b); +void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the RevocationBasepoint + * The expiry height of the HTLC */ -struct LDKRevocationBasepoint RevocationBasepoint_clone(const struct LDKRevocationBasepoint *NONNULL_PTR orig); +uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the RevocationBasepoint. + * The expiry height of the HTLC */ -uint64_t RevocationBasepoint_hash(const struct LDKRevocationBasepoint *NONNULL_PTR o); +void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Get inner Public Key + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -MUST_USE_RES struct LDKPublicKey RevocationBasepoint_to_public_key(const struct LDKRevocationBasepoint *NONNULL_PTR this_arg); +struct LDKCOption_u64Z UpdateAddHTLC_get_skimmed_fee_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Serialize the RevocationBasepoint object into a byte array which can be read by RevocationBasepoint_read + * The extra fee skimmed by the sender of this message. See + * [`ChannelConfig::accept_underpaying_htlcs`]. + * + * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs */ -struct LDKCVec_u8Z RevocationBasepoint_write(const struct LDKRevocationBasepoint *NONNULL_PTR obj); +void UpdateAddHTLC_set_skimmed_fee_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write + * The onion routing packet with encrypted data for the next hop. */ -struct LDKCResult_RevocationBasepointDecodeErrorZ RevocationBasepoint_read(struct LDKu8slice ser); +struct LDKOnionPacket UpdateAddHTLC_get_onion_routing_packet(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Frees any resources used by the RevocationKey, if is_owned is set and inner is non-NULL. + * The onion routing packet with encrypted data for the next hop. */ -void RevocationKey_free(struct LDKRevocationKey this_obj); - -struct LDKPublicKey RevocationKey_get_a(const struct LDKRevocationKey *NONNULL_PTR this_ptr); - -void RevocationKey_set_a(struct LDKRevocationKey *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UpdateAddHTLC_set_onion_routing_packet(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKOnionPacket val); /** - * Constructs a new RevocationKey given each field + * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion + * routing packet and the recipient-provided encrypted payload within. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKRevocationKey RevocationKey_new(struct LDKPublicKey a_arg); +struct LDKPublicKey UpdateAddHTLC_get_blinding_point(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); /** - * Checks if two RevocationKeys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion + * routing packet and the recipient-provided encrypted payload within. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool RevocationKey_eq(const struct LDKRevocationKey *NONNULL_PTR a, const struct LDKRevocationKey *NONNULL_PTR b); +void UpdateAddHTLC_set_blinding_point(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the RevocationKey + * Constructs a new UpdateAddHTLC given each field + * + * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKRevocationKey RevocationKey_clone(const struct LDKRevocationKey *NONNULL_PTR orig); +MUST_USE_RES struct LDKUpdateAddHTLC UpdateAddHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, uint64_t amount_msat_arg, struct LDKThirtyTwoBytes payment_hash_arg, uint32_t cltv_expiry_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, struct LDKOnionPacket onion_routing_packet_arg, struct LDKPublicKey blinding_point_arg); /** - * Generates a non-cryptographic 64-bit hash of the RevocationKey. + * Creates a copy of the UpdateAddHTLC */ -uint64_t RevocationKey_hash(const struct LDKRevocationKey *NONNULL_PTR o); +struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); /** - * Derives a per-commitment-transaction revocation public key from one party's per-commitment - * point and the other party's [`RevocationBasepoint`]. This is the public equivalent of - * [`chan_utils::derive_private_revocation_key`] - using only public keys to derive a public - * key instead of private keys. - * - * Note that this is infallible iff we trust that at least one of the two input keys are randomly - * generated (ie our own). - * - * [`chan_utils::derive_private_revocation_key`]: crate::ln::chan_utils::derive_private_revocation_key + * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC. */ -MUST_USE_RES struct LDKRevocationKey RevocationKey_from_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_basepoint, struct LDKPublicKey per_commitment_point); +uint64_t UpdateAddHTLC_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR o); /** - * Get inner Public Key + * Checks if two UpdateAddHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPublicKey RevocationKey_to_public_key(const struct LDKRevocationKey *NONNULL_PTR this_arg); +bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); /** - * Serialize the RevocationKey object into a byte array which can be read by RevocationKey_read + * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z RevocationKey_write(const struct LDKRevocationKey *NONNULL_PTR obj); +void OnionMessage_free(struct LDKOnionMessage this_obj); /** - * Read a RevocationKey from a byte array, created by RevocationKey_write + * Used in decrypting the onion packet's payload. */ -struct LDKCResult_RevocationKeyDecodeErrorZ RevocationKey_read(struct LDKu8slice ser); +struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * Frees any resources used by the ExpandedKey, if is_owned is set and inner is non-NULL. + * Used in decrypting the onion packet's payload. */ -void ExpandedKey_free(struct LDKExpandedKey this_obj); +void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. - * - * It is recommended to cache this value and not regenerate it for each new inbound payment. + * The full onion packet including hop data, pubkey, and hmac */ -MUST_USE_RES struct LDKExpandedKey ExpandedKey_new(const uint8_t (*key_material)[32]); +struct LDKPacket OnionMessage_get_onion_routing_packet(const struct LDKOnionMessage *NONNULL_PTR this_ptr); /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment`], but no - * `ChannelManager` is required. Useful for generating invoices for [phantom node payments] without - * a `ChannelManager`. - * - * `keys` is generated by calling [`NodeSigner::get_inbound_payment_key_material`] and then - * calling [`ExpandedKey::new`] with its result. It is recommended to cache this value and not - * regenerate it for each new inbound payment. - * - * `current_time` is a Unix timestamp representing the current time. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::sign::PhantomKeysManager - * [`NodeSigner::get_inbound_payment_key_material`]: crate::sign::NodeSigner::get_inbound_payment_key_material + * The full onion packet including hop data, pubkey, and hmac */ -struct LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ create(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, uint32_t invoice_expiry_delta_secs, const struct LDKEntropySource *NONNULL_PTR entropy_source, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +void OnionMessage_set_onion_routing_packet(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPacket val); /** - * Equivalent to [`crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash`], - * but no `ChannelManager` is required. Useful for generating invoices for [phantom node payments] - * without a `ChannelManager`. - * - * See [`create`] for information on the `keys` and `current_time` parameters. - * - * Note that if `min_final_cltv_expiry_delta` is set to some value, then the payment will not be receivable - * on versions of LDK prior to 0.0.114. - * - * [phantom node payments]: crate::sign::PhantomKeysManager + * Constructs a new OnionMessage given each field */ -struct LDKCResult_ThirtyTwoBytesNoneZ create_from_hash(const struct LDKExpandedKey *NONNULL_PTR keys, struct LDKCOption_u64Z min_value_msat, struct LDKThirtyTwoBytes payment_hash, uint32_t invoice_expiry_delta_secs, uint64_t current_time, struct LDKCOption_u16Z min_final_cltv_expiry_delta); +MUST_USE_RES struct LDKOnionMessage OnionMessage_new(struct LDKPublicKey blinding_point_arg, struct LDKPacket onion_routing_packet_arg); /** - * Frees any resources used by the DecodeError + * Creates a copy of the OnionMessage */ -void DecodeError_free(struct LDKDecodeError this_ptr); +struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); /** - * Creates a copy of the DecodeError + * Generates a non-cryptographic 64-bit hash of the OnionMessage. */ -struct LDKDecodeError DecodeError_clone(const struct LDKDecodeError *NONNULL_PTR orig); +uint64_t OnionMessage_hash(const struct LDKOnionMessage *NONNULL_PTR o); /** - * Utility method to constructs a new UnknownVersion-variant DecodeError + * Checks if two OnionMessages contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKDecodeError DecodeError_unknown_version(void); +bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); /** - * Utility method to constructs a new UnknownRequiredFeature-variant DecodeError + * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKDecodeError DecodeError_unknown_required_feature(void); +void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); /** - * Utility method to constructs a new InvalidValue-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_invalid_value(void); +struct LDKChannelId UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new ShortRead-variant DecodeError + * The channel ID */ -struct LDKDecodeError DecodeError_short_read(void); +void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Utility method to constructs a new BadLengthDescriptor-variant DecodeError + * The HTLC ID */ -struct LDKDecodeError DecodeError_bad_length_descriptor(void); +uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Io-variant DecodeError + * The HTLC ID */ -struct LDKDecodeError DecodeError_io(enum LDKIOError a); +void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new UnsupportedCompression-variant DecodeError + * The pre-image of the payment hash, allowing HTLC redemption */ -struct LDKDecodeError DecodeError_unsupported_compression(void); +const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the DecodeError. + * The pre-image of the payment hash, allowing HTLC redemption */ -uint64_t DecodeError_hash(const struct LDKDecodeError *NONNULL_PTR o); +void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two DecodeErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Constructs a new UpdateFulfillHTLC given each field */ -bool DecodeError_eq(const struct LDKDecodeError *NONNULL_PTR a, const struct LDKDecodeError *NONNULL_PTR b); +MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKChannelId channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); /** - * Frees any resources used by the Init, if is_owned is set and inner is non-NULL. + * Creates a copy of the UpdateFulfillHTLC */ -void Init_free(struct LDKInit this_obj); +struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); /** - * The relevant features which the sender supports. + * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC. */ -struct LDKInitFeatures Init_get_features(const struct LDKInit *NONNULL_PTR this_ptr); +uint64_t UpdateFulfillHTLC_hash(const struct LDKUpdateFulfillHTLC *NONNULL_PTR o); /** - * The relevant features which the sender supports. + * Checks if two UpdateFulfillHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Init_set_features(struct LDKInit *NONNULL_PTR this_ptr, struct LDKInitFeatures val); +bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); /** - * Indicates chains the sender is interested in. - * - * If there are no common chains, the connection will be closed. - * - * Returns a copy of the field. + * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_CVec_ThirtyTwoBytesZZ Init_get_networks(const struct LDKInit *NONNULL_PTR this_ptr); +void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); /** - * Indicates chains the sender is interested in. - * - * If there are no common chains, the connection will be closed. + * The channel ID */ -void Init_set_networks(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_CVec_ThirtyTwoBytesZZ val); +struct LDKChannelId UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * The channel ID */ -struct LDKCOption_SocketAddressZ Init_get_remote_network_address(const struct LDKInit *NONNULL_PTR this_ptr); +void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The receipient's network address. - * - * This adds the option to report a remote IP address back to a connecting peer using the init - * message. A node can decide to use that information to discover a potential update to its - * public IPv4 address (NAT) and use that for a [`NodeAnnouncement`] update message containing - * the new address. + * The HTLC ID */ -void Init_set_remote_network_address(struct LDKInit *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); +uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); /** - * Constructs a new Init given each field + * The HTLC ID */ -MUST_USE_RES struct LDKInit Init_new(struct LDKInitFeatures features_arg, struct LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg, struct LDKCOption_SocketAddressZ remote_network_address_arg); +void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Creates a copy of the Init + * Creates a copy of the UpdateFailHTLC */ -struct LDKInit Init_clone(const struct LDKInit *NONNULL_PTR orig); +struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Init. + * Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC. */ -uint64_t Init_hash(const struct LDKInit *NONNULL_PTR o); +uint64_t UpdateFailHTLC_hash(const struct LDKUpdateFailHTLC *NONNULL_PTR o); /** - * Checks if two Inits contain equal inner contents. + * Checks if two UpdateFailHTLCs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Init_eq(const struct LDKInit *NONNULL_PTR a, const struct LDKInit *NONNULL_PTR b); +bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); /** - * Frees any resources used by the ErrorMessage, if is_owned is set and inner is non-NULL. + * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. */ -void ErrorMessage_free(struct LDKErrorMessage this_obj); +void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); /** - * The channel ID involved in the error. - * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * The channel ID */ -const uint8_t (*ErrorMessage_get_channel_id(const struct LDKErrorMessage *NONNULL_PTR this_ptr))[32]; +struct LDKChannelId UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * The channel ID involved in the error. - * - * All-0s indicates a general error unrelated to a specific channel, after which all channels - * with the sending peer should be closed. + * The channel ID */ -void ErrorMessage_set_channel_id(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The HTLC ID */ -struct LDKStr ErrorMessage_get_data(const struct LDKErrorMessage *NONNULL_PTR this_ptr); +uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * A possibly human-readable error description. - * - * The string should be sanitized before it is used (e.g., emitted to logs or printed to - * `stdout`). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The HTLC ID */ -void ErrorMessage_set_data(struct LDKErrorMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new ErrorMessage given each field + * The failure code */ -MUST_USE_RES struct LDKErrorMessage ErrorMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); /** - * Creates a copy of the ErrorMessage + * The failure code */ -struct LDKErrorMessage ErrorMessage_clone(const struct LDKErrorMessage *NONNULL_PTR orig); +void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the ErrorMessage. + * Creates a copy of the UpdateFailMalformedHTLC */ -uint64_t ErrorMessage_hash(const struct LDKErrorMessage *NONNULL_PTR o); +struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); /** - * Checks if two ErrorMessages contain equal inner contents. + * Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. + */ +uint64_t UpdateFailMalformedHTLC_hash(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR o); + +/** + * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ErrorMessage_eq(const struct LDKErrorMessage *NONNULL_PTR a, const struct LDKErrorMessage *NONNULL_PTR b); +bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); /** - * Frees any resources used by the WarningMessage, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. */ -void WarningMessage_free(struct LDKWarningMessage this_obj); +void CommitmentSignedBatch_free(struct LDKCommitmentSignedBatch this_obj); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * Batch size N: all N `commitment_signed` messages must be received before being processed */ -const uint8_t (*WarningMessage_get_channel_id(const struct LDKWarningMessage *NONNULL_PTR this_ptr))[32]; +uint16_t CommitmentSignedBatch_get_batch_size(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr); /** - * The channel ID involved in the warning. - * - * All-0s indicates a warning unrelated to a specific channel. + * Batch size N: all N `commitment_signed` messages must be received before being processed */ -void WarningMessage_set_channel_id(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void CommitmentSignedBatch_set_batch_size(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, uint16_t val); /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) */ -struct LDKStr WarningMessage_get_data(const struct LDKWarningMessage *NONNULL_PTR this_ptr); +const uint8_t (*CommitmentSignedBatch_get_funding_txid(const struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr))[32]; /** - * A possibly human-readable warning description. - * - * The string should be sanitized before it is used (e.g. emitted to logs or printed to - * stdout). Otherwise, a well crafted error message may trigger a security vulnerability in - * the terminal emulator or the logging subsystem. + * The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) */ -void WarningMessage_set_data(struct LDKWarningMessage *NONNULL_PTR this_ptr, struct LDKStr val); +void CommitmentSignedBatch_set_funding_txid(struct LDKCommitmentSignedBatch *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new WarningMessage given each field + * Constructs a new CommitmentSignedBatch given each field */ -MUST_USE_RES struct LDKWarningMessage WarningMessage_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKStr data_arg); +MUST_USE_RES struct LDKCommitmentSignedBatch CommitmentSignedBatch_new(uint16_t batch_size_arg, struct LDKThirtyTwoBytes funding_txid_arg); /** - * Creates a copy of the WarningMessage + * Creates a copy of the CommitmentSignedBatch */ -struct LDKWarningMessage WarningMessage_clone(const struct LDKWarningMessage *NONNULL_PTR orig); +struct LDKCommitmentSignedBatch CommitmentSignedBatch_clone(const struct LDKCommitmentSignedBatch *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the WarningMessage. + * Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. */ -uint64_t WarningMessage_hash(const struct LDKWarningMessage *NONNULL_PTR o); +uint64_t CommitmentSignedBatch_hash(const struct LDKCommitmentSignedBatch *NONNULL_PTR o); /** - * Checks if two WarningMessages contain equal inner contents. + * Checks if two CommitmentSignedBatchs contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool WarningMessage_eq(const struct LDKWarningMessage *NONNULL_PTR a, const struct LDKWarningMessage *NONNULL_PTR b); +bool CommitmentSignedBatch_eq(const struct LDKCommitmentSignedBatch *NONNULL_PTR a, const struct LDKCommitmentSignedBatch *NONNULL_PTR b); /** - * Frees any resources used by the Ping, if is_owned is set and inner is non-NULL. + * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. */ -void Ping_free(struct LDKPing this_obj); +void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); /** - * The desired response length. + * The channel ID */ -uint16_t Ping_get_ponglen(const struct LDKPing *NONNULL_PTR this_ptr); +struct LDKChannelId CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The desired response length. + * The channel ID */ -void Ping_set_ponglen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The ping packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * A signature on the commitment transaction */ -uint16_t Ping_get_byteslen(const struct LDKPing *NONNULL_PTR this_ptr); +struct LDKECDSASignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * The ping packet size. + * A signature on the commitment transaction + */ +void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); + +/** + * Signatures on the HTLC transactions * - * This field is not sent on the wire. byteslen zeros are sent. + * Returns a copy of the field. */ -void Ping_set_byteslen(struct LDKPing *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_ECDSASignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * Constructs a new Ping given each field + * Signatures on the HTLC transactions */ -MUST_USE_RES struct LDKPing Ping_new(uint16_t ponglen_arg, uint16_t byteslen_arg); +void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); /** - * Creates a copy of the Ping + * Optional batch size and other parameters + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKPing Ping_clone(const struct LDKPing *NONNULL_PTR orig); +struct LDKCommitmentSignedBatch CommitmentSigned_get_batch(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Ping. + * Optional batch size and other parameters + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t Ping_hash(const struct LDKPing *NONNULL_PTR o); +void CommitmentSigned_set_batch(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCommitmentSignedBatch val); /** - * Checks if two Pings contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new CommitmentSigned given each field + * + * Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool Ping_eq(const struct LDKPing *NONNULL_PTR a, const struct LDKPing *NONNULL_PTR b); +MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKChannelId channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg, struct LDKCommitmentSignedBatch batch_arg); /** - * Frees any resources used by the Pong, if is_owned is set and inner is non-NULL. + * Creates a copy of the CommitmentSigned */ -void Pong_free(struct LDKPong this_obj); +struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Generates a non-cryptographic 64-bit hash of the CommitmentSigned. */ -uint16_t Pong_get_byteslen(const struct LDKPong *NONNULL_PTR this_ptr); +uint64_t CommitmentSigned_hash(const struct LDKCommitmentSigned *NONNULL_PTR o); /** - * The pong packet size. - * - * This field is not sent on the wire. byteslen zeros are sent. + * Checks if two CommitmentSigneds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Pong_set_byteslen(struct LDKPong *NONNULL_PTR this_ptr, uint16_t val); +bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); /** - * Constructs a new Pong given each field + * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPong Pong_new(uint16_t byteslen_arg); +void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); /** - * Creates a copy of the Pong + * The channel ID */ -struct LDKPong Pong_clone(const struct LDKPong *NONNULL_PTR orig); +struct LDKChannelId RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Pong. + * The channel ID */ -uint64_t Pong_hash(const struct LDKPong *NONNULL_PTR o); +void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Checks if two Pongs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The secret corresponding to the per-commitment point */ -bool Pong_eq(const struct LDKPong *NONNULL_PTR a, const struct LDKPong *NONNULL_PTR b); +const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; /** - * Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. + * The secret corresponding to the per-commitment point */ -void OpenChannel_free(struct LDKOpenChannel this_obj); +void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The genesis hash of the blockchain where the channel is to be opened + * The next sender-broadcast commitment transaction's per-commitment point */ -const uint8_t (*OpenChannel_get_chain_hash(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * The next sender-broadcast commitment transaction's per-commitment point */ -void OpenChannel_set_chain_hash(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * A temporary channel ID, until the funding outpoint is announced + * Constructs a new RevokeAndACK given each field */ -const uint8_t (*OpenChannel_get_temporary_channel_id(const struct LDKOpenChannel *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKChannelId channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); /** - * A temporary channel ID, until the funding outpoint is announced + * Creates a copy of the RevokeAndACK */ -void OpenChannel_set_temporary_channel_id(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); /** - * The channel value + * Generates a non-cryptographic 64-bit hash of the RevokeAndACK. */ -uint64_t OpenChannel_get_funding_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +uint64_t RevokeAndACK_hash(const struct LDKRevokeAndACK *NONNULL_PTR o); /** - * The channel value + * Checks if two RevokeAndACKs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OpenChannel_set_funding_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. */ -uint64_t OpenChannel_get_push_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_free(struct LDKUpdateFee this_obj); /** - * The amount to push to the counterparty as part of the open, in milli-satoshi + * The channel ID */ -void OpenChannel_set_push_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelId UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The channel ID */ -uint64_t OpenChannel_get_dust_limit_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Fee rate per 1000-weight of the transaction */ -void OpenChannel_set_dust_limit_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Fee rate per 1000-weight of the transaction */ -uint64_t OpenChannel_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Constructs a new UpdateFee given each field */ -void OpenChannel_set_max_htlc_value_in_flight_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKChannelId channel_id_arg, uint32_t feerate_per_kw_arg); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Creates a copy of the UpdateFee */ -uint64_t OpenChannel_get_channel_reserve_satoshis(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Generates a non-cryptographic 64-bit hash of the UpdateFee. */ -void OpenChannel_set_channel_reserve_satoshis(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +uint64_t UpdateFee_hash(const struct LDKUpdateFee *NONNULL_PTR o); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Checks if two UpdateFees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t OpenChannel_get_htlc_minimum_msat(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_htlc_minimum_msat(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint64_t val); +void ChannelReestablish_free(struct LDKChannelReestablish this_obj); /** - * The feerate per 1000-weight of sender generated transactions, until updated by - * [`UpdateFee`] + * The channel ID */ -uint32_t OpenChannel_get_feerate_per_kw(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKChannelId ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The feerate per 1000-weight of sender generated transactions, until updated by - * [`UpdateFee`] + * The channel ID + */ +void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKChannelId val); + +/** + * The next commitment number for the sender */ -void OpenChannel_set_feerate_per_kw(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint32_t val); +uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if - * they broadcast a commitment transaction + * The next commitment number for the sender */ -uint16_t OpenChannel_get_to_self_delay(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if - * they broadcast a commitment transaction + * The next commitment number for the recipient */ -void OpenChannel_set_to_self_delay(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards sender + * The next commitment number for the recipient */ -uint16_t OpenChannel_get_max_accepted_htlcs(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum number of inbound HTLCs towards sender + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -void OpenChannel_set_max_accepted_htlcs(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint16_t val); +const uint8_t (*ChannelReestablish_get_your_last_per_commitment_secret(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; /** - * The sender's key controlling the funding transaction + * Proof that the sender knows the per-commitment secret of a specific commitment transaction + * belonging to the recipient */ -struct LDKPublicKey OpenChannel_get_funding_pubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_your_last_per_commitment_secret(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The sender's key controlling the funding transaction + * The sender's per-commitment point for their current commitment transaction */ -void OpenChannel_set_funding_pubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKPublicKey ChannelReestablish_get_my_current_per_commitment_point(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The sender's per-commitment point for their current commitment transaction */ -struct LDKPublicKey OpenChannel_get_revocation_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_my_current_per_commitment_point(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The next funding transaction ID */ -void OpenChannel_set_revocation_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCOption_ThirtyTwoBytesZ ChannelReestablish_get_next_funding_txid(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); /** - * A payment key to sender for transactions broadcast by counterparty + * The next funding transaction ID */ -struct LDKPublicKey OpenChannel_get_payment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +void ChannelReestablish_set_next_funding_txid(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * A payment key to sender for transactions broadcast by counterparty + * Constructs a new ChannelReestablish given each field */ -void OpenChannel_set_payment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKChannelReestablish ChannelReestablish_new(struct LDKChannelId channel_id_arg, uint64_t next_local_commitment_number_arg, uint64_t next_remote_commitment_number_arg, struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg, struct LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Creates a copy of the ChannelReestablish */ -struct LDKPublicKey OpenChannel_get_delayed_payment_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Generates a non-cryptographic 64-bit hash of the ChannelReestablish. */ -void OpenChannel_set_delayed_payment_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ChannelReestablish_hash(const struct LDKChannelReestablish *NONNULL_PTR o); /** - * Used to derive an HTLC payment key to sender + * Checks if two ChannelReestablishs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKPublicKey OpenChannel_get_htlc_basepoint(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); /** - * Used to derive an HTLC payment key to sender + * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. */ -void OpenChannel_set_htlc_basepoint(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The channel ID */ -struct LDKPublicKey OpenChannel_get_first_per_commitment_point(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKChannelId AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * The channel ID */ -void OpenChannel_set_first_per_commitment_point(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * The channel flags to be used + * The short channel ID */ -uint8_t OpenChannel_get_channel_flags(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The channel flags to be used + * The short channel ID */ -void OpenChannel_set_channel_flags(struct LDKOpenChannel *NONNULL_PTR this_ptr, uint8_t val); +void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); /** - * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close + * A signature by the node key */ -struct LDKCOption_CVec_u8ZZ OpenChannel_get_shutdown_scriptpubkey(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKECDSASignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close + * A signature by the node key */ -void OpenChannel_set_shutdown_scriptpubkey(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A signature by the funding key */ -struct LDKChannelTypeFeatures OpenChannel_get_channel_type(const struct LDKOpenChannel *NONNULL_PTR this_ptr); +struct LDKECDSASignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent - * - * If this is `None`, we derive the channel type from the intersection of our - * feature bits with our counterparty's feature bits from the [`Init`] message. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * A signature by the funding key */ -void OpenChannel_set_channel_type(struct LDKOpenChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Constructs a new OpenChannel given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new AnnouncementSignatures given each field */ -MUST_USE_RES struct LDKOpenChannel OpenChannel_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t push_msat_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t channel_reserve_satoshis_arg, uint64_t htlc_minimum_msat_arg, uint32_t feerate_per_kw_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); +MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKChannelId channel_id_arg, uint64_t short_channel_id_arg, struct LDKECDSASignature node_signature_arg, struct LDKECDSASignature bitcoin_signature_arg); /** - * Creates a copy of the OpenChannel + * Creates a copy of the AnnouncementSignatures */ -struct LDKOpenChannel OpenChannel_clone(const struct LDKOpenChannel *NONNULL_PTR orig); +struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the OpenChannel. + * Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures. */ -uint64_t OpenChannel_hash(const struct LDKOpenChannel *NONNULL_PTR o); +uint64_t AnnouncementSignatures_hash(const struct LDKAnnouncementSignatures *NONNULL_PTR o); /** - * Checks if two OpenChannels contain equal inner contents. + * Checks if two AnnouncementSignaturess contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool OpenChannel_eq(const struct LDKOpenChannel *NONNULL_PTR a, const struct LDKOpenChannel *NONNULL_PTR b); +bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); /** - * Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. + * Frees any resources used by the SocketAddress */ -void OpenChannelV2_free(struct LDKOpenChannelV2 this_obj); +void SocketAddress_free(struct LDKSocketAddress this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * Creates a copy of the SocketAddress */ -const uint8_t (*OpenChannelV2_get_chain_hash(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr))[32]; +struct LDKSocketAddress SocketAddress_clone(const struct LDKSocketAddress *NONNULL_PTR orig); /** - * The genesis hash of the blockchain where the channel is to be opened + * Utility method to constructs a new TcpIpV4-variant SocketAddress */ -void OpenChannelV2_set_chain_hash(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKSocketAddress SocketAddress_tcp_ip_v4(struct LDKFourBytes addr, uint16_t port); /** - * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint + * Utility method to constructs a new TcpIpV6-variant SocketAddress */ -const uint8_t (*OpenChannelV2_get_temporary_channel_id(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr))[32]; +struct LDKSocketAddress SocketAddress_tcp_ip_v6(struct LDKSixteenBytes addr, uint16_t port); /** - * A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint + * Utility method to constructs a new OnionV2-variant SocketAddress */ -void OpenChannelV2_set_temporary_channel_id(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKSocketAddress SocketAddress_onion_v2(struct LDKTwelveBytes a); /** - * The feerate for the funding transaction set by the channel initiator + * Utility method to constructs a new OnionV3-variant SocketAddress */ -uint32_t OpenChannelV2_get_funding_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKSocketAddress SocketAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); /** - * The feerate for the funding transaction set by the channel initiator + * Utility method to constructs a new Hostname-variant SocketAddress */ -void OpenChannelV2_set_funding_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +struct LDKSocketAddress SocketAddress_hostname(struct LDKHostname hostname, uint16_t port); /** - * The feerate for the commitment transaction set by the channel initiator + * Generates a non-cryptographic 64-bit hash of the SocketAddress. */ -uint32_t OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +uint64_t SocketAddress_hash(const struct LDKSocketAddress *NONNULL_PTR o); /** - * The feerate for the commitment transaction set by the channel initiator + * Checks if two SocketAddresss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +bool SocketAddress_eq(const struct LDKSocketAddress *NONNULL_PTR a, const struct LDKSocketAddress *NONNULL_PTR b); /** - * Part of the channel value contributed by the channel initiator + * Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read */ -uint64_t OpenChannelV2_get_funding_satoshis(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z SocketAddress_write(const struct LDKSocketAddress *NONNULL_PTR obj); /** - * Part of the channel value contributed by the channel initiator + * Read a SocketAddress from a byte array, created by SocketAddress_write */ -void OpenChannelV2_set_funding_satoshis(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_SocketAddressDecodeErrorZ SocketAddress_read(struct LDKu8slice ser); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted + * Creates a copy of the SocketAddressParseError */ -uint64_t OpenChannelV2_get_dust_limit_satoshis(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +enum LDKSocketAddressParseError SocketAddressParseError_clone(const enum LDKSocketAddressParseError *NONNULL_PTR orig); /** - * The threshold below which outputs on transactions broadcast by the channel initiator will be - * omitted + * Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError */ -void OpenChannelV2_set_dust_limit_satoshis(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +enum LDKSocketAddressParseError SocketAddressParseError_socket_addr_parse(void); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * Utility method to constructs a new InvalidInput-variant SocketAddressParseError */ -uint64_t OpenChannelV2_get_max_htlc_value_in_flight_msat(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_input(void); /** - * The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi + * Utility method to constructs a new InvalidPort-variant SocketAddressParseError */ -void OpenChannelV2_set_max_htlc_value_in_flight_msat(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_port(void); /** - * The minimum HTLC size incoming to channel initiator, in milli-satoshi + * Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError */ -uint64_t OpenChannelV2_get_htlc_minimum_msat(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +enum LDKSocketAddressParseError SocketAddressParseError_invalid_onion_v3(void); /** - * The minimum HTLC size incoming to channel initiator, in milli-satoshi + * Generates a non-cryptographic 64-bit hash of the SocketAddressParseError. */ -void OpenChannelV2_set_htlc_minimum_msat(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +uint64_t SocketAddressParseError_hash(const enum LDKSocketAddressParseError *NONNULL_PTR o); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * Checks if two SocketAddressParseErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint16_t OpenChannelV2_get_to_self_delay(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +bool SocketAddressParseError_eq(const enum LDKSocketAddressParseError *NONNULL_PTR a, const enum LDKSocketAddressParseError *NONNULL_PTR b); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * Get the string representation of a SocketAddressParseError object */ -void OpenChannelV2_set_to_self_delay(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint16_t val); +struct LDKStr SocketAddressParseError_to_str(const enum LDKSocketAddressParseError *NONNULL_PTR o); /** - * The maximum number of inbound HTLCs towards channel initiator + * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. + * + * The host part must end with \".onion\". */ -uint16_t OpenChannelV2_get_max_accepted_htlcs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCResult_SocketAddressSocketAddressParseErrorZ parse_onion_address(struct LDKStr host, uint16_t port); /** - * The maximum number of inbound HTLCs towards channel initiator + * Get the string representation of a SocketAddress object */ -void OpenChannelV2_set_max_accepted_htlcs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint16_t val); +struct LDKStr SocketAddress_to_str(const struct LDKSocketAddress *NONNULL_PTR o); /** - * The locktime for the funding transaction + * Read a SocketAddress object from a string */ -uint32_t OpenChannelV2_get_locktime(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCResult_SocketAddressSocketAddressParseErrorZ SocketAddress_from_str(struct LDKStr s); /** - * The locktime for the funding transaction + * Frees any resources used by the UnsignedGossipMessage */ -void OpenChannelV2_set_locktime(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); /** - * The channel initiator's key controlling the funding transaction + * Creates a copy of the UnsignedGossipMessage */ -struct LDKPublicKey OpenChannelV2_get_funding_pubkey(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); /** - * The channel initiator's key controlling the funding transaction + * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage */ -void OpenChannelV2_set_funding_pubkey(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage */ -struct LDKPublicKey OpenChannelV2_get_revocation_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage */ -void OpenChannelV2_set_revocation_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); /** - * A payment key to channel initiator for transactions broadcast by counterparty + * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read */ -struct LDKPublicKey OpenChannelV2_get_payment_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); /** - * A payment key to channel initiator for transactions broadcast by counterparty + * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. */ -void OpenChannelV2_set_payment_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); /** - * Used to derive a payment key to channel initiator for transactions broadcast by channel - * initiator + * The advertised features */ -struct LDKPublicKey OpenChannelV2_get_delayed_payment_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive a payment key to channel initiator for transactions broadcast by channel - * initiator + * The advertised features */ -void OpenChannelV2_set_delayed_payment_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Used to derive an HTLC payment key to channel initiator + * A strictly monotonic announcement counter, with gaps allowed */ -struct LDKPublicKey OpenChannelV2_get_htlc_basepoint(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive an HTLC payment key to channel initiator + * A strictly monotonic announcement counter, with gaps allowed */ -void OpenChannelV2_set_htlc_basepoint(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); /** - * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -struct LDKPublicKey OpenChannelV2_get_first_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-channel-initiator transaction's per commitment point + * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back + * to this node). */ -void OpenChannelV2_set_first_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + * An RGB color for UI purposes */ -struct LDKPublicKey OpenChannelV2_get_second_per_commitment_point(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; /** - * The second to-be-broadcast-by-channel-initiator transaction's per commitment point + * An RGB color for UI purposes */ -void OpenChannelV2_set_second_per_commitment_point(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * Channel flags + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -uint8_t OpenChannelV2_get_channel_flags(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Channel flags + * An alias, for UI purposes. + * + * This should be sanitized before use. There is no guarantee of uniqueness. */ -void OpenChannelV2_set_channel_flags(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, uint8_t val); +void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we - * collaboratively close + * List of addresses on which this node is reachable + * + * Returns a copy of the field. */ -struct LDKCOption_CVec_u8ZZ OpenChannelV2_get_shutdown_scriptpubkey(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCVec_SocketAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we - * collaboratively close + * List of addresses on which this node is reachable */ -void OpenChannelV2_set_shutdown_scriptpubkey(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. + * Excess address data which was signed as a part of the message which we do not (yet) understand how + * to decode. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -struct LDKChannelTypeFeatures OpenChannelV2_get_channel_type(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_address_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. + * Excess address data which was signed as a part of the message which we do not (yet) understand how + * to decode. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. */ -void OpenChannelV2_set_channel_type(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void UnsignedNodeAnnouncement_set_excess_address_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Optionally, a requirement that only confirmed inputs can be added + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -enum LDKCOption_NoneZ OpenChannelV2_get_require_confirmed_inputs(const struct LDKOpenChannelV2 *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_get_excess_data(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); /** - * Optionally, a requirement that only confirmed inputs can be added + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -void OpenChannelV2_set_require_confirmed_inputs(struct LDKOpenChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +void UnsignedNodeAnnouncement_set_excess_data(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Constructs a new OpenChannelV2 given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new UnsignedNodeAnnouncement given each field */ -MUST_USE_RES struct LDKOpenChannelV2 OpenChannelV2_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKThirtyTwoBytes temporary_channel_id_arg, uint32_t funding_feerate_sat_per_1000_weight_arg, uint32_t commitment_feerate_sat_per_1000_weight_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKPublicKey second_per_commitment_point_arg, uint8_t channel_flags_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +MUST_USE_RES struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_new(struct LDKNodeFeatures features_arg, uint32_t timestamp_arg, struct LDKNodeId node_id_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg, struct LDKCVec_u8Z excess_address_data_arg, struct LDKCVec_u8Z excess_data_arg); /** - * Creates a copy of the OpenChannelV2 + * Creates a copy of the UnsignedNodeAnnouncement */ -struct LDKOpenChannelV2 OpenChannelV2_clone(const struct LDKOpenChannelV2 *NONNULL_PTR orig); +struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the OpenChannelV2. + * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement. */ -uint64_t OpenChannelV2_hash(const struct LDKOpenChannelV2 *NONNULL_PTR o); +uint64_t UnsignedNodeAnnouncement_hash(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR o); /** - * Checks if two OpenChannelV2s contain equal inner contents. + * Checks if two UnsignedNodeAnnouncements contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool OpenChannelV2_eq(const struct LDKOpenChannelV2 *NONNULL_PTR a, const struct LDKOpenChannelV2 *NONNULL_PTR b); +bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); /** - * Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_free(struct LDKAcceptChannel this_obj); +void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); + +/** + * The signature by the node key + */ +struct LDKECDSASignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * A temporary channel ID, until the funding outpoint is announced + * The signature by the node key */ -const uint8_t (*AcceptChannel_get_temporary_channel_id(const struct LDKAcceptChannel *NONNULL_PTR this_ptr))[32]; +void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * A temporary channel ID, until the funding outpoint is announced + * The actual content of the announcement */ -void AcceptChannel_set_temporary_channel_id(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * The actual content of the announcement */ -uint64_t AcceptChannel_get_dust_limit_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); /** - * The threshold below which outputs on transactions broadcast by sender will be omitted + * Constructs a new NodeAnnouncement given each field */ -void AcceptChannel_set_dust_limit_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Creates a copy of the NodeAnnouncement */ -uint64_t AcceptChannel_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); /** - * The maximum inbound HTLC value in flight towards sender, in milli-satoshi + * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement. */ -void AcceptChannel_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +uint64_t NodeAnnouncement_hash(const struct LDKNodeAnnouncement *NONNULL_PTR o); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Checks if two NodeAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t AcceptChannel_get_channel_reserve_satoshis(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); /** - * The minimum value unencumbered by HTLCs for the counterparty to keep in the channel + * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -void AcceptChannel_set_channel_reserve_satoshis(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The advertised channel features */ -uint64_t AcceptChannel_get_htlc_minimum_msat(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The advertised channel features */ -void AcceptChannel_set_htlc_minimum_msat(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint64_t val); +void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Minimum depth of the funding transaction before the channel is considered open + * The genesis hash of the blockchain where the channel is to be opened */ -uint32_t AcceptChannel_get_minimum_depth(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; /** - * Minimum depth of the funding transaction before the channel is considered open + * The genesis hash of the blockchain where the channel is to be opened */ -void AcceptChannel_set_minimum_depth(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint32_t val); +void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The short channel ID */ -uint16_t AcceptChannel_get_to_self_delay(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction + * The short channel ID */ -void AcceptChannel_set_to_self_delay(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); /** - * The maximum number of inbound HTLCs towards sender + * One of the two `node_id`s which are endpoints of this channel */ -uint16_t AcceptChannel_get_max_accepted_htlcs(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards sender + * One of the two `node_id`s which are endpoints of this channel */ -void AcceptChannel_set_max_accepted_htlcs(struct LDKAcceptChannel *NONNULL_PTR this_ptr, uint16_t val); +void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * The sender's key controlling the funding transaction + * The other of the two `node_id`s which are endpoints of this channel */ -struct LDKPublicKey AcceptChannel_get_funding_pubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The sender's key controlling the funding transaction + * The other of the two `node_id`s which are endpoints of this channel */ -void AcceptChannel_set_funding_pubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The funding key for the first node */ -struct LDKPublicKey AcceptChannel_get_revocation_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The funding key for the first node */ -void AcceptChannel_set_revocation_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * A payment key to sender for transactions broadcast by counterparty + * The funding key for the second node */ -struct LDKPublicKey AcceptChannel_get_payment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * A payment key to sender for transactions broadcast by counterparty + * The funding key for the second node */ -void AcceptChannel_set_payment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -struct LDKPublicKey AcceptChannel_get_delayed_payment_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_get_excess_data(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Used to derive a payment key to sender for transactions broadcast by sender + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -void AcceptChannel_set_delayed_payment_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void UnsignedChannelAnnouncement_set_excess_data(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * Constructs a new UnsignedChannelAnnouncement given each field */ -struct LDKPublicKey AcceptChannel_get_htlc_basepoint(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_new(struct LDKChannelFeatures features_arg, struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, struct LDKNodeId node_id_1_arg, struct LDKNodeId node_id_2_arg, struct LDKNodeId bitcoin_key_1_arg, struct LDKNodeId bitcoin_key_2_arg, struct LDKCVec_u8Z excess_data_arg); /** - * Used to derive an HTLC payment key to sender for transactions broadcast by counterparty + * Creates a copy of the UnsignedChannelAnnouncement */ -void AcceptChannel_set_htlc_basepoint(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement. */ -struct LDKPublicKey AcceptChannel_get_first_per_commitment_point(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +uint64_t UnsignedChannelAnnouncement_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR o); /** - * The first to-be-broadcast-by-sender transaction's per commitment point + * Checks if two UnsignedChannelAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void AcceptChannel_set_first_per_commitment_point(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); /** - * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close + * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. */ -struct LDKCOption_CVec_u8ZZ AcceptChannel_get_shutdown_scriptpubkey(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); /** - * A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close + * Authentication of the announcement by the first public node */ -void AcceptChannel_set_shutdown_scriptpubkey(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +struct LDKECDSASignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The channel type that this channel will represent. - * - * If this is `None`, we derive the channel type from the intersection of - * our feature bits with our counterparty's feature bits from the [`Init`] message. - * This is required to match the equivalent field in [`OpenChannel::channel_type`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Authentication of the announcement by the first public node */ -struct LDKChannelTypeFeatures AcceptChannel_get_channel_type(const struct LDKAcceptChannel *NONNULL_PTR this_ptr); +void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The channel type that this channel will represent. - * - * If this is `None`, we derive the channel type from the intersection of - * our feature bits with our counterparty's feature bits from the [`Init`] message. - * This is required to match the equivalent field in [`OpenChannel::channel_type`]. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Authentication of the announcement by the second public node */ -void AcceptChannel_set_channel_type(struct LDKAcceptChannel *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +struct LDKECDSASignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Constructs a new AcceptChannel given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Authentication of the announcement by the second public node */ -MUST_USE_RES struct LDKAcceptChannel AcceptChannel_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t channel_reserve_satoshis_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg); +void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Creates a copy of the AcceptChannel + * Proof of funding UTXO ownership by the first public node */ -struct LDKAcceptChannel AcceptChannel_clone(const struct LDKAcceptChannel *NONNULL_PTR orig); +struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the AcceptChannel. + * Proof of funding UTXO ownership by the first public node */ -uint64_t AcceptChannel_hash(const struct LDKAcceptChannel *NONNULL_PTR o); +void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Checks if two AcceptChannels contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Proof of funding UTXO ownership by the second public node */ -bool AcceptChannel_eq(const struct LDKAcceptChannel *NONNULL_PTR a, const struct LDKAcceptChannel *NONNULL_PTR b); +struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * Frees any resources used by the AcceptChannelV2, if is_owned is set and inner is non-NULL. + * Proof of funding UTXO ownership by the second public node */ -void AcceptChannelV2_free(struct LDKAcceptChannelV2 this_obj); +void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The same `temporary_channel_id` received from the initiator's `open_channel2` message. + * The actual announcement */ -const uint8_t (*AcceptChannelV2_get_temporary_channel_id(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr))[32]; +struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); /** - * The same `temporary_channel_id` received from the initiator's `open_channel2` message. + * The actual announcement */ -void AcceptChannelV2_set_temporary_channel_id(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); /** - * Part of the channel value contributed by the channel acceptor + * Constructs a new ChannelAnnouncement given each field */ -uint64_t AcceptChannelV2_get_funding_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKECDSASignature node_signature_1_arg, struct LDKECDSASignature node_signature_2_arg, struct LDKECDSASignature bitcoin_signature_1_arg, struct LDKECDSASignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); /** - * Part of the channel value contributed by the channel acceptor + * Creates a copy of the ChannelAnnouncement */ -void AcceptChannelV2_set_funding_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); /** - * The threshold below which outputs on transactions broadcast by the channel acceptor will be - * omitted + * Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement. */ -uint64_t AcceptChannelV2_get_dust_limit_satoshis(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +uint64_t ChannelAnnouncement_hash(const struct LDKChannelAnnouncement *NONNULL_PTR o); /** - * The threshold below which outputs on transactions broadcast by the channel acceptor will be - * omitted + * Checks if two ChannelAnnouncements contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void AcceptChannelV2_set_dust_limit_satoshis(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); /** - * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi + * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. */ -uint64_t AcceptChannelV2_get_max_htlc_value_in_flight_msat(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); /** - * The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi + * The genesis hash of the blockchain where the channel is to be opened */ -void AcceptChannelV2_set_max_htlc_value_in_flight_msat(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; /** - * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + * The genesis hash of the blockchain where the channel is to be opened */ -uint64_t AcceptChannelV2_get_htlc_minimum_msat(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The minimum HTLC size incoming to channel acceptor, in milli-satoshi + * The short channel ID */ -void AcceptChannelV2_set_htlc_minimum_msat(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint64_t val); +uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Minimum depth of the funding transaction before the channel is considered open + * The short channel ID */ -uint32_t AcceptChannelV2_get_minimum_depth(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Minimum depth of the funding transaction before the channel is considered open + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -void AcceptChannelV2_set_minimum_depth(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint32_t val); +uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * A strictly monotonic announcement counter, with gaps allowed, specific to this channel */ -uint16_t AcceptChannelV2_get_to_self_delay(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The number of blocks which the counterparty will have to wait to claim on-chain funds if they - * broadcast a commitment transaction + * Flags pertaining to this message. */ -void AcceptChannelV2_set_to_self_delay(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint16_t val); +uint8_t UnsignedChannelUpdate_get_message_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The maximum number of inbound HTLCs towards channel acceptor + * Flags pertaining to this message. */ -uint16_t AcceptChannelV2_get_max_accepted_htlcs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_message_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The maximum number of inbound HTLCs towards channel acceptor + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -void AcceptChannelV2_set_max_accepted_htlcs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, uint16_t val); +uint8_t UnsignedChannelUpdate_get_channel_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The channel acceptor's key controlling the funding transaction + * Flags pertaining to the channel, including to which direction in the channel this update + * applies and whether the direction is currently able to forward HTLCs. */ -struct LDKPublicKey AcceptChannelV2_get_funding_pubkey(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_channel_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); /** - * The channel acceptor's key controlling the funding transaction + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -void AcceptChannelV2_set_funding_pubkey(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The number of blocks such that if: + * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` + * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines + * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a + * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, + * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before + * forwarding. Note that the HTLC sender is the one who originally sets this value when + * constructing the route. */ -struct LDKPublicKey AcceptChannelV2_get_revocation_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); /** - * Used to derive a revocation key for transactions broadcast by counterparty + * The minimum HTLC size incoming to sender, in milli-satoshi */ -void AcceptChannelV2_set_revocation_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * A payment key to channel acceptor for transactions broadcast by counterparty + * The minimum HTLC size incoming to sender, in milli-satoshi */ -struct LDKPublicKey AcceptChannelV2_get_payment_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * A payment key to channel acceptor for transactions broadcast by counterparty + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -void AcceptChannelV2_set_payment_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Used to derive a payment key to channel acceptor for transactions broadcast by channel - * acceptor + * The maximum HTLC value incoming to sender, in milli-satoshi. + * + * This used to be optional. */ -struct LDKPublicKey AcceptChannelV2_get_delayed_payment_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); /** - * Used to derive a payment key to channel acceptor for transactions broadcast by channel - * acceptor + * The base HTLC fee charged by sender, in milli-satoshi */ -void AcceptChannelV2_set_delayed_payment_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + * The base HTLC fee charged by sender, in milli-satoshi */ -struct LDKPublicKey AcceptChannelV2_get_htlc_basepoint(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty + * The amount to fee multiplier, in micro-satoshi */ -void AcceptChannelV2_set_htlc_basepoint(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + * The amount to fee multiplier, in micro-satoshi */ -struct LDKPublicKey AcceptChannelV2_get_first_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); /** - * The first to-be-broadcast-by-channel-acceptor transaction's per commitment point + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * + * Returns a copy of the field. */ -void AcceptChannelV2_set_first_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); /** - * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + * Excess data which was signed as a part of the message which we do not (yet) understand how + * to decode. + * + * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. */ -struct LDKPublicKey AcceptChannelV2_get_second_per_commitment_point(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * The second to-be-broadcast-by-channel-acceptor transaction's per commitment point + * Constructs a new UnsignedChannelUpdate given each field */ -void AcceptChannelV2_set_second_per_commitment_point(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t message_flags_arg, uint8_t channel_flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); /** - * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we - * collaboratively close + * Creates a copy of the UnsignedChannelUpdate */ -struct LDKCOption_CVec_u8ZZ AcceptChannelV2_get_shutdown_scriptpubkey(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); /** - * Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we - * collaboratively close + * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate. */ -void AcceptChannelV2_set_shutdown_scriptpubkey(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +uint64_t UnsignedChannelUpdate_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR o); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. - * - * This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two UnsignedChannelUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKChannelTypeFeatures AcceptChannelV2_get_channel_type(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); /** - * The channel type that this channel will represent. If none is set, we derive the channel - * type from the intersection of our feature bits with our counterparty's feature bits from - * the Init message. - * - * This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. */ -void AcceptChannelV2_set_channel_type(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +void ChannelUpdate_free(struct LDKChannelUpdate this_obj); /** - * Optionally, a requirement that only confirmed inputs can be added + * A signature of the channel update */ -enum LDKCOption_NoneZ AcceptChannelV2_get_require_confirmed_inputs(const struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr); +struct LDKECDSASignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * Optionally, a requirement that only confirmed inputs can be added + * A signature of the channel update */ -void AcceptChannelV2_set_require_confirmed_inputs(struct LDKAcceptChannelV2 *NONNULL_PTR this_ptr, enum LDKCOption_NoneZ val); +void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * Constructs a new AcceptChannelV2 given each field - * - * Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * The actual channel update */ -MUST_USE_RES struct LDKAcceptChannelV2 AcceptChannelV2_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, uint64_t funding_satoshis_arg, uint64_t dust_limit_satoshis_arg, uint64_t max_htlc_value_in_flight_msat_arg, uint64_t htlc_minimum_msat_arg, uint32_t minimum_depth_arg, uint16_t to_self_delay_arg, uint16_t max_accepted_htlcs_arg, struct LDKPublicKey funding_pubkey_arg, struct LDKPublicKey revocation_basepoint_arg, struct LDKPublicKey payment_basepoint_arg, struct LDKPublicKey delayed_payment_basepoint_arg, struct LDKPublicKey htlc_basepoint_arg, struct LDKPublicKey first_per_commitment_point_arg, struct LDKPublicKey second_per_commitment_point_arg, struct LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg, struct LDKChannelTypeFeatures channel_type_arg, enum LDKCOption_NoneZ require_confirmed_inputs_arg); +struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); /** - * Creates a copy of the AcceptChannelV2 + * The actual channel update */ -struct LDKAcceptChannelV2 AcceptChannelV2_clone(const struct LDKAcceptChannelV2 *NONNULL_PTR orig); +void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); /** - * Generates a non-cryptographic 64-bit hash of the AcceptChannelV2. + * Constructs a new ChannelUpdate given each field */ -uint64_t AcceptChannelV2_hash(const struct LDKAcceptChannelV2 *NONNULL_PTR o); +MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); /** - * Checks if two AcceptChannelV2s contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the ChannelUpdate */ -bool AcceptChannelV2_eq(const struct LDKAcceptChannelV2 *NONNULL_PTR a, const struct LDKAcceptChannelV2 *NONNULL_PTR b); +struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); /** - * Frees any resources used by the FundingCreated, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the ChannelUpdate. */ -void FundingCreated_free(struct LDKFundingCreated this_obj); +uint64_t ChannelUpdate_hash(const struct LDKChannelUpdate *NONNULL_PTR o); /** - * A temporary channel ID, until the funding is established + * Checks if two ChannelUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const uint8_t (*FundingCreated_get_temporary_channel_id(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); /** - * A temporary channel ID, until the funding is established + * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. */ -void FundingCreated_set_temporary_channel_id(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); /** - * The funding transaction ID + * The genesis hash of the blockchain being queried */ -const uint8_t (*FundingCreated_get_funding_txid(const struct LDKFundingCreated *NONNULL_PTR this_ptr))[32]; +const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The funding transaction ID + * The genesis hash of the blockchain being queried */ -void FundingCreated_set_funding_txid(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The specific output index funding this channel + * The height of the first block for the channel UTXOs being queried */ -uint16_t FundingCreated_get_funding_output_index(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * The specific output index funding this channel + * The height of the first block for the channel UTXOs being queried */ -void FundingCreated_set_funding_output_index(struct LDKFundingCreated *NONNULL_PTR this_ptr, uint16_t val); +void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The number of blocks to include in the query results */ -struct LDKECDSASignature FundingCreated_get_signature(const struct LDKFundingCreated *NONNULL_PTR this_ptr); +uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); /** - * The signature of the channel initiator (funder) on the initial commitment transaction + * The number of blocks to include in the query results */ -void FundingCreated_set_signature(struct LDKFundingCreated *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new FundingCreated given each field + * Constructs a new QueryChannelRange given each field */ -MUST_USE_RES struct LDKFundingCreated FundingCreated_new(struct LDKThirtyTwoBytes temporary_channel_id_arg, struct LDKThirtyTwoBytes funding_txid_arg, uint16_t funding_output_index_arg, struct LDKECDSASignature signature_arg); +MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); /** - * Creates a copy of the FundingCreated + * Creates a copy of the QueryChannelRange */ -struct LDKFundingCreated FundingCreated_clone(const struct LDKFundingCreated *NONNULL_PTR orig); +struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the FundingCreated. + * Generates a non-cryptographic 64-bit hash of the QueryChannelRange. */ -uint64_t FundingCreated_hash(const struct LDKFundingCreated *NONNULL_PTR o); +uint64_t QueryChannelRange_hash(const struct LDKQueryChannelRange *NONNULL_PTR o); /** - * Checks if two FundingCreateds contain equal inner contents. + * Checks if two QueryChannelRanges contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool FundingCreated_eq(const struct LDKFundingCreated *NONNULL_PTR a, const struct LDKFundingCreated *NONNULL_PTR b); +bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); /** - * Frees any resources used by the FundingSigned, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. */ -void FundingSigned_free(struct LDKFundingSigned this_obj); +void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); /** - * The channel ID + * The genesis hash of the blockchain being queried */ -const uint8_t (*FundingSigned_get_channel_id(const struct LDKFundingSigned *NONNULL_PTR this_ptr))[32]; +const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; /** - * The channel ID + * The genesis hash of the blockchain being queried */ -void FundingSigned_set_channel_id(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The height of the first block in the range of the reply */ -struct LDKECDSASignature FundingSigned_get_signature(const struct LDKFundingSigned *NONNULL_PTR this_ptr); +uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The signature of the channel acceptor (fundee) on the initial commitment transaction + * The height of the first block in the range of the reply */ -void FundingSigned_set_signature(struct LDKFundingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new FundingSigned given each field + * The number of blocks included in the range of the reply */ -MUST_USE_RES struct LDKFundingSigned FundingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKECDSASignature signature_arg); +uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Creates a copy of the FundingSigned + * The number of blocks included in the range of the reply */ -struct LDKFundingSigned FundingSigned_clone(const struct LDKFundingSigned *NONNULL_PTR orig); +void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); /** - * Generates a non-cryptographic 64-bit hash of the FundingSigned. + * True when this is the final reply for a query */ -uint64_t FundingSigned_hash(const struct LDKFundingSigned *NONNULL_PTR o); +bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * Checks if two FundingSigneds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * True when this is the final reply for a query */ -bool FundingSigned_eq(const struct LDKFundingSigned *NONNULL_PTR a, const struct LDKFundingSigned *NONNULL_PTR b); +void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); /** - * Frees any resources used by the ChannelReady, if is_owned is set and inner is non-NULL. + * The `short_channel_id`s in the channel range + * + * Returns a copy of the field. */ -void ChannelReady_free(struct LDKChannelReady this_obj); +struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); /** - * The channel ID + * The `short_channel_id`s in the channel range */ -const uint8_t (*ChannelReady_get_channel_id(const struct LDKChannelReady *NONNULL_PTR this_ptr))[32]; +void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * The channel ID + * Constructs a new ReplyChannelRange given each field */ -void ChannelReady_set_channel_id(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The per-commitment point of the second commitment transaction + * Creates a copy of the ReplyChannelRange */ -struct LDKPublicKey ChannelReady_get_next_per_commitment_point(const struct LDKChannelReady *NONNULL_PTR this_ptr); +struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); /** - * The per-commitment point of the second commitment transaction + * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange. */ -void ChannelReady_set_next_per_commitment_point(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKPublicKey val); +uint64_t ReplyChannelRange_hash(const struct LDKReplyChannelRange *NONNULL_PTR o); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * Checks if two ReplyChannelRanges contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCOption_u64Z ChannelReady_get_short_channel_id_alias(const struct LDKChannelReady *NONNULL_PTR this_ptr); +bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); /** - * If set, provides a `short_channel_id` alias for this channel. - * - * The sender will accept payments to be forwarded over this SCID and forward them to this - * messages' recipient. + * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. */ -void ChannelReady_set_short_channel_id_alias(struct LDKChannelReady *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); /** - * Constructs a new ChannelReady given each field + * The genesis hash of the blockchain being queried */ -MUST_USE_RES struct LDKChannelReady ChannelReady_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKPublicKey next_per_commitment_point_arg, struct LDKCOption_u64Z short_channel_id_alias_arg); +const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the ChannelReady + * The genesis hash of the blockchain being queried */ -struct LDKChannelReady ChannelReady_clone(const struct LDKChannelReady *NONNULL_PTR orig); +void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Generates a non-cryptographic 64-bit hash of the ChannelReady. + * The short_channel_ids that are being queried + * + * Returns a copy of the field. */ -uint64_t ChannelReady_hash(const struct LDKChannelReady *NONNULL_PTR o); +struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); /** - * Checks if two ChannelReadys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The short_channel_ids that are being queried */ -bool ChannelReady_eq(const struct LDKChannelReady *NONNULL_PTR a, const struct LDKChannelReady *NONNULL_PTR b); +void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Frees any resources used by the Stfu, if is_owned is set and inner is non-NULL. + * Constructs a new QueryShortChannelIds given each field */ -void Stfu_free(struct LDKStfu this_obj); +MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); /** - * The channel ID where quiescence is intended + * Creates a copy of the QueryShortChannelIds */ -const uint8_t (*Stfu_get_channel_id(const struct LDKStfu *NONNULL_PTR this_ptr))[32]; +struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); /** - * The channel ID where quiescence is intended + * Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds. */ -void Stfu_set_channel_id(struct LDKStfu *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +uint64_t QueryShortChannelIds_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR o); /** - * Initiator flag, 1 if initiating, 0 if replying to an stfu. + * Checks if two QueryShortChannelIdss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint8_t Stfu_get_initiator(const struct LDKStfu *NONNULL_PTR this_ptr); +bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); /** - * Initiator flag, 1 if initiating, 0 if replying to an stfu. + * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. */ -void Stfu_set_initiator(struct LDKStfu *NONNULL_PTR this_ptr, uint8_t val); +void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); /** - * Constructs a new Stfu given each field + * The genesis hash of the blockchain that was queried */ -MUST_USE_RES struct LDKStfu Stfu_new(struct LDKThirtyTwoBytes channel_id_arg, uint8_t initiator_arg); +const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the Stfu + * The genesis hash of the blockchain that was queried */ -struct LDKStfu Stfu_clone(const struct LDKStfu *NONNULL_PTR orig); +void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two Stfus contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -bool Stfu_eq(const struct LDKStfu *NONNULL_PTR a, const struct LDKStfu *NONNULL_PTR b); +bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Splice, if is_owned is set and inner is non-NULL. + * Indicates if the query recipient maintains up-to-date channel + * information for the `chain_hash` */ -void Splice_free(struct LDKSplice this_obj); +void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); /** - * The channel ID where splicing is intended + * Constructs a new ReplyShortChannelIdsEnd given each field */ -const uint8_t (*Splice_get_channel_id(const struct LDKSplice *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); /** - * The channel ID where splicing is intended + * Creates a copy of the ReplyShortChannelIdsEnd */ -void Splice_set_channel_id(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd. */ -const uint8_t (*Splice_get_chain_hash(const struct LDKSplice *NONNULL_PTR this_ptr))[32]; +uint64_t ReplyShortChannelIdsEnd_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR o); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * Checks if two ReplyShortChannelIdsEnds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Splice_set_chain_hash(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. + * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. */ -int64_t Splice_get_relative_satoshis(const struct LDKSplice *NONNULL_PTR this_ptr); +void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. + * The genesis hash of the blockchain for channel and node information */ -void Splice_set_relative_satoshis(struct LDKSplice *NONNULL_PTR this_ptr, int64_t val); +const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; /** - * The feerate for the new funding transaction, set by the splice initiator + * The genesis hash of the blockchain for channel and node information */ -uint32_t Splice_get_funding_feerate_perkw(const struct LDKSplice *NONNULL_PTR this_ptr); +void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The feerate for the new funding transaction, set by the splice initiator + * The starting unix timestamp */ -void Splice_set_funding_feerate_perkw(struct LDKSplice *NONNULL_PTR this_ptr, uint32_t val); +uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The locktime for the new funding transaction + * The starting unix timestamp */ -uint32_t Splice_get_locktime(const struct LDKSplice *NONNULL_PTR this_ptr); +void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The locktime for the new funding transaction + * The range of information in seconds */ -void Splice_set_locktime(struct LDKSplice *NONNULL_PTR this_ptr, uint32_t val); +uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); /** - * The key of the sender (splice initiator) controlling the new funding transaction + * The range of information in seconds */ -struct LDKPublicKey Splice_get_funding_pubkey(const struct LDKSplice *NONNULL_PTR this_ptr); +void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); /** - * The key of the sender (splice initiator) controlling the new funding transaction + * Constructs a new GossipTimestampFilter given each field */ -void Splice_set_funding_pubkey(struct LDKSplice *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); /** - * Constructs a new Splice given each field + * Creates a copy of the GossipTimestampFilter */ -MUST_USE_RES struct LDKSplice Splice_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes chain_hash_arg, int64_t relative_satoshis_arg, uint32_t funding_feerate_perkw_arg, uint32_t locktime_arg, struct LDKPublicKey funding_pubkey_arg); +struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); /** - * Creates a copy of the Splice + * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter. */ -struct LDKSplice Splice_clone(const struct LDKSplice *NONNULL_PTR orig); +uint64_t GossipTimestampFilter_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR o); /** - * Checks if two Splices contain equal inner contents. + * Checks if two GossipTimestampFilters contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Splice_eq(const struct LDKSplice *NONNULL_PTR a, const struct LDKSplice *NONNULL_PTR b); +bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); /** - * Frees any resources used by the SpliceAck, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ErrorAction */ -void SpliceAck_free(struct LDKSpliceAck this_obj); +void ErrorAction_free(struct LDKErrorAction this_ptr); /** - * The channel ID where splicing is intended + * Creates a copy of the ErrorAction */ -const uint8_t (*SpliceAck_get_channel_id(const struct LDKSpliceAck *NONNULL_PTR this_ptr))[32]; +struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); /** - * The channel ID where splicing is intended + * Utility method to constructs a new DisconnectPeer-variant ErrorAction */ -void SpliceAck_set_channel_id(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction */ -const uint8_t (*SpliceAck_get_chain_hash(const struct LDKSpliceAck *NONNULL_PTR this_ptr))[32]; +struct LDKErrorAction ErrorAction_disconnect_peer_with_warning(struct LDKWarningMessage msg); /** - * The genesis hash of the blockchain where the channel is intended to be spliced + * Utility method to constructs a new IgnoreError-variant ErrorAction */ -void SpliceAck_set_chain_hash(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKErrorAction ErrorAction_ignore_error(void); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. + * Utility method to constructs a new IgnoreAndLog-variant ErrorAction */ -int64_t SpliceAck_get_relative_satoshis(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); /** - * The intended change in channel capacity: the amount to be added (positive value) - * or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. + * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction */ -void SpliceAck_set_relative_satoshis(struct LDKSpliceAck *NONNULL_PTR this_ptr, int64_t val); +struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * Utility method to constructs a new SendErrorMessage-variant ErrorAction */ -struct LDKPublicKey SpliceAck_get_funding_pubkey(const struct LDKSpliceAck *NONNULL_PTR this_ptr); +struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); /** - * The key of the sender (splice acceptor) controlling the new funding transaction + * Utility method to constructs a new SendWarningMessage-variant ErrorAction */ -void SpliceAck_set_funding_pubkey(struct LDKSpliceAck *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); /** - * Constructs a new SpliceAck given each field + * Generates a non-cryptographic 64-bit hash of the ErrorAction. */ -MUST_USE_RES struct LDKSpliceAck SpliceAck_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes chain_hash_arg, int64_t relative_satoshis_arg, struct LDKPublicKey funding_pubkey_arg); +uint64_t ErrorAction_hash(const struct LDKErrorAction *NONNULL_PTR o); /** - * Creates a copy of the SpliceAck + * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. */ -struct LDKSpliceAck SpliceAck_clone(const struct LDKSpliceAck *NONNULL_PTR orig); +void LightningError_free(struct LDKLightningError this_obj); /** - * Checks if two SpliceAcks contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A human-readable message describing the error */ -bool SpliceAck_eq(const struct LDKSpliceAck *NONNULL_PTR a, const struct LDKSpliceAck *NONNULL_PTR b); +struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * Frees any resources used by the SpliceLocked, if is_owned is set and inner is non-NULL. + * A human-readable message describing the error */ -void SpliceLocked_free(struct LDKSpliceLocked this_obj); +void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); /** - * The channel ID + * The action which should be taken against the offending peer. */ -const uint8_t (*SpliceLocked_get_channel_id(const struct LDKSpliceLocked *NONNULL_PTR this_ptr))[32]; +struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); /** - * The channel ID + * The action which should be taken against the offending peer. */ -void SpliceLocked_set_channel_id(struct LDKSpliceLocked *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); /** - * Constructs a new SpliceLocked given each field + * Constructs a new LightningError given each field */ -MUST_USE_RES struct LDKSpliceLocked SpliceLocked_new(struct LDKThirtyTwoBytes channel_id_arg); +MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); /** - * Creates a copy of the SpliceLocked + * Creates a copy of the LightningError */ -struct LDKSpliceLocked SpliceLocked_clone(const struct LDKSpliceLocked *NONNULL_PTR orig); +struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); /** - * Checks if two SpliceLockeds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. */ -bool SpliceLocked_eq(const struct LDKSpliceLocked *NONNULL_PTR a, const struct LDKSpliceLocked *NONNULL_PTR b); +void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); /** - * Frees any resources used by the TxAddInput, if is_owned is set and inner is non-NULL. + * `update_add_htlc` messages which should be sent */ -void TxAddInput_free(struct LDKTxAddInput this_obj); +struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The channel ID + * `update_add_htlc` messages which should be sent */ -const uint8_t (*TxAddInput_get_channel_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr))[32]; +void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); /** - * The channel ID + * `update_fulfill_htlc` messages which should be sent */ -void TxAddInput_set_channel_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * A randomly chosen unique identifier for this input, which is even for initiators and odd for - * non-initiators. + * `update_fulfill_htlc` messages which should be sent */ -uint64_t TxAddInput_get_serial_id(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); /** - * A randomly chosen unique identifier for this input, which is even for initiators and odd for - * non-initiators. + * `update_fail_htlc` messages which should be sent */ -void TxAddInput_set_serial_id(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Serialized transaction that contains the output this input spends to verify that it is non - * malleable. + * `update_fail_htlc` messages which should be sent */ -struct LDKTransactionU16LenLimited TxAddInput_get_prevtx(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); /** - * Serialized transaction that contains the output this input spends to verify that it is non - * malleable. + * `update_fail_malformed_htlc` messages which should be sent */ -void TxAddInput_set_prevtx(struct LDKTxAddInput *NONNULL_PTR this_ptr, struct LDKTransactionU16LenLimited val); +struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The index of the output being spent + * `update_fail_malformed_htlc` messages which should be sent */ -uint32_t TxAddInput_get_prevtx_out(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); /** - * The index of the output being spent + * An `update_fee` message which should be sent + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void TxAddInput_set_prevtx_out(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); +struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * The sequence number of this input + * An `update_fee` message which should be sent + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint32_t TxAddInput_get_sequence(const struct LDKTxAddInput *NONNULL_PTR this_ptr); +void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); /** - * The sequence number of this input + * A `commitment_signed` message which should be sent */ -void TxAddInput_set_sequence(struct LDKTxAddInput *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); /** - * Constructs a new TxAddInput given each field + * A `commitment_signed` message which should be sent */ -MUST_USE_RES struct LDKTxAddInput TxAddInput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg, struct LDKTransactionU16LenLimited prevtx_arg, uint32_t prevtx_out_arg, uint32_t sequence_arg); +void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); /** - * Creates a copy of the TxAddInput + * Constructs a new CommitmentUpdate given each field + * + * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKTxAddInput TxAddInput_clone(const struct LDKTxAddInput *NONNULL_PTR orig); +MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); /** - * Generates a non-cryptographic 64-bit hash of the TxAddInput. + * Creates a copy of the CommitmentUpdate */ -uint64_t TxAddInput_hash(const struct LDKTxAddInput *NONNULL_PTR o); +struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); /** - * Checks if two TxAddInputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate. */ -bool TxAddInput_eq(const struct LDKTxAddInput *NONNULL_PTR a, const struct LDKTxAddInput *NONNULL_PTR b); +uint64_t CommitmentUpdate_hash(const struct LDKCommitmentUpdate *NONNULL_PTR o); /** - * Frees any resources used by the TxAddOutput, if is_owned is set and inner is non-NULL. + * Checks if two CommitmentUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxAddOutput_free(struct LDKTxAddOutput this_obj); +bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); /** - * The channel ID + * Calls the free function if one is set */ -const uint8_t (*TxAddOutput_get_channel_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr))[32]; +void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); /** - * The channel ID + * Calls the free function if one is set */ -void TxAddOutput_set_channel_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); /** - * A randomly chosen unique identifier for this output, which is even for initiators and odd for - * non-initiators. + * Calls the free function if one is set */ -uint64_t TxAddOutput_get_serial_id(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); /** - * A randomly chosen unique identifier for this output, which is even for initiators and odd for - * non-initiators. + * Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL. */ -void TxAddOutput_set_serial_id(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); +void FinalOnionHopData_free(struct LDKFinalOnionHopData this_obj); /** - * The satoshi value of the output + * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. + * Because it is generated by the recipient and included in the invoice, it also provides + * proof to the recipient that the payment was sent by someone with the generated invoice. */ -uint64_t TxAddOutput_get_sats(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +const uint8_t (*FinalOnionHopData_get_payment_secret(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr))[32]; /** - * The satoshi value of the output + * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. + * Because it is generated by the recipient and included in the invoice, it also provides + * proof to the recipient that the payment was sent by someone with the generated invoice. */ -void TxAddOutput_set_sats(struct LDKTxAddOutput *NONNULL_PTR this_ptr, uint64_t val); +void FinalOnionHopData_set_payment_secret(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The scriptPubKey for the output + * The intended total amount that this payment is for. + * + * Message serialization may panic if this value is more than 21 million Bitcoin. */ -struct LDKCVec_u8Z TxAddOutput_get_script(const struct LDKTxAddOutput *NONNULL_PTR this_ptr); +uint64_t FinalOnionHopData_get_total_msat(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr); /** - * The scriptPubKey for the output + * The intended total amount that this payment is for. + * + * Message serialization may panic if this value is more than 21 million Bitcoin. */ -void TxAddOutput_set_script(struct LDKTxAddOutput *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void FinalOnionHopData_set_total_msat(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new TxAddOutput given each field + * Constructs a new FinalOnionHopData given each field */ -MUST_USE_RES struct LDKTxAddOutput TxAddOutput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg, uint64_t sats_arg, struct LDKCVec_u8Z script_arg); +MUST_USE_RES struct LDKFinalOnionHopData FinalOnionHopData_new(struct LDKThirtyTwoBytes payment_secret_arg, uint64_t total_msat_arg); /** - * Creates a copy of the TxAddOutput + * Creates a copy of the FinalOnionHopData */ -struct LDKTxAddOutput TxAddOutput_clone(const struct LDKTxAddOutput *NONNULL_PTR orig); +struct LDKFinalOnionHopData FinalOnionHopData_clone(const struct LDKFinalOnionHopData *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the TxAddOutput. + * Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL. */ -uint64_t TxAddOutput_hash(const struct LDKTxAddOutput *NONNULL_PTR o); +void OnionPacket_free(struct LDKOnionPacket this_obj); /** - * Checks if two TxAddOutputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * BOLT 4 version number. */ -bool TxAddOutput_eq(const struct LDKTxAddOutput *NONNULL_PTR a, const struct LDKTxAddOutput *NONNULL_PTR b); +uint8_t OnionPacket_get_version(const struct LDKOnionPacket *NONNULL_PTR this_ptr); /** - * Frees any resources used by the TxRemoveInput, if is_owned is set and inner is non-NULL. + * BOLT 4 version number. */ -void TxRemoveInput_free(struct LDKTxRemoveInput this_obj); +void OnionPacket_set_version(struct LDKOnionPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * The channel ID + * In order to ensure we always return an error on onion decode in compliance with [BOLT + * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to + * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral + * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd + * like. + * + * Returns a copy of the field. */ -const uint8_t (*TxRemoveInput_get_channel_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_PublicKeySecp256k1ErrorZ OnionPacket_get_public_key(const struct LDKOnionPacket *NONNULL_PTR this_ptr); /** - * The channel ID + * In order to ensure we always return an error on onion decode in compliance with [BOLT + * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to + * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral + * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd + * like. */ -void TxRemoveInput_set_channel_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void OnionPacket_set_public_key(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKCResult_PublicKeySecp256k1ErrorZ val); /** - * The serial ID of the input to be removed + * HMAC to verify the integrity of hop_data. */ -uint64_t TxRemoveInput_get_serial_id(const struct LDKTxRemoveInput *NONNULL_PTR this_ptr); +const uint8_t (*OnionPacket_get_hmac(const struct LDKOnionPacket *NONNULL_PTR this_ptr))[32]; /** - * The serial ID of the input to be removed + * HMAC to verify the integrity of hop_data. */ -void TxRemoveInput_set_serial_id(struct LDKTxRemoveInput *NONNULL_PTR this_ptr, uint64_t val); +void OnionPacket_set_hmac(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Constructs a new TxRemoveInput given each field + * Creates a copy of the OnionPacket */ -MUST_USE_RES struct LDKTxRemoveInput TxRemoveInput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg); +struct LDKOnionPacket OnionPacket_clone(const struct LDKOnionPacket *NONNULL_PTR orig); /** - * Creates a copy of the TxRemoveInput + * Generates a non-cryptographic 64-bit hash of the OnionPacket. */ -struct LDKTxRemoveInput TxRemoveInput_clone(const struct LDKTxRemoveInput *NONNULL_PTR orig); +uint64_t OnionPacket_hash(const struct LDKOnionPacket *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the TxRemoveInput. + * Checks if two OnionPackets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t TxRemoveInput_hash(const struct LDKTxRemoveInput *NONNULL_PTR o); +bool OnionPacket_eq(const struct LDKOnionPacket *NONNULL_PTR a, const struct LDKOnionPacket *NONNULL_PTR b); /** - * Checks if two TxRemoveInputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL. */ -bool TxRemoveInput_eq(const struct LDKTxRemoveInput *NONNULL_PTR a, const struct LDKTxRemoveInput *NONNULL_PTR b); +void TrampolineOnionPacket_free(struct LDKTrampolineOnionPacket this_obj); /** - * Frees any resources used by the TxRemoveOutput, if is_owned is set and inner is non-NULL. + * Bolt 04 version number */ -void TxRemoveOutput_free(struct LDKTxRemoveOutput this_obj); +uint8_t TrampolineOnionPacket_get_version(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * The channel ID + * Bolt 04 version number */ -const uint8_t (*TxRemoveOutput_get_channel_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr))[32]; +void TrampolineOnionPacket_set_version(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * The channel ID + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -void TxRemoveOutput_set_channel_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKPublicKey TrampolineOnionPacket_get_public_key(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * The serial ID of the output to be removed + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -uint64_t TxRemoveOutput_get_serial_id(const struct LDKTxRemoveOutput *NONNULL_PTR this_ptr); +void TrampolineOnionPacket_set_public_key(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The serial ID of the output to be removed + * Encrypted payload for the next hop + * + * Returns a copy of the field. */ -void TxRemoveOutput_set_serial_id(struct LDKTxRemoveOutput *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z TrampolineOnionPacket_get_hop_data(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr); /** - * Constructs a new TxRemoveOutput given each field + * Encrypted payload for the next hop */ -MUST_USE_RES struct LDKTxRemoveOutput TxRemoveOutput_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t serial_id_arg); +void TrampolineOnionPacket_set_hop_data(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Creates a copy of the TxRemoveOutput + * HMAC to verify the integrity of hop_data */ -struct LDKTxRemoveOutput TxRemoveOutput_clone(const struct LDKTxRemoveOutput *NONNULL_PTR orig); +const uint8_t (*TrampolineOnionPacket_get_hmac(const struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr))[32]; /** - * Generates a non-cryptographic 64-bit hash of the TxRemoveOutput. + * HMAC to verify the integrity of hop_data */ -uint64_t TxRemoveOutput_hash(const struct LDKTxRemoveOutput *NONNULL_PTR o); +void TrampolineOnionPacket_set_hmac(struct LDKTrampolineOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Checks if two TxRemoveOutputs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new TrampolineOnionPacket given each field */ -bool TxRemoveOutput_eq(const struct LDKTxRemoveOutput *NONNULL_PTR a, const struct LDKTxRemoveOutput *NONNULL_PTR b); +MUST_USE_RES struct LDKTrampolineOnionPacket TrampolineOnionPacket_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); /** - * Frees any resources used by the TxComplete, if is_owned is set and inner is non-NULL. + * Creates a copy of the TrampolineOnionPacket */ -void TxComplete_free(struct LDKTxComplete this_obj); +struct LDKTrampolineOnionPacket TrampolineOnionPacket_clone(const struct LDKTrampolineOnionPacket *NONNULL_PTR orig); /** - * The channel ID + * Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket. */ -const uint8_t (*TxComplete_get_channel_id(const struct LDKTxComplete *NONNULL_PTR this_ptr))[32]; +uint64_t TrampolineOnionPacket_hash(const struct LDKTrampolineOnionPacket *NONNULL_PTR o); /** - * The channel ID + * Checks if two TrampolineOnionPackets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void TxComplete_set_channel_id(struct LDKTxComplete *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +bool TrampolineOnionPacket_eq(const struct LDKTrampolineOnionPacket *NONNULL_PTR a, const struct LDKTrampolineOnionPacket *NONNULL_PTR b); /** - * Constructs a new TxComplete given each field + * Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read */ -MUST_USE_RES struct LDKTxComplete TxComplete_new(struct LDKThirtyTwoBytes channel_id_arg); +struct LDKCVec_u8Z TrampolineOnionPacket_write(const struct LDKTrampolineOnionPacket *NONNULL_PTR obj); /** - * Creates a copy of the TxComplete + * Get the string representation of a DecodeError object */ -struct LDKTxComplete TxComplete_clone(const struct LDKTxComplete *NONNULL_PTR orig); +struct LDKStr DecodeError_to_str(const struct LDKDecodeError *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the TxComplete. + * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read */ -uint64_t TxComplete_hash(const struct LDKTxComplete *NONNULL_PTR o); +struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); /** - * Checks if two TxCompletes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a AcceptChannel from a byte array, created by AcceptChannel_write */ -bool TxComplete_eq(const struct LDKTxComplete *NONNULL_PTR a, const struct LDKTxComplete *NONNULL_PTR b); +struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); /** - * Frees any resources used by the TxSignatures, if is_owned is set and inner is non-NULL. + * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read */ -void TxSignatures_free(struct LDKTxSignatures this_obj); +struct LDKCVec_u8Z AcceptChannelV2_write(const struct LDKAcceptChannelV2 *NONNULL_PTR obj); /** - * The channel ID + * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write */ -const uint8_t (*TxSignatures_get_channel_id(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_AcceptChannelV2DecodeErrorZ AcceptChannelV2_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the Stfu object into a byte array which can be read by Stfu_read */ -void TxSignatures_set_channel_id(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z Stfu_write(const struct LDKStfu *NONNULL_PTR obj); /** - * The TXID + * Read a Stfu from a byte array, created by Stfu_write */ -const uint8_t (*TxSignatures_get_tx_hash(const struct LDKTxSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_StfuDecodeErrorZ Stfu_read(struct LDKu8slice ser); /** - * The TXID + * Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read */ -void TxSignatures_set_tx_hash(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z SpliceInit_write(const struct LDKSpliceInit *NONNULL_PTR obj); /** - * The list of witnesses - * - * Returns a copy of the field. + * Read a SpliceInit from a byte array, created by SpliceInit_write */ -struct LDKCVec_WitnessZ TxSignatures_get_witnesses(const struct LDKTxSignatures *NONNULL_PTR this_ptr); +struct LDKCResult_SpliceInitDecodeErrorZ SpliceInit_read(struct LDKu8slice ser); /** - * The list of witnesses + * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read */ -void TxSignatures_set_witnesses(struct LDKTxSignatures *NONNULL_PTR this_ptr, struct LDKCVec_WitnessZ val); +struct LDKCVec_u8Z SpliceAck_write(const struct LDKSpliceAck *NONNULL_PTR obj); /** - * Constructs a new TxSignatures given each field + * Read a SpliceAck from a byte array, created by SpliceAck_write */ -MUST_USE_RES struct LDKTxSignatures TxSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes tx_hash_arg, struct LDKCVec_WitnessZ witnesses_arg); +struct LDKCResult_SpliceAckDecodeErrorZ SpliceAck_read(struct LDKu8slice ser); /** - * Creates a copy of the TxSignatures + * Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read */ -struct LDKTxSignatures TxSignatures_clone(const struct LDKTxSignatures *NONNULL_PTR orig); +struct LDKCVec_u8Z SpliceLocked_write(const struct LDKSpliceLocked *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the TxSignatures. + * Read a SpliceLocked from a byte array, created by SpliceLocked_write */ -uint64_t TxSignatures_hash(const struct LDKTxSignatures *NONNULL_PTR o); +struct LDKCResult_SpliceLockedDecodeErrorZ SpliceLocked_read(struct LDKu8slice ser); /** - * Checks if two TxSignaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read */ -bool TxSignatures_eq(const struct LDKTxSignatures *NONNULL_PTR a, const struct LDKTxSignatures *NONNULL_PTR b); +struct LDKCVec_u8Z TxAddInput_write(const struct LDKTxAddInput *NONNULL_PTR obj); /** - * Frees any resources used by the TxInitRbf, if is_owned is set and inner is non-NULL. + * Read a TxAddInput from a byte array, created by TxAddInput_write */ -void TxInitRbf_free(struct LDKTxInitRbf this_obj); +struct LDKCResult_TxAddInputDecodeErrorZ TxAddInput_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read */ -const uint8_t (*TxInitRbf_get_channel_id(const struct LDKTxInitRbf *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z TxAddOutput_write(const struct LDKTxAddOutput *NONNULL_PTR obj); /** - * The channel ID + * Read a TxAddOutput from a byte array, created by TxAddOutput_write */ -void TxInitRbf_set_channel_id(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_TxAddOutputDecodeErrorZ TxAddOutput_read(struct LDKu8slice ser); /** - * The locktime of the transaction + * Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read */ -uint32_t TxInitRbf_get_locktime(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxRemoveInput_write(const struct LDKTxRemoveInput *NONNULL_PTR obj); /** - * The locktime of the transaction + * Read a TxRemoveInput from a byte array, created by TxRemoveInput_write */ -void TxInitRbf_set_locktime(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_TxRemoveInputDecodeErrorZ TxRemoveInput_read(struct LDKu8slice ser); /** - * The feerate of the transaction + * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read */ -uint32_t TxInitRbf_get_feerate_sat_per_1000_weight(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxRemoveOutput_write(const struct LDKTxRemoveOutput *NONNULL_PTR obj); /** - * The feerate of the transaction + * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write */ -void TxInitRbf_set_feerate_sat_per_1000_weight(struct LDKTxInitRbf *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_TxRemoveOutputDecodeErrorZ TxRemoveOutput_read(struct LDKu8slice ser); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Serialize the TxComplete object into a byte array which can be read by TxComplete_read */ -struct LDKCOption_i64Z TxInitRbf_get_funding_output_contribution(const struct LDKTxInitRbf *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z TxComplete_write(const struct LDKTxComplete *NONNULL_PTR obj); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Read a TxComplete from a byte array, created by TxComplete_write */ -void TxInitRbf_set_funding_output_contribution(struct LDKTxInitRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); +struct LDKCResult_TxCompleteDecodeErrorZ TxComplete_read(struct LDKu8slice ser); /** - * Constructs a new TxInitRbf given each field + * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read */ -MUST_USE_RES struct LDKTxInitRbf TxInitRbf_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t locktime_arg, uint32_t feerate_sat_per_1000_weight_arg, struct LDKCOption_i64Z funding_output_contribution_arg); +struct LDKCVec_u8Z TxSignatures_write(const struct LDKTxSignatures *NONNULL_PTR obj); /** - * Creates a copy of the TxInitRbf + * Read a TxSignatures from a byte array, created by TxSignatures_write */ -struct LDKTxInitRbf TxInitRbf_clone(const struct LDKTxInitRbf *NONNULL_PTR orig); +struct LDKCResult_TxSignaturesDecodeErrorZ TxSignatures_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the TxInitRbf. + * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read */ -uint64_t TxInitRbf_hash(const struct LDKTxInitRbf *NONNULL_PTR o); +struct LDKCVec_u8Z TxInitRbf_write(const struct LDKTxInitRbf *NONNULL_PTR obj); /** - * Checks if two TxInitRbfs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a TxInitRbf from a byte array, created by TxInitRbf_write */ -bool TxInitRbf_eq(const struct LDKTxInitRbf *NONNULL_PTR a, const struct LDKTxInitRbf *NONNULL_PTR b); +struct LDKCResult_TxInitRbfDecodeErrorZ TxInitRbf_read(struct LDKu8slice ser); /** - * Frees any resources used by the TxAckRbf, if is_owned is set and inner is non-NULL. + * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read */ -void TxAckRbf_free(struct LDKTxAckRbf this_obj); +struct LDKCVec_u8Z TxAckRbf_write(const struct LDKTxAckRbf *NONNULL_PTR obj); /** - * The channel ID + * Read a TxAckRbf from a byte array, created by TxAckRbf_write */ -const uint8_t (*TxAckRbf_get_channel_id(const struct LDKTxAckRbf *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_TxAckRbfDecodeErrorZ TxAckRbf_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the TxAbort object into a byte array which can be read by TxAbort_read */ -void TxAckRbf_set_channel_id(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z TxAbort_write(const struct LDKTxAbort *NONNULL_PTR obj); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Read a TxAbort from a byte array, created by TxAbort_write */ -struct LDKCOption_i64Z TxAckRbf_get_funding_output_contribution(const struct LDKTxAckRbf *NONNULL_PTR this_ptr); +struct LDKCResult_TxAbortDecodeErrorZ TxAbort_read(struct LDKu8slice ser); /** - * The number of satoshis the sender will contribute to or, if negative, remove from - * (e.g. splice-out) the funding output of the transaction + * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read */ -void TxAckRbf_set_funding_output_contribution(struct LDKTxAckRbf *NONNULL_PTR this_ptr, struct LDKCOption_i64Z val); +struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); /** - * Constructs a new TxAckRbf given each field + * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write */ -MUST_USE_RES struct LDKTxAckRbf TxAckRbf_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCOption_i64Z funding_output_contribution_arg); +struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); /** - * Creates a copy of the TxAckRbf + * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read */ -struct LDKTxAckRbf TxAckRbf_clone(const struct LDKTxAckRbf *NONNULL_PTR orig); +struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the TxAckRbf. + * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write */ -uint64_t TxAckRbf_hash(const struct LDKTxAckRbf *NONNULL_PTR o); +struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); /** - * Checks if two TxAckRbfs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read */ -bool TxAckRbf_eq(const struct LDKTxAckRbf *NONNULL_PTR a, const struct LDKTxAckRbf *NONNULL_PTR b); +struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); /** - * Frees any resources used by the TxAbort, if is_owned is set and inner is non-NULL. + * Read a ClosingSigned from a byte array, created by ClosingSigned_write */ -void TxAbort_free(struct LDKTxAbort this_obj); +struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read */ -const uint8_t (*TxAbort_get_channel_id(const struct LDKTxAbort *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); /** - * The channel ID + * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write */ -void TxAbort_set_channel_id(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); /** - * Message data - * - * Returns a copy of the field. + * Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read */ -struct LDKCVec_u8Z TxAbort_get_data(const struct LDKTxAbort *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z CommitmentSignedBatch_write(const struct LDKCommitmentSignedBatch *NONNULL_PTR obj); /** - * Message data + * Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write */ -void TxAbort_set_data(struct LDKTxAbort *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKCResult_CommitmentSignedBatchDecodeErrorZ CommitmentSignedBatch_read(struct LDKu8slice ser); /** - * Constructs a new TxAbort given each field + * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read */ -MUST_USE_RES struct LDKTxAbort TxAbort_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z data_arg); +struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); /** - * Creates a copy of the TxAbort + * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write */ -struct LDKTxAbort TxAbort_clone(const struct LDKTxAbort *NONNULL_PTR orig); +struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the TxAbort. + * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read */ -uint64_t TxAbort_hash(const struct LDKTxAbort *NONNULL_PTR o); +struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); /** - * Checks if two TxAborts contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a FundingCreated from a byte array, created by FundingCreated_write */ -bool TxAbort_eq(const struct LDKTxAbort *NONNULL_PTR a, const struct LDKTxAbort *NONNULL_PTR b); +struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); /** - * Frees any resources used by the Shutdown, if is_owned is set and inner is non-NULL. + * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read */ -void Shutdown_free(struct LDKShutdown this_obj); +struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); /** - * The channel ID + * Read a FundingSigned from a byte array, created by FundingSigned_write */ -const uint8_t (*Shutdown_get_channel_id(const struct LDKShutdown *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read */ -void Shutdown_set_channel_id(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * Read a ChannelReady from a byte array, created by ChannelReady_write */ -struct LDKCVec_u8Z Shutdown_get_scriptpubkey(const struct LDKShutdown *NONNULL_PTR this_ptr); +struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); /** - * The destination of this peer's funds on closing. - * - * Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. + * Serialize the Init object into a byte array which can be read by Init_read */ -void Shutdown_set_scriptpubkey(struct LDKShutdown *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); /** - * Constructs a new Shutdown given each field + * Read a Init from a byte array, created by Init_write */ -MUST_USE_RES struct LDKShutdown Shutdown_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKCVec_u8Z scriptpubkey_arg); +struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); /** - * Creates a copy of the Shutdown + * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read */ -struct LDKShutdown Shutdown_clone(const struct LDKShutdown *NONNULL_PTR orig); +struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the Shutdown. + * Read a OpenChannel from a byte array, created by OpenChannel_write */ -uint64_t Shutdown_hash(const struct LDKShutdown *NONNULL_PTR o); +struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); /** - * Checks if two Shutdowns contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read */ -bool Shutdown_eq(const struct LDKShutdown *NONNULL_PTR a, const struct LDKShutdown *NONNULL_PTR b); +struct LDKCVec_u8Z OpenChannelV2_write(const struct LDKOpenChannelV2 *NONNULL_PTR obj); /** - * Frees any resources used by the ClosingSignedFeeRange, if is_owned is set and inner is non-NULL. + * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write */ -void ClosingSignedFeeRange_free(struct LDKClosingSignedFeeRange this_obj); +struct LDKCResult_OpenChannelV2DecodeErrorZ OpenChannelV2_read(struct LDKu8slice ser); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read */ -uint64_t ClosingSignedFeeRange_get_min_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); /** - * The minimum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write */ -void ClosingSignedFeeRange_set_min_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Serialize the Shutdown object into a byte array which can be read by Shutdown_read */ -uint64_t ClosingSignedFeeRange_get_max_fee_satoshis(const struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); /** - * The maximum absolute fee, in satoshis, which the sender is willing to place on the closing - * transaction. + * Read a Shutdown from a byte array, created by Shutdown_write */ -void ClosingSignedFeeRange_set_max_fee_satoshis(struct LDKClosingSignedFeeRange *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); /** - * Constructs a new ClosingSignedFeeRange given each field + * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read */ -MUST_USE_RES struct LDKClosingSignedFeeRange ClosingSignedFeeRange_new(uint64_t min_fee_satoshis_arg, uint64_t max_fee_satoshis_arg); +struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); /** - * Creates a copy of the ClosingSignedFeeRange + * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write */ -struct LDKClosingSignedFeeRange ClosingSignedFeeRange_clone(const struct LDKClosingSignedFeeRange *NONNULL_PTR orig); +struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the ClosingSignedFeeRange. + * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read */ -uint64_t ClosingSignedFeeRange_hash(const struct LDKClosingSignedFeeRange *NONNULL_PTR o); +struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); /** - * Checks if two ClosingSignedFeeRanges contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write */ -bool ClosingSignedFeeRange_eq(const struct LDKClosingSignedFeeRange *NONNULL_PTR a, const struct LDKClosingSignedFeeRange *NONNULL_PTR b); +struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); /** - * Frees any resources used by the ClosingSigned, if is_owned is set and inner is non-NULL. + * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read */ -void ClosingSigned_free(struct LDKClosingSigned this_obj); +struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); /** - * The channel ID + * Read a UpdateFee from a byte array, created by UpdateFee_write */ -const uint8_t (*ClosingSigned_get_channel_id(const struct LDKClosingSigned *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read */ -void ClosingSigned_set_channel_id(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); /** - * The proposed total fee for the closing transaction + * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write */ -uint64_t ClosingSigned_get_fee_satoshis(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); /** - * The proposed total fee for the closing transaction + * Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read */ -void ClosingSigned_set_fee_satoshis(struct LDKClosingSigned *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_u8Z OnionPacket_write(const struct LDKOnionPacket *NONNULL_PTR obj); /** - * A signature on the closing transaction + * Read a OnionPacket from a byte array, created by OnionPacket_write */ -struct LDKECDSASignature ClosingSigned_get_signature(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +struct LDKCResult_OnionPacketDecodeErrorZ OnionPacket_read(struct LDKu8slice ser); /** - * A signature on the closing transaction + * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read */ -void ClosingSigned_set_signature(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write */ -struct LDKClosingSignedFeeRange ClosingSigned_get_fee_range(const struct LDKClosingSigned *NONNULL_PTR this_ptr); +struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); /** - * The minimum and maximum fees which the sender is willing to accept, provided only by new - * nodes. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a OnionMessage from a byte array, created by OnionMessage_write */ -void ClosingSigned_set_fee_range(struct LDKClosingSigned *NONNULL_PTR this_ptr, struct LDKClosingSignedFeeRange val); +struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); /** - * Constructs a new ClosingSigned given each field - * - * Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read */ -MUST_USE_RES struct LDKClosingSigned ClosingSigned_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t fee_satoshis_arg, struct LDKECDSASignature signature_arg, struct LDKClosingSignedFeeRange fee_range_arg); +struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); /** - * Creates a copy of the ClosingSigned + * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read */ -struct LDKClosingSigned ClosingSigned_clone(const struct LDKClosingSigned *NONNULL_PTR orig); +struct LDKCVec_u8Z FinalOnionHopData_write(const struct LDKFinalOnionHopData *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the ClosingSigned. + * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write */ -uint64_t ClosingSigned_hash(const struct LDKClosingSigned *NONNULL_PTR o); +struct LDKCResult_FinalOnionHopDataDecodeErrorZ FinalOnionHopData_read(struct LDKu8slice ser); /** - * Checks if two ClosingSigneds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the Ping object into a byte array which can be read by Ping_read */ -bool ClosingSigned_eq(const struct LDKClosingSigned *NONNULL_PTR a, const struct LDKClosingSigned *NONNULL_PTR b); +struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); /** - * Frees any resources used by the UpdateAddHTLC, if is_owned is set and inner is non-NULL. + * Read a Ping from a byte array, created by Ping_write */ -void UpdateAddHTLC_free(struct LDKUpdateAddHTLC this_obj); +struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); /** - * The channel ID + * Serialize the Pong object into a byte array which can be read by Pong_read */ -const uint8_t (*UpdateAddHTLC_get_channel_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); /** - * The channel ID + * Read a Pong from a byte array, created by Pong_write */ -void UpdateAddHTLC_set_channel_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); /** - * The HTLC ID + * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read */ -uint64_t UpdateAddHTLC_get_htlc_id(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); /** - * The HTLC ID + * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write */ -void UpdateAddHTLC_set_htlc_id(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); /** - * The HTLC value in milli-satoshi + * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read */ -uint64_t UpdateAddHTLC_get_amount_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); /** - * The HTLC value in milli-satoshi + * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write */ -void UpdateAddHTLC_set_amount_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read */ -const uint8_t (*UpdateAddHTLC_get_payment_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); /** - * The payment hash, the pre-image of which controls HTLC redemption + * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write */ -void UpdateAddHTLC_set_payment_hash(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); /** - * The expiry height of the HTLC + * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read */ -uint32_t UpdateAddHTLC_get_cltv_expiry(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); /** - * The expiry height of the HTLC + * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write */ -void UpdateAddHTLC_set_cltv_expiry(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); /** - * The extra fee skimmed by the sender of this message. See - * [`ChannelConfig::accept_underpaying_htlcs`]. - * - * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read */ -struct LDKCOption_u64Z UpdateAddHTLC_get_skimmed_fee_msat(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); /** - * The extra fee skimmed by the sender of this message. See - * [`ChannelConfig::accept_underpaying_htlcs`]. - * - * [`ChannelConfig::accept_underpaying_htlcs`]: crate::util::config::ChannelConfig::accept_underpaying_htlcs + * Read a ErrorMessage from a byte array, created by ErrorMessage_write */ -void UpdateAddHTLC_set_skimmed_fee_msat(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); /** - * The onion routing packet with encrypted data for the next hop. + * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read */ -struct LDKOnionPacket UpdateAddHTLC_get_onion_routing_packet(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); /** - * The onion routing packet with encrypted data for the next hop. + * Read a WarningMessage from a byte array, created by WarningMessage_write */ -void UpdateAddHTLC_set_onion_routing_packet(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKOnionPacket val); +struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); /** - * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion - * routing packet and the recipient-provided encrypted payload within. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read */ -struct LDKPublicKey UpdateAddHTLC_get_blinding_point(const struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); /** - * Provided if we are relaying or receiving a payment within a blinded path, to decrypt the onion - * routing packet and the recipient-provided encrypted payload within. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write */ -void UpdateAddHTLC_set_blinding_point(struct LDKUpdateAddHTLC *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); /** - * Constructs a new UpdateAddHTLC given each field - * - * Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read */ -MUST_USE_RES struct LDKUpdateAddHTLC UpdateAddHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, uint64_t amount_msat_arg, struct LDKThirtyTwoBytes payment_hash_arg, uint32_t cltv_expiry_arg, struct LDKCOption_u64Z skimmed_fee_msat_arg, struct LDKOnionPacket onion_routing_packet_arg, struct LDKPublicKey blinding_point_arg); +struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); /** - * Creates a copy of the UpdateAddHTLC + * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write */ -struct LDKUpdateAddHTLC UpdateAddHTLC_clone(const struct LDKUpdateAddHTLC *NONNULL_PTR orig); +struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the UpdateAddHTLC. + * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write */ -uint64_t UpdateAddHTLC_hash(const struct LDKUpdateAddHTLC *NONNULL_PTR o); +struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); /** - * Checks if two UpdateAddHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read */ -bool UpdateAddHTLC_eq(const struct LDKUpdateAddHTLC *NONNULL_PTR a, const struct LDKUpdateAddHTLC *NONNULL_PTR b); +struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); /** - * Frees any resources used by the OnionMessage, if is_owned is set and inner is non-NULL. + * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read */ -void OnionMessage_free(struct LDKOnionMessage this_obj); +struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); /** - * Used in decrypting the onion packet's payload. + * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write */ -struct LDKPublicKey OnionMessage_get_blinding_point(const struct LDKOnionMessage *NONNULL_PTR this_ptr); +struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); /** - * Used in decrypting the onion packet's payload. + * Calculates the overflow safe ending block height for the query. + * + * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. */ -void OnionMessage_set_blinding_point(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); /** - * The full onion packet including hop data, pubkey, and hmac + * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read */ -struct LDKPacket OnionMessage_get_onion_routing_packet(const struct LDKOnionMessage *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); /** - * The full onion packet including hop data, pubkey, and hmac + * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write */ -void OnionMessage_set_onion_routing_packet(struct LDKOnionMessage *NONNULL_PTR this_ptr, struct LDKPacket val); +struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); /** - * Constructs a new OnionMessage given each field + * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write */ -MUST_USE_RES struct LDKOnionMessage OnionMessage_new(struct LDKPublicKey blinding_point_arg, struct LDKPacket onion_routing_packet_arg); +struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); /** - * Creates a copy of the OnionMessage + * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read */ -struct LDKOnionMessage OnionMessage_clone(const struct LDKOnionMessage *NONNULL_PTR orig); +struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the OnionMessage. + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read */ -uint64_t OnionMessage_hash(const struct LDKOnionMessage *NONNULL_PTR o); +struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); /** - * Checks if two OnionMessages contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write */ -bool OnionMessage_eq(const struct LDKOnionMessage *NONNULL_PTR a, const struct LDKOnionMessage *NONNULL_PTR b); +struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); /** - * Frees any resources used by the UpdateFulfillHTLC, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void UpdateFulfillHTLC_free(struct LDKUpdateFulfillHTLC this_obj); +void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); /** - * The channel ID + * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. */ -const uint8_t (*UpdateFulfillHTLC_get_channel_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); /** - * The channel ID + * Constructs a new IgnoringMessageHandler given each field */ -void UpdateFulfillHTLC_set_channel_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); /** - * The HTLC ID + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -uint64_t UpdateFulfillHTLC_get_htlc_id(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr); +struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The HTLC ID + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -void UpdateFulfillHTLC_set_htlc_id(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, uint64_t val); +struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The pre-image of the payment hash, allowing HTLC redemption + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -const uint8_t (*UpdateFulfillHTLC_get_payment_preimage(const struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr))[32]; +struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * The pre-image of the payment hash, allowing HTLC redemption + * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is */ -void UpdateFulfillHTLC_set_payment_preimage(struct LDKUpdateFulfillHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Constructs a new UpdateFulfillHTLC given each field + * Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is */ -MUST_USE_RES struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t htlc_id_arg, struct LDKThirtyTwoBytes payment_preimage_arg); +struct LDKAsyncPaymentsMessageHandler IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Creates a copy of the UpdateFulfillHTLC + * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is */ -struct LDKUpdateFulfillHTLC UpdateFulfillHTLC_clone(const struct LDKUpdateFulfillHTLC *NONNULL_PTR orig); +struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFulfillHTLC. + * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is */ -uint64_t UpdateFulfillHTLC_hash(const struct LDKUpdateFulfillHTLC *NONNULL_PTR o); +struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Checks if two UpdateFulfillHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is */ -bool UpdateFulfillHTLC_eq(const struct LDKUpdateFulfillHTLC *NONNULL_PTR a, const struct LDKUpdateFulfillHTLC *NONNULL_PTR b); +struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); /** - * Frees any resources used by the UpdateFailHTLC, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. */ -void UpdateFailHTLC_free(struct LDKUpdateFailHTLC this_obj); +void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); /** - * The channel ID + * Constructs a new ErroringMessageHandler */ -const uint8_t (*UpdateFailHTLC_get_channel_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); /** - * The channel ID + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -void UpdateFailHTLC_set_channel_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * The HTLC ID + * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is */ -uint64_t UpdateFailHTLC_get_htlc_id(const struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr); +struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); /** - * The HTLC ID + * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. */ -void UpdateFailHTLC_set_htlc_id(struct LDKUpdateFailHTLC *NONNULL_PTR this_ptr, uint64_t val); +void MessageHandler_free(struct LDKMessageHandler this_obj); /** - * Creates a copy of the UpdateFailHTLC + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -struct LDKUpdateFailHTLC UpdateFailHTLC_clone(const struct LDKUpdateFailHTLC *NONNULL_PTR orig); +const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFailHTLC. + * A message handler which handles messages specific to channels. Usually this is just a + * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ -uint64_t UpdateFailHTLC_hash(const struct LDKUpdateFailHTLC *NONNULL_PTR o); +void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); /** - * Checks if two UpdateFailHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -bool UpdateFailHTLC_eq(const struct LDKUpdateFailHTLC *NONNULL_PTR a, const struct LDKUpdateFailHTLC *NONNULL_PTR b); +const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UpdateFailMalformedHTLC, if is_owned is set and inner is non-NULL. + * A message handler which handles messages updating our knowledge of the network channel + * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * + * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync */ -void UpdateFailMalformedHTLC_free(struct LDKUpdateFailMalformedHTLC this_obj); +void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); /** - * The channel ID + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger */ -const uint8_t (*UpdateFailMalformedHTLC_get_channel_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr))[32]; +const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * The channel ID + * A message handler which handles onion messages. This should generally be an + * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger */ -void UpdateFailMalformedHTLC_set_channel_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); /** - * The HTLC ID + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -uint64_t UpdateFailMalformedHTLC_get_htlc_id(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +const struct LDKCustomMessageHandler *MessageHandler_get_custom_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); /** - * The HTLC ID + * A message handler which handles custom messages. The only LDK-provided implementation is + * [`IgnoringMessageHandler`]. */ -void UpdateFailMalformedHTLC_set_htlc_id(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void MessageHandler_set_custom_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKCustomMessageHandler val); /** - * The failure code + * Constructs a new MessageHandler given each field */ -uint16_t UpdateFailMalformedHTLC_get_failure_code(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg, struct LDKCustomMessageHandler custom_message_handler_arg); /** - * The failure code + * Creates a copy of a SocketDescriptor */ -void UpdateFailMalformedHTLC_set_failure_code(struct LDKUpdateFailMalformedHTLC *NONNULL_PTR this_ptr, uint16_t val); +struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); /** - * Creates a copy of the UpdateFailMalformedHTLC + * Calls the free function if one is set */ -struct LDKUpdateFailMalformedHTLC UpdateFailMalformedHTLC_clone(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR orig); +void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. + * Frees any resources used by the PeerDetails, if is_owned is set and inner is non-NULL. */ -uint64_t UpdateFailMalformedHTLC_hash(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR o); +void PeerDetails_free(struct LDKPeerDetails this_obj); /** - * Checks if two UpdateFailMalformedHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The node id of the peer. + * + * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter + * passed in to [`PeerManager::new_outbound_connection`]. */ -bool UpdateFailMalformedHTLC_eq(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR a, const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR b); +struct LDKPublicKey PeerDetails_get_counterparty_node_id(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CommitmentSigned, if is_owned is set and inner is non-NULL. + * The node id of the peer. + * + * For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter + * passed in to [`PeerManager::new_outbound_connection`]. */ -void CommitmentSigned_free(struct LDKCommitmentSigned this_obj); +void PeerDetails_set_counterparty_node_id(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The channel ID + * The socket address the peer provided in the initial handshake. + * + * Will only be `Some` if an address had been previously provided to + * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. + * + * Returns a copy of the field. */ -const uint8_t (*CommitmentSigned_get_channel_id(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr))[32]; +struct LDKCOption_SocketAddressZ PeerDetails_get_socket_address(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * The channel ID + * The socket address the peer provided in the initial handshake. + * + * Will only be `Some` if an address had been previously provided to + * [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. */ -void CommitmentSigned_set_channel_id(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void PeerDetails_set_socket_address(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKCOption_SocketAddressZ val); /** - * A signature on the commitment transaction + * The features the peer provided in the initial handshake. */ -struct LDKECDSASignature CommitmentSigned_get_signature(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +struct LDKInitFeatures PeerDetails_get_init_features(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * A signature on the commitment transaction + * The features the peer provided in the initial handshake. */ -void CommitmentSigned_set_signature(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void PeerDetails_set_init_features(struct LDKPeerDetails *NONNULL_PTR this_ptr, struct LDKInitFeatures val); /** - * Signatures on the HTLC transactions + * Indicates the direction of the peer connection. * - * Returns a copy of the field. + * Will be `true` for inbound connections, and `false` for outbound connections. */ -struct LDKCVec_ECDSASignatureZ CommitmentSigned_get_htlc_signatures(const struct LDKCommitmentSigned *NONNULL_PTR this_ptr); +bool PeerDetails_get_is_inbound_connection(const struct LDKPeerDetails *NONNULL_PTR this_ptr); /** - * Signatures on the HTLC transactions + * Indicates the direction of the peer connection. + * + * Will be `true` for inbound connections, and `false` for outbound connections. */ -void CommitmentSigned_set_htlc_signatures(struct LDKCommitmentSigned *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); +void PeerDetails_set_is_inbound_connection(struct LDKPeerDetails *NONNULL_PTR this_ptr, bool val); /** - * Constructs a new CommitmentSigned given each field + * Constructs a new PeerDetails given each field */ -MUST_USE_RES struct LDKCommitmentSigned CommitmentSigned_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKECDSASignature signature_arg, struct LDKCVec_ECDSASignatureZ htlc_signatures_arg); +MUST_USE_RES struct LDKPeerDetails PeerDetails_new(struct LDKPublicKey counterparty_node_id_arg, struct LDKCOption_SocketAddressZ socket_address_arg, struct LDKInitFeatures init_features_arg, bool is_inbound_connection_arg); /** - * Creates a copy of the CommitmentSigned + * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. */ -struct LDKCommitmentSigned CommitmentSigned_clone(const struct LDKCommitmentSigned *NONNULL_PTR orig); +void PeerHandleError_free(struct LDKPeerHandleError this_obj); /** - * Generates a non-cryptographic 64-bit hash of the CommitmentSigned. + * Constructs a new PeerHandleError given each field */ -uint64_t CommitmentSigned_hash(const struct LDKCommitmentSigned *NONNULL_PTR o); +MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); /** - * Checks if two CommitmentSigneds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the PeerHandleError */ -bool CommitmentSigned_eq(const struct LDKCommitmentSigned *NONNULL_PTR a, const struct LDKCommitmentSigned *NONNULL_PTR b); +struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); /** - * Frees any resources used by the RevokeAndACK, if is_owned is set and inner is non-NULL. + * Get the string representation of a PeerHandleError object */ -void RevokeAndACK_free(struct LDKRevokeAndACK this_obj); +struct LDKStr PeerHandleError_to_str(const struct LDKPeerHandleError *NONNULL_PTR o); /** - * The channel ID + * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. */ -const uint8_t (*RevokeAndACK_get_channel_id(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +void PeerManager_free(struct LDKPeerManager this_obj); /** - * The channel ID + * Constructs a new `PeerManager` with the given message handlers. + * + * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be + * cryptographically secure random bytes. + * + * `current_time` is used as an always-increasing counter that survives across restarts and is + * incremented irregularly internally. In general it is best to simply use the current UNIX + * timestamp, however if it is not available a persistent counter that increases once per + * minute should suffice. */ -void RevokeAndACK_set_channel_id(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKNodeSigner node_signer); /** - * The secret corresponding to the per-commitment point + * Returns a list of [`PeerDetails`] for connected peers that have completed the initial + * handshake. */ -const uint8_t (*RevokeAndACK_get_per_commitment_secret(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCVec_PeerDetailsZ PeerManager_list_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * The secret corresponding to the per-commitment point + * Returns the [`PeerDetails`] of a connected peer that has completed the initial handshake. + * + * Will return `None` if the peer is unknown or it hasn't completed the initial handshake. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void RevokeAndACK_set_per_commitment_secret(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKPeerDetails PeerManager_peer_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Indicates a new outbound connection has been established to a node with the given `node_id` + * and an optional remote network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * If an `Err` is returned here you must disconnect the connection immediately. + * + * Returns a small number of bytes to send to the remote node (currently always 50). + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -struct LDKPublicKey RevokeAndACK_get_next_per_commitment_point(const struct LDKRevokeAndACK *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); /** - * The next sender-broadcast commitment transaction's per-commitment point + * Indicates a new inbound connection has been established to a node with an optional remote + * network address. + * + * The remote network address adds the option to report a remote IP address back to a connecting + * peer using the init message. + * The user should pass the remote network address of the host they are connected to. + * + * May refuse the connection by returning an Err, but will never write bytes to the remote end + * (outbound connector always speaks first). If an `Err` is returned here you must disconnect + * the connection immediately. + * + * Panics if descriptor is duplicative with some other descriptor which has not yet been + * [`socket_disconnected`]. + * + * [`socket_disconnected`]: PeerManager::socket_disconnected */ -void RevokeAndACK_set_next_per_commitment_point(struct LDKRevokeAndACK *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); /** - * Constructs a new RevokeAndACK given each field + * Indicates that there is room to write data to the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before + * returning. Thus, be very careful with reentrancy issues! The invariants around calling + * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be + * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't + * sufficient! + * + * [`send_data`]: SocketDescriptor::send_data + * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail */ -MUST_USE_RES struct LDKRevokeAndACK RevokeAndACK_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKThirtyTwoBytes per_commitment_secret_arg, struct LDKPublicKey next_per_commitment_point_arg); +MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * Creates a copy of the RevokeAndACK + * Indicates that data was read from the given socket descriptor. + * + * May return an Err to indicate that the connection should be closed. + * + * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. + * Thus, however, you should call [`process_events`] after any `read_event` to generate + * [`send_data`] calls to handle responses. + * + * If `Ok(true)` is returned, further read_events should not be triggered until a + * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the + * send buffer). + * + * In order to avoid processing too many messages at once per peer, `data` should be on the + * order of 4KiB. + * + * [`send_data`]: SocketDescriptor::send_data + * [`process_events`]: PeerManager::process_events */ -struct LDKRevokeAndACK RevokeAndACK_clone(const struct LDKRevokeAndACK *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); /** - * Generates a non-cryptographic 64-bit hash of the RevokeAndACK. + * Checks for any events generated by our handlers and processes them. Includes sending most + * response messages as well as messages generated by calls to handler functions directly (eg + * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * + * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] + * or one of the other clients provided in our language bindings. + * + * Note that if there are any other calls to this function waiting on lock(s) this may return + * without doing any work. All available events that need handling will be handled before the + * other calls return. + * + * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards + * [`send_data`]: SocketDescriptor::send_data */ -uint64_t RevokeAndACK_hash(const struct LDKRevokeAndACK *NONNULL_PTR o); +void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Checks if two RevokeAndACKs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Indicates that the given socket descriptor's connection is now closed. */ -bool RevokeAndACK_eq(const struct LDKRevokeAndACK *NONNULL_PTR a, const struct LDKRevokeAndACK *NONNULL_PTR b); +void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); /** - * Frees any resources used by the UpdateFee, if is_owned is set and inner is non-NULL. + * Disconnect a peer given its node id. + * + * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the + * peer. Thus, be very careful about reentrancy issues. + * + * [`disconnect_socket`]: SocketDescriptor::disconnect_socket */ -void UpdateFee_free(struct LDKUpdateFee this_obj); +void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * The channel ID + * Disconnects all currently-connected peers. This is useful on platforms where there may be + * an indication that TCP sockets have stalled even if we weren't around to time them out + * using regular ping/pongs. */ -const uint8_t (*UpdateFee_get_channel_id(const struct LDKUpdateFee *NONNULL_PTR this_ptr))[32]; +void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * The channel ID + * Send pings to each peer and disconnect those which did not respond to the last round of + * pings. + * + * This may be called on any timescale you want, however, roughly once every ten seconds is + * preferred. The call rate determines both how often we send a ping to our peers and how much + * time they have to respond before we disconnect them. + * + * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy + * issues! + * + * [`send_data`]: SocketDescriptor::send_data */ -void UpdateFee_set_channel_id(struct LDKUpdateFee *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); /** - * Fee rate per 1000-weight of the transaction + * Generates a signed node_announcement from the given arguments, sending it to all connected + * peers. Note that peers will likely ignore this message unless we have at least one public + * channel which has at least six confirmations on-chain. + * + * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this + * node to humans. They carry no in-protocol meaning. + * + * `addresses` represent the set (possibly empty) of socket addresses on which this node + * accepts incoming connections. These will be included in the node_announcement, publicly + * tying these addresses together and to this node. If you wish to preserve user privacy, + * addresses should likely contain only Tor Onion addresses. + * + * Panics if `addresses` is absurdly large (more than 100). + * + * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events */ -uint32_t UpdateFee_get_feerate_per_kw(const struct LDKUpdateFee *NONNULL_PTR this_ptr); +void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_SocketAddressZ addresses); /** - * Fee rate per 1000-weight of the transaction + * Gets the weight for an HTLC-Success transaction. */ -void UpdateFee_set_feerate_per_kw(struct LDKUpdateFee *NONNULL_PTR this_ptr, uint32_t val); +uint64_t htlc_success_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * Constructs a new UpdateFee given each field + * Gets the weight for an HTLC-Timeout transaction. */ -MUST_USE_RES struct LDKUpdateFee UpdateFee_new(struct LDKThirtyTwoBytes channel_id_arg, uint32_t feerate_per_kw_arg); +uint64_t htlc_timeout_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * Creates a copy of the UpdateFee + * Creates a copy of the HTLCClaim */ -struct LDKUpdateFee UpdateFee_clone(const struct LDKUpdateFee *NONNULL_PTR orig); +enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the UpdateFee. + * Utility method to constructs a new OfferedTimeout-variant HTLCClaim */ -uint64_t UpdateFee_hash(const struct LDKUpdateFee *NONNULL_PTR o); +enum LDKHTLCClaim HTLCClaim_offered_timeout(void); /** - * Checks if two UpdateFees contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new OfferedPreimage-variant HTLCClaim */ -bool UpdateFee_eq(const struct LDKUpdateFee *NONNULL_PTR a, const struct LDKUpdateFee *NONNULL_PTR b); +enum LDKHTLCClaim HTLCClaim_offered_preimage(void); /** - * Frees any resources used by the ChannelReestablish, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim */ -void ChannelReestablish_free(struct LDKChannelReestablish this_obj); +enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); /** - * The channel ID + * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim */ -const uint8_t (*ChannelReestablish_get_channel_id(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); /** - * The channel ID + * Utility method to constructs a new Revocation-variant HTLCClaim */ -void ChannelReestablish_set_channel_id(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +enum LDKHTLCClaim HTLCClaim_revocation(void); /** - * The next commitment number for the sender + * Checks if two HTLCClaims contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t ChannelReestablish_get_next_local_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); /** - * The next commitment number for the sender + * Check if a given input witness attempts to claim a HTLC. */ -void ChannelReestablish_set_next_local_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); /** - * The next commitment number for the recipient + * Build the commitment secret from the seed and the commitment number */ -uint64_t ChannelReestablish_get_next_remote_commitment_number(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); /** - * The next commitment number for the recipient + * Build a closing transaction */ -void ChannelReestablish_set_next_remote_commitment_number(struct LDKChannelReestablish *NONNULL_PTR this_ptr, uint64_t val); +struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. */ -const uint8_t (*ChannelReestablish_get_your_last_per_commitment_secret(const struct LDKChannelReestablish *NONNULL_PTR this_ptr))[32]; +void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); /** - * Proof that the sender knows the per-commitment secret of a specific commitment transaction - * belonging to the recipient + * Creates a copy of the CounterpartyCommitmentSecrets */ -void ChannelReestablish_set_your_last_per_commitment_secret(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); /** - * The sender's per-commitment point for their current commitment transaction + * Creates a new empty `CounterpartyCommitmentSecrets` structure. */ -struct LDKPublicKey ChannelReestablish_get_my_current_per_commitment_point(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); /** - * The sender's per-commitment point for their current commitment transaction + * Returns the minimum index of all stored secrets. Note that indexes start + * at 1 << 48 and get decremented by one for each new secret. */ -void ChannelReestablish_set_my_current_per_commitment_point(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); /** - * The next funding transaction ID + * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret + * was generated in accordance with BOLT 3 and is consistent with previous secrets. */ -struct LDKCOption_ThirtyTwoBytesZ ChannelReestablish_get_next_funding_txid(const struct LDKChannelReestablish *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); /** - * The next funding transaction ID + * Returns the secret at `idx`. + * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelReestablish_set_next_funding_txid(struct LDKChannelReestablish *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); /** - * Constructs a new ChannelReestablish given each field + * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read */ -MUST_USE_RES struct LDKChannelReestablish ChannelReestablish_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t next_local_commitment_number_arg, uint64_t next_remote_commitment_number_arg, struct LDKThirtyTwoBytes your_last_per_commitment_secret_arg, struct LDKPublicKey my_current_per_commitment_point_arg, struct LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg); +struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); /** - * Creates a copy of the ChannelReestablish + * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write */ -struct LDKChannelReestablish ChannelReestablish_clone(const struct LDKChannelReestablish *NONNULL_PTR orig); +struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the ChannelReestablish. + * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) + * from the base secret and the per_commitment_point. */ -uint64_t ChannelReestablish_hash(const struct LDKChannelReestablish *NONNULL_PTR o); +struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); /** - * Checks if two ChannelReestablishs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Derives a per-commitment-transaction revocation key from its constituent parts. + * + * Only the cheating participant owns a valid witness to propagate a revoked + * commitment transaction, thus per_commitment_secret always come from cheater + * and revocation_base_secret always come from punisher, which is the broadcaster + * of the transaction spending with this key knowledge. */ -bool ChannelReestablish_eq(const struct LDKChannelReestablish *NONNULL_PTR a, const struct LDKChannelReestablish *NONNULL_PTR b); +struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); /** - * Frees any resources used by the AnnouncementSignatures, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. */ -void AnnouncementSignatures_free(struct LDKAnnouncementSignatures this_obj); +void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); /** - * The channel ID + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -const uint8_t (*AnnouncementSignatures_get_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr))[32]; +struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The channel ID + * The broadcaster's per-commitment public key which was used to derive the other keys. */ -void AnnouncementSignatures_set_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The short channel ID + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -uint64_t AnnouncementSignatures_get_short_channel_id(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKRevocationKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * The short channel ID + * The revocation key which is used to allow the broadcaster of the commitment + * transaction to provide their counterparty the ability to punish them if they broadcast + * an old state. */ -void AnnouncementSignatures_set_short_channel_id(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, uint64_t val); +void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKRevocationKey val); /** - * A signature by the node key + * Broadcaster's HTLC Key */ -struct LDKECDSASignature AnnouncementSignatures_get_node_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKHtlcKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * A signature by the node key + * Broadcaster's HTLC Key */ -void AnnouncementSignatures_set_node_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); /** - * A signature by the funding key + * Countersignatory's HTLC Key */ -struct LDKECDSASignature AnnouncementSignatures_get_bitcoin_signature(const struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr); +struct LDKHtlcKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * A signature by the funding key + * Countersignatory's HTLC Key */ -void AnnouncementSignatures_set_bitcoin_signature(struct LDKAnnouncementSignatures *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); /** - * Constructs a new AnnouncementSignatures given each field + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -MUST_USE_RES struct LDKAnnouncementSignatures AnnouncementSignatures_new(struct LDKThirtyTwoBytes channel_id_arg, uint64_t short_channel_id_arg, struct LDKECDSASignature node_signature_arg, struct LDKECDSASignature bitcoin_signature_arg); +struct LDKDelayedPaymentKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); /** - * Creates a copy of the AnnouncementSignatures + * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) */ -struct LDKAnnouncementSignatures AnnouncementSignatures_clone(const struct LDKAnnouncementSignatures *NONNULL_PTR orig); +void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentKey val); /** - * Generates a non-cryptographic 64-bit hash of the AnnouncementSignatures. + * Constructs a new TxCreationKeys given each field */ -uint64_t AnnouncementSignatures_hash(const struct LDKAnnouncementSignatures *NONNULL_PTR o); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKRevocationKey revocation_key_arg, struct LDKHtlcKey broadcaster_htlc_key_arg, struct LDKHtlcKey countersignatory_htlc_key_arg, struct LDKDelayedPaymentKey broadcaster_delayed_payment_key_arg); /** - * Checks if two AnnouncementSignaturess contain equal inner contents. + * Checks if two TxCreationKeyss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool AnnouncementSignatures_eq(const struct LDKAnnouncementSignatures *NONNULL_PTR a, const struct LDKAnnouncementSignatures *NONNULL_PTR b); - -/** - * Frees any resources used by the SocketAddress - */ -void SocketAddress_free(struct LDKSocketAddress this_ptr); +bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); /** - * Creates a copy of the SocketAddress + * Creates a copy of the TxCreationKeys */ -struct LDKSocketAddress SocketAddress_clone(const struct LDKSocketAddress *NONNULL_PTR orig); +struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); /** - * Utility method to constructs a new TcpIpV4-variant SocketAddress + * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read */ -struct LDKSocketAddress SocketAddress_tcp_ip_v4(struct LDKFourBytes addr, uint16_t port); +struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); /** - * Utility method to constructs a new TcpIpV6-variant SocketAddress + * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write */ -struct LDKSocketAddress SocketAddress_tcp_ip_v6(struct LDKSixteenBytes addr, uint16_t port); +struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); /** - * Utility method to constructs a new OnionV2-variant SocketAddress + * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. */ -struct LDKSocketAddress SocketAddress_onion_v2(struct LDKTwelveBytes a); +void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); /** - * Utility method to constructs a new OnionV3-variant SocketAddress + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKSocketAddress SocketAddress_onion_v3(struct LDKThirtyTwoBytes ed25519_pubkey, uint16_t checksum, uint8_t version, uint16_t port); +struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new Hostname-variant SocketAddress + * The public key which is used to sign all commitment transactions, as it appears in the + * on-chain channel lock-in 2-of-2 multisig output. */ -struct LDKSocketAddress SocketAddress_hostname(struct LDKHostname hostname, uint16_t port); +void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Generates a non-cryptographic 64-bit hash of the SocketAddress. + * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -uint64_t SocketAddress_hash(const struct LDKSocketAddress *NONNULL_PTR o); +struct LDKRevocationBasepoint ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Checks if two SocketAddresss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment + * revocation keys. This is combined with the per-commitment-secret generated by the + * counterparty to create a secret which the counterparty can reveal to revoke previous + * states. */ -bool SocketAddress_eq(const struct LDKSocketAddress *NONNULL_PTR a, const struct LDKSocketAddress *NONNULL_PTR b); +void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKRevocationBasepoint val); /** - * Serialize the SocketAddress object into a byte array which can be read by SocketAddress_read + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCVec_u8Z SocketAddress_write(const struct LDKSocketAddress *NONNULL_PTR obj); +struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Read a SocketAddress from a byte array, created by SocketAddress_write + * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately + * spendable primary channel balance on the broadcaster's commitment transaction. This key is + * static across every commitment transaction. */ -struct LDKCResult_SocketAddressDecodeErrorZ SocketAddress_read(struct LDKu8slice ser); +void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Creates a copy of the SocketAddressParseError + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -enum LDKSocketAddressParseError SocketAddressParseError_clone(const enum LDKSocketAddressParseError *NONNULL_PTR orig); +struct LDKDelayedPaymentBasepoint ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError + * The base point which is used (with derive_public_key) to derive a per-commitment payment + * public key which receives non-HTLC-encumbered funds which are only available for spending + * after some delay (or can be claimed via the revocation path). */ -enum LDKSocketAddressParseError SocketAddressParseError_socket_addr_parse(void); +void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentBasepoint val); /** - * Utility method to constructs a new InvalidInput-variant SocketAddressParseError + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_input(void); +struct LDKHtlcBasepoint ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new InvalidPort-variant SocketAddressParseError + * The base point which is used (with derive_public_key) to derive a per-commitment public key + * which is used to encumber HTLC-in-flight outputs. */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_port(void); +void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKHtlcBasepoint val); /** - * Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError + * Constructs a new ChannelPublicKeys given each field */ -enum LDKSocketAddressParseError SocketAddressParseError_invalid_onion_v3(void); +MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKRevocationBasepoint revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKDelayedPaymentBasepoint delayed_payment_basepoint_arg, struct LDKHtlcBasepoint htlc_basepoint_arg); /** - * Generates a non-cryptographic 64-bit hash of the SocketAddressParseError. + * Creates a copy of the ChannelPublicKeys */ -uint64_t SocketAddressParseError_hash(const enum LDKSocketAddressParseError *NONNULL_PTR o); +struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); /** - * Checks if two SocketAddressParseErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys. */ -bool SocketAddressParseError_eq(const enum LDKSocketAddressParseError *NONNULL_PTR a, const enum LDKSocketAddressParseError *NONNULL_PTR b); +uint64_t ChannelPublicKeys_hash(const struct LDKChannelPublicKeys *NONNULL_PTR o); /** - * Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. - * - * The host part must end with \".onion\". + * Checks if two ChannelPublicKeyss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_SocketAddressSocketAddressParseErrorZ parse_onion_address(struct LDKStr host, uint16_t port); +bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); /** - * Get the string representation of a SocketAddress object + * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read */ -struct LDKStr SocketAddress_to_str(const struct LDKSocketAddress *NONNULL_PTR o); +struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); /** - * Read a SocketAddress object from a string + * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write */ -struct LDKCResult_SocketAddressSocketAddressParseErrorZ SocketAddress_from_str(struct LDKStr s); +struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); /** - * Frees any resources used by the UnsignedGossipMessage + * Create per-state keys from channel base points and the per-commitment point. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -void UnsignedGossipMessage_free(struct LDKUnsignedGossipMessage this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR broadcaster_delayed_payment_base, const struct LDKHtlcBasepoint *NONNULL_PTR broadcaster_htlc_base, const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_revocation_base, const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_htlc_base); /** - * Creates a copy of the UnsignedGossipMessage + * Generate per-state keys from channel static keys. + * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_clone(const struct LDKUnsignedGossipMessage *NONNULL_PTR orig); +MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * Utility method to constructs a new ChannelAnnouncement-variant UnsignedGossipMessage + * A script either spendable by the revocation + * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. + * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_announcement(struct LDKUnsignedChannelAnnouncement a); +struct LDKCVec_u8Z get_revokeable_redeemscript(const struct LDKRevocationKey *NONNULL_PTR revocation_key, uint16_t contest_delay, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key); /** - * Utility method to constructs a new ChannelUpdate-variant UnsignedGossipMessage + * Returns the script for the counterparty's output on a holder's commitment transaction based on + * the channel type. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_channel_update(struct LDKUnsignedChannelUpdate a); +struct LDKCVec_u8Z get_counterparty_payment_script(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, struct LDKPublicKey payment_key); /** - * Utility method to constructs a new NodeAnnouncement-variant UnsignedGossipMessage + * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. */ -struct LDKUnsignedGossipMessage UnsignedGossipMessage_node_announcement(struct LDKUnsignedNodeAnnouncement a); +void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); /** - * Serialize the UnsignedGossipMessage object into a byte array which can be read by UnsignedGossipMessage_read + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -struct LDKCVec_u8Z UnsignedGossipMessage_write(const struct LDKUnsignedGossipMessage *NONNULL_PTR obj); +bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedNodeAnnouncement, if is_owned is set and inner is non-NULL. + * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). + * Note that this is not the same as whether it is ountbound *from us*. To determine that you + * need to compare this value to whether the commitment transaction in question is that of + * the counterparty or our own. */ -void UnsignedNodeAnnouncement_free(struct LDKUnsignedNodeAnnouncement this_obj); +void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); /** - * The advertised features + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -struct LDKNodeFeatures UnsignedNodeAnnouncement_get_features(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * The advertised features + * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is + * this divided by 1000. */ -void UnsignedNodeAnnouncement_set_features(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); /** - * A strictly monotonic announcement counter, with gaps allowed + * The CLTV lock-time at which this HTLC expires. */ -uint32_t UnsignedNodeAnnouncement_get_timestamp(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * A strictly monotonic announcement counter, with gaps allowed + * The CLTV lock-time at which this HTLC expires. */ -void UnsignedNodeAnnouncement_set_timestamp(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, uint32_t val); +void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * The hash of the preimage which unlocks this HTLC. */ -struct LDKNodeId UnsignedNodeAnnouncement_get_node_id(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; /** - * The `node_id` this announcement originated from (don't rebroadcast the `node_announcement` back - * to this node). + * The hash of the preimage which unlocks this HTLC. */ -void UnsignedNodeAnnouncement_set_node_id(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * An RGB color for UI purposes + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -const uint8_t (*UnsignedNodeAnnouncement_get_rgb(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr))[3]; +struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); /** - * An RGB color for UI purposes + * The position within the commitment transactions' outputs. This may be None if the value is + * below the dust limit (in which case no output appears in the commitment transaction and the + * value is spent to additional transaction fees). */ -void UnsignedNodeAnnouncement_set_rgb(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); /** - * An alias, for UI purposes. - * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Constructs a new HTLCOutputInCommitment given each field */ -struct LDKNodeAlias UnsignedNodeAnnouncement_get_alias(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); /** - * An alias, for UI purposes. - * - * This should be sanitized before use. There is no guarantee of uniqueness. + * Creates a copy of the HTLCOutputInCommitment */ -void UnsignedNodeAnnouncement_set_alias(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); /** - * List of addresses on which this node is reachable - * - * Returns a copy of the field. + * Checks if two HTLCOutputInCommitments contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_SocketAddressZ UnsignedNodeAnnouncement_get_addresses(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr); +bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); /** - * List of addresses on which this node is reachable + * Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. + * Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, + * e. g. in commitment transactions. */ -void UnsignedNodeAnnouncement_set_addresses(struct LDKUnsignedNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); +MUST_USE_RES uint64_t HTLCOutputInCommitment_to_bitcoin_amount(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_arg); /** - * Creates a copy of the UnsignedNodeAnnouncement + * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read */ -struct LDKUnsignedNodeAnnouncement UnsignedNodeAnnouncement_clone(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR orig); +struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedNodeAnnouncement. + * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write */ -uint64_t UnsignedNodeAnnouncement_hash(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR o); +struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); /** - * Checks if two UnsignedNodeAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc + * does not need to have its previous_output_index filled. */ -bool UnsignedNodeAnnouncement_eq(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR a, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR b); +struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKTxCreationKeys *NONNULL_PTR keys); /** - * Frees any resources used by the NodeAnnouncement, if is_owned is set and inner is non-NULL. + * Gets the redeemscript for a funding output from the two funding public keys. + * Note that the order of funding public keys does not matter. */ -void NodeAnnouncement_free(struct LDKNodeAnnouncement this_obj); +struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); /** - * The signature by the node key + * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC + * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the + * transaction which needs signing, and can be used to construct an HTLC transaction which is + * broadcastable given a counterparty HTLC signature. + * + * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the + * commitment transaction). */ -struct LDKECDSASignature NodeAnnouncement_get_signature(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key, const struct LDKRevocationKey *NONNULL_PTR revocation_key); /** - * The signature by the node key + * Returns the witness required to satisfy and spend a HTLC input. */ -void NodeAnnouncement_set_signature(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKWitness build_htlc_input_witness(struct LDKECDSASignature local_sig, struct LDKECDSASignature remote_sig, struct LDKCOption_ThirtyTwoBytesZ preimage, struct LDKu8slice redeem_script, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); /** - * The actual content of the announcement + * Gets the witnessScript for the to_remote output when anchors are enabled. */ -struct LDKUnsignedNodeAnnouncement NodeAnnouncement_get_contents(const struct LDKNodeAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); /** - * The actual content of the announcement + * Gets the witnessScript for an anchor output from the funding public key. + * The witness in the spending input must be: + * + * After 16 blocks of confirmation, an alternative satisfying witness could be: + * <> + * (empty vector required to satisfy compliance with MINIMALIF-standard rule) */ -void NodeAnnouncement_set_contents(struct LDKNodeAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedNodeAnnouncement val); +struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); /** - * Constructs a new NodeAnnouncement given each field + * Returns the witness required to satisfy and spend an anchor input. */ -MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncement_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedNodeAnnouncement contents_arg); +struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKECDSASignature funding_sig); /** - * Creates a copy of the NodeAnnouncement + * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKNodeAnnouncement NodeAnnouncement_clone(const struct LDKNodeAnnouncement *NONNULL_PTR orig); +void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); /** - * Generates a non-cryptographic 64-bit hash of the NodeAnnouncement. + * Holder public keys */ -uint64_t NodeAnnouncement_hash(const struct LDKNodeAnnouncement *NONNULL_PTR o); +struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Checks if two NodeAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Holder public keys */ -bool NodeAnnouncement_eq(const struct LDKNodeAnnouncement *NONNULL_PTR a, const struct LDKNodeAnnouncement *NONNULL_PTR b); +void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Frees any resources used by the UnsignedChannelAnnouncement, if is_owned is set and inner is non-NULL. + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -void UnsignedChannelAnnouncement_free(struct LDKUnsignedChannelAnnouncement this_obj); +uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The advertised channel features + * The contest delay selected by the holder, which applies to counterparty-broadcast transactions */ -struct LDKChannelFeatures UnsignedChannelAnnouncement_get_features(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * The advertised channel features + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -void UnsignedChannelAnnouncement_set_features(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The genesis hash of the blockchain where the channel is to be opened + * Whether the holder is the initiator of this channel. + * This is an input to the commitment number obscure factor computation. */ -const uint8_t (*UnsignedChannelAnnouncement_get_chain_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr))[32]; +void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); /** - * The genesis hash of the blockchain where the channel is to be opened + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UnsignedChannelAnnouncement_set_chain_hash(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The short channel ID + * The late-bound counterparty channel transaction parameters. + * These parameters are populated at the point in the protocol where the counterparty provides them. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t UnsignedChannelAnnouncement_get_short_channel_id(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); /** - * The short channel ID + * The late-bound funding outpoint + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UnsignedChannelAnnouncement_set_short_channel_id(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, uint64_t val); +struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * One of the two `node_id`s which are endpoints of this channel + * The late-bound funding outpoint + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * One of the two `node_id`s which are endpoints of this channel + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -void UnsignedChannelAnnouncement_set_node_id_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKChannelTypeFeatures ChannelTransactionParameters_get_channel_type_features(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * The other of the two `node_id`s which are endpoints of this channel + * This channel's type, as negotiated during channel open. For old objects where this field + * wasn't serialized, it will default to static_remote_key at deserialization. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_node_id_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +void ChannelTransactionParameters_set_channel_type_features(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); /** - * The other of the two `node_id`s which are endpoints of this channel + * Constructs a new ChannelTransactionParameters given each field + * + * Note that counterparty_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void UnsignedChannelAnnouncement_set_node_id_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKChannelTypeFeatures channel_type_features_arg); /** - * The funding key for the first node + * Creates a copy of the ChannelTransactionParameters */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_1(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); /** - * The funding key for the first node + * Generates a non-cryptographic 64-bit hash of the ChannelTransactionParameters. */ -void UnsignedChannelAnnouncement_set_bitcoin_key_1(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +uint64_t ChannelTransactionParameters_hash(const struct LDKChannelTransactionParameters *NONNULL_PTR o); /** - * The funding key for the second node + * Checks if two ChannelTransactionParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKNodeId UnsignedChannelAnnouncement_get_bitcoin_key_2(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); /** - * The funding key for the second node + * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -void UnsignedChannelAnnouncement_set_bitcoin_key_2(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKNodeId val); +void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. - * - * Returns a copy of the field. + * Counter-party public keys */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_get_excess_data(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Counter-party public keys */ -void UnsignedChannelAnnouncement_set_excess_data(struct LDKUnsignedChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); /** - * Constructs a new UnsignedChannelAnnouncement given each field + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -MUST_USE_RES struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_new(struct LDKChannelFeatures features_arg, struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, struct LDKNodeId node_id_1_arg, struct LDKNodeId node_id_2_arg, struct LDKNodeId bitcoin_key_1_arg, struct LDKNodeId bitcoin_key_2_arg, struct LDKCVec_u8Z excess_data_arg); +uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); /** - * Creates a copy of the UnsignedChannelAnnouncement + * The contest delay selected by the counterparty, which applies to holder-broadcast transactions */ -struct LDKUnsignedChannelAnnouncement UnsignedChannelAnnouncement_clone(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR orig); +void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedChannelAnnouncement. + * Constructs a new CounterpartyChannelTransactionParameters given each field */ -uint64_t UnsignedChannelAnnouncement_hash(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR o); +MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); /** - * Checks if two UnsignedChannelAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the CounterpartyChannelTransactionParameters */ -bool UnsignedChannelAnnouncement_eq(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR a, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR b); +struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelAnnouncement, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the CounterpartyChannelTransactionParameters. */ -void ChannelAnnouncement_free(struct LDKChannelAnnouncement this_obj); +uint64_t CounterpartyChannelTransactionParameters_hash(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR o); /** - * Authentication of the announcement by the first public node + * Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKECDSASignature ChannelAnnouncement_get_node_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); /** - * Authentication of the announcement by the first public node + * Whether the late bound parameters are populated. */ -void ChannelAnnouncement_set_node_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Authentication of the announcement by the second public node + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the holder is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -struct LDKECDSASignature ChannelAnnouncement_get_node_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Authentication of the announcement by the second public node + * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, + * given that the counterparty is the broadcaster. + * + * self.is_populated() must be true before calling this function. */ -void ChannelAnnouncement_set_node_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Proof of funding UTXO ownership by the first public node + * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read */ -struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_1(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); /** - * Proof of funding UTXO ownership by the first public node + * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write */ -void ChannelAnnouncement_set_bitcoin_signature_1(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); /** - * Proof of funding UTXO ownership by the second public node + * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read */ -struct LDKECDSASignature ChannelAnnouncement_get_bitcoin_signature_2(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); /** - * Proof of funding UTXO ownership by the second public node + * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write */ -void ChannelAnnouncement_set_bitcoin_signature_2(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); /** - * The actual announcement + * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. */ -struct LDKUnsignedChannelAnnouncement ChannelAnnouncement_get_contents(const struct LDKChannelAnnouncement *NONNULL_PTR this_ptr); +void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); /** - * The actual announcement + * Get the channel pubkeys for the broadcaster */ -void ChannelAnnouncement_set_contents(struct LDKChannelAnnouncement *NONNULL_PTR this_ptr, struct LDKUnsignedChannelAnnouncement val); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Constructs a new ChannelAnnouncement given each field + * Get the channel pubkeys for the countersignatory */ -MUST_USE_RES struct LDKChannelAnnouncement ChannelAnnouncement_new(struct LDKECDSASignature node_signature_1_arg, struct LDKECDSASignature node_signature_2_arg, struct LDKECDSASignature bitcoin_signature_1_arg, struct LDKECDSASignature bitcoin_signature_2_arg, struct LDKUnsignedChannelAnnouncement contents_arg); +MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelAnnouncement + * Get the contest delay applicable to the transactions. + * Note that the contest delay was selected by the countersignatory. */ -struct LDKChannelAnnouncement ChannelAnnouncement_clone(const struct LDKChannelAnnouncement *NONNULL_PTR orig); +MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelAnnouncement. + * Whether the channel is outbound from the broadcaster. + * + * The boolean representing the side that initiated the channel is + * an input to the commitment number obscure factor computation. */ -uint64_t ChannelAnnouncement_hash(const struct LDKChannelAnnouncement *NONNULL_PTR o); +MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Checks if two ChannelAnnouncements contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The funding outpoint */ -bool ChannelAnnouncement_eq(const struct LDKChannelAnnouncement *NONNULL_PTR a, const struct LDKChannelAnnouncement *NONNULL_PTR b); +MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * Frees any resources used by the UnsignedChannelUpdate, if is_owned is set and inner is non-NULL. + * Whether to use anchors for this channel */ -void UnsignedChannelUpdate_free(struct LDKUnsignedChannelUpdate this_obj); +MUST_USE_RES struct LDKChannelTypeFeatures DirectedChannelTransactionParameters_channel_type_features(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain where the channel is to be opened + * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -const uint8_t (*UnsignedChannelUpdate_get_chain_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr))[32]; +void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); /** - * The genesis hash of the blockchain where the channel is to be opened + * Our counterparty's signature for the transaction */ -void UnsignedChannelUpdate_set_chain_hash(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKECDSASignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * The short channel ID + * Our counterparty's signature for the transaction */ -uint64_t UnsignedChannelUpdate_get_short_channel_id(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * The short channel ID + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * + * Returns a copy of the field. */ -void UnsignedChannelUpdate_set_short_channel_id(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCVec_ECDSASignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * All non-dust counterparty HTLC signatures, in the order they appear in the transaction */ -uint32_t UnsignedChannelUpdate_get_timestamp(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); /** - * A strictly monotonic announcement counter, with gaps allowed, specific to this channel + * Creates a copy of the HolderCommitmentTransaction */ -void UnsignedChannelUpdate_set_timestamp(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); /** - * Channel flags + * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read */ -uint8_t UnsignedChannelUpdate_get_flags(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); /** - * Channel flags + * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write */ -void UnsignedChannelUpdate_set_flags(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint8_t val); +struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Create a new holder transaction with the given counterparty signatures. + * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. */ -uint16_t UnsignedChannelUpdate_get_cltv_expiry_delta(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKECDSASignature counterparty_sig, struct LDKCVec_ECDSASignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); /** - * The number of blocks such that if: - * `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` - * then we need to fail the HTLC backwards. When forwarding an HTLC, `cltv_expiry_delta` determines - * the outgoing HTLC's minimum `cltv_expiry` value -- so, if an incoming HTLC comes in with a - * `cltv_expiry` of 100000, and the node we're forwarding to has a `cltv_expiry_delta` value of 10, - * then we'll check that the outgoing HTLC's `cltv_expiry` value is at least 100010 before - * forwarding. Note that the HTLC sender is the one who originally sets this value when - * constructing the route. + * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void UnsignedChannelUpdate_set_cltv_expiry_delta(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint16_t val); +void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The commitment transaction */ -uint64_t UnsignedChannelUpdate_get_htlc_minimum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); /** - * The minimum HTLC size incoming to sender, in milli-satoshi + * The commitment transaction */ -void UnsignedChannelUpdate_set_htlc_minimum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); /** - * The maximum HTLC value incoming to sender, in milli-satoshi. + * The txid for the commitment transaction. * - * This used to be optional. + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -uint64_t UnsignedChannelUpdate_get_htlc_maximum_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; /** - * The maximum HTLC value incoming to sender, in milli-satoshi. + * The txid for the commitment transaction. * - * This used to be optional. + * This is provided as a performance optimization, instead of calling transaction.txid() + * multiple times. */ -void UnsignedChannelUpdate_set_htlc_maximum_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint64_t val); +void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Constructs a new BuiltCommitmentTransaction given each field */ -uint32_t UnsignedChannelUpdate_get_fee_base_msat(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); /** - * The base HTLC fee charged by sender, in milli-satoshi + * Creates a copy of the BuiltCommitmentTransaction */ -void UnsignedChannelUpdate_set_fee_base_msat(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); /** - * The amount to fee multiplier, in micro-satoshi + * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read */ -uint32_t UnsignedChannelUpdate_get_fee_proportional_millionths(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); /** - * The amount to fee multiplier, in micro-satoshi + * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write */ -void UnsignedChannelUpdate_set_fee_proportional_millionths(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Get the SIGHASH_ALL sighash value of the transaction. * - * Returns a copy of the field. + * This can be used to verify a signature. */ -struct LDKCVec_u8Z UnsignedChannelUpdate_get_excess_data(const struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Excess data which was signed as a part of the message which we do not (yet) understand how - * to decode. - * - * This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. + * Signs the counterparty's commitment transaction. */ -void UnsignedChannelUpdate_set_excess_data(struct LDKUnsignedChannelUpdate *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * Constructs a new UnsignedChannelUpdate given each field + * Signs the holder commitment transaction because we are about to broadcast it. */ -MUST_USE_RES struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_new(struct LDKThirtyTwoBytes chain_hash_arg, uint64_t short_channel_id_arg, uint32_t timestamp_arg, uint8_t flags_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, struct LDKCVec_u8Z excess_data_arg); +MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Creates a copy of the UnsignedChannelUpdate + * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. */ -struct LDKUnsignedChannelUpdate UnsignedChannelUpdate_clone(const struct LDKUnsignedChannelUpdate *NONNULL_PTR orig); +void ClosingTransaction_free(struct LDKClosingTransaction this_obj); /** - * Generates a non-cryptographic 64-bit hash of the UnsignedChannelUpdate. + * Creates a copy of the ClosingTransaction + */ +struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. */ -uint64_t UnsignedChannelUpdate_hash(const struct LDKUnsignedChannelUpdate *NONNULL_PTR o); +uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); /** - * Checks if two UnsignedChannelUpdates contain equal inner contents. + * Checks if two ClosingTransactions contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool UnsignedChannelUpdate_eq(const struct LDKUnsignedChannelUpdate *NONNULL_PTR a, const struct LDKUnsignedChannelUpdate *NONNULL_PTR b); +bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); /** - * Frees any resources used by the ChannelUpdate, if is_owned is set and inner is non-NULL. + * Construct an object of the class */ -void ChannelUpdate_free(struct LDKChannelUpdate this_obj); +MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); /** - * A signature of the channel update + * Trust our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -struct LDKECDSASignature ChannelUpdate_get_signature(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * A signature of the channel update + * Verify our pre-built transaction. + * + * Applies a wrapper which allows access to the transaction. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -void ChannelUpdate_set_signature(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); /** - * The actual channel update + * The value to be sent to the holder, or zero if the output will be omitted */ -struct LDKUnsignedChannelUpdate ChannelUpdate_get_contents(const struct LDKChannelUpdate *NONNULL_PTR this_ptr); +MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * The actual channel update + * The value to be sent to the counterparty, or zero if the output will be omitted */ -void ChannelUpdate_set_contents(struct LDKChannelUpdate *NONNULL_PTR this_ptr, struct LDKUnsignedChannelUpdate val); +MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Constructs a new ChannelUpdate given each field + * The destination of the holder's output */ -MUST_USE_RES struct LDKChannelUpdate ChannelUpdate_new(struct LDKECDSASignature signature_arg, struct LDKUnsignedChannelUpdate contents_arg); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelUpdate + * The destination of the counterparty's output */ -struct LDKChannelUpdate ChannelUpdate_clone(const struct LDKChannelUpdate *NONNULL_PTR orig); +MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelUpdate. + * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. */ -uint64_t ChannelUpdate_hash(const struct LDKChannelUpdate *NONNULL_PTR o); +void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); /** - * Checks if two ChannelUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The pre-built Bitcoin commitment transaction */ -bool ChannelUpdate_eq(const struct LDKChannelUpdate *NONNULL_PTR a, const struct LDKChannelUpdate *NONNULL_PTR b); +MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the QueryChannelRange, if is_owned is set and inner is non-NULL. + * Get the SIGHASH_ALL sighash value of the transaction. + * + * This can be used to verify a signature. */ -void QueryChannelRange_free(struct LDKQueryChannelRange this_obj); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * The genesis hash of the blockchain being queried + * Sign a transaction, either because we are counter-signing the counterparty's transaction or + * because we are about to broadcast a holder transaction. */ -const uint8_t (*QueryChannelRange_get_chain_hash(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKECDSASignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); /** - * The genesis hash of the blockchain being queried + * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void QueryChannelRange_set_chain_hash(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); /** - * The height of the first block for the channel UTXOs being queried + * Creates a copy of the CommitmentTransaction */ -uint32_t QueryChannelRange_get_first_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); /** - * The height of the first block for the channel UTXOs being queried + * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read */ -void QueryChannelRange_set_first_blocknum(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); /** - * The number of blocks to include in the query results + * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write */ -uint32_t QueryChannelRange_get_number_of_blocks(const struct LDKQueryChannelRange *NONNULL_PTR this_ptr); +struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); /** - * The number of blocks to include in the query results + * The backwards-counting commitment number */ -void QueryChannelRange_set_number_of_blocks(struct LDKQueryChannelRange *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Constructs a new QueryChannelRange given each field + * The per commitment point used by the broadcaster. */ -MUST_USE_RES struct LDKQueryChannelRange QueryChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg); +MUST_USE_RES struct LDKPublicKey CommitmentTransaction_per_commitment_point(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Creates a copy of the QueryChannelRange + * The value to be sent to the broadcaster */ -struct LDKQueryChannelRange QueryChannelRange_clone(const struct LDKQueryChannelRange *NONNULL_PTR orig); +MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the QueryChannelRange. + * The value to be sent to the counterparty */ -uint64_t QueryChannelRange_hash(const struct LDKQueryChannelRange *NONNULL_PTR o); +MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Checks if two QueryChannelRanges contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The feerate paid per 1000-weight-unit in this commitment transaction. */ -bool QueryChannelRange_eq(const struct LDKQueryChannelRange *NONNULL_PTR a, const struct LDKQueryChannelRange *NONNULL_PTR b); +MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * Frees any resources used by the ReplyChannelRange, if is_owned is set and inner is non-NULL. + * Trust our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * This should only be used if you fully trust the builder of this object. It should not + * be used by an external signer - instead use the verify function. */ -void ReplyChannelRange_free(struct LDKReplyChannelRange this_obj); +MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); /** - * The genesis hash of the blockchain being queried + * Verify our pre-built transaction and derived transaction creation public keys. + * + * Applies a wrapper which allows access to these fields. + * + * An external validating signer must call this method before signing + * or using the built transaction. */ -const uint8_t (*ReplyChannelRange_get_chain_hash(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); /** - * The genesis hash of the blockchain being queried + * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. */ -void ReplyChannelRange_set_chain_hash(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); /** - * The height of the first block in the range of the reply + * The transaction ID of the built Bitcoin transaction */ -uint32_t ReplyChannelRange_get_first_blocknum(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The height of the first block in the range of the reply + * The pre-built Bitcoin commitment transaction */ -void ReplyChannelRange_set_first_blocknum(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The number of blocks included in the range of the reply + * The pre-calculated transaction creation public keys. */ -uint32_t ReplyChannelRange_get_number_of_blocks(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The number of blocks included in the range of the reply + * Should anchors be used. */ -void ReplyChannelRange_set_number_of_blocks(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKChannelTypeFeatures TrustedCommitmentTransaction_channel_type_features(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * True when this is the final reply for a query + * Get a signature for each HTLC which was included in the commitment transaction (ie for + * which HTLCOutputInCommitment::transaction_output_index.is_some()). + * + * The returned Vec has one entry for each HTLC, and in the same order. + * + * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. */ -bool ReplyChannelRange_get_sync_complete(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_CVec_ECDSASignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * True when this is the final reply for a query + * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to + * the broadcaster, in the built transaction, if any exists. + * + * There are two cases where this may return `None`: + * - The balance of the revokeable output is below the dust limit (only found on commitments + * early in the channel's lifetime, i.e. before the channel reserve is met). + * - This commitment was created before LDK 0.0.117. In this case, the + * commitment transaction previously didn't contain enough information to locate the + * revokeable output. */ -void ReplyChannelRange_set_sync_complete(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKCOption_usizeZ TrustedCommitmentTransaction_revokeable_output_index(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); /** - * The `short_channel_id`s in the channel range + * Helper method to build an unsigned justice transaction spending the revokeable + * `to_local` output to a destination script. Fee estimation accounts for the expected + * revocation witness data that will be added when signed. * - * Returns a copy of the field. + * This method will error if the given fee rate results in a fee greater than the value + * of the output being spent, or if there exists no revokeable `to_local` output on this + * commitment transaction. See [`Self::revokeable_output_index`] for more details. + * + * The built transaction will allow fee bumping with RBF, and this method takes + * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different + * fee rates may be built. */ -struct LDKCVec_u64Z ReplyChannelRange_get_short_channel_ids(const struct LDKReplyChannelRange *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_TransactionNoneZ TrustedCommitmentTransaction_build_to_local_justice_tx(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, uint64_t feerate_per_kw, struct LDKCVec_u8Z destination_script); /** - * The `short_channel_id`s in the channel range + * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a + * shared secret first. This prevents on-chain observers from discovering how many commitment + * transactions occurred in a channel before it was closed. + * + * This function gets the shared secret from relevant channel public keys and can be used to + * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. */ -void ReplyChannelRange_set_short_channel_ids(struct LDKReplyChannelRange *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); /** - * Constructs a new ReplyChannelRange given each field + * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read */ -MUST_USE_RES struct LDKReplyChannelRange ReplyChannelRange_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_blocknum_arg, uint32_t number_of_blocks_arg, bool sync_complete_arg, struct LDKCVec_u64Z short_channel_ids_arg); +struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); /** - * Creates a copy of the ReplyChannelRange + * Read a InitFeatures from a byte array, created by InitFeatures_write */ -struct LDKReplyChannelRange ReplyChannelRange_clone(const struct LDKReplyChannelRange *NONNULL_PTR orig); +struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); /** - * Generates a non-cryptographic 64-bit hash of the ReplyChannelRange. + * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read */ -uint64_t ReplyChannelRange_hash(const struct LDKReplyChannelRange *NONNULL_PTR o); +struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); /** - * Checks if two ReplyChannelRanges contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write */ -bool ReplyChannelRange_eq(const struct LDKReplyChannelRange *NONNULL_PTR a, const struct LDKReplyChannelRange *NONNULL_PTR b); +struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); /** - * Frees any resources used by the QueryShortChannelIds, if is_owned is set and inner is non-NULL. + * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read */ -void QueryShortChannelIds_free(struct LDKQueryShortChannelIds this_obj); +struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); /** - * The genesis hash of the blockchain being queried + * Read a NodeFeatures from a byte array, created by NodeFeatures_write */ -const uint8_t (*QueryShortChannelIds_get_chain_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain being queried + * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read */ -void QueryShortChannelIds_set_chain_hash(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); /** - * The short_channel_ids that are being queried - * - * Returns a copy of the field. + * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write */ -struct LDKCVec_u64Z QueryShortChannelIds_get_short_channel_ids(const struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr); +struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); /** - * The short_channel_ids that are being queried + * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read */ -void QueryShortChannelIds_set_short_channel_ids(struct LDKQueryShortChannelIds *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); /** - * Constructs a new QueryShortChannelIds given each field + * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write */ -MUST_USE_RES struct LDKQueryShortChannelIds QueryShortChannelIds_new(struct LDKThirtyTwoBytes chain_hash_arg, struct LDKCVec_u64Z short_channel_ids_arg); +struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); /** - * Creates a copy of the QueryShortChannelIds + * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read */ -struct LDKQueryShortChannelIds QueryShortChannelIds_clone(const struct LDKQueryShortChannelIds *NONNULL_PTR orig); +struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the QueryShortChannelIds. + * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write */ -uint64_t QueryShortChannelIds_hash(const struct LDKQueryShortChannelIds *NONNULL_PTR o); +struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); /** - * Checks if two QueryShortChannelIdss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read */ -bool QueryShortChannelIds_eq(const struct LDKQueryShortChannelIds *NONNULL_PTR a, const struct LDKQueryShortChannelIds *NONNULL_PTR b); +struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); /** - * Frees any resources used by the ReplyShortChannelIdsEnd, if is_owned is set and inner is non-NULL. + * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write */ -void ReplyShortChannelIdsEnd_free(struct LDKReplyShortChannelIdsEnd this_obj); +struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain that was queried + * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. */ -const uint8_t (*ReplyShortChannelIdsEnd_get_chain_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr))[32]; +void ShutdownScript_free(struct LDKShutdownScript this_obj); /** - * The genesis hash of the blockchain that was queried + * Creates a copy of the ShutdownScript */ -void ReplyShortChannelIdsEnd_set_chain_hash(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * Checks if two ShutdownScripts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -bool ReplyShortChannelIdsEnd_get_full_information(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr); +bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); /** - * Indicates if the query recipient maintains up-to-date channel - * information for the `chain_hash` + * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. */ -void ReplyShortChannelIdsEnd_set_full_information(struct LDKReplyShortChannelIdsEnd *NONNULL_PTR this_ptr, bool val); +void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); /** - * Constructs a new ReplyShortChannelIdsEnd given each field + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -MUST_USE_RES struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_new(struct LDKThirtyTwoBytes chain_hash_arg, bool full_information_arg); +struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); /** - * Creates a copy of the ReplyShortChannelIdsEnd + * The script that did not meet the requirements from [BOLT #2]. + * + * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md */ -struct LDKReplyShortChannelIdsEnd ReplyShortChannelIdsEnd_clone(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR orig); +void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Generates a non-cryptographic 64-bit hash of the ReplyShortChannelIdsEnd. + * Constructs a new InvalidShutdownScript given each field */ -uint64_t ReplyShortChannelIdsEnd_hash(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR o); +MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); /** - * Checks if two ReplyShortChannelIdsEnds contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the InvalidShutdownScript */ -bool ReplyShortChannelIdsEnd_eq(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR a, const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR b); +struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); /** - * Frees any resources used by the GossipTimestampFilter, if is_owned is set and inner is non-NULL. + * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read */ -void GossipTimestampFilter_free(struct LDKGossipTimestampFilter this_obj); +struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); /** - * The genesis hash of the blockchain for channel and node information + * Read a ShutdownScript from a byte array, created by ShutdownScript_write */ -const uint8_t (*GossipTimestampFilter_get_chain_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr))[32]; +struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); /** - * The genesis hash of the blockchain for channel and node information + * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. */ -void GossipTimestampFilter_set_chain_hash(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); /** - * The starting unix timestamp + * Generates a P2WSH script pubkey from the given [`WScriptHash`]. */ -uint32_t GossipTimestampFilter_get_first_timestamp(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); /** - * The starting unix timestamp + * Generates a witness script pubkey from the given segwit version and program. + * + * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or + * [`ShutdownScript::new_p2wsh`] instead. + * + * # Errors + * + * This function may return an error if `program` is invalid for the segwit `version`. */ -void GossipTimestampFilter_set_first_timestamp(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); /** - * The range of information in seconds + * Converts the shutdown script into the underlying [`ScriptBuf`]. */ -uint32_t GossipTimestampFilter_get_timestamp_range(const struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); /** - * The range of information in seconds + * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void GossipTimestampFilter_set_timestamp_range(struct LDKGossipTimestampFilter *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); /** - * Constructs a new GossipTimestampFilter given each field + * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. + * + * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. */ -MUST_USE_RES struct LDKGossipTimestampFilter GossipTimestampFilter_new(struct LDKThirtyTwoBytes chain_hash_arg, uint32_t first_timestamp_arg, uint32_t timestamp_range_arg); +MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); /** - * Creates a copy of the GossipTimestampFilter + * Get the string representation of a ShutdownScript object */ -struct LDKGossipTimestampFilter GossipTimestampFilter_clone(const struct LDKGossipTimestampFilter *NONNULL_PTR orig); +struct LDKStr ShutdownScript_to_str(const struct LDKShutdownScript *NONNULL_PTR o); /** - * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter. + * Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. */ -uint64_t GossipTimestampFilter_hash(const struct LDKGossipTimestampFilter *NONNULL_PTR o); +void ChannelId_free(struct LDKChannelId this_obj); -/** - * Checks if two GossipTimestampFilters contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ -bool GossipTimestampFilter_eq(const struct LDKGossipTimestampFilter *NONNULL_PTR a, const struct LDKGossipTimestampFilter *NONNULL_PTR b); +const uint8_t (*ChannelId_get_a(const struct LDKChannelId *NONNULL_PTR this_ptr))[32]; -/** - * Frees any resources used by the ErrorAction - */ -void ErrorAction_free(struct LDKErrorAction this_ptr); +void ChannelId_set_a(struct LDKChannelId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Creates a copy of the ErrorAction + * Constructs a new ChannelId given each field */ -struct LDKErrorAction ErrorAction_clone(const struct LDKErrorAction *NONNULL_PTR orig); +MUST_USE_RES struct LDKChannelId ChannelId_new(struct LDKThirtyTwoBytes a_arg); /** - * Utility method to constructs a new DisconnectPeer-variant ErrorAction + * Creates a copy of the ChannelId */ -struct LDKErrorAction ErrorAction_disconnect_peer(struct LDKErrorMessage msg); +struct LDKChannelId ChannelId_clone(const struct LDKChannelId *NONNULL_PTR orig); /** - * Utility method to constructs a new DisconnectPeerWithWarning-variant ErrorAction + * Checks if two ChannelIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKErrorAction ErrorAction_disconnect_peer_with_warning(struct LDKWarningMessage msg); +bool ChannelId_eq(const struct LDKChannelId *NONNULL_PTR a, const struct LDKChannelId *NONNULL_PTR b); /** - * Utility method to constructs a new IgnoreError-variant ErrorAction + * Generates a non-cryptographic 64-bit hash of the ChannelId. */ -struct LDKErrorAction ErrorAction_ignore_error(void); +uint64_t ChannelId_hash(const struct LDKChannelId *NONNULL_PTR o); /** - * Utility method to constructs a new IgnoreAndLog-variant ErrorAction + * Create _v1_ channel ID based on a funding TX ID and output index */ -struct LDKErrorAction ErrorAction_ignore_and_log(enum LDKLevel a); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_txid(const uint8_t (*txid)[32], uint16_t output_index); /** - * Utility method to constructs a new IgnoreDuplicateGossip-variant ErrorAction + * Create _v1_ channel ID from a funding tx outpoint */ -struct LDKErrorAction ErrorAction_ignore_duplicate_gossip(void); +MUST_USE_RES struct LDKChannelId ChannelId_v1_from_funding_outpoint(struct LDKOutPoint outpoint); /** - * Utility method to constructs a new SendErrorMessage-variant ErrorAction + * Create a _temporary_ channel ID randomly, based on an entropy source. */ -struct LDKErrorAction ErrorAction_send_error_message(struct LDKErrorMessage msg); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_from_entropy_source(const struct LDKEntropySource *NONNULL_PTR entropy_source); /** - * Utility method to constructs a new SendWarningMessage-variant ErrorAction + * Generic constructor; create a new channel ID from the provided data. + * Use a more specific `*_from_*` constructor when possible. */ -struct LDKErrorAction ErrorAction_send_warning_message(struct LDKWarningMessage msg, enum LDKLevel log_level); +MUST_USE_RES struct LDKChannelId ChannelId_from_bytes(struct LDKThirtyTwoBytes data); /** - * Generates a non-cryptographic 64-bit hash of the ErrorAction. + * Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). */ -uint64_t ErrorAction_hash(const struct LDKErrorAction *NONNULL_PTR o); +MUST_USE_RES struct LDKChannelId ChannelId_new_zero(void); /** - * Frees any resources used by the LightningError, if is_owned is set and inner is non-NULL. + * Check whether ID is consisting of all zeros (uninitialized) */ -void LightningError_free(struct LDKLightningError this_obj); +MUST_USE_RES bool ChannelId_is_zero(const struct LDKChannelId *NONNULL_PTR this_arg); /** - * A human-readable message describing the error + * Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty + * revocation basepoint and hashing the result. The basepoints will be concatenated in increasing + * sorted order. */ -struct LDKStr LightningError_get_err(const struct LDKLightningError *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelId ChannelId_v2_from_revocation_basepoints(const struct LDKRevocationBasepoint *NONNULL_PTR ours, const struct LDKRevocationBasepoint *NONNULL_PTR theirs); /** - * A human-readable message describing the error + * Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder + * revocation basepoint and hashing the result. */ -void LightningError_set_err(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKStr val); +MUST_USE_RES struct LDKChannelId ChannelId_temporary_v2_from_revocation_basepoint(const struct LDKRevocationBasepoint *NONNULL_PTR our_revocation_basepoint); /** - * The action which should be taken against the offending peer. + * Serialize the ChannelId object into a byte array which can be read by ChannelId_read */ -struct LDKErrorAction LightningError_get_action(const struct LDKLightningError *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ChannelId_write(const struct LDKChannelId *NONNULL_PTR obj); /** - * The action which should be taken against the offending peer. + * Read a ChannelId from a byte array, created by ChannelId_write */ -void LightningError_set_action(struct LDKLightningError *NONNULL_PTR this_ptr, struct LDKErrorAction val); +struct LDKCResult_ChannelIdDecodeErrorZ ChannelId_read(struct LDKu8slice ser); /** - * Constructs a new LightningError given each field + * Get the string representation of a ChannelId object */ -MUST_USE_RES struct LDKLightningError LightningError_new(struct LDKStr err_arg, struct LDKErrorAction action_arg); +struct LDKStr ChannelId_to_str(const struct LDKChannelId *NONNULL_PTR o); /** - * Creates a copy of the LightningError + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice + * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared + * down + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * `duration_since_epoch` is the current time since epoch in seconds. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + * + * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. */ -struct LDKLightningError LightningError_clone(const struct LDKLightningError *NONNULL_PTR orig); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** - * Frees any resources used by the CommitmentUpdate, if is_owned is set and inner is non-NULL. + * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" + * See [`PhantomKeysManager`] for more information on phantom node payments. + * + * `phantom_route_hints` parameter: + * * Contains channel info for all nodes participating in the phantom invoice + * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each + * participating node + * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is + * updated when a channel becomes disabled or closes + * * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum + * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected + * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node + * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as + * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. + * + * `description_hash` is a SHA-256 hash of the description text + * + * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference + * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). + * If `None` is provided for `payment_hash`, then one will be created. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * `duration_since_epoch` is the current time since epoch in seconds. + * + * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom + * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this + * requirement). + * + * [`PhantomKeysManager`]: crate::sign::PhantomKeysManager + * [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints + * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment + * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash + * [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels + * + * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. */ -void CommitmentUpdate_free(struct LDKCommitmentUpdate this_obj); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); /** - * `update_add_htlc` messages which should be sent + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -struct LDKCVec_UpdateAddHTLCZ CommitmentUpdate_get_update_add_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * `update_add_htlc` messages which should be sent + * Utility to construct an invoice. Generally, unless you want to do something like a custom + * cltv_expiry, this is what you should be using to create an invoice. The reason being, this + * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user + * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify + * that the payment secret is valid when the invoice is paid. + * Use this variant if you want to pass the `description_hash` to the invoice. + * + * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for + * in excess of the current time. + * + * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to + * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. + * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block + * confirmations during routing. + * + * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA */ -void CommitmentUpdate_set_update_add_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateAddHTLCZ val); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * `update_fulfill_htlc` messages which should be sent + * See [`create_invoice_from_channelmanager_with_description_hash`] + * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. */ -struct LDKCVec_UpdateFulfillHTLCZ CommitmentUpdate_get_update_fulfill_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * `update_fulfill_htlc` messages which should be sent + * See [`create_invoice_from_channelmanager`] + * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not + * available and the current time is supplied by the caller. */ -void CommitmentUpdate_set_update_fulfill_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFulfillHTLCZ val); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * `update_fail_htlc` messages which should be sent + * See [`create_invoice_from_channelmanager_and_duration_since_epoch`] + * This version allows for providing a custom [`PaymentHash`] for the invoice. + * This may be useful if you're building an on-chain swap or involving another protocol where + * the payment hash is also involved outside the scope of lightning. */ -struct LDKCVec_UpdateFailHTLCZ CommitmentUpdate_get_update_fail_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); /** - * `update_fail_htlc` messages which should be sent + * Builds the necessary parameters to pay or pre-flight probe the given zero-amount + * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or + * [`ChannelManager::send_preflight_probes`]. + * + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. + * + * Will always succeed unless the invoice has an amount specified, in which case + * [`payment_parameters_from_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -void CommitmentUpdate_set_update_fail_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailHTLCZ val); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); /** - * `update_fail_malformed_htlc` messages which should be sent + * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using + * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. + * + * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the + * same [`PaymentHash`] has never been paid before. + * + * Will always succeed unless the invoice has no amount specified, in which case + * [`payment_parameters_from_zero_amount_invoice`] should be used. + * + * [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment + * [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes */ -struct LDKCVec_UpdateFailMalformedHTLCZ CommitmentUpdate_get_update_fail_malformed_htlcs(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); /** - * `update_fail_malformed_htlc` messages which should be sent + * Frees any resources used by the Retry */ -void CommitmentUpdate_set_update_fail_malformed_htlcs(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCVec_UpdateFailMalformedHTLCZ val); +void Retry_free(struct LDKRetry this_ptr); /** - * An `update_fee` message which should be sent - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the Retry */ -struct LDKUpdateFee CommitmentUpdate_get_update_fee(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); /** - * An `update_fee` message which should be sent - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new Attempts-variant Retry */ -void CommitmentUpdate_set_update_fee(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKUpdateFee val); +struct LDKRetry Retry_attempts(uint32_t a); /** - * A `commitment_signed` message which should be sent + * Utility method to constructs a new Timeout-variant Retry */ -struct LDKCommitmentSigned CommitmentUpdate_get_commitment_signed(const struct LDKCommitmentUpdate *NONNULL_PTR this_ptr); +struct LDKRetry Retry_timeout(uint64_t a); /** - * A `commitment_signed` message which should be sent + * Checks if two Retrys contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void CommitmentUpdate_set_commitment_signed(struct LDKCommitmentUpdate *NONNULL_PTR this_ptr, struct LDKCommitmentSigned val); +bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); /** - * Constructs a new CommitmentUpdate given each field - * - * Note that update_fee_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the Retry. */ -MUST_USE_RES struct LDKCommitmentUpdate CommitmentUpdate_new(struct LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg, struct LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg, struct LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg, struct LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg, struct LDKUpdateFee update_fee_arg, struct LDKCommitmentSigned commitment_signed_arg); +uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); /** - * Creates a copy of the CommitmentUpdate + * Serialize the Retry object into a byte array which can be read by Retry_read */ -struct LDKCommitmentUpdate CommitmentUpdate_clone(const struct LDKCommitmentUpdate *NONNULL_PTR orig); +struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); /** - * Generates a non-cryptographic 64-bit hash of the CommitmentUpdate. + * Read a Retry from a byte array, created by Retry_write */ -uint64_t CommitmentUpdate_hash(const struct LDKCommitmentUpdate *NONNULL_PTR o); +struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); /** - * Checks if two CommitmentUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the RetryableSendFailure */ -bool CommitmentUpdate_eq(const struct LDKCommitmentUpdate *NONNULL_PTR a, const struct LDKCommitmentUpdate *NONNULL_PTR b); +enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure */ -void ChannelMessageHandler_free(struct LDKChannelMessageHandler this_ptr); +enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); /** - * Calls the free function if one is set + * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure */ -void RoutingMessageHandler_free(struct LDKRoutingMessageHandler this_ptr); +enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); /** - * Calls the free function if one is set + * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure */ -void OnionMessageHandler_free(struct LDKOnionMessageHandler this_ptr); +enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); /** - * Frees any resources used by the FinalOnionHopData, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure */ -void FinalOnionHopData_free(struct LDKFinalOnionHopData this_obj); +enum LDKRetryableSendFailure RetryableSendFailure_onion_packet_size_exceeded(void); /** - * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. - * Because it is generated by the recipient and included in the invoice, it also provides - * proof to the recipient that the payment was sent by someone with the generated invoice. + * Checks if two RetryableSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -const uint8_t (*FinalOnionHopData_get_payment_secret(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr))[32]; +bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); /** - * When sending a multi-part payment, this secret is used to identify a payment across HTLCs. - * Because it is generated by the recipient and included in the invoice, it also provides - * proof to the recipient that the payment was sent by someone with the generated invoice. + * Frees any resources used by the PaymentSendFailure */ -void FinalOnionHopData_set_payment_secret(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); /** - * The intended total amount that this payment is for. - * - * Message serialization may panic if this value is more than 21 million Bitcoin. + * Creates a copy of the PaymentSendFailure */ -uint64_t FinalOnionHopData_get_total_msat(const struct LDKFinalOnionHopData *NONNULL_PTR this_ptr); +struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); /** - * The intended total amount that this payment is for. - * - * Message serialization may panic if this value is more than 21 million Bitcoin. + * Utility method to constructs a new ParameterError-variant PaymentSendFailure */ -void FinalOnionHopData_set_total_msat(struct LDKFinalOnionHopData *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); /** - * Constructs a new FinalOnionHopData given each field + * Utility method to constructs a new PathParameterError-variant PaymentSendFailure */ -MUST_USE_RES struct LDKFinalOnionHopData FinalOnionHopData_new(struct LDKThirtyTwoBytes payment_secret_arg, uint64_t total_msat_arg); +struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); /** - * Creates a copy of the FinalOnionHopData + * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure */ -struct LDKFinalOnionHopData FinalOnionHopData_clone(const struct LDKFinalOnionHopData *NONNULL_PTR orig); +struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); /** - * Frees any resources used by the OnionPacket, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure */ -void OnionPacket_free(struct LDKOnionPacket this_obj); +struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); /** - * BOLT 4 version number. + * Utility method to constructs a new PartialFailure-variant PaymentSendFailure */ -uint8_t OnionPacket_get_version(const struct LDKOnionPacket *NONNULL_PTR this_ptr); +struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); /** - * BOLT 4 version number. + * Checks if two PaymentSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void OnionPacket_set_version(struct LDKOnionPacket *NONNULL_PTR this_ptr, uint8_t val); +bool PaymentSendFailure_eq(const struct LDKPaymentSendFailure *NONNULL_PTR a, const struct LDKPaymentSendFailure *NONNULL_PTR b); /** - * In order to ensure we always return an error on onion decode in compliance with [BOLT - * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to - * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral - * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd - * like. - * - * Returns a copy of the field. + * Frees any resources used by the Bolt12PaymentError */ -struct LDKCResult_PublicKeySecp256k1ErrorZ OnionPacket_get_public_key(const struct LDKOnionPacket *NONNULL_PTR this_ptr); +void Bolt12PaymentError_free(struct LDKBolt12PaymentError this_ptr); /** - * In order to ensure we always return an error on onion decode in compliance with [BOLT - * #4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md), we have to - * deserialize `OnionPacket`s contained in [`UpdateAddHTLC`] messages even if the ephemeral - * public key (here) is bogus, so we hold a [`Result`] instead of a [`PublicKey`] as we'd - * like. + * Creates a copy of the Bolt12PaymentError */ -void OnionPacket_set_public_key(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKCResult_PublicKeySecp256k1ErrorZ val); +struct LDKBolt12PaymentError Bolt12PaymentError_clone(const struct LDKBolt12PaymentError *NONNULL_PTR orig); /** - * HMAC to verify the integrity of hop_data. + * Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError */ -const uint8_t (*OnionPacket_get_hmac(const struct LDKOnionPacket *NONNULL_PTR this_ptr))[32]; +struct LDKBolt12PaymentError Bolt12PaymentError_unexpected_invoice(void); /** - * HMAC to verify the integrity of hop_data. + * Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError */ -void OnionPacket_set_hmac(struct LDKOnionPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKBolt12PaymentError Bolt12PaymentError_duplicate_invoice(void); /** - * Creates a copy of the OnionPacket + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError */ -struct LDKOnionPacket OnionPacket_clone(const struct LDKOnionPacket *NONNULL_PTR orig); +struct LDKBolt12PaymentError Bolt12PaymentError_unknown_required_features(void); /** - * Generates a non-cryptographic 64-bit hash of the OnionPacket. + * Utility method to constructs a new SendingFailed-variant Bolt12PaymentError */ -uint64_t OnionPacket_hash(const struct LDKOnionPacket *NONNULL_PTR o); +struct LDKBolt12PaymentError Bolt12PaymentError_sending_failed(enum LDKRetryableSendFailure a); /** - * Checks if two OnionPackets contain equal inner contents. + * Checks if two Bolt12PaymentErrors contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool OnionPacket_eq(const struct LDKOnionPacket *NONNULL_PTR a, const struct LDKOnionPacket *NONNULL_PTR b); +bool Bolt12PaymentError_eq(const struct LDKBolt12PaymentError *NONNULL_PTR a, const struct LDKBolt12PaymentError *NONNULL_PTR b); /** - * Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read + * Frees any resources used by the ProbeSendFailure */ -struct LDKCVec_u8Z AcceptChannel_write(const struct LDKAcceptChannel *NONNULL_PTR obj); +void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); /** - * Read a AcceptChannel from a byte array, created by AcceptChannel_write + * Creates a copy of the ProbeSendFailure */ -struct LDKCResult_AcceptChannelDecodeErrorZ AcceptChannel_read(struct LDKu8slice ser); +struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); /** - * Serialize the AcceptChannelV2 object into a byte array which can be read by AcceptChannelV2_read + * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure */ -struct LDKCVec_u8Z AcceptChannelV2_write(const struct LDKAcceptChannelV2 *NONNULL_PTR obj); +struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); /** - * Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write + * Utility method to constructs a new SendingFailed-variant ProbeSendFailure */ -struct LDKCResult_AcceptChannelV2DecodeErrorZ AcceptChannelV2_read(struct LDKu8slice ser); +struct LDKProbeSendFailure ProbeSendFailure_sending_failed(struct LDKPaymentSendFailure a); /** - * Serialize the Stfu object into a byte array which can be read by Stfu_read + * Checks if two ProbeSendFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z Stfu_write(const struct LDKStfu *NONNULL_PTR obj); +bool ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); /** - * Read a Stfu from a byte array, created by Stfu_write + * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_StfuDecodeErrorZ Stfu_read(struct LDKu8slice ser); +void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); /** - * Serialize the Splice object into a byte array which can be read by Splice_read + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -struct LDKCVec_u8Z Splice_write(const struct LDKSplice *NONNULL_PTR obj); +struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Read a Splice from a byte array, created by Splice_write + * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat + * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to + * authenticate the sender to the recipient and prevent payment-probing (deanonymization) + * attacks. + * + * If you do not have one, the [`Route`] you pay over must not contain multiple paths as + * multi-path payments require a recipient-provided secret. + * + * Some implementations may reject spontaneous payments with payment secrets, so you may only + * want to provide a secret for a spontaneous payment if MPP is needed and you know your + * recipient will not reject it. */ -struct LDKCResult_SpliceDecodeErrorZ Splice_read(struct LDKu8slice ser); +void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Serialize the SpliceAck object into a byte array which can be read by SpliceAck_read + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. + * + * Returns a copy of the field. */ -struct LDKCVec_u8Z SpliceAck_write(const struct LDKSpliceAck *NONNULL_PTR obj); +struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); /** - * Read a SpliceAck from a byte array, created by SpliceAck_write + * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of + * arbitrary length. This gives recipients substantially more flexibility to receive + * additional data. + * + * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication + * scheme to authenticate received payments against expected payments and invoices, this field + * is not used in LDK for received payments, and can be used to store arbitrary data in + * invoices which will be received with the payment. + * + * Note that this field was added to the lightning specification more recently than + * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata + * may not be supported as universally. */ -struct LDKCResult_SpliceAckDecodeErrorZ SpliceAck_read(struct LDKu8slice ser); +void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Serialize the SpliceLocked object into a byte array which can be read by SpliceLocked_read + * Creates a copy of the RecipientOnionFields */ -struct LDKCVec_u8Z SpliceLocked_write(const struct LDKSpliceLocked *NONNULL_PTR obj); +struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); /** - * Read a SpliceLocked from a byte array, created by SpliceLocked_write + * Checks if two RecipientOnionFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_SpliceLockedDecodeErrorZ SpliceLocked_read(struct LDKu8slice ser); +bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); /** - * Serialize the TxAddInput object into a byte array which can be read by TxAddInput_read + * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read */ -struct LDKCVec_u8Z TxAddInput_write(const struct LDKTxAddInput *NONNULL_PTR obj); +struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); /** - * Read a TxAddInput from a byte array, created by TxAddInput_write + * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write */ -struct LDKCResult_TxAddInputDecodeErrorZ TxAddInput_read(struct LDKu8slice ser); +struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); /** - * Serialize the TxAddOutput object into a byte array which can be read by TxAddOutput_read + * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common + * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] + * but do not require or provide any further data. */ -struct LDKCVec_u8Z TxAddOutput_write(const struct LDKTxAddOutput *NONNULL_PTR obj); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); /** - * Read a TxAddOutput from a byte array, created by TxAddOutput_write + * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create + * payable HTLCs except for single-path spontaneous payments, i.e. this should generally + * only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending + * a spontaneous MPP this will not work as all MPP require payment secrets; you may + * instead want to use [`RecipientOnionFields::secret_only`]. + * + * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment + * [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only */ -struct LDKCResult_TxAddOutputDecodeErrorZ TxAddOutput_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); /** - * Serialize the TxRemoveInput object into a byte array which can be read by TxRemoveInput_read + * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each + * TLV is provided as a `(u64, Vec)` for the type number and serialized value + * respectively. TLV type numbers must be unique and within the range + * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. + * + * This method will also error for types in the experimental range which have been + * standardized within the protocol, which only includes 5482373484 (keysend) for now. + * + * See [`Self::custom_tlvs`] for more info. */ -struct LDKCVec_u8Z TxRemoveInput_write(const struct LDKTxRemoveInput *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); /** - * Read a TxRemoveInput from a byte array, created by TxRemoveInput_write + * Gets the custom TLVs that will be sent or have been received. + * + * Custom TLVs allow sending extra application-specific data with a payment. They provide + * additional flexibility on top of payment metadata, as while other implementations may + * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs + * do not have this restriction. + * + * Note that if this field is non-empty, it will contain strictly increasing TLVs, each + * represented by a `(u64, Vec)` for its type number and serialized value respectively. + * This is validated when setting this field using [`Self::with_custom_tlvs`]. */ -struct LDKCResult_TxRemoveInputDecodeErrorZ TxRemoveInput_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); /** - * Serialize the TxRemoveOutput object into a byte array which can be read by TxRemoveOutput_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z TxRemoveOutput_write(const struct LDKTxRemoveOutput *NONNULL_PTR obj); +void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); /** - * Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write + * Creates a copy of a Type */ -struct LDKCResult_TxRemoveOutputDecodeErrorZ TxRemoveOutput_read(struct LDKu8slice ser); +struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); /** - * Serialize the TxComplete object into a byte array which can be read by TxComplete_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z TxComplete_write(const struct LDKTxComplete *NONNULL_PTR obj); +void Type_free(struct LDKType this_ptr); /** - * Read a TxComplete from a byte array, created by TxComplete_write + * Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_TxCompleteDecodeErrorZ TxComplete_read(struct LDKu8slice ser); +void OfferId_free(struct LDKOfferId this_obj); + +const uint8_t (*OfferId_get_a(const struct LDKOfferId *NONNULL_PTR this_ptr))[32]; + +void OfferId_set_a(struct LDKOfferId *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the TxSignatures object into a byte array which can be read by TxSignatures_read + * Constructs a new OfferId given each field */ -struct LDKCVec_u8Z TxSignatures_write(const struct LDKTxSignatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferId OfferId_new(struct LDKThirtyTwoBytes a_arg); /** - * Read a TxSignatures from a byte array, created by TxSignatures_write + * Creates a copy of the OfferId */ -struct LDKCResult_TxSignaturesDecodeErrorZ TxSignatures_read(struct LDKu8slice ser); +struct LDKOfferId OfferId_clone(const struct LDKOfferId *NONNULL_PTR orig); /** - * Serialize the TxInitRbf object into a byte array which can be read by TxInitRbf_read + * Checks if two OfferIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCVec_u8Z TxInitRbf_write(const struct LDKTxInitRbf *NONNULL_PTR obj); +bool OfferId_eq(const struct LDKOfferId *NONNULL_PTR a, const struct LDKOfferId *NONNULL_PTR b); /** - * Read a TxInitRbf from a byte array, created by TxInitRbf_write + * Serialize the OfferId object into a byte array which can be read by OfferId_read */ -struct LDKCResult_TxInitRbfDecodeErrorZ TxInitRbf_read(struct LDKu8slice ser); +struct LDKCVec_u8Z OfferId_write(const struct LDKOfferId *NONNULL_PTR obj); /** - * Serialize the TxAckRbf object into a byte array which can be read by TxAckRbf_read + * Read a OfferId from a byte array, created by OfferId_write */ -struct LDKCVec_u8Z TxAckRbf_write(const struct LDKTxAckRbf *NONNULL_PTR obj); +struct LDKCResult_OfferIdDecodeErrorZ OfferId_read(struct LDKu8slice ser); /** - * Read a TxAckRbf from a byte array, created by TxAckRbf_write + * Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_TxAckRbfDecodeErrorZ TxAckRbf_read(struct LDKu8slice ser); +void OfferWithExplicitMetadataBuilder_free(struct LDKOfferWithExplicitMetadataBuilder this_obj); /** - * Serialize the TxAbort object into a byte array which can be read by TxAbort_read + * Creates a copy of the OfferWithExplicitMetadataBuilder */ -struct LDKCVec_u8Z TxAbort_write(const struct LDKTxAbort *NONNULL_PTR obj); +struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_clone(const struct LDKOfferWithExplicitMetadataBuilder *NONNULL_PTR orig); /** - * Read a TxAbort from a byte array, created by TxAbort_write + * Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_TxAbortDecodeErrorZ TxAbort_read(struct LDKu8slice ser); +void OfferWithDerivedMetadataBuilder_free(struct LDKOfferWithDerivedMetadataBuilder this_obj); /** - * Serialize the AnnouncementSignatures object into a byte array which can be read by AnnouncementSignatures_read + * Creates a copy of the OfferWithDerivedMetadataBuilder */ -struct LDKCVec_u8Z AnnouncementSignatures_write(const struct LDKAnnouncementSignatures *NONNULL_PTR obj); +struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_clone(const struct LDKOfferWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write + * Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices. + * The associated secret key must be remembered while the offer is valid. + * + * Use a different pubkey per offer to avoid correlating offers. + * + * # Note + * + * If constructing an [`Offer`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder */ -struct LDKCResult_AnnouncementSignaturesDecodeErrorZ AnnouncementSignatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferWithExplicitMetadataBuilder OfferWithExplicitMetadataBuilder_new(struct LDKPublicKey signing_pubkey); /** - * Serialize the ChannelReestablish object into a byte array which can be read by ChannelReestablish_read + * Sets the [`Offer::metadata`] to the given bytes. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ChannelReestablish_write(const struct LDKChannelReestablish *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_metadata(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKCVec_u8Z metadata); /** - * Read a ChannelReestablish from a byte array, created by ChannelReestablish_write + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -struct LDKCResult_ChannelReestablishDecodeErrorZ ChannelReestablish_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_chain(struct LDKOfferWithExplicitMetadataBuilder this_arg, enum LDKNetwork network); /** - * Serialize the ClosingSigned object into a byte array which can be read by ClosingSigned_read + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ClosingSigned_write(const struct LDKClosingSigned *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_amount_msats(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t amount_msats); /** - * Read a ClosingSigned from a byte array, created by ClosingSigned_write + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_ClosingSignedDecodeErrorZ ClosingSigned_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_absolute_expiry(struct LDKOfferWithExplicitMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Serialize the ClosingSignedFeeRange object into a byte array which can be read by ClosingSignedFeeRange_read + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ClosingSignedFeeRange_write(const struct LDKClosingSignedFeeRange *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_description(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr description); /** - * Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_ClosingSignedFeeRangeDecodeErrorZ ClosingSignedFeeRange_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_issuer(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKStr issuer); /** - * Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -struct LDKCVec_u8Z CommitmentSigned_write(const struct LDKCommitmentSigned *NONNULL_PTR obj); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_path(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Read a CommitmentSigned from a byte array, created by CommitmentSigned_write + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_CommitmentSignedDecodeErrorZ CommitmentSigned_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithExplicitMetadataBuilder_supported_quantity(struct LDKOfferWithExplicitMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Serialize the FundingCreated object into a byte array which can be read by FundingCreated_read + * Builds an [`Offer`] from the builder's settings. */ -struct LDKCVec_u8Z FundingCreated_write(const struct LDKFundingCreated *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithExplicitMetadataBuilder_build(struct LDKOfferWithExplicitMetadataBuilder this_arg); /** - * Read a FundingCreated from a byte array, created by FundingCreated_write + * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing + * pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient + * privacy by using a different signing pubkey for each offer. Otherwise, the provided + * `node_id` is used for the signing pubkey. + * + * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by + * [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the + * offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the + * metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, + * use [`InvoiceRequest::verify_using_recipient_data`]. + * + * [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata + * [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -struct LDKCResult_FundingCreatedDecodeErrorZ FundingCreated_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKOfferWithDerivedMetadataBuilder OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce); /** - * Serialize the FundingSigned object into a byte array which can be read by FundingSigned_read + * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, + * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. + * + * See [`Offer::chains`] on how this relates to the payment currency. + * + * Successive calls to this method will add another chain hash. */ -struct LDKCVec_u8Z FundingSigned_write(const struct LDKFundingSigned *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_chain(struct LDKOfferWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * Read a FundingSigned from a byte array, created by FundingSigned_write + * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_FundingSignedDecodeErrorZ FundingSigned_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_amount_msats(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t amount_msats); /** - * Serialize the ChannelReady object into a byte array which can be read by ChannelReady_read + * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Offer::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ChannelReady_write(const struct LDKChannelReady *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_absolute_expiry(struct LDKOfferWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); /** - * Read a ChannelReady from a byte array, created by ChannelReady_write + * Sets the [`Offer::description`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCResult_ChannelReadyDecodeErrorZ ChannelReady_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_description(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Serialize the Init object into a byte array which can be read by Init_read + * Sets the [`Offer::issuer`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z Init_write(const struct LDKInit *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_issuer(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Read a Init from a byte array, created by Init_write + * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by + * private channels or if [`Offer::signing_pubkey`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -struct LDKCResult_InitDecodeErrorZ Init_read(struct LDKu8slice ser); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_path(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * Serialize the OpenChannel object into a byte array which can be read by OpenChannel_read + * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to + * [`Quantity::One`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z OpenChannel_write(const struct LDKOpenChannel *NONNULL_PTR obj); +MUST_USE_RES void OfferWithDerivedMetadataBuilder_supported_quantity(struct LDKOfferWithDerivedMetadataBuilder this_arg, struct LDKQuantity quantity); /** - * Read a OpenChannel from a byte array, created by OpenChannel_write + * Builds an [`Offer`] from the builder's settings. */ -struct LDKCResult_OpenChannelDecodeErrorZ OpenChannel_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_OfferBolt12SemanticErrorZ OfferWithDerivedMetadataBuilder_build(struct LDKOfferWithDerivedMetadataBuilder this_arg); /** - * Serialize the OpenChannelV2 object into a byte array which can be read by OpenChannelV2_read + * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z OpenChannelV2_write(const struct LDKOpenChannelV2 *NONNULL_PTR obj); +void Offer_free(struct LDKOffer this_obj); /** - * Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write + * Creates a copy of the Offer */ -struct LDKCResult_OpenChannelV2DecodeErrorZ OpenChannelV2_read(struct LDKu8slice ser); +struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); /** - * Serialize the RevokeAndACK object into a byte array which can be read by RevokeAndACK_read + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKCVec_u8Z RevokeAndACK_write(const struct LDKRevokeAndACK *NONNULL_PTR obj); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a RevokeAndACK from a byte array, created by RevokeAndACK_write + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -struct LDKCResult_RevokeAndACKDecodeErrorZ RevokeAndACK_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Serialize the Shutdown object into a byte array which can be read by Shutdown_read + * The minimum amount required for a successful payment of a single item. */ -struct LDKCVec_u8Z Shutdown_write(const struct LDKShutdown *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_AmountZ Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a Shutdown from a byte array, created by Shutdown_write + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_ShutdownDecodeErrorZ Shutdown_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Serialize the UpdateFailHTLC object into a byte array which can be read by UpdateFailHTLC_read + * Features pertaining to the offer. */ -struct LDKCVec_u8Z UpdateFailHTLC_write(const struct LDKUpdateFailHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -struct LDKCResult_UpdateFailHTLCDecodeErrorZ UpdateFailHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Serialize the UpdateFailMalformedHTLC object into a byte array which can be read by UpdateFailMalformedHTLC_read + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z UpdateFailMalformedHTLC_write(const struct LDKUpdateFailMalformedHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -struct LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ UpdateFailMalformedHTLC_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Serialize the UpdateFee object into a byte array which can be read by UpdateFee_read + * The quantity of items supported. */ -struct LDKCVec_u8Z UpdateFee_write(const struct LDKUpdateFee *NONNULL_PTR obj); +MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a UpdateFee from a byte array, created by UpdateFee_write + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_UpdateFeeDecodeErrorZ UpdateFee_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Serialize the UpdateFulfillHTLC object into a byte array which can be read by UpdateFulfillHTLC_read + * Returns the id of the offer. */ -struct LDKCVec_u8Z UpdateFulfillHTLC_write(const struct LDKUpdateFulfillHTLC *NONNULL_PTR obj); +MUST_USE_RES struct LDKOfferId Offer_id(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write + * Returns whether the given chain is supported by the offer. */ -struct LDKCResult_UpdateFulfillHTLCDecodeErrorZ UpdateFulfillHTLC_read(struct LDKu8slice ser); +MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); /** - * Serialize the OnionPacket object into a byte array which can be read by OnionPacket_read + * Whether the offer has expired. */ -struct LDKCVec_u8Z OnionPacket_write(const struct LDKOnionPacket *NONNULL_PTR obj); +MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a OnionPacket from a byte array, created by OnionPacket_write + * Whether the offer has expired given the duration since the Unix epoch. */ -struct LDKCResult_OnionPacketDecodeErrorZ OnionPacket_read(struct LDKu8slice ser); +MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * Serialize the UpdateAddHTLC object into a byte array which can be read by UpdateAddHTLC_read + * Returns whether the given quantity is valid for the offer. */ -struct LDKCVec_u8Z UpdateAddHTLC_write(const struct LDKUpdateAddHTLC *NONNULL_PTR obj); +MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); /** - * Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write + * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -struct LDKCResult_UpdateAddHTLCDecodeErrorZ UpdateAddHTLC_read(struct LDKu8slice ser); +MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); /** - * Read a OnionMessage from a byte array, created by OnionMessage_write + * Similar to [`Offer::request_invoice`] except it: + * - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each + * request, + * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called + * such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the + * invoice was requested using a base [`ExpandedKey`] from which the payer id was derived, + * and + * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can + * be used when sending the payment for the requested invoice. + * + * Useful to protect the sender's privacy. + * + * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id + * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -struct LDKCResult_OnionMessageDecodeErrorZ OnionMessage_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_payer_id(const struct LDKOffer *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); /** - * Serialize the OnionMessage object into a byte array which can be read by OnionMessage_read + * Similar to [`Offer::request_invoice_deriving_payer_id`] except uses `payer_id` for the + * [`InvoiceRequest::payer_id`] instead of deriving a different key for each request. + * + * Useful for recurring payments using the same `payer_id` with different invoices. + * + * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id */ -struct LDKCVec_u8Z OnionMessage_write(const struct LDKOnionMessage *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice_deriving_metadata(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKPublicKey payer_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, struct LDKThirtyTwoBytes payment_id); /** - * Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read + * Creates an [`InvoiceRequestBuilder`] for the offer with the given `metadata` and `payer_id`, + * which will be reflected in the `Bolt12Invoice` response. + * + * The `metadata` is useful for including information about the derivation of `payer_id` such + * that invoice response handling can be stateless. Also serves as payer-provided entropy while + * hashing in the signature calculation. + * + * This should not leak any information such as by using a simple BIP-32 derivation path. + * Otherwise, payments may be correlated. + * + * Errors if the offer contains unknown required features. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest */ -struct LDKCVec_u8Z FinalOnionHopData_write(const struct LDKFinalOnionHopData *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ Offer_request_invoice(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id); /** - * Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write + * Generates a non-cryptographic 64-bit hash of the Offer. */ -struct LDKCResult_FinalOnionHopDataDecodeErrorZ FinalOnionHopData_read(struct LDKu8slice ser); +uint64_t Offer_hash(const struct LDKOffer *NONNULL_PTR o); /** - * Serialize the Ping object into a byte array which can be read by Ping_read + * Read a Offer from a byte array, created by Offer_write */ -struct LDKCVec_u8Z Ping_write(const struct LDKPing *NONNULL_PTR obj); +struct LDKCResult_OfferDecodeErrorZ Offer_read(struct LDKu8slice ser); /** - * Read a Ping from a byte array, created by Ping_write + * Serialize the Offer object into a byte array which can be read by Offer_read */ -struct LDKCResult_PingDecodeErrorZ Ping_read(struct LDKu8slice ser); +struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); /** - * Serialize the Pong object into a byte array which can be read by Pong_read + * Frees any resources used by the Amount */ -struct LDKCVec_u8Z Pong_write(const struct LDKPong *NONNULL_PTR obj); +void Amount_free(struct LDKAmount this_ptr); /** - * Read a Pong from a byte array, created by Pong_write + * Creates a copy of the Amount */ -struct LDKCResult_PongDecodeErrorZ Pong_read(struct LDKu8slice ser); +struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); /** - * Serialize the UnsignedChannelAnnouncement object into a byte array which can be read by UnsignedChannelAnnouncement_read + * Utility method to constructs a new Bitcoin-variant Amount */ -struct LDKCVec_u8Z UnsignedChannelAnnouncement_write(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR obj); +struct LDKAmount Amount_bitcoin(uint64_t amount_msats); /** - * Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write + * Utility method to constructs a new Currency-variant Amount */ -struct LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ UnsignedChannelAnnouncement_read(struct LDKu8slice ser); +struct LDKAmount Amount_currency(struct LDKThreeBytes iso4217_code, uint64_t amount); /** - * Serialize the ChannelAnnouncement object into a byte array which can be read by ChannelAnnouncement_read + * Frees any resources used by the Quantity */ -struct LDKCVec_u8Z ChannelAnnouncement_write(const struct LDKChannelAnnouncement *NONNULL_PTR obj); +void Quantity_free(struct LDKQuantity this_ptr); /** - * Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write + * Creates a copy of the Quantity */ -struct LDKCResult_ChannelAnnouncementDecodeErrorZ ChannelAnnouncement_read(struct LDKu8slice ser); +struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); /** - * Serialize the UnsignedChannelUpdate object into a byte array which can be read by UnsignedChannelUpdate_read + * Utility method to constructs a new Bounded-variant Quantity */ -struct LDKCVec_u8Z UnsignedChannelUpdate_write(const struct LDKUnsignedChannelUpdate *NONNULL_PTR obj); +struct LDKQuantity Quantity_bounded(uint64_t a); /** - * Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write + * Utility method to constructs a new Unbounded-variant Quantity */ -struct LDKCResult_UnsignedChannelUpdateDecodeErrorZ UnsignedChannelUpdate_read(struct LDKu8slice ser); +struct LDKQuantity Quantity_unbounded(void); /** - * Serialize the ChannelUpdate object into a byte array which can be read by ChannelUpdate_read + * Utility method to constructs a new One-variant Quantity */ -struct LDKCVec_u8Z ChannelUpdate_write(const struct LDKChannelUpdate *NONNULL_PTR obj); +struct LDKQuantity Quantity_one(void); /** - * Read a ChannelUpdate from a byte array, created by ChannelUpdate_write + * Read a Offer object from a string */ -struct LDKCResult_ChannelUpdateDecodeErrorZ ChannelUpdate_read(struct LDKu8slice ser); +struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); /** - * Serialize the ErrorMessage object into a byte array which can be read by ErrorMessage_read + * Get the string representation of a Offer object */ -struct LDKCVec_u8Z ErrorMessage_write(const struct LDKErrorMessage *NONNULL_PTR obj); +struct LDKStr Offer_to_str(const struct LDKOffer *NONNULL_PTR o); /** - * Read a ErrorMessage from a byte array, created by ErrorMessage_write + * Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ErrorMessageDecodeErrorZ ErrorMessage_read(struct LDKu8slice ser); +void InvoiceWithExplicitSigningPubkeyBuilder_free(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_obj); /** - * Serialize the WarningMessage object into a byte array which can be read by WarningMessage_read + * Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z WarningMessage_write(const struct LDKWarningMessage *NONNULL_PTR obj); +void InvoiceWithDerivedSigningPubkeyBuilder_free(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_obj); /** - * Read a WarningMessage from a byte array, created by WarningMessage_write + * Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by + * [`UnsignedBolt12Invoice::sign`]. */ -struct LDKCResult_WarningMessageDecodeErrorZ WarningMessage_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ InvoiceWithExplicitSigningPubkeyBuilder_build(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Serialize the UnsignedNodeAnnouncement object into a byte array which can be read by UnsignedNodeAnnouncement_read + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z UnsignedNodeAnnouncement_write(const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -struct LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ UnsignedNodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Serialize the NodeAnnouncement object into a byte array which can be read by NodeAnnouncement_read + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -struct LDKCVec_u8Z NodeAnnouncement_write(const struct LDKNodeAnnouncement *NONNULL_PTR obj); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -struct LDKCResult_NodeAnnouncementDecodeErrorZ NodeAnnouncement_read(struct LDKu8slice ser); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Read a QueryShortChannelIds from a byte array, created by QueryShortChannelIds_write + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -struct LDKCResult_QueryShortChannelIdsDecodeErrorZ QueryShortChannelIds_read(struct LDKu8slice ser); +MUST_USE_RES void InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithExplicitSigningPubkeyBuilder this_arg); /** - * Serialize the QueryShortChannelIds object into a byte array which can be read by QueryShortChannelIds_read + * Builds a signed [`Bolt12Invoice`] after checking for valid semantics. */ -struct LDKCVec_u8Z QueryShortChannelIds_write(const struct LDKQueryShortChannelIds *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read + *Sets the [`Bolt12Invoice::relative_expiry`] + *as seconds since [`Bolt12Invoice::created_at`]. + *Any expiry that has already passed is valid and can be checked for using + *[`Bolt12Invoice::is_expired`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKCVec_u8Z ReplyShortChannelIdsEnd_write(const struct LDKReplyShortChannelIdsEnd *NONNULL_PTR obj); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, uint32_t relative_expiry_secs); /** - * Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write + *Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. */ -struct LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ ReplyShortChannelIdsEnd_read(struct LDKu8slice ser); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*script_hash)[32]); /** - * Calculates the overflow safe ending block height for the query. + *Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. * - * Overflow returns `0xffffffff`, otherwise returns `first_blocknum + number_of_blocks`. + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. */ -MUST_USE_RES uint32_t QueryChannelRange_end_blocknum(const struct LDKQueryChannelRange *NONNULL_PTR this_arg); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, const uint8_t (*pubkey_hash)[20]); /** - * Serialize the QueryChannelRange object into a byte array which can be read by QueryChannelRange_read + *Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. + * + * Successive calls to this method will add another address. Caller is responsible for not + * adding duplicate addresses and only calling if capable of receiving to P2TR addresses. */ -struct LDKCVec_u8Z QueryChannelRange_write(const struct LDKQueryChannelRange *NONNULL_PTR obj); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg, struct LDKTweakedPublicKey output_key); /** - * Read a QueryChannelRange from a byte array, created by QueryChannelRange_write + *Sets [`Bolt12Invoice::invoice_features`] + *to indicate MPP may be used. Otherwise, MPP is disallowed. */ -struct LDKCResult_QueryChannelRangeDecodeErrorZ QueryChannelRange_read(struct LDKu8slice ser); +MUST_USE_RES void InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(struct LDKInvoiceWithDerivedSigningPubkeyBuilder this_arg); /** - * Read a ReplyChannelRange from a byte array, created by ReplyChannelRange_write + * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ReplyChannelRangeDecodeErrorZ ReplyChannelRange_read(struct LDKu8slice ser); +void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); /** - * Serialize the ReplyChannelRange object into a byte array which can be read by ReplyChannelRange_read + * Creates a copy of the UnsignedBolt12Invoice */ -struct LDKCVec_u8Z ReplyChannelRange_write(const struct LDKReplyChannelRange *NONNULL_PTR obj); +struct LDKUnsignedBolt12Invoice UnsignedBolt12Invoice_clone(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR orig); /** - * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + * Calls the free function if one is set */ -struct LDKCVec_u8Z GossipTimestampFilter_write(const struct LDKGossipTimestampFilter *NONNULL_PTR obj); +void SignBolt12InvoiceFn_free(struct LDKSignBolt12InvoiceFn this_ptr); /** - * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + * Returns the [`TaggedHash`] of the invoice to sign. */ -struct LDKCResult_GossipTimestampFilterDecodeErrorZ GossipTimestampFilter_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. */ -void CustomMessageHandler_free(struct LDKCustomMessageHandler this_ptr); +void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); /** - * Frees any resources used by the IgnoringMessageHandler, if is_owned is set and inner is non-NULL. + * Creates a copy of the Bolt12Invoice */ -void IgnoringMessageHandler_free(struct LDKIgnoringMessageHandler this_obj); +struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); /** - * Constructs a new IgnoringMessageHandler given each field + * Duration since the Unix epoch when the invoice was created. */ -MUST_USE_RES struct LDKIgnoringMessageHandler IgnoringMessageHandler_new(void); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new EventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is + * Duration since + *[`Bolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -struct LDKEventsProvider IgnoringMessageHandler_as_EventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Whether the invoice has expired. */ -struct LDKMessageSendEventsProvider IgnoringMessageHandler_as_MessageSendEventsProvider(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -struct LDKRoutingMessageHandler IgnoringMessageHandler_as_RoutingMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_StrZ UnsignedBolt12Invoice_fallbacks(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + * Features pertaining to paying an invoice. */ -struct LDKOnionMessageHandler IgnoringMessageHandler_as_OnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new OffersMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OffersMessageHandler must be freed before this_arg is + * The public key corresponding to the key used to sign the invoice. */ -struct LDKOffersMessageHandler IgnoringMessageHandler_as_OffersMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new CustomOnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomOnionMessageHandler must be freed before this_arg is + * The chains that may be used when paying a requested invoice. + * + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -struct LDKCustomOnionMessageHandler IgnoringMessageHandler_as_CustomOnionMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageReader which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageReader must be freed before this_arg is + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. + * + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -struct LDKCustomMessageReader IgnoringMessageHandler_as_CustomMessageReader(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new CustomMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CustomMessageHandler must be freed before this_arg is + * Opaque bytes set by the originating [`Offer`]. + * + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata */ -struct LDKCustomMessageHandler IgnoringMessageHandler_as_CustomMessageHandler(const struct LDKIgnoringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the ErroringMessageHandler, if is_owned is set and inner is non-NULL. + * The minimum amount required for a successful payment of a single item. + * + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -void ErroringMessageHandler_free(struct LDKErroringMessageHandler this_obj); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new ErroringMessageHandler + * Features pertaining to the originating [`Offer`]. + * + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKErroringMessageHandler ErroringMessageHandler_new(void); +MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * A complete description of the purpose of the originating offer or refund. + * + * From [`Offer::description`] or [`Refund::description`]. + * + * [`Offer::description`]: crate::offers::offer::Offer::description + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKMessageSendEventsProvider ErroringMessageHandler_as_MessageSendEventsProvider(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new ChannelMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelMessageHandler must be freed before this_arg is + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry */ -struct LDKChannelMessageHandler ErroringMessageHandler_as_ChannelMessageHandler(const struct LDKErroringMessageHandler *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageHandler, if is_owned is set and inner is non-NULL. + * The issuer of the offer or refund. + * + * From [`Offer::issuer`] or [`Refund::issuer`]. + * + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void MessageHandler_free(struct LDKMessageHandler this_obj); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * Paths to the recipient originating from publicly reachable nodes. * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * From [`Offer::paths`] or [`Refund::paths`]. + * + * [`Offer::paths`]: crate::offers::offer::Offer::paths */ -const struct LDKChannelMessageHandler *MessageHandler_get_chan_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles messages specific to channels. Usually this is just a - * [`ChannelManager`] object or an [`ErroringMessageHandler`]. + * The quantity of items supported. * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. + * + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -void MessageHandler_set_chan_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKChannelMessageHandler val); +MUST_USE_RES struct LDKCOption_QuantityZ UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * An unpredictable series of bytes from the payer. * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -const struct LDKRoutingMessageHandler *MessageHandler_get_route_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles messages updating our knowledge of the network channel - * graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`]. + * Features pertaining to requesting an invoice. * - * [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -void MessageHandler_set_route_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKRoutingMessageHandler val); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles onion messages. This should generally be an - * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * The quantity of items requested or refunded for. * - * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -const struct LDKOnionMessageHandler *MessageHandler_get_onion_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles onion messages. This should generally be an - * [`OnionMessenger`], but can also be an [`IgnoringMessageHandler`]. + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. * - * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * [`message_paths`]: Self::message_paths */ -void MessageHandler_set_onion_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKOnionMessageHandler val); +MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_id(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles custom messages. The only LDK-provided implementation is - * [`IgnoringMessageHandler`]. + * A payer-provided note reflected back in the invoice. + * + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -const struct LDKCustomMessageHandler *MessageHandler_get_custom_message_handler(const struct LDKMessageHandler *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * A message handler which handles custom messages. The only LDK-provided implementation is - * [`IgnoringMessageHandler`]. + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. */ -void MessageHandler_set_custom_message_handler(struct LDKMessageHandler *NONNULL_PTR this_ptr, struct LDKCustomMessageHandler val); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new MessageHandler given each field + * The minimum amount required for a successful payment of the invoice. */ -MUST_USE_RES struct LDKMessageHandler MessageHandler_new(struct LDKChannelMessageHandler chan_handler_arg, struct LDKRoutingMessageHandler route_handler_arg, struct LDKOnionMessageHandler onion_message_handler_arg, struct LDKCustomMessageHandler custom_message_handler_arg); +MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of a SocketDescriptor + * Duration since the Unix epoch when the invoice was created. */ -struct LDKSocketDescriptor SocketDescriptor_clone(const struct LDKSocketDescriptor *NONNULL_PTR orig); +MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Duration since + *[`Bolt12Invoice::created_at`] + * when the invoice has expired and therefore should no longer be paid. */ -void SocketDescriptor_free(struct LDKSocketDescriptor this_ptr); +MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the PeerHandleError, if is_owned is set and inner is non-NULL. + * Whether the invoice has expired. */ -void PeerHandleError_free(struct LDKPeerHandleError this_obj); +MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new PeerHandleError given each field + * Fallback addresses for paying the invoice on-chain, in order of most-preferred to + * least-preferred. */ -MUST_USE_RES struct LDKPeerHandleError PeerHandleError_new(void); +MUST_USE_RES struct LDKCVec_StrZ Bolt12Invoice_fallbacks(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Creates a copy of the PeerHandleError + * Features pertaining to paying an invoice. */ -struct LDKPeerHandleError PeerHandleError_clone(const struct LDKPeerHandleError *NONNULL_PTR orig); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Frees any resources used by the PeerManager, if is_owned is set and inner is non-NULL. + * The public key corresponding to the key used to sign the invoice. */ -void PeerManager_free(struct LDKPeerManager this_obj); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Constructs a new `PeerManager` with the given message handlers. + * The chains that may be used when paying a requested invoice. * - * `ephemeral_random_data` is used to derive per-connection ephemeral keys and must be - * cryptographically secure random bytes. + * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. * - * `current_time` is used as an always-increasing counter that survives across restarts and is - * incremented irregularly internally. In general it is best to simply use the current UNIX - * timestamp, however if it is not available a persistent counter that increases once per - * minute should suffice. + * [`Offer::chains`]: crate::offers::offer::Offer::chains */ -MUST_USE_RES struct LDKPeerManager PeerManager_new(struct LDKMessageHandler message_handler, uint32_t current_time, const uint8_t (*ephemeral_random_data)[32], struct LDKLogger logger, struct LDKNodeSigner node_signer); +MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Get a list of tuples mapping from node id to network addresses for peers which have - * completed the initial handshake. + * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the + * invoice originated from an offer. * - * For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter - * passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial - * handshake has completed and we are sure the remote peer has the private key for the given - * [`PublicKey`]. + * From [`InvoiceRequest::chain`] or [`Refund::chain`]. * - * The returned `Option`s will only be `Some` if an address had been previously given via - * [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`]. + * [`offer_chains`]: Self::offer_chains + * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain */ -MUST_USE_RES struct LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ PeerManager_get_peer_node_ids(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Indicates a new outbound connection has been established to a node with the given `node_id` - * and an optional remote network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. + * Opaque bytes set by the originating [`Offer`]. * - * If an `Err` is returned here you must disconnect the connection immediately. + * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or + * if the [`Offer`] did not set it. * - * Returns a small number of bytes to send to the remote node (currently always 50). + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + */ +MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * The minimum amount required for a successful payment of a single item. * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. + * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if + * the [`Offer`] did not set it. * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::amount`]: crate::offers::offer::Offer::amount */ -MUST_USE_RES struct LDKCResult_CVec_u8ZPeerHandleErrorZ PeerManager_new_outbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey their_node_id, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); +MUST_USE_RES struct LDKCOption_AmountZ Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Indicates a new inbound connection has been established to a node with an optional remote - * network address. - * - * The remote network address adds the option to report a remote IP address back to a connecting - * peer using the init message. - * The user should pass the remote network address of the host they are connected to. + * Features pertaining to the originating [`Offer`]. * - * May refuse the connection by returning an Err, but will never write bytes to the remote end - * (outbound connector always speaks first). If an `Err` is returned here you must disconnect - * the connection immediately. + * From [`Offer::offer_features`]; `None` if the invoice was created in response to a + * [`Refund`]. * - * Panics if descriptor is duplicative with some other descriptor which has not yet been - * [`socket_disconnected`]. + * [`Offer`]: crate::offers::offer::Offer + * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features * - * [`socket_disconnected`]: PeerManager::socket_disconnected + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_new_inbound_connection(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor descriptor, struct LDKCOption_SocketAddressZ remote_network_address); +MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Indicates that there is room to write data to the given socket descriptor. + * A complete description of the purpose of the originating offer or refund. * - * May return an Err to indicate that the connection should be closed. + * From [`Offer::description`] or [`Refund::description`]. * - * May call [`send_data`] on the descriptor passed in (or an equal descriptor) before - * returning. Thus, be very careful with reentrancy issues! The invariants around calling - * [`write_buffer_space_avail`] in case a write did not fully complete must still hold - be - * ready to call [`write_buffer_space_avail`] again if a write call generated here isn't - * sufficient! + * [`Offer::description`]: crate::offers::offer::Offer::description * - * [`send_data`]: SocketDescriptor::send_data - * [`write_buffer_space_avail`]: PeerManager::write_buffer_space_avail + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NonePeerHandleErrorZ PeerManager_write_buffer_space_avail(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Indicates that data was read from the given socket descriptor. + * Duration since the Unix epoch when an invoice should no longer be requested. * - * May return an Err to indicate that the connection should be closed. + * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. * - * Will *not* call back into [`send_data`] on any descriptors to avoid reentrancy complexity. - * Thus, however, you should call [`process_events`] after any `read_event` to generate - * [`send_data`] calls to handle responses. + * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + */ +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * The issuer of the offer or refund. * - * If `Ok(true)` is returned, further read_events should not be triggered until a - * [`send_data`] call on this descriptor has `resume_read` set (preventing DoS issues in the - * send buffer). + * From [`Offer::issuer`] or [`Refund::issuer`]. * - * In order to avoid processing too many messages at once per peer, `data` should be on the - * order of 4KiB. + * [`Offer::issuer`]: crate::offers::offer::Offer::issuer * - * [`send_data`]: SocketDescriptor::send_data - * [`process_events`]: PeerManager::process_events + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_boolPeerHandleErrorZ PeerManager_read_event(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKSocketDescriptor *NONNULL_PTR peer_descriptor, struct LDKu8slice data); +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Checks for any events generated by our handlers and processes them. Includes sending most - * response messages as well as messages generated by calls to handler functions directly (eg - * functions like [`ChannelManager::process_pending_htlc_forwards`] or [`send_payment`]). + * Paths to the recipient originating from publicly reachable nodes. * - * May call [`send_data`] on [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! + * From [`Offer::paths`] or [`Refund::paths`]. * - * You don't have to call this function explicitly if you are using [`lightning-net-tokio`] - * or one of the other clients provided in our language bindings. + * [`Offer::paths`]: crate::offers::offer::Offer::paths + */ +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * The quantity of items supported. * - * Note that if there are any other calls to this function waiting on lock(s) this may return - * without doing any work. All available events that need handling will be handled before the - * other calls return. + * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a + * [`Refund`]. * - * [`send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards - * [`send_data`]: SocketDescriptor::send_data + * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity */ -void PeerManager_process_events(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_QuantityZ Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Indicates that the given socket descriptor's connection is now closed. + * An unpredictable series of bytes from the payer. + * + * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. */ -void PeerManager_socket_disconnected(const struct LDKPeerManager *NONNULL_PTR this_arg, const struct LDKSocketDescriptor *NONNULL_PTR descriptor); +MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Disconnect a peer given its node id. - * - * If a peer is connected, this will call [`disconnect_socket`] on the descriptor for the - * peer. Thus, be very careful about reentrancy issues. + * Features pertaining to requesting an invoice. * - * [`disconnect_socket`]: SocketDescriptor::disconnect_socket + * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. */ -void PeerManager_disconnect_by_node_id(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Disconnects all currently-connected peers. This is useful on platforms where there may be - * an indication that TCP sockets have stalled even if we weren't around to time them out - * using regular ping/pongs. + * The quantity of items requested or refunded for. + * + * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. */ -void PeerManager_disconnect_all_peers(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Send pings to each peer and disconnect those which did not respond to the last round of - * pings. - * - * This may be called on any timescale you want, however, roughly once every ten seconds is - * preferred. The call rate determines both how often we send a ping to our peers and how much - * time they have to respond before we disconnect them. - * - * May call [`send_data`] on all [`SocketDescriptor`]s. Thus, be very careful with reentrancy - * issues! + * A possibly transient pubkey used to sign the invoice request or to send an invoice for a + * refund in case there are no [`message_paths`]. * - * [`send_data`]: SocketDescriptor::send_data + * [`message_paths`]: Self::message_paths */ -void PeerManager_timer_tick_occurred(const struct LDKPeerManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_id(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); /** - * Generates a signed node_announcement from the given arguments, sending it to all connected - * peers. Note that peers will likely ignore this message unless we have at least one public - * channel which has at least six confirmations on-chain. - * - * `rgb` is a node \"color\" and `alias` is a printable human-readable string to describe this - * node to humans. They carry no in-protocol meaning. + * A payer-provided note reflected back in the invoice. * - * `addresses` represent the set (possibly empty) of socket addresses on which this node - * accepts incoming connections. These will be included in the node_announcement, publicly - * tying these addresses together and to this node. If you wish to preserve user privacy, - * addresses should likely contain only Tor Onion addresses. + * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. * - * Panics if `addresses` is absurdly large (more than 100). + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + */ +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * The minimum amount required for a successful payment of the invoice. + */ +MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. + */ +MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * Hash that was used for signing the invoice. + */ +MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); + +/** + * Verifies that the invoice was for a request or refund created using the given key by + * checking the payer metadata from the invoice request. * - * [`get_and_clear_pending_msg_events`]: MessageSendEventsProvider::get_and_clear_pending_msg_events + * Returns the associated [`PaymentId`] to use when sending the payment. */ -void PeerManager_broadcast_node_announcement(const struct LDKPeerManager *NONNULL_PTR this_arg, struct LDKThreeBytes rgb, struct LDKThirtyTwoBytes alias, struct LDKCVec_SocketAddressZ addresses); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Gets the weight for an HTLC-Success transaction. + * Verifies that the invoice was for a request or refund created using the given key by + * checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was + * sent through. */ -uint64_t htlc_success_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify_using_payer_data(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Gets the weight for an HTLC-Timeout transaction. + * Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. */ -uint64_t htlc_timeout_tx_weight(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +uint64_t Bolt12Invoice_hash(const struct LDKBolt12Invoice *NONNULL_PTR o); /** - * Creates a copy of the HTLCClaim + * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read */ -enum LDKHTLCClaim HTLCClaim_clone(const enum LDKHTLCClaim *NONNULL_PTR orig); +struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); /** - * Utility method to constructs a new OfferedTimeout-variant HTLCClaim + * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read */ -enum LDKHTLCClaim HTLCClaim_offered_timeout(void); +struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); /** - * Utility method to constructs a new OfferedPreimage-variant HTLCClaim + * Read a Bolt12Invoice from a byte array, created by Bolt12Invoice_write */ -enum LDKHTLCClaim HTLCClaim_offered_preimage(void); +struct LDKCResult_Bolt12InvoiceDecodeErrorZ Bolt12Invoice_read(struct LDKu8slice ser); + +/** + * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. + */ +void InvoiceError_free(struct LDKInvoiceError this_obj); + +/** + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); + +/** + * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); + +/** + * An explanation of the error. + */ +struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new AcceptedTimeout-variant HTLCClaim + * An explanation of the error. */ -enum LDKHTLCClaim HTLCClaim_accepted_timeout(void); +void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Utility method to constructs a new AcceptedPreimage-variant HTLCClaim + * Constructs a new InvoiceError given each field + * + * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKHTLCClaim HTLCClaim_accepted_preimage(void); +MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); /** - * Utility method to constructs a new Revocation-variant HTLCClaim + * Creates a copy of the InvoiceError */ -enum LDKHTLCClaim HTLCClaim_revocation(void); +struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); /** - * Checks if two HTLCClaims contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. */ -bool HTLCClaim_eq(const enum LDKHTLCClaim *NONNULL_PTR a, const enum LDKHTLCClaim *NONNULL_PTR b); +void ErroneousField_free(struct LDKErroneousField this_obj); /** - * Check if a given input witness attempts to claim a HTLC. + * The type number of the TLV field containing the error. */ -MUST_USE_RES struct LDKCOption_HTLCClaimZ HTLCClaim_from_witness(struct LDKWitness witness); +uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * Build the commitment secret from the seed and the commitment number + * The type number of the TLV field containing the error. */ -struct LDKThirtyTwoBytes build_commitment_secret(const uint8_t (*commitment_seed)[32], uint64_t idx); +void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); /** - * Build a closing transaction + * A value to use for the TLV field to avoid the error. + * + * Returns a copy of the field. */ -struct LDKTransaction build_closing_transaction(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CounterpartyCommitmentSecrets, if is_owned is set and inner is non-NULL. + * A value to use for the TLV field to avoid the error. */ -void CounterpartyCommitmentSecrets_free(struct LDKCounterpartyCommitmentSecrets this_obj); +void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); /** - * Creates a copy of the CounterpartyCommitmentSecrets + * Constructs a new ErroneousField given each field */ -struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_clone(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR orig); +MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); /** - * Creates a new empty `CounterpartyCommitmentSecrets` structure. + * Creates a copy of the ErroneousField */ -MUST_USE_RES struct LDKCounterpartyCommitmentSecrets CounterpartyCommitmentSecrets_new(void); +struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); /** - * Returns the minimum index of all stored secrets. Note that indexes start - * at 1 << 48 and get decremented by one for each new secret. + * Creates an [`InvoiceError`] with the given message. */ -MUST_USE_RES uint64_t CounterpartyCommitmentSecrets_get_min_seen_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceError InvoiceError_from_string(struct LDKStr s); /** - * Inserts the `secret` at `idx`. Returns `Ok(())` if the secret - * was generated in accordance with BOLT 3 and is consistent with previous secrets. + * Get the string representation of a InvoiceError object */ -MUST_USE_RES struct LDKCResult_NoneNoneZ CounterpartyCommitmentSecrets_provide_secret(struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx, struct LDKThirtyTwoBytes secret); +struct LDKStr InvoiceError_to_str(const struct LDKInvoiceError *NONNULL_PTR o); /** - * Returns the secret at `idx`. - * Returns `None` if `idx` is < [`CounterpartyCommitmentSecrets::get_min_seen_secret`]. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read */ -MUST_USE_RES struct LDKThirtyTwoBytes CounterpartyCommitmentSecrets_get_secret(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR this_arg, uint64_t idx); +struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); /** - * Serialize the CounterpartyCommitmentSecrets object into a byte array which can be read by CounterpartyCommitmentSecrets_read + * Read a InvoiceError from a byte array, created by InvoiceError_write */ -struct LDKCVec_u8Z CounterpartyCommitmentSecrets_write(const struct LDKCounterpartyCommitmentSecrets *NONNULL_PTR obj); +struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); /** - * Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write + * Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ CounterpartyCommitmentSecrets_read(struct LDKu8slice ser); +void InvoiceRequestWithExplicitPayerIdBuilder_free(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_obj); /** - * Derives a per-commitment-transaction private key (eg an htlc key or delayed_payment key) - * from the base secret and the per_commitment_point. + * Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL. */ -struct LDKSecretKey derive_private_key(struct LDKPublicKey per_commitment_point, const uint8_t (*base_secret)[32]); +void InvoiceRequestWithDerivedPayerIdBuilder_free(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_obj); /** - * Derives a per-commitment-transaction revocation key from its constituent parts. - * - * Only the cheating participant owns a valid witness to propagate a revoked - * commitment transaction, thus per_commitment_secret always come from cheater - * and revocation_base_secret always come from punisher, which is the broadcaster - * of the transaction spending with this key knowledge. + * Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed + * by [`UnsignedInvoiceRequest::sign`]. */ -struct LDKSecretKey derive_private_revocation_key(const uint8_t (*per_commitment_secret)[32], const uint8_t (*countersignatory_revocation_base_secret)[32]); +MUST_USE_RES struct LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_build(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg); /** - * Frees any resources used by the TxCreationKeys, if is_owned is set and inner is non-NULL. + * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported + * by the offer. + * + * Successive calls to this method will override the previous setting. */ -void TxCreationKeys_free(struct LDKTxCreationKeys this_obj); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_chain(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, enum LDKNetwork network); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is + * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). + * + * Successive calls to this method will override the previous setting. + * + * [`quantity`]: Self::quantity */ -struct LDKPublicKey TxCreationKeys_get_per_commitment_point(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t amount_msats); /** - * The broadcaster's per-commitment public key which was used to derive the other keys. + * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` + * does not conform to [`Offer::is_valid_quantity`]. + * + * Successive calls to this method will override the previous setting. */ -void TxCreationKeys_set_per_commitment_point(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithExplicitPayerIdBuilder_quantity(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, uint64_t quantity); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Sets the [`InvoiceRequest::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKRevocationKey TxCreationKeys_get_revocation_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES void InvoiceRequestWithExplicitPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithExplicitPayerIdBuilder this_arg, struct LDKStr payer_note); /** - * The revocation key which is used to allow the broadcaster of the commitment - * transaction to provide their counterparty the ability to punish them if they broadcast - * an old state. + * Builds a signed [`InvoiceRequest`] after checking for valid semantics. */ -void TxCreationKeys_set_revocation_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKRevocationKey val); +MUST_USE_RES struct LDKCResult_InvoiceRequestBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg); /** - * Broadcaster's HTLC Key + * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported + * by the offer. + * + * Successive calls to this method will override the previous setting. */ -struct LDKHtlcKey TxCreationKeys_get_broadcaster_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_chain(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, enum LDKNetwork network); /** - * Broadcaster's HTLC Key + * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is + * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). + * + * Successive calls to this method will override the previous setting. + * + * [`quantity`]: Self::quantity */ -void TxCreationKeys_set_broadcaster_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t amount_msats); /** - * Countersignatory's HTLC Key + * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` + * does not conform to [`Offer::is_valid_quantity`]. + * + * Successive calls to this method will override the previous setting. */ -struct LDKHtlcKey TxCreationKeys_get_countersignatory_htlc_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneBolt12SemanticErrorZ InvoiceRequestWithDerivedPayerIdBuilder_quantity(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, uint64_t quantity); /** - * Countersignatory's HTLC Key + * Sets the [`InvoiceRequest::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -void TxCreationKeys_set_countersignatory_htlc_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKHtlcKey val); +MUST_USE_RES void InvoiceRequestWithDerivedPayerIdBuilder_payer_note(struct LDKInvoiceRequestWithDerivedPayerIdBuilder this_arg, struct LDKStr payer_note); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -struct LDKDelayedPaymentKey TxCreationKeys_get_broadcaster_delayed_payment_key(const struct LDKTxCreationKeys *NONNULL_PTR this_ptr); +void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); /** - * Broadcaster's Payment Key (which isn't allowed to be spent from for some delay) + * Creates a copy of the UnsignedInvoiceRequest */ -void TxCreationKeys_set_broadcaster_delayed_payment_key(struct LDKTxCreationKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentKey val); +struct LDKUnsignedInvoiceRequest UnsignedInvoiceRequest_clone(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR orig); /** - * Constructs a new TxCreationKeys given each field + * Calls the free function if one is set */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_new(struct LDKPublicKey per_commitment_point_arg, struct LDKRevocationKey revocation_key_arg, struct LDKHtlcKey broadcaster_htlc_key_arg, struct LDKHtlcKey countersignatory_htlc_key_arg, struct LDKDelayedPaymentKey broadcaster_delayed_payment_key_arg); +void SignInvoiceRequestFn_free(struct LDKSignInvoiceRequestFn this_ptr); /** - * Checks if two TxCreationKeyss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns the [`TaggedHash`] of the invoice to sign. */ -bool TxCreationKeys_eq(const struct LDKTxCreationKeys *NONNULL_PTR a, const struct LDKTxCreationKeys *NONNULL_PTR b); +MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the TxCreationKeys + * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. */ -struct LDKTxCreationKeys TxCreationKeys_clone(const struct LDKTxCreationKeys *NONNULL_PTR orig); +void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); /** - * Serialize the TxCreationKeys object into a byte array which can be read by TxCreationKeys_read + * Creates a copy of the InvoiceRequest */ -struct LDKCVec_u8Z TxCreationKeys_write(const struct LDKTxCreationKeys *NONNULL_PTR obj); +struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); /** - * Read a TxCreationKeys from a byte array, created by TxCreationKeys_write + * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_TxCreationKeysDecodeErrorZ TxCreationKeys_read(struct LDKu8slice ser); +void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); /** - * Frees any resources used by the ChannelPublicKeys, if is_owned is set and inner is non-NULL. + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -void ChannelPublicKeys_free(struct LDKChannelPublicKeys this_obj); +struct LDKOfferId VerifiedInvoiceRequest_get_offer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. */ -struct LDKPublicKey ChannelPublicKeys_get_funding_pubkey(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +void VerifiedInvoiceRequest_set_offer_id(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKOfferId val); /** - * The public key which is used to sign all commitment transactions, as it appears in the - * on-chain channel lock-in 2-of-2 multisig output. + * Creates a copy of the VerifiedInvoiceRequest */ -void ChannelPublicKeys_set_funding_pubkey(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKRevocationBasepoint ChannelPublicKeys_get_revocation_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_revocation_key) to derive per-commitment - * revocation keys. This is combined with the per-commitment-secret generated by the - * counterparty to create a secret which the counterparty can reveal to revoke previous - * states. + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -void ChannelPublicKeys_set_revocation_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKRevocationBasepoint val); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * The minimum amount required for a successful payment of a single item. */ -struct LDKPublicKey ChannelPublicKeys_get_payment_point(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_AmountZ UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The public key on which the non-broadcaster (ie the countersignatory) receives an immediately - * spendable primary channel balance on the broadcaster's commitment transaction. This key is - * static across every commitment transaction. + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelPublicKeys_set_payment_point(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Features pertaining to the offer. */ -struct LDKDelayedPaymentBasepoint ChannelPublicKeys_get_delayed_payment_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment payment - * public key which receives non-HTLC-encumbered funds which are only available for spending - * after some delay (or can be claimed via the revocation path). + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -void ChannelPublicKeys_set_delayed_payment_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKDelayedPaymentBasepoint val); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKHtlcBasepoint ChannelPublicKeys_get_htlc_basepoint(const struct LDKChannelPublicKeys *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * The base point which is used (with derive_public_key) to derive a per-commitment public key - * which is used to encumber HTLC-in-flight outputs. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void ChannelPublicKeys_set_htlc_basepoint(struct LDKChannelPublicKeys *NONNULL_PTR this_ptr, struct LDKHtlcBasepoint val); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new ChannelPublicKeys given each field + * The quantity of items supported. */ -MUST_USE_RES struct LDKChannelPublicKeys ChannelPublicKeys_new(struct LDKPublicKey funding_pubkey_arg, struct LDKRevocationBasepoint revocation_basepoint_arg, struct LDKPublicKey payment_point_arg, struct LDKDelayedPaymentBasepoint delayed_payment_basepoint_arg, struct LDKHtlcBasepoint htlc_basepoint_arg); +MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelPublicKeys + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelPublicKeys ChannelPublicKeys_clone(const struct LDKChannelPublicKeys *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelPublicKeys. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -uint64_t ChannelPublicKeys_hash(const struct LDKChannelPublicKeys *NONNULL_PTR o); +MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two ChannelPublicKeyss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A chain from [`Offer::chains`] that the offer is valid for. */ -bool ChannelPublicKeys_eq(const struct LDKChannelPublicKeys *NONNULL_PTR a, const struct LDKChannelPublicKeys *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the ChannelPublicKeys object into a byte array which can be read by ChannelPublicKeys_read + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -struct LDKCVec_u8Z ChannelPublicKeys_write(const struct LDKChannelPublicKeys *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write + * Features pertaining to requesting an invoice. */ -struct LDKCResult_ChannelPublicKeysDecodeErrorZ ChannelPublicKeys_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Create per-state keys from channel base points and the per-commitment point. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_derive_new(struct LDKPublicKey per_commitment_point, const struct LDKDelayedPaymentBasepoint *NONNULL_PTR broadcaster_delayed_payment_base, const struct LDKHtlcBasepoint *NONNULL_PTR broadcaster_htlc_base, const struct LDKRevocationBasepoint *NONNULL_PTR countersignatory_revocation_base, const struct LDKHtlcBasepoint *NONNULL_PTR countersignatory_htlc_base); +MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generate per-state keys from channel static keys. - * Key set is asymmetric and can't be used as part of counter-signatory set of transactions. + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES struct LDKTxCreationKeys TxCreationKeys_from_channel_static_keys(struct LDKPublicKey per_commitment_point, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_id(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * A script either spendable by the revocation - * key or the broadcaster_delayed_payment_key and satisfying the relative-locktime OP_CSV constrain. - * Encumbering a `to_holder` output on a commitment transaction or 2nd-stage HTLC transactions. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z get_revokeable_redeemscript(const struct LDKRevocationKey *NONNULL_PTR revocation_key, uint16_t contest_delay, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key); +MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); /** - * Returns the script for the counterparty's output on a holder's commitment transaction based on - * the channel type. + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKCVec_u8Z get_counterparty_payment_script(const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, struct LDKPublicKey payment_key); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCOutputInCommitment, if is_owned is set and inner is non-NULL. + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -void HTLCOutputInCommitment_free(struct LDKHTLCOutputInCommitment this_obj); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * The minimum amount required for a successful payment of a single item. */ -bool HTLCOutputInCommitment_get_offered(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_AmountZ InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). - * Note that this is not the same as whether it is ountbound *from us*. To determine that you - * need to compare this value to whether the commitment transaction in question is that of - * the counterparty or our own. + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void HTLCOutputInCommitment_set_offered(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Features pertaining to the offer. */ -uint64_t HTLCOutputInCommitment_get_amount_msat(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The value, in msat, of the HTLC. The value as it appears in the commitment transaction is - * this divided by 1000. + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -void HTLCOutputInCommitment_set_amount_msat(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The CLTV lock-time at which this HTLC expires. + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint32_t HTLCOutputInCommitment_get_cltv_expiry(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The CLTV lock-time at which this HTLC expires. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -void HTLCOutputInCommitment_set_cltv_expiry(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The hash of the preimage which unlocks this HTLC. + * The quantity of items supported. */ -const uint8_t (*HTLCOutputInCommitment_get_payment_hash(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The hash of the preimage which unlocks this HTLC. + * The public key used by the recipient to sign invoices. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void HTLCOutputInCommitment_set_payment_hash(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -struct LDKCOption_u32Z HTLCOutputInCommitment_get_transaction_output_index(const struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * The position within the commitment transactions' outputs. This may be None if the value is - * below the dust limit (in which case no output appears in the commitment transaction and the - * value is spent to additional transaction fees). + * A chain from [`Offer::chains`] that the offer is valid for. */ -void HTLCOutputInCommitment_set_transaction_output_index(struct LDKHTLCOutputInCommitment *NONNULL_PTR this_ptr, struct LDKCOption_u32Z val); +MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new HTLCOutputInCommitment given each field + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. + * + * [`chain`]: Self::chain */ -MUST_USE_RES struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_new(bool offered_arg, uint64_t amount_msat_arg, uint32_t cltv_expiry_arg, struct LDKThirtyTwoBytes payment_hash_arg, struct LDKCOption_u32Z transaction_output_index_arg); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCOutputInCommitment + * Features pertaining to requesting an invoice. */ -struct LDKHTLCOutputInCommitment HTLCOutputInCommitment_clone(const struct LDKHTLCOutputInCommitment *NONNULL_PTR orig); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Checks if two HTLCOutputInCommitments contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -bool HTLCOutputInCommitment_eq(const struct LDKHTLCOutputInCommitment *NONNULL_PTR a, const struct LDKHTLCOutputInCommitment *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKCVec_u8Z HTLCOutputInCommitment_write(const struct LDKHTLCOutputInCommitment *NONNULL_PTR obj); +MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCResult_HTLCOutputInCommitmentDecodeErrorZ HTLCOutputInCommitment_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc - * does not need to have its previous_output_index filled. + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -struct LDKCVec_u8Z get_htlc_redeemscript(const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKTxCreationKeys *NONNULL_PTR keys); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Gets the redeemscript for a funding output from the two funding public keys. - * Note that the order of funding public keys does not matter. + * Creates an [`InvoiceBuilder`] for the request with the given required fields. + * + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds + * where [`std::time::SystemTime`] is not available. + * + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. + * + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -struct LDKCVec_u8Z make_funding_redeemscript(struct LDKPublicKey broadcaster, struct LDKPublicKey countersignatory); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ InvoiceRequest_respond_with_no_std(const struct LDKInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Builds an unsigned HTLC-Success or HTLC-Timeout transaction from the given channel and HTLC - * parameters. This is used by [`TrustedCommitmentTransaction::get_htlc_sigs`] to fetch the - * transaction which needs signing, and can be used to construct an HTLC transaction which is - * broadcastable given a counterparty HTLC signature. + * Verifies that the request was for an offer created using the given key by checking the + * metadata from the offer. * - * Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the - * commitment transaction). + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKTransaction build_htlc_transaction(const uint8_t (*commitment_txid)[32], uint32_t feerate_per_kw, uint16_t contest_delay, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features, const struct LDKDelayedPaymentKey *NONNULL_PTR broadcaster_delayed_payment_key, const struct LDKRevocationKey *NONNULL_PTR revocation_key); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_metadata(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Returns the witness required to satisfy and spend a HTLC input. + * Verifies that the request was for an offer created using the given key by checking a nonce + * included with the [`BlindedMessagePath`] for which the request was sent through. + * + * Returns the verified request which contains the derived keys needed to sign a + * [`Bolt12Invoice`] for the request if they could be extracted from the metadata. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKWitness build_htlc_input_witness(struct LDKECDSASignature local_sig, struct LDKECDSASignature remote_sig, struct LDKCOption_ThirtyTwoBytesZ preimage, struct LDKu8slice redeem_script, const struct LDKChannelTypeFeatures *NONNULL_PTR channel_type_features); +MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify_using_recipient_data(struct LDKInvoiceRequest this_arg, struct LDKNonce nonce, const struct LDKExpandedKey *NONNULL_PTR key); /** - * Gets the witnessScript for the to_remote output when anchors are enabled. + * Signature of the invoice request using [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -struct LDKCVec_u8Z get_to_countersignatory_with_anchors_redeemscript(struct LDKPublicKey payment_point); +MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); /** - * Gets the witnessScript for an anchor output from the funding public key. - * The witness in the spending input must be: - * - * After 16 blocks of confirmation, an alternative satisfying witness could be: - * <> - * (empty vector required to satisfy compliance with MINIMALIF-standard rule) + * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). + * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) + * for the selected chain. */ -struct LDKCVec_u8Z get_anchor_redeemscript(struct LDKPublicKey funding_pubkey); +MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Returns the witness required to satisfy and spend an anchor input. + * Opaque bytes set by the originator. Useful for authentication and validating fields since it + * is reflected in `invoice_request` messages along with all the other fields from the `offer`. */ -struct LDKWitness build_anchor_input_witness(struct LDKPublicKey funding_key, struct LDKECDSASignature funding_sig); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * The minimum amount required for a successful payment of a single item. */ -void ChannelTransactionParameters_free(struct LDKChannelTransactionParameters this_obj); +MUST_USE_RES struct LDKCOption_AmountZ VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Holder public keys + * A complete description of the purpose of the payment. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelPublicKeys ChannelTransactionParameters_get_holder_pubkeys(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Holder public keys + * Features pertaining to the offer. */ -void ChannelTransactionParameters_set_holder_pubkeys(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * Duration since the Unix epoch when an invoice should no longer be requested. + * + * If `None`, the offer does not expire. */ -uint16_t ChannelTransactionParameters_get_holder_selected_contest_delay(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The contest delay selected by the holder, which applies to counterparty-broadcast transactions + * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTransactionParameters_set_holder_selected_contest_delay(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide + * recipient privacy by obfuscating its node id. */ -bool ChannelTransactionParameters_get_is_outbound_from_holder(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Whether the holder is the initiator of this channel. - * This is an input to the commitment number obscure factor computation. + * The quantity of items supported. */ -void ChannelTransactionParameters_set_is_outbound_from_holder(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, bool val); +MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. + * The public key used by the recipient to sign invoices. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCounterpartyChannelTransactionParameters ChannelTransactionParameters_get_counterparty_parameters(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The late-bound counterparty channel transaction parameters. - * These parameters are populated at the point in the protocol where the counterparty provides them. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`payer_id`]: Self::payer_id */ -void ChannelTransactionParameters_set_counterparty_parameters(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKCounterpartyChannelTransactionParameters val); +MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * A chain from [`Offer::chains`] that the offer is valid for. */ -struct LDKOutPoint ChannelTransactionParameters_get_funding_outpoint(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * The late-bound funding outpoint + * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which + * must be greater than or equal to [`Offer::amount`], converted if necessary. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`chain`]: Self::chain */ -void ChannelTransactionParameters_set_funding_outpoint(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * This channel's type, as negotiated during channel open. For old objects where this field - * wasn't serialized, it will default to static_remote_key at deserialization. + * Features pertaining to requesting an invoice. */ -struct LDKChannelTypeFeatures ChannelTransactionParameters_get_channel_type_features(const struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * This channel's type, as negotiated during channel open. For old objects where this field - * wasn't serialized, it will default to static_remote_key at deserialization. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -void ChannelTransactionParameters_set_channel_type_features(struct LDKChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelTypeFeatures val); +MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Constructs a new ChannelTransactionParameters given each field - * - * Note that counterparty_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None - * Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES struct LDKChannelTransactionParameters ChannelTransactionParameters_new(struct LDKChannelPublicKeys holder_pubkeys_arg, uint16_t holder_selected_contest_delay_arg, bool is_outbound_from_holder_arg, struct LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg, struct LDKOutPoint funding_outpoint_arg, struct LDKChannelTypeFeatures channel_type_features_arg); +MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelTransactionParameters + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKChannelTransactionParameters ChannelTransactionParameters_clone(const struct LDKChannelTransactionParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the ChannelTransactionParameters. + * Creates an [`InvoiceBuilder`] for the request with the given required fields and using the + * [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned + * creation time is used for the `created_at` parameter. + * + * [`Duration`]: core::time::Duration */ -uint64_t ChannelTransactionParameters_hash(const struct LDKChannelTransactionParameters *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Checks if two ChannelTransactionParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates an [`InvoiceBuilder`] for the request with the given required fields. + * + * Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after + * `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds + * where [`std::time::SystemTime`] is not available. + * + * The caller is expected to remember the preimage of `payment_hash` in order to claim a payment + * for the invoice. + * + * The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It + * must contain one or more elements ordered from most-preferred to least-preferred, if there's + * a preference. Note, however, that any privacy is lost if a public node id was used for + * [`Offer::signing_pubkey`]. + * + * Errors if the request contains unknown required features. + * + * # Note + * + * If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], + * then first use [`InvoiceRequest::verify_using_metadata`] or + * [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods + * instead. + * + * [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at + * [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey */ -bool ChannelTransactionParameters_eq(const struct LDKChannelTransactionParameters *NONNULL_PTR a, const struct LDKChannelTransactionParameters *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_with_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Frees any resources used by the CounterpartyChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. + * + * See [`InvoiceRequest::respond_with`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void CounterpartyChannelTransactionParameters_free(struct LDKCounterpartyChannelTransactionParameters this_obj); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash); /** - * Counter-party public keys + * Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses + * derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use + * the same [`ExpandedKey`] as the one used to create the offer. + * + * See [`InvoiceRequest::respond_with_no_std`] for further details. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -struct LDKChannelPublicKeys CounterpartyChannelTransactionParameters_get_pubkeys(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ VerifiedInvoiceRequest_respond_using_derived_keys_no_std(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg, struct LDKCVec_BlindedPaymentPathZ payment_paths, struct LDKThirtyTwoBytes payment_hash, uint64_t created_at); /** - * Counter-party public keys + * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read */ -void CounterpartyChannelTransactionParameters_set_pubkeys(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, struct LDKChannelPublicKeys val); +struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read */ -uint16_t CounterpartyChannelTransactionParameters_get_selected_contest_delay(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); /** - * The contest delay selected by the counterparty, which applies to holder-broadcast transactions + * Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. */ -void CounterpartyChannelTransactionParameters_set_selected_contest_delay(struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR this_ptr, uint16_t val); +void InvoiceRequestFields_free(struct LDKInvoiceRequestFields this_obj); /** - * Constructs a new CounterpartyChannelTransactionParameters given each field + * A possibly transient pubkey used to sign the invoice request. */ -MUST_USE_RES struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_new(struct LDKChannelPublicKeys pubkeys_arg, uint16_t selected_contest_delay_arg); +struct LDKPublicKey InvoiceRequestFields_get_payer_id(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Creates a copy of the CounterpartyChannelTransactionParameters + * A possibly transient pubkey used to sign the invoice request. */ -struct LDKCounterpartyChannelTransactionParameters CounterpartyChannelTransactionParameters_clone(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR orig); +void InvoiceRequestFields_set_payer_id(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Generates a non-cryptographic 64-bit hash of the CounterpartyChannelTransactionParameters. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -uint64_t CounterpartyChannelTransactionParameters_hash(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR o); +struct LDKCOption_u64Z InvoiceRequestFields_get_quantity(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Checks if two CounterpartyChannelTransactionParameterss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. */ -bool CounterpartyChannelTransactionParameters_eq(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR a, const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR b); +void InvoiceRequestFields_set_quantity(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Whether the late bound parameters are populated. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTransactionParameters_is_populated(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKUntrustedString InvoiceRequestFields_get_payer_note_truncated(const struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the holder is the broadcaster. + * A payer-provided note which will be seen by the recipient and reflected back in the invoice + * response. Truncated to [`PAYER_NOTE_LIMIT`] characters. * - * self.is_populated() must be true before calling this function. + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_holder_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +void InvoiceRequestFields_set_payer_note_truncated(struct LDKInvoiceRequestFields *NONNULL_PTR this_ptr, struct LDKUntrustedString val); /** - * Convert the holder/counterparty parameters to broadcaster/countersignatory-organized parameters, - * given that the counterparty is the broadcaster. + * Constructs a new InvoiceRequestFields given each field * - * self.is_populated() must be true before calling this function. + * Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKDirectedChannelTransactionParameters ChannelTransactionParameters_as_counterparty_broadcastable(const struct LDKChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInvoiceRequestFields InvoiceRequestFields_new(struct LDKPublicKey payer_id_arg, struct LDKCOption_u64Z quantity_arg, struct LDKUntrustedString payer_note_truncated_arg); /** - * Serialize the CounterpartyChannelTransactionParameters object into a byte array which can be read by CounterpartyChannelTransactionParameters_read + * Creates a copy of the InvoiceRequestFields */ -struct LDKCVec_u8Z CounterpartyChannelTransactionParameters_write(const struct LDKCounterpartyChannelTransactionParameters *NONNULL_PTR obj); +struct LDKInvoiceRequestFields InvoiceRequestFields_clone(const struct LDKInvoiceRequestFields *NONNULL_PTR orig); /** - * Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write + * Checks if two InvoiceRequestFieldss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ CounterpartyChannelTransactionParameters_read(struct LDKu8slice ser); +bool InvoiceRequestFields_eq(const struct LDKInvoiceRequestFields *NONNULL_PTR a, const struct LDKInvoiceRequestFields *NONNULL_PTR b); /** - * Serialize the ChannelTransactionParameters object into a byte array which can be read by ChannelTransactionParameters_read + * Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read */ -struct LDKCVec_u8Z ChannelTransactionParameters_write(const struct LDKChannelTransactionParameters *NONNULL_PTR obj); +struct LDKCVec_u8Z InvoiceRequestFields_write(const struct LDKInvoiceRequestFields *NONNULL_PTR obj); /** - * Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write + * Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write */ -struct LDKCResult_ChannelTransactionParametersDecodeErrorZ ChannelTransactionParameters_read(struct LDKu8slice ser); +struct LDKCResult_InvoiceRequestFieldsDecodeErrorZ InvoiceRequestFields_read(struct LDKu8slice ser); /** - * Frees any resources used by the DirectedChannelTransactionParameters, if is_owned is set and inner is non-NULL. + * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. */ -void DirectedChannelTransactionParameters_free(struct LDKDirectedChannelTransactionParameters this_obj); +void TaggedHash_free(struct LDKTaggedHash this_obj); /** - * Get the channel pubkeys for the broadcaster + * Creates a copy of the TaggedHash */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_broadcaster_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); /** - * Get the channel pubkeys for the countersignatory + * Returns the digest to sign. */ -MUST_USE_RES struct LDKChannelPublicKeys DirectedChannelTransactionParameters_countersignatory_pubkeys(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; /** - * Get the contest delay applicable to the transactions. - * Note that the contest delay was selected by the countersignatory. + * Returns the tag used in the tagged hash. */ -MUST_USE_RES uint16_t DirectedChannelTransactionParameters_contest_delay(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * Whether the channel is outbound from the broadcaster. - * - * The boolean representing the side that initiated the channel is - * an input to the commitment number obscure factor computation. + * Returns the merkle root used in the tagged hash. */ -MUST_USE_RES bool DirectedChannelTransactionParameters_is_outbound(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); /** - * The funding outpoint + * Frees any resources used by the SignError */ -MUST_USE_RES struct LDKOutPoint DirectedChannelTransactionParameters_funding_outpoint(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +void SignError_free(struct LDKSignError this_ptr); /** - * Whether to use anchors for this channel + * Creates a copy of the SignError */ -MUST_USE_RES struct LDKChannelTypeFeatures DirectedChannelTransactionParameters_channel_type_features(const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR this_arg); +struct LDKSignError SignError_clone(const struct LDKSignError *NONNULL_PTR orig); /** - * Frees any resources used by the HolderCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Signing-variant SignError */ -void HolderCommitmentTransaction_free(struct LDKHolderCommitmentTransaction this_obj); +struct LDKSignError SignError_signing(void); /** - * Our counterparty's signature for the transaction + * Utility method to constructs a new Verification-variant SignError */ -struct LDKECDSASignature HolderCommitmentTransaction_get_counterparty_sig(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +struct LDKSignError SignError_verification(enum LDKSecp256k1Error a); /** - * Our counterparty's signature for the transaction + * Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. */ -void HolderCommitmentTransaction_set_counterparty_sig(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +void Nonce_free(struct LDKNonce this_obj); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction - * - * Returns a copy of the field. + * Creates a copy of the Nonce */ -struct LDKCVec_ECDSASignatureZ HolderCommitmentTransaction_get_counterparty_htlc_sigs(const struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr); +struct LDKNonce Nonce_clone(const struct LDKNonce *NONNULL_PTR orig); /** - * All non-dust counterparty HTLC signatures, in the order they appear in the transaction + * Checks if two Nonces contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void HolderCommitmentTransaction_set_counterparty_htlc_sigs(struct LDKHolderCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKCVec_ECDSASignatureZ val); +bool Nonce_eq(const struct LDKNonce *NONNULL_PTR a, const struct LDKNonce *NONNULL_PTR b); /** - * Creates a copy of the HolderCommitmentTransaction + * Creates a `Nonce` from the given [`EntropySource`]. */ -struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_clone(const struct LDKHolderCommitmentTransaction *NONNULL_PTR orig); +MUST_USE_RES struct LDKNonce Nonce_from_entropy_source(struct LDKEntropySource entropy_source); /** - * Serialize the HolderCommitmentTransaction object into a byte array which can be read by HolderCommitmentTransaction_read + * Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. */ -struct LDKCVec_u8Z HolderCommitmentTransaction_write(const struct LDKHolderCommitmentTransaction *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice Nonce_as_slice(const struct LDKNonce *NONNULL_PTR this_arg); /** - * Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write + * Serialize the Nonce object into a byte array which can be read by Nonce_read */ -struct LDKCResult_HolderCommitmentTransactionDecodeErrorZ HolderCommitmentTransaction_read(struct LDKu8slice ser); +struct LDKCVec_u8Z Nonce_write(const struct LDKNonce *NONNULL_PTR obj); /** - * Create a new holder transaction with the given counterparty signatures. - * The funding keys are used to figure out which signature should go first when building the transaction for broadcast. + * Read a Nonce from a byte array, created by Nonce_write */ -MUST_USE_RES struct LDKHolderCommitmentTransaction HolderCommitmentTransaction_new(struct LDKCommitmentTransaction commitment_tx, struct LDKECDSASignature counterparty_sig, struct LDKCVec_ECDSASignatureZ counterparty_htlc_sigs, struct LDKPublicKey holder_funding_key, struct LDKPublicKey counterparty_funding_key); +struct LDKCResult_NonceDecodeErrorZ Nonce_read(struct LDKu8slice ser); /** - * Frees any resources used by the BuiltCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. */ -void BuiltCommitmentTransaction_free(struct LDKBuiltCommitmentTransaction this_obj); +void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); /** - * The commitment transaction + * Creates a copy of the Bolt12ParseError */ -struct LDKTransaction BuiltCommitmentTransaction_get_transaction(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr); +struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); /** - * The commitment transaction + * Creates a copy of the Bolt12SemanticError */ -void BuiltCommitmentTransaction_set_transaction(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKTransaction val); +enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError */ -const uint8_t (*BuiltCommitmentTransaction_get_txid(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr))[32]; +enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); /** - * The txid for the commitment transaction. - * - * This is provided as a performance optimization, instead of calling transaction.txid() - * multiple times. + * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError */ -void BuiltCommitmentTransaction_set_txid(struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); /** - * Constructs a new BuiltCommitmentTransaction given each field + * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_new(struct LDKTransaction transaction_arg, struct LDKThirtyTwoBytes txid_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); /** - * Creates a copy of the BuiltCommitmentTransaction + * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError */ -struct LDKBuiltCommitmentTransaction BuiltCommitmentTransaction_clone(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); /** - * Serialize the BuiltCommitmentTransaction object into a byte array which can be read by BuiltCommitmentTransaction_read + * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError */ -struct LDKCVec_u8Z BuiltCommitmentTransaction_write(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR obj); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); /** - * Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write + * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError */ -struct LDKCResult_BuiltCommitmentTransactionDecodeErrorZ BuiltCommitmentTransaction_read(struct LDKu8slice ser); +enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKThirtyTwoBytes BuiltCommitmentTransaction_get_sighash_all(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); /** - * Signs the counterparty's commitment transaction. + * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_counterparty_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); /** - * Signs the holder commitment transaction because we are about to broadcast it. + * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKECDSASignature BuiltCommitmentTransaction_sign_holder_commitment(const struct LDKBuiltCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis, const struct LDKEntropySource *NONNULL_PTR entropy_source); +enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); /** - * Frees any resources used by the ClosingTransaction, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError */ -void ClosingTransaction_free(struct LDKClosingTransaction this_obj); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); /** - * Creates a copy of the ClosingTransaction + * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError */ -struct LDKClosingTransaction ClosingTransaction_clone(const struct LDKClosingTransaction *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); /** - * Generates a non-cryptographic 64-bit hash of the ClosingTransaction. + * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError */ -uint64_t ClosingTransaction_hash(const struct LDKClosingTransaction *NONNULL_PTR o); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); /** - * Checks if two ClosingTransactions contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError */ -bool ClosingTransaction_eq(const struct LDKClosingTransaction *NONNULL_PTR a, const struct LDKClosingTransaction *NONNULL_PTR b); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); /** - * Construct an object of the class + * Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKClosingTransaction ClosingTransaction_new(uint64_t to_holder_value_sat, uint64_t to_counterparty_value_sat, struct LDKCVec_u8Z to_holder_script, struct LDKCVec_u8Z to_counterparty_script, struct LDKOutPoint funding_outpoint); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_signing_pubkey(void); /** - * Trust our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKTrustedClosingTransaction ClosingTransaction_trust(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); /** - * Verify our pre-built transaction. - * - * Applies a wrapper which allows access to the transaction. - * - * An external validating signer must call this method before signing - * or using the built transaction. + * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKCResult_TrustedClosingTransactionNoneZ ClosingTransaction_verify(const struct LDKClosingTransaction *NONNULL_PTR this_arg, struct LDKOutPoint funding_outpoint); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); /** - * The value to be sent to the holder, or zero if the output will be omitted + * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError */ -MUST_USE_RES uint64_t ClosingTransaction_to_holder_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); /** - * The value to be sent to the counterparty, or zero if the output will be omitted + * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError */ -MUST_USE_RES uint64_t ClosingTransaction_to_counterparty_value_sat(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); /** - * The destination of the holder's output + * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_holder_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); /** - * The destination of the counterparty's output + * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKu8slice ClosingTransaction_to_counterparty_script(const struct LDKClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); /** - * Frees any resources used by the TrustedClosingTransaction, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError */ -void TrustedClosingTransaction_free(struct LDKTrustedClosingTransaction this_obj); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_id(void); /** - * The pre-built Bitcoin commitment transaction + * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKTransaction TrustedClosingTransaction_built_transaction(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); /** - * Get the SIGHASH_ALL sighash value of the transaction. - * - * This can be used to verify a signature. + * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedClosingTransaction_get_sighash_all(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); /** - * Sign a transaction, either because we are counter-signing the counterparty's transaction or - * because we are about to broadcast a holder transaction. + * Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError */ -MUST_USE_RES struct LDKECDSASignature TrustedClosingTransaction_sign(const struct LDKTrustedClosingTransaction *NONNULL_PTR this_arg, const uint8_t (*funding_key)[32], struct LDKu8slice funding_redeemscript, uint64_t channel_value_satoshis); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_paths(void); /** - * Frees any resources used by the CommitmentTransaction, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError */ -void CommitmentTransaction_free(struct LDKCommitmentTransaction this_obj); +enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); /** - * Creates a copy of the CommitmentTransaction + * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError */ -struct LDKCommitmentTransaction CommitmentTransaction_clone(const struct LDKCommitmentTransaction *NONNULL_PTR orig); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); /** - * Serialize the CommitmentTransaction object into a byte array which can be read by CommitmentTransaction_read + * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError */ -struct LDKCVec_u8Z CommitmentTransaction_write(const struct LDKCommitmentTransaction *NONNULL_PTR obj); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); /** - * Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write + * Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError */ -struct LDKCResult_CommitmentTransactionDecodeErrorZ CommitmentTransaction_read(struct LDKu8slice ser); +enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_payment_hash(void); /** - * The backwards-counting commitment number + * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError */ -MUST_USE_RES uint64_t CommitmentTransaction_commitment_number(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); /** - * The per commitment point used by the broadcaster. + * Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPublicKey CommitmentTransaction_per_commitment_point(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +void RefundMaybeWithDerivedMetadataBuilder_free(struct LDKRefundMaybeWithDerivedMetadataBuilder this_obj); /** - * The value to be sent to the broadcaster + * Creates a copy of the RefundMaybeWithDerivedMetadataBuilder */ -MUST_USE_RES uint64_t CommitmentTransaction_to_broadcaster_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKRefundMaybeWithDerivedMetadataBuilder RefundMaybeWithDerivedMetadataBuilder_clone(const struct LDKRefundMaybeWithDerivedMetadataBuilder *NONNULL_PTR orig); /** - * The value to be sent to the counterparty + * Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to + * send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey. + * + * Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], + * and [`Refund::amount_msats`]. + * + * # Note + * + * If constructing a [`Refund`] for use with a [`ChannelManager`], use + * [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + * [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder */ -MUST_USE_RES uint64_t CommitmentTransaction_to_countersignatory_value_sat(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_new(struct LDKCVec_u8Z metadata, struct LDKPublicKey payer_id, uint64_t amount_msats); /** - * The feerate paid per 1000-weight-unit in this commitment transaction. + * Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id + * is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a + * different payer id for each refund, assuming a different nonce is used. Otherwise, the + * provided `node_id` is used for the payer id. + * + * Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by + * [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the + * refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the + * metadata must be included in each [`BlindedMessagePath`] instead. In this case, use + * [`Bolt12Invoice::verify_using_payer_data`]. + * + * The `payment_id` is encrypted in the metadata and should be unique. This ensures that only + * one invoice will be paid for the refund and that payments can be uniquely identified. + * + * [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata + * [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data + * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey */ -MUST_USE_RES uint32_t CommitmentTransaction_feerate_per_kw(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(struct LDKPublicKey node_id, const struct LDKExpandedKey *NONNULL_PTR expanded_key, struct LDKNonce nonce, uint64_t amount_msats, struct LDKThirtyTwoBytes payment_id); /** - * Trust our pre-built transaction and derived transaction creation public keys. - * - * Applies a wrapper which allows access to these fields. + * Sets the [`Refund::description`]. * - * This should only be used if you fully trust the builder of this object. It should not - * be used by an external signer - instead use the verify function. + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKTrustedCommitmentTransaction CommitmentTransaction_trust(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_description(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr description); /** - * Verify our pre-built transaction and derived transaction creation public keys. + * Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has + * already passed is valid and can be checked for using [`Refund::is_expired`]. * - * Applies a wrapper which allows access to these fields. + * Successive calls to this method will override the previous setting. + */ +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t absolute_expiry); + +/** + * Sets the [`Refund::issuer`]. * - * An external validating signer must call this method before signing - * or using the built transaction. + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKCResult_TrustedCommitmentTransactionNoneZ CommitmentTransaction_verify(const struct LDKCommitmentTransaction *NONNULL_PTR this_arg, const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKChannelPublicKeys *NONNULL_PTR broadcaster_keys, const struct LDKChannelPublicKeys *NONNULL_PTR countersignatory_keys); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_issuer(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr issuer); /** - * Frees any resources used by the TrustedCommitmentTransaction, if is_owned is set and inner is non-NULL. + * Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected + * by private channels or if [`Refund::payer_id`] is not a public node id. + * + * Successive calls to this method will add another blinded path. Caller is responsible for not + * adding duplicate paths. */ -void TrustedCommitmentTransaction_free(struct LDKTrustedCommitmentTransaction this_obj); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_path(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKBlindedMessagePath path); /** - * The transaction ID of the built Bitcoin transaction + * Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not + * called, [`Network::Bitcoin`] is assumed. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKThirtyTwoBytes TrustedCommitmentTransaction_txid(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_chain(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, enum LDKNetwork network); /** - * The pre-built Bitcoin commitment transaction + * Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful + * when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an + * [`Offer`] as specified by [`InvoiceRequest::quantity`]. + * + * Successive calls to this method will override the previous setting. + * + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity + * [`Offer`]: crate::offers::offer::Offer */ -MUST_USE_RES struct LDKBuiltCommitmentTransaction TrustedCommitmentTransaction_built_transaction(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_quantity(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, uint64_t quantity); /** - * The pre-calculated transaction creation public keys. + * Sets the [`Refund::payer_note`]. + * + * Successive calls to this method will override the previous setting. */ -MUST_USE_RES struct LDKTxCreationKeys TrustedCommitmentTransaction_keys(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES void RefundMaybeWithDerivedMetadataBuilder_payer_note(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg, struct LDKStr payer_note); /** - * Should anchors be used. + * Builds a [`Refund`] after checking for valid semantics. */ -MUST_USE_RES struct LDKChannelTypeFeatures TrustedCommitmentTransaction_channel_type_features(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_RefundBolt12SemanticErrorZ RefundMaybeWithDerivedMetadataBuilder_build(struct LDKRefundMaybeWithDerivedMetadataBuilder this_arg); /** - * Get a signature for each HTLC which was included in the commitment transaction (ie for - * which HTLCOutputInCommitment::transaction_output_index.is_some()). - * - * The returned Vec has one entry for each HTLC, and in the same order. - * - * This function is only valid in the holder commitment context, it always uses EcdsaSighashType::All. + * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_CVec_ECDSASignatureZNoneZ TrustedCommitmentTransaction_get_htlc_sigs(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, const uint8_t (*htlc_base_key)[32], const struct LDKDirectedChannelTransactionParameters *NONNULL_PTR channel_parameters, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void Refund_free(struct LDKRefund this_obj); /** - * Returns the index of the revokeable output, i.e. the `to_local` output sending funds to - * the broadcaster, in the built transaction, if any exists. - * - * There are two cases where this may return `None`: - * - The balance of the revokeable output is below the dust limit (only found on commitments - * early in the channel's lifetime, i.e. before the channel reserve is met). - * - This commitment was created before LDK 0.0.117. In this case, the - * commitment transaction previously didn't contain enough information to locate the - * revokeable output. + * Creates a copy of the Refund */ -MUST_USE_RES struct LDKCOption_usizeZ TrustedCommitmentTransaction_revokeable_output_index(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg); +struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); /** - * Helper method to build an unsigned justice transaction spending the revokeable - * `to_local` output to a destination script. Fee estimation accounts for the expected - * revocation witness data that will be added when signed. - * - * This method will error if the given fee rate results in a fee greater than the value - * of the output being spent, or if there exists no revokeable `to_local` output on this - * commitment transaction. See [`Self::revokeable_output_index`] for more details. - * - * The built transaction will allow fee bumping with RBF, and this method takes - * `feerate_per_kw` as an input such that multiple copies of a justice transaction at different - * fee rates may be built. + * A complete description of the purpose of the refund. Intended to be displayed to the user + * but with the caveat that it has not been verified in any way. */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ TrustedCommitmentTransaction_build_to_local_justice_tx(const struct LDKTrustedCommitmentTransaction *NONNULL_PTR this_arg, uint64_t feerate_per_kw, struct LDKCVec_u8Z destination_script); +MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Commitment transaction numbers which appear in the transactions themselves are XOR'd with a - * shared secret first. This prevents on-chain observers from discovering how many commitment - * transactions occurred in a channel before it was closed. + * Duration since the Unix epoch when an invoice should no longer be sent. * - * This function gets the shared secret from relevant channel public keys and can be used to - * \"decrypt\" the commitment transaction number given a commitment transaction on-chain. + * If `None`, the refund does not expire. */ -uint64_t get_commitment_transaction_number_obscure_factor(struct LDKPublicKey broadcaster_payment_basepoint, struct LDKPublicKey countersignatory_payment_basepoint, bool outbound_from_broadcaster); +MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two InitFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Whether the refund has expired. */ -bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); +MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two NodeFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Whether the refund has expired given the duration since the Unix epoch. */ -bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); +MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); /** - * Checks if two ChannelFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be + * displayed to the user but with the caveat that it has not been verified in any way. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two Bolt11InvoiceFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender + * privacy by obfuscating its node id. */ -bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKCVec_BlindedMessagePathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two OfferFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * An unpredictable series of bytes, typically containing information about the derivation of + * [`payer_id`]. + * + * [`payer_id`]: Self::payer_id */ -bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two InvoiceRequestFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * A chain that the refund is valid for. */ -bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two Bolt12InvoiceFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). + * + * [`chain`]: Self::chain */ -bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); +MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two BlindedHopFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Features pertaining to requesting an invoice. */ -bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Checks if two ChannelTypeFeaturess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The quantity of an item that refund is for. */ -bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); +MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Creates a copy of the InitFeatures + * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly + * transient pubkey. + * + * [`paths`]: Self::paths */ -struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); +MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Creates a copy of the NodeFeatures + * Payer provided note to include in the invoice. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); +MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); /** - * Creates a copy of the ChannelFeatures + * Generates a non-cryptographic 64-bit hash of the Refund. */ -struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); +uint64_t Refund_hash(const struct LDKRefund *NONNULL_PTR o); /** - * Creates a copy of the Bolt11InvoiceFeatures + * Read a Refund from a byte array, created by Refund_write */ -struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); +struct LDKCResult_RefundDecodeErrorZ Refund_read(struct LDKu8slice ser); /** - * Creates a copy of the OfferFeatures + * Serialize the Refund object into a byte array which can be read by Refund_read */ -struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); +struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); /** - * Creates a copy of the InvoiceRequestFeatures + * Read a Refund object from a string */ -struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); +struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); /** - * Creates a copy of the Bolt12InvoiceFeatures + * Get the string representation of a Refund object */ -struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); +struct LDKStr Refund_to_str(const struct LDKRefund *NONNULL_PTR o); /** - * Creates a copy of the BlindedHopFeatures + * Creates a copy of the UtxoLookupError */ -struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); +enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); /** - * Creates a copy of the ChannelTypeFeatures + * Utility method to constructs a new UnknownChain-variant UtxoLookupError */ -struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); +enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); /** - * Generates a non-cryptographic 64-bit hash of the InitFeatures. + * Utility method to constructs a new UnknownTx-variant UtxoLookupError */ -uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); +enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); /** - * Generates a non-cryptographic 64-bit hash of the NodeFeatures. + * Frees any resources used by the UtxoResult */ -uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); +void UtxoResult_free(struct LDKUtxoResult this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. + * Creates a copy of the UtxoResult */ -uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); +struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. + * Utility method to constructs a new Sync-variant UtxoResult */ -uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); +struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); /** - * Generates a non-cryptographic 64-bit hash of the OfferFeatures. + * Utility method to constructs a new Async-variant UtxoResult */ -uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); +struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); /** - * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. + * Calls the free function if one is set */ -uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); +void UtxoLookup_free(struct LDKUtxoLookup this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. + * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. */ -uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); +void UtxoFuture_free(struct LDKUtxoFuture this_obj); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. + * Creates a copy of the UtxoFuture */ -uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); +struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. + * Builds a new future for later resolution. */ -uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); +MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); /** - * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. + * Resolves this future against the given `graph` and with the given `result`. + * + * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling + * forwarding the validated gossip message onwards to peers. + * + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. + * + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -void InitFeatures_free(struct LDKInitFeatures this_obj); +void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. + * Resolves this future against the given `graph` and with the given `result`. + * + * The given `gossip` is used to broadcast any validated messages onwards to all peers which + * have available buffer space. + * + * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order + * to allow us to interact with peers again, you should call [`PeerManager::process_events`] + * after this. + * + * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high + * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events */ -void NodeFeatures_free(struct LDKNodeFeatures this_obj); +void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); /** - * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. */ -void ChannelFeatures_free(struct LDKChannelFeatures this_obj); +void NodeId_free(struct LDKNodeId this_obj); /** - * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Creates a copy of the NodeId */ -void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); +struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); /** - * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. + * Checks if two NodeIds contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void OfferFeatures_free(struct LDKOfferFeatures this_obj); +bool NodeId_eq(const struct LDKNodeId *NONNULL_PTR a, const struct LDKNodeId *NONNULL_PTR b); /** - * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. + * Create a new NodeId from a public key */ -void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); +MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); /** - * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. + * Create a new NodeId from a slice of bytes */ -void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); +MUST_USE_RES struct LDKCResult_NodeIdDecodeErrorZ NodeId_from_slice(struct LDKu8slice bytes); /** - * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. + * Get the public key slice from this NodeId */ -void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); +MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. + * Get the public key as an array from this NodeId */ -void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); +MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; /** - * Create a blank Features with no features set + * Get the public key from this NodeId */ -MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); +MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Get the string representation of a NodeId object */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); +struct LDKStr NodeId_to_str(const struct LDKNodeId *NONNULL_PTR o); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Generates a non-cryptographic 64-bit hash of the NodeId. */ -MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Serialize the NodeId object into a byte array which can be read by NodeId_read */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Read a NodeId from a byte array, created by NodeId_write */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void NetworkGraph_free(struct LDKNetworkGraph this_obj); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); /** - * Create a blank Features with no features set + * Frees any resources used by the NetworkUpdate */ -MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); +void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Creates a copy of the NetworkUpdate */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); +struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ -MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Utility method to constructs a new NodeFailure-variant NetworkUpdate */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write */ -MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); /** - * Create a blank Features with no features set + * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); +void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming an existing [`NetworkGraph`]. + * UTXO lookup is used to make sure announced channels exist on-chain, channel data is + * correct, and the announcement is signed with channel owners' keys. */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); +MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Adds a provider used to check new announcements. Does not affect + * existing announcements unless they are updated. + * Add, update or remove the provider would replace the current one. */ -MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); +void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * Handles any network updates originating from [`Event`]s. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * [`Event`]: crate::events::Event */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Gets the chain hash for this network graph. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * Verifies the signature of a [`NodeAnnouncement`]. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Returns an error if it is invalid. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * Verifies all signatures included in a [`ChannelAnnouncement`]. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits - */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); - -/** - * Create a blank Features with no features set + * Returns an error if one of the signatures is invalid. */ -MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); +struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); +struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * The minimum value, which must be relayed to the next hop via the channel */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Create a blank Features with no features set + * The maximum value which may be relayed to the next hop via the channel. */ -MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); +void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Fees charged when the channel is used for routing */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); +struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Fees charged when the channel is used for routing */ -MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); +void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * When the last update to the channel direction was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * The difference in CLTV values that you must have when routing through this channel. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Create a blank Features with no features set + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); +bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Whether the channel can be currently used for payments (in this one direction). */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); +void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); +struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * Most recent update for the channel received from the network + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * Constructs a new ChannelUpdateInfo given each field * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, uint32_t last_update_arg, uint16_t cltv_expiry_delta_arg, bool enabled_arg, struct LDKChannelUpdate last_update_message_arg); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Creates a copy of the ChannelUpdateInfo */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Checks if two ChannelUpdateInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); /** - * Create a blank Features with no features set + * Get the string representation of a ChannelUpdateInfo object */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); +struct LDKStr ChannelUpdateInfo_to_str(const struct LDKChannelUpdateInfo *NONNULL_PTR o); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); +struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelInfo_free(struct LDKChannelInfo this_obj); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Protocol features of a channel communicated during its announcement */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Source node of the first direction of a channel */ -MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Create a blank Features with no features set + * Source node of the first direction of a channel */ -MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); +void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Source node of the second direction of a channel */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); +struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * Source node of the second direction of a channel */ -MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); +void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * The channel capacity as seen on-chain, if chain lookup is available. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * Details about the first direction of a channel * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * Details about the first direction of a channel * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Create a blank Features with no features set + * Details about the second direction of a channel + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); +struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Returns true if this `Features` object contains required features unknown by `other`. + * Details about the second direction of a channel + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); +void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); /** - * Returns true if this `Features` object contains unknown feature flags which are set as - * \"required\". + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); /** - * Sets a required feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). + * An initial announcement of the channel + * Mostly redundant with the data we store in fields explicitly. + * Everything else is useful only for sending out for initial routing sync. + * Not stored if contains excess data to prevent DoS. * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); /** - * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined - * by [BOLT 9]. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). - * - * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md + * Creates a copy of the ChannelInfo */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); /** - * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will - * be set instead (i.e., `bit - 1`). - * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Checks if two ChannelInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); /** - * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined - * by [bLIP 2] or if it is a known `T` feature. - * - * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be - * set instead (i.e., `bit + 1`). + * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. * - * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); +MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); /** - * Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read + * Get the string representation of a ChannelInfo object */ -struct LDKCVec_u8Z InitFeatures_write(const struct LDKInitFeatures *NONNULL_PTR obj); +struct LDKStr ChannelInfo_to_str(const struct LDKChannelInfo *NONNULL_PTR o); /** - * Read a InitFeatures from a byte array, created by InitFeatures_write + * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read */ -struct LDKCResult_InitFeaturesDecodeErrorZ InitFeatures_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); /** - * Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read + * Read a ChannelInfo from a byte array, created by ChannelInfo_write */ -struct LDKCVec_u8Z ChannelFeatures_write(const struct LDKChannelFeatures *NONNULL_PTR obj); +struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); /** - * Read a ChannelFeatures from a byte array, created by ChannelFeatures_write + * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_ChannelFeaturesDecodeErrorZ ChannelFeatures_read(struct LDKu8slice ser); +void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); /** - * Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read + * Creates a copy of the DirectedChannelInfo */ -struct LDKCVec_u8Z NodeFeatures_write(const struct LDKNodeFeatures *NONNULL_PTR obj); +struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); /** - * Read a NodeFeatures from a byte array, created by NodeFeatures_write + * Returns information for the channel. */ -struct LDKCResult_NodeFeaturesDecodeErrorZ NodeFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read + * Returns the [`EffectiveCapacity`] of the channel in the direction. + * + * This is either the total capacity from the funding transaction, if known, or the + * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, + * otherwise. */ -struct LDKCVec_u8Z Bolt11InvoiceFeatures_write(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write + * Returns the `node_id` of the source hop. + * + * Refers to the `node_id` forwarding the payment to the next hop. */ -struct LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ Bolt11InvoiceFeatures_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_source(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read + * Returns the `node_id` of the target hop. + * + * Refers to the `node_id` receiving the payment from the previous hop. */ -struct LDKCVec_u8Z Bolt12InvoiceFeatures_write(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR obj); +MUST_USE_RES struct LDKNodeId DirectedChannelInfo_target(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); /** - * Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write + * Frees any resources used by the EffectiveCapacity */ -struct LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ Bolt12InvoiceFeatures_read(struct LDKu8slice ser); +void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); /** - * Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read + * Creates a copy of the EffectiveCapacity */ -struct LDKCVec_u8Z BlindedHopFeatures_write(const struct LDKBlindedHopFeatures *NONNULL_PTR obj); +struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); /** - * Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write + * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity */ -struct LDKCResult_BlindedHopFeaturesDecodeErrorZ BlindedHopFeatures_read(struct LDKu8slice ser); +struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); /** - * Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read + * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity */ -struct LDKCVec_u8Z ChannelTypeFeatures_write(const struct LDKChannelTypeFeatures *NONNULL_PTR obj); +struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); /** - * Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write + * Utility method to constructs a new Total-variant EffectiveCapacity */ -struct LDKCResult_ChannelTypeFeaturesDecodeErrorZ ChannelTypeFeatures_read(struct LDKu8slice ser); +struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); /** - * Set this feature as optional. + * Utility method to constructs a new Infinite-variant EffectiveCapacity */ -void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); /** - * Set this feature as required. + * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity */ -void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); /** - * Checks if this feature is supported. + * Utility method to constructs a new Unknown-variant EffectiveCapacity */ -MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); /** - * Set this feature as optional. + * Returns the effective capacity denominated in millisatoshi. */ -void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read */ -void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); /** - * Checks if this feature is supported. + * Read a RoutingFees from a byte array, created by RoutingFees_write */ -MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); /** - * Checks if this feature is required. + * Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_free(struct LDKNodeAnnouncementDetails this_obj); /** - * Checks if this feature is required. + * Protocol features the node announced support for */ -MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKNodeFeatures NodeAnnouncementDetails_get_features(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Protocol features the node announced support for */ -void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_features(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Set this feature as required. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint32_t NodeAnnouncementDetails_get_last_update(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * When the last known update to the node state was issued. + * Value is opaque, as set in the announcement. */ -MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_last_update(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, uint32_t val); /** - * Set this feature as optional. + * Color assigned to the node */ -void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +const uint8_t (*NodeAnnouncementDetails_get_rgb(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr))[3]; /** - * Set this feature as required. + * Color assigned to the node */ -void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_rgb(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKThreeBytes val); /** - * Checks if this feature is supported. + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKNodeAlias NodeAnnouncementDetails_get_alias(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Moniker assigned to the node. + * May be invalid or malicious (eg control chars), + * should not be exposed to the user. */ -void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_alias(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKNodeAlias val); /** - * Set this feature as required. + * Internet-level addresses via which one can connect to the node + * + * Returns a copy of the field. */ -void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_SocketAddressZ NodeAnnouncementDetails_get_addresses(const struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * Internet-level addresses via which one can connect to the node */ -MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementDetails_set_addresses(struct LDKNodeAnnouncementDetails *NONNULL_PTR this_ptr, struct LDKCVec_SocketAddressZ val); /** - * Checks if this feature is required. + * Constructs a new NodeAnnouncementDetails given each field */ -MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKCVec_SocketAddressZ addresses_arg); /** - * Checks if this feature is required. + * Creates a copy of the NodeAnnouncementDetails */ -MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementDetails NodeAnnouncementDetails_clone(const struct LDKNodeAnnouncementDetails *NONNULL_PTR orig); /** - * Set this feature as optional. + * Checks if two NodeAnnouncementDetailss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool NodeAnnouncementDetails_eq(const struct LDKNodeAnnouncementDetails *NONNULL_PTR a, const struct LDKNodeAnnouncementDetails *NONNULL_PTR b); /** - * Set this feature as required. + * Frees any resources used by the NodeAnnouncementInfo */ -void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_ptr); /** - * Checks if this feature is supported. + * Creates a copy of the NodeAnnouncementInfo */ -MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); /** - * Set this feature as optional. + * Utility method to constructs a new Relayed-variant NodeAnnouncementInfo */ -void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_relayed(struct LDKNodeAnnouncement a); /** - * Set this feature as required. + * Utility method to constructs a new Local-variant NodeAnnouncementInfo */ -void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_local(struct LDKNodeAnnouncementDetails a); /** - * Checks if this feature is supported. + * Checks if two NodeAnnouncementInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); /** - * Checks if this feature is required. + * Protocol features the node announced support for */ -MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeFeatures NodeAnnouncementInfo_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * When the last known update to the node state was issued. + * + * Value may or may not be a timestamp, depending on the policy of the origin node. */ -MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint32_t NodeAnnouncementInfo_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Color assigned to the node */ -void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKThreeBytes NodeAnnouncementInfo_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Moniker assigned to the node. + * + * May be invalid or malicious (eg control chars), should not be exposed to the user. */ -void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAlias NodeAnnouncementInfo_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Internet-level addresses via which one can connect to the node */ -MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * An initial announcement of the node + * + * Not stored if contains excess data to prevent DoS. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAnnouncement NodeAnnouncementInfo_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read */ -void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); /** - * Checks if this feature is supported. + * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write */ -MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); /** - * Set this feature as optional. + * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. */ -void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void NodeAlias_free(struct LDKNodeAlias this_obj); + +const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; + +void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Set this feature as required. + * Constructs a new NodeAlias given each field */ -void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); /** - * Checks if this feature is supported. + * Creates a copy of the NodeAlias */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Generates a non-cryptographic 64-bit hash of the NodeAlias. */ -MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); /** - * Checks if this feature is required. + * Checks if two NodeAliass contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); /** - * Checks if this feature is required. + * Get the string representation of a NodeAlias object */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKStr NodeAlias_to_str(const struct LDKNodeAlias *NONNULL_PTR o); /** - * Set this feature as optional. + * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read */ -void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); /** - * Set this feature as required. + * Read a NodeAlias from a byte array, created by NodeAlias_write */ -void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); /** - * Checks if this feature is supported. + * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void NodeInfo_free(struct LDKNodeInfo this_obj); /** - * Set this feature as optional. + * All valid channels a node has announced + * + * Returns a copy of the field. */ -void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * All valid channels a node has announced */ -void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Checks if this feature is supported. + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. + * + * Returns a copy of the field. */ -MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_NodeAnnouncementInfoZ NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * More information about a node from node_announcement. + * Optional because we store a Node entry after learning about it from + * a channel announcement, but before receiving a node announcement. */ -void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCOption_NodeAnnouncementInfoZ val); /** - * Set this feature as required. + * Creates a copy of the NodeInfo */ -void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Checks if two NodeInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); /** - * Checks if this feature is required. + * Returns whether the node has only announced Tor addresses. */ -MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeInfo_is_tor_only(const struct LDKNodeInfo *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Get the string representation of a NodeInfo object */ -MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr NodeInfo_to_str(const struct LDKNodeInfo *NONNULL_PTR o); /** - * Checks if this feature is required. + * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read */ -MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); /** - * Set this feature as optional. + * Read a NodeInfo from a byte array, created by NodeInfo_write */ -void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); /** - * Set this feature as required. + * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read */ -void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); /** - * Checks if this feature is supported. + * Read a NetworkGraph from a byte array, created by NetworkGraph_write */ -MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); /** - * Set this feature as optional. + * Get the string representation of a NetworkGraph object */ -void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr NetworkGraph_to_str(const struct LDKNetworkGraph *NONNULL_PTR o); /** - * Set this feature as required. + * Creates a new, empty, network graph. */ -void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); /** - * Checks if this feature is supported. + * Returns a read-only view of the network graph. */ -MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * The unix timestamp provided by the most recent rapid gossip sync. + * It will be set by the rapid sync process after every sync completion. */ -void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Update the unix timestamp provided by the most recent rapid gossip sync. + * This should be done automatically by the rapid sync process after every sync completion. */ -void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); /** - * Checks if this feature is supported. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement. + * + * You probably don't want to call this directly, instead relying on a P2PGossipSync's + * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); /** - * Checks if this feature is required. + * For an already known node (from channel announcements), update its stored properties from a + * given node announcement without verifying the associated signatures. Because we aren't + * given the associated signatures here we cannot relay the node announcement to any of our + * peers. */ -MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); /** - * Checks if this feature is required. + * Store or update channel info from a channel announcement. + * + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Checks if this feature is required. + * Store or update channel info from a channel announcement. + * + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * This will skip verification of if the channel is actually on-chain. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement_no_lookup(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); /** - * Set this feature as optional. + * Store or update channel info from a channel announcement without verifying the associated + * signatures. Because we aren't given the associated signatures here we cannot relay the + * channel announcement to any of our peers. + * + * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify + * the corresponding UTXO exists on chain and is correctly-formatted. */ -void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); /** - * Set this feature as required. + * Update channel from partial announcement data received via rapid gossip sync + * + * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the + * rapid gossip sync server) + * + * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. */ -void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); /** - * Checks if this feature is supported. + * Marks a channel in the graph as failed permanently. + * + * The channel and any node for which this was their last channel are removed from the graph. */ -MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * Set this feature as optional. + * Marks a node in the graph as permanently failed, effectively removing it and its channels + * from local storage. */ -void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); /** - * Set this feature as required. + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * Note that for users of the `lightning-background-processor` crate this method may be + * automatically called regularly for you. + * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + * This method is only available with the `std` feature. See + * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. */ -void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Removes information about channels that we haven't heard any updates about in some time. + * This can be used regularly to prune the network graph of channels that likely no longer + * exist. + * + * While there is no formal requirement that nodes regularly re-broadcast their channel + * updates every two weeks, the non-normative section of BOLT 7 currently suggests that + * pruning occur for updates which are at least two weeks old, which we implement here. + * + * This method will also cause us to stop tracking removed nodes and channels if they have been + * in the map for a while so that these can be resynced from gossip in the future. + * + * This function takes the current unix time as an argument. For users with the `std` feature + * enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. */ -MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); /** - * Set this feature as optional. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel. + * + * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s + * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept + * routing messages from a source using a protocol other than the lightning P2P protocol. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * Set this feature as required. + * For an already known (from announcement) channel, update info about one of the directions + * of the channel without verifying the associated signatures. Because we aren't given the + * associated signatures here we cannot relay the channel update to any of our peers. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); /** - * Checks if this feature is supported. + * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. + * + * This checks whether the update currently is applicable by [`Self::update_channel`]. + * + * If built with `no-std`, any updates with a timestamp more than two weeks in the past or + * materially in the future will be rejected. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); /** - * Set this feature as optional. + * Returns information on a channel with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); /** - * Set this feature as required. + * Returns the list of channels in the graph */ -void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Returns information on a node with the given id. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * Checks if this feature is required. + * Returns the list of nodes in the graph */ -MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Get network addresses by node id. + * Returns None if the requested node is completely unknown, + * or if node announcement for the node was never received. */ -MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); /** - * Checks if this feature is required. + * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void DefaultRouter_free(struct LDKDefaultRouter this_obj); /** - * Checks if this feature is required. + * Creates a new router. */ -MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); /** - * Set this feature as optional. + * Constructs a new Router which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is */ -void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Constructs a new MessageRouter which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is */ -void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKMessageRouter DefaultRouter_as_MessageRouter(const struct LDKDefaultRouter *NONNULL_PTR this_arg); /** - * Checks if this feature is supported. + * Calls the free function if one is set */ -MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void Router_free(struct LDKRouter this_ptr); /** - * Set this feature as optional. + * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. */ -void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); /** - * Set this feature as required. + * Initialize a new `ScorerAccountingForInFlightHtlcs`. */ -void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); /** - * Checks if this feature is supported. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); + +/** + * Creates a copy of the InFlightHtlcs + */ +struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Constructs an empty `InFlightHtlcs`. */ -MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); /** - * Set this feature as optional. + * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); /** - * Set this feature as required. + * Adds a known HTLC given the public key of the HTLC source, target, and short channel + * id. */ -void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void InFlightHtlcs_add_inflight_htlc(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid, uint64_t used_msat); /** - * Checks if this feature is supported. + * Returns liquidity in msat given the public key of the HTLC source, target, and short channel + * id. */ -MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); /** - * Set this feature as optional. + * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); /** - * Set this feature as required. + * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write */ -void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); /** - * Checks if this feature is supported. + * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteHop_free(struct LDKRouteHop this_obj); /** - * Set this feature as optional. + * The node_id of the node at this hop. */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The node_id of the node at this hop. */ -void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if this feature is supported. + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The node_announcement features of the node at this hop. For the last hop, these may be + * amended to match the features present in the invoice this node generated. */ -MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); /** - * Checks if this feature is required. + * The channel that should be used from the previous hop to reach this node. */ -MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The channel that should be used from the previous hop to reach this node. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as optional. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The channel_announcement features of the channel that should be used from the previous hop + * to reach this node. */ -void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); /** - * Checks if this feature is supported. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire + * blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment */ -MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The fee taken on this hop (for paying for the use of the *next* channel in the path). + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire + * blinded path + * * otherwise, this is the full value of this [`Path`]'s part of the payment */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as required. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination */ -void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The CLTV delta added for this hop. + * If this is the last hop in [`Path::hops`]: + * * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded + * path + * * otherwise, this is the CLTV delta expected at the destination */ -MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); /** - * Set this feature as optional. + * Indicates whether this hop is possibly announced in the public network graph. + * + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * Indicates whether this hop is possibly announced in the public network graph. + * + * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we + * either know for sure it's announced in the public graph, or if any public channels exist + * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe + * the channel to be unannounced. + * + * Will be `true` for objects serialized with LDK version 0.0.116 and before. */ -void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); /** - * Checks if this feature is supported. + * Constructs a new RouteHop given each field */ -MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg, bool maybe_announced_channel_arg); /** - * Checks if this feature is required. + * Creates a copy of the RouteHop */ -MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); /** - * Checks if this feature is required. + * Generates a non-cryptographic 64-bit hash of the RouteHop. */ -MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); /** - * Checks if this feature is required. + * Checks if two RouteHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); /** - * Set this feature as optional. + * Serialize the RouteHop object into a byte array which can be read by RouteHop_read */ -void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); /** - * Set this feature as required. + * Read a RouteHop from a byte array, created by RouteHop_write */ -void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); /** - * Checks if this feature is supported. + * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedTail_free(struct LDKBlindedTail this_obj); /** - * Set this feature as optional. + * The hops of the [`BlindedPaymentPath`] provided by the recipient. */ -void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The hops of the [`BlindedPaymentPath`] provided by the recipient. */ -void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); /** - * Checks if this feature is supported. + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES bool NodeFeatures_supports_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * The blinding point of the [`BlindedPaymentPath`] provided by the recipient. */ -MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Checks if this feature is required. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -MUST_USE_RES bool NodeFeatures_requires_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from + * inferring the destination. May be 0. */ -void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); /** - * Set this feature as required. + * The total amount paid on this [`Path`], excluding the fees. */ -void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The total amount paid on this [`Path`], excluding the fees. */ -MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as optional. + * Constructs a new BlindedTail given each field */ -void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); /** - * Set this feature as required. + * Creates a copy of the BlindedTail */ -void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Generates a non-cryptographic 64-bit hash of the BlindedTail. */ -MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); /** - * Checks if this feature is required. + * Checks if two BlindedTails contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); /** - * Checks if this feature is required. + * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read */ -MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); /** - * Set this feature as optional. + * Read a BlindedTail from a byte array, created by BlindedTail_write */ -void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); /** - * Set this feature as required. + * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Path_free(struct LDKPath this_obj); /** - * Checks if this feature is supported. + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -MUST_USE_RES bool InitFeatures_supports_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The list of unblinded hops in this [`Path`]. Must be at least length one. */ -void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); /** - * Set this feature as required. + * The blinded path at which this path terminates, if we're sending to one, and its metadata. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The blinded path at which this path terminates, if we're sending to one, and its metadata. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); /** - * Set this feature as optional. + * Constructs a new Path given each field + * + * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); /** - * Set this feature as required. + * Creates a copy of the Path */ -void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Generates a non-cryptographic 64-bit hash of the Path. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); /** - * Checks if this feature is required. + * Checks if two Paths contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InitFeatures_requires_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); /** - * Checks if this feature is required. + * Gets the fees for a given path, excluding any excess paid to the recipient. */ -MUST_USE_RES bool NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * Checks if this feature is required. + * Gets the total amount paid on this [`Path`], excluding the fees. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Gets the final hop's CLTV expiry delta. */ -void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. */ -void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void Route_free(struct LDKRoute this_obj); /** - * Checks if this feature is supported. + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. */ -MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no + * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be + * the same. */ -void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); /** - * Set this feature as required. + * The `route_params` parameter passed to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The `route_params` parameter passed to [`find_route`]. + * + * This is used by `ChannelManager` to track information which may be required for retries. + * + * Will be `None` for objects serialized with LDK versions prior to 0.0.117. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); /** - * Checks if this feature is required. + * Constructs a new Route given each field + * + * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); /** - * Checks if this feature is required. + * Creates a copy of the Route */ -MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); /** - * Set this feature as optional. + * Generates a non-cryptographic 64-bit hash of the Route. */ -void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); /** - * Set this feature as required. + * Checks if two Routes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); /** - * Checks if this feature is supported. + * Returns the total amount of fees paid on this [`Route`]. + * + * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to + * the recipient, which can happen in excess of the amount passed to [`find_route`] via + * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message */ -MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); /** - * Set this feature as optional. + * Returns the total amount paid on this [`Route`], excluding the fees. + * + * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if + * we had to reach the [`htlc_minimum_msat`] limits. + * + * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message */ -void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); /** - * Set this feature as required. + * Get the string representation of a Route object */ -void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKStr Route_to_str(const struct LDKRoute *NONNULL_PTR o); /** - * Checks if this feature is supported. + * Serialize the Route object into a byte array which can be read by Route_read */ -MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); /** - * Checks if this feature is required. + * Read a Route from a byte array, created by Route_write */ -MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); /** - * Checks if this feature is required. + * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteParameters_free(struct LDKRouteParameters this_obj); /** - * Set this feature as optional. + * The parameters of the failed payment path. */ -void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The parameters of the failed payment path. */ -void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); /** - * Checks if this feature is supported. + * The amount in msats sent on the failed payment path. */ -MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The amount in msats sent on the failed payment path. */ -void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Set this feature as required. + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ -void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The maximum total fees, in millisatoshi, that may accrue during route finding. + * + * This limit also applies to the total fees that may arise while retrying failed payment + * paths. + * + * Note that values below a few sats may result in some paths being spuriously ignored. */ -MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Set this feature as optional. + * Constructs a new RouteParameters given each field */ -void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); /** - * Set this feature as required. + * Creates a copy of the RouteParameters */ -void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); /** - * Checks if this feature is supported. + * Generates a non-cryptographic 64-bit hash of the RouteParameters. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); /** - * Checks if this feature is required. + * Checks if two RouteParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); +bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); /** - * Checks if this feature is required. + * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. + * + * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats */ -MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); /** - * Checks if this feature is required. + * Sets the maximum number of hops that can be included in a payment path, based on the provided + * [`RecipientOnionFields`] and blinded paths. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ RouteParameters_set_max_path_length(struct LDKRouteParameters *NONNULL_PTR this_arg, const struct LDKRecipientOnionFields *NONNULL_PTR recipient_onion, bool is_keysend, uint32_t best_block_height); /** - * Set this feature as optional. + * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read */ -void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); /** - * Set this feature as required. + * Read a RouteParameters from a byte array, created by RouteParameters_write */ -void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); /** - * Checks if this feature is supported. + * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +void PaymentParameters_free(struct LDKPaymentParameters this_obj); /** - * Checks if this feature is required. + * Information about the payee, such as their features and route hints for their channels. */ -MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); +struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * Information about the payee, such as their features and route hints for their channels. */ -void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); /** - * Set this feature as required. + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); +struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. */ -MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Set this feature as optional. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Set this feature as required. + * The maximum total CLTV delta we accept for the route. + * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. */ -void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); /** - * Checks if this feature is supported. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * The maximum number of paths that may be used by (MPP) payments. + * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. */ -void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * Set this feature as required. + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. */ -void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +uint8_t PaymentParameters_get_max_path_length(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * The maximum number of [`Path::hops`] in any returned path. + * Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. */ -MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_max_path_length(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * Checks if this feature is required. + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. + * + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); +uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Checks if this feature is required. + * Selects the maximum share of a channel's total capacity which will be sent over a channel, + * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas + * a lower value prefers to send larger MPP parts, potentially saturating channels and + * increasing failure probability for those paths. + * + * Note that this restriction will be relaxed during pathfinding after paths which meet this + * restriction have been found. While paths which meet this criteria will be searched for, it + * is ultimately up to the scorer to select them over other paths. + * + * A value of 0 will allow payments up to and including a channel's total announced usable + * capacity, a value of one will only use up to half its capacity, two 1/4, etc. + * + * Default value: 2 */ -MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); /** - * Checks if this feature is required. + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. + * + * Returns a copy of the field. */ -MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Set this feature as optional. + * A list of SCIDs which this payment was previously attempted over and which caused the + * payment to fail. Future attempts for the same payment shouldn't be relayed through any of + * these SCIDs. */ -void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Set this feature as required. + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this + * payment was previously attempted over and which caused the payment to fail. Future attempts + * for the same payment shouldn't be relayed through any of these blinded paths. + * + * Returns a copy of the field. */ -void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); +struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); /** - * Checks if this feature is supported. + * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this + * payment was previously attempted over and which caused the payment to fail. Future attempts + * for the same payment shouldn't be relayed through any of these blinded paths. */ -MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); /** - * Checks if this feature is required. + * Constructs a new PaymentParameters given each field */ -MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPayee payee_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_path_length_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); /** - * Frees any resources used by the ShutdownScript, if is_owned is set and inner is non-NULL. + * Creates a copy of the PaymentParameters */ -void ShutdownScript_free(struct LDKShutdownScript this_obj); +struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); /** - * Creates a copy of the ShutdownScript + * Generates a non-cryptographic 64-bit hash of the PaymentParameters. */ -struct LDKShutdownScript ShutdownScript_clone(const struct LDKShutdownScript *NONNULL_PTR orig); +uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); /** - * Checks if two ShutdownScripts contain equal inner contents. + * Checks if two PaymentParameterss contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool ShutdownScript_eq(const struct LDKShutdownScript *NONNULL_PTR a, const struct LDKShutdownScript *NONNULL_PTR b); +bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); /** - * Frees any resources used by the InvalidShutdownScript, if is_owned is set and inner is non-NULL. + * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read */ -void InvalidShutdownScript_free(struct LDKInvalidShutdownScript this_obj); +struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); /** - * The script that did not meet the requirements from [BOLT #2]. - * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md + * Read a PaymentParameters from a byte array, created by PaymentParameters_write */ -struct LDKCVec_u8Z InvalidShutdownScript_get_script(const struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr); +struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); /** - * The script that did not meet the requirements from [BOLT #2]. + * Creates a payee with the node id of the given `pubkey`. * - * [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md - */ -void InvalidShutdownScript_set_script(struct LDKInvalidShutdownScript *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); - -/** - * Constructs a new InvalidShutdownScript given each field + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. */ -MUST_USE_RES struct LDKInvalidShutdownScript InvalidShutdownScript_new(struct LDKCVec_u8Z script_arg); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); /** - * Creates a copy of the InvalidShutdownScript + * Creates a payee with the node id of the given `pubkey` to use for keysend payments. + * + * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has + * provided. + * + * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose + * whether your router will be allowed to find a multi-part route for this payment. If you + * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via + * [`RecipientOnionFields::secret_only`]. + * + * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only */ -struct LDKInvalidShutdownScript InvalidShutdownScript_clone(const struct LDKInvalidShutdownScript *NONNULL_PTR orig); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); /** - * Serialize the ShutdownScript object into a byte array which can be read by ShutdownScript_read + * Creates parameters for paying to a blinded payee from the provided invoice. Sets + * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and + * [`PaymentParameters::expiry_time`]. */ -struct LDKCVec_u8Z ShutdownScript_write(const struct LDKShutdownScript *NONNULL_PTR obj); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); /** - * Read a ShutdownScript from a byte array, created by ShutdownScript_write + * Creates parameters for paying to a blinded payee from the provided blinded route hints. */ -struct LDKCResult_ShutdownScriptDecodeErrorZ ShutdownScript_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_BlindedPaymentPathZ blinded_route_hints); /** - * Generates a P2WPKH script pubkey from the given [`WPubkeyHash`]. + * Frees any resources used by the Payee */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wpkh(const uint8_t (*pubkey_hash)[20]); +void Payee_free(struct LDKPayee this_ptr); /** - * Generates a P2WSH script pubkey from the given [`WScriptHash`]. + * Creates a copy of the Payee */ -MUST_USE_RES struct LDKShutdownScript ShutdownScript_new_p2wsh(const uint8_t (*script_hash)[32]); +struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); /** - * Generates a witness script pubkey from the given segwit version and program. - * - * Note for version-zero witness scripts you must use [`ShutdownScript::new_p2wpkh`] or - * [`ShutdownScript::new_p2wsh`] instead. - * - * # Errors - * - * This function may return an error if `program` is invalid for the segwit `version`. + * Utility method to constructs a new Blinded-variant Payee */ -MUST_USE_RES struct LDKCResult_ShutdownScriptInvalidShutdownScriptZ ShutdownScript_new_witness_program(struct LDKWitnessProgram witness_program); +struct LDKPayee Payee_blinded(struct LDKCVec_BlindedPaymentPathZ route_hints, struct LDKBolt12InvoiceFeatures features); /** - * Converts the shutdown script into the underlying [`ScriptBuf`]. + * Utility method to constructs a new Clear-variant Payee */ -MUST_USE_RES struct LDKCVec_u8Z ShutdownScript_into_inner(struct LDKShutdownScript this_arg); +struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); /** - * Returns the [`PublicKey`] used for a P2WPKH shutdown script if constructed directly from it. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the Payee. */ -MUST_USE_RES struct LDKPublicKey ShutdownScript_as_legacy_pubkey(const struct LDKShutdownScript *NONNULL_PTR this_arg); +uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); /** - * Returns whether the shutdown script is compatible with the features as defined by BOLT #2. - * - * Specifically, checks for compliance with feature `option_shutdown_anysegwit`. + * Checks if two Payees contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES bool ShutdownScript_is_compatible(const struct LDKShutdownScript *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR features); +bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); /** - * Frees any resources used by the Retry + * Serialize the RouteHint object into a byte array which can be read by RouteHint_read */ -void Retry_free(struct LDKRetry this_ptr); +struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); /** - * Creates a copy of the Retry + * Read a RouteHint from a byte array, created by RouteHint_write */ -struct LDKRetry Retry_clone(const struct LDKRetry *NONNULL_PTR orig); +struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); /** - * Utility method to constructs a new Attempts-variant Retry + * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read */ -struct LDKRetry Retry_attempts(uint32_t a); +struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); /** - * Utility method to constructs a new Timeout-variant Retry + * Read a RouteHintHop from a byte array, created by RouteHintHop_write */ -struct LDKRetry Retry_timeout(uint64_t a); +struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); /** - * Checks if two Retrys contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. */ -bool Retry_eq(const struct LDKRetry *NONNULL_PTR a, const struct LDKRetry *NONNULL_PTR b); +void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); /** - * Generates a non-cryptographic 64-bit hash of the Retry. + * Creates a copy of the FirstHopCandidate */ -uint64_t Retry_hash(const struct LDKRetry *NONNULL_PTR o); +struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); /** - * Serialize the Retry object into a byte array which can be read by Retry_read + * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z Retry_write(const struct LDKRetry *NONNULL_PTR obj); +void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); /** - * Read a Retry from a byte array, created by Retry_write + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. */ -struct LDKCResult_RetryDecodeErrorZ Retry_read(struct LDKu8slice ser); +uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); /** - * Creates a copy of the RetryableSendFailure + * The short channel ID of the channel, i.e. the identifier by which we refer to this + * channel. */ -enum LDKRetryableSendFailure RetryableSendFailure_clone(const enum LDKRetryableSendFailure *NONNULL_PTR orig); +void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); /** - * Utility method to constructs a new PaymentExpired-variant RetryableSendFailure + * Creates a copy of the PublicHopCandidate */ -enum LDKRetryableSendFailure RetryableSendFailure_payment_expired(void); +struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new RouteNotFound-variant RetryableSendFailure + * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. */ -enum LDKRetryableSendFailure RetryableSendFailure_route_not_found(void); +void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); /** - * Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure + * Creates a copy of the PrivateHopCandidate */ -enum LDKRetryableSendFailure RetryableSendFailure_duplicate_payment(void); +struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); /** - * Checks if two RetryableSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. */ -bool RetryableSendFailure_eq(const enum LDKRetryableSendFailure *NONNULL_PTR a, const enum LDKRetryableSendFailure *NONNULL_PTR b); +void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); /** - * Frees any resources used by the PaymentSendFailure + * Creates a copy of the BlindedPathCandidate */ -void PaymentSendFailure_free(struct LDKPaymentSendFailure this_ptr); +struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); /** - * Creates a copy of the PaymentSendFailure + * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. */ -struct LDKPaymentSendFailure PaymentSendFailure_clone(const struct LDKPaymentSendFailure *NONNULL_PTR orig); +void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); /** - * Utility method to constructs a new ParameterError-variant PaymentSendFailure + * Creates a copy of the OneHopBlindedPathCandidate */ -struct LDKPaymentSendFailure PaymentSendFailure_parameter_error(struct LDKAPIError a); +struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); /** - * Utility method to constructs a new PathParameterError-variant PaymentSendFailure + * Frees any resources used by the CandidateRouteHop */ -struct LDKPaymentSendFailure PaymentSendFailure_path_parameter_error(struct LDKCVec_CResult_NoneAPIErrorZZ a); +void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); /** - * Utility method to constructs a new AllFailedResendSafe-variant PaymentSendFailure + * Creates a copy of the CandidateRouteHop */ -struct LDKPaymentSendFailure PaymentSendFailure_all_failed_resend_safe(struct LDKCVec_APIErrorZ a); +struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); /** - * Utility method to constructs a new DuplicatePayment-variant PaymentSendFailure + * Utility method to constructs a new FirstHop-variant CandidateRouteHop */ -struct LDKPaymentSendFailure PaymentSendFailure_duplicate_payment(void); +struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); /** - * Utility method to constructs a new PartialFailure-variant PaymentSendFailure + * Utility method to constructs a new PublicHop-variant CandidateRouteHop */ -struct LDKPaymentSendFailure PaymentSendFailure_partial_failure(struct LDKCVec_CResult_NoneAPIErrorZZ results, struct LDKRouteParameters failed_paths_retry, struct LDKThirtyTwoBytes payment_id); +struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); /** - * Checks if two PaymentSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Utility method to constructs a new PrivateHop-variant CandidateRouteHop */ -bool PaymentSendFailure_eq(const struct LDKPaymentSendFailure *NONNULL_PTR a, const struct LDKPaymentSendFailure *NONNULL_PTR b); +struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); /** - * Frees any resources used by the ProbeSendFailure + * Utility method to constructs a new Blinded-variant CandidateRouteHop */ -void ProbeSendFailure_free(struct LDKProbeSendFailure this_ptr); +struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); /** - * Creates a copy of the ProbeSendFailure + * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop */ -struct LDKProbeSendFailure ProbeSendFailure_clone(const struct LDKProbeSendFailure *NONNULL_PTR orig); +struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); /** - * Utility method to constructs a new RouteNotFound-variant ProbeSendFailure + * Returns the globally unique short channel ID for this hop, if one is known. + * + * This only returns `Some` if the channel is public (either our own, or one we've learned + * from the public network graph), and thus the short channel ID we have for this channel is + * globally unique and identifies this channel in a global namespace. */ -struct LDKProbeSendFailure ProbeSendFailure_route_not_found(void); +MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendingFailed-variant ProbeSendFailure + * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the + * next-hop for an HTLC taking this hop. + * + * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the + * next-hop goes on chain with a payment preimage. */ -struct LDKProbeSendFailure ProbeSendFailure_sending_failed(struct LDKPaymentSendFailure a); +MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Checks if two ProbeSendFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns the minimum amount that can be sent over this hop, in millisatoshis. */ -bool ProbeSendFailure_eq(const struct LDKProbeSendFailure *NONNULL_PTR a, const struct LDKProbeSendFailure *NONNULL_PTR b); +MUST_USE_RES uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * Frees any resources used by the RecipientOnionFields, if is_owned is set and inner is non-NULL. + * Returns the fees that must be paid to route an HTLC over this channel. */ -void RecipientOnionFields_free(struct LDKRecipientOnionFields this_obj); +MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. + * Returns the source node id of current hop. * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. + * Source node id refers to the node forwarding the HTLC through this hop. * - * Some implementations may reject spontaneous payments with payment secrets, so you may only - * want to provide a secret for a spontaneous payment if MPP is needed and you know your - * recipient will not reject it. + * For [`Self::FirstHop`] we return payer's node id. */ -struct LDKCOption_ThirtyTwoBytesZ RecipientOnionFields_get_payment_secret(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat - * in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to - * authenticate the sender to the recipient and prevent payment-probing (deanonymization) - * attacks. + * Returns the target node id of this hop, if known. * - * If you do not have one, the [`Route`] you pay over must not contain multiple paths as - * multi-path payments require a recipient-provided secret. + * Target node id refers to the node receiving the HTLC after this hop. * - * Some implementations may reject spontaneous payments with payment secrets, so you may only - * want to provide a secret for a spontaneous payment if MPP is needed and you know your - * recipient will not reject it. + * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded + * path is unknown. + * + * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, + * and such a return value would be somewhat nonsensical. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void RecipientOnionFields_set_payment_secret(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); /** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. + * Finds a route from us (payer) to the given target node (payee). * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. + * If the payee provided features in their invoice, they should be provided via the `payee` field + * in the given [`RouteParameters::payment_params`]. + * Without this, MPP will only be used if the payee's features are available in the network graph. * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. + * Private routing paths between a public node and the target may be included in the `payee` field + * of [`RouteParameters::payment_params`]. * - * Returns a copy of the field. - */ -struct LDKCOption_CVec_u8ZZ RecipientOnionFields_get_payment_metadata(const struct LDKRecipientOnionFields *NONNULL_PTR this_ptr); - -/** - * The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of - * arbitrary length. This gives recipients substantially more flexibility to receive - * additional data. + * If some channels aren't announced, it may be useful to fill in `first_hops` with the results + * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels + * from `network_graph` will be ignored, and only those in `first_hops` will be used. * - * In LDK, while the [`Self::payment_secret`] is fixed based on an internal authentication - * scheme to authenticate received payments against expected payments and invoices, this field - * is not used in LDK for received payments, and can be used to store arbitrary data in - * invoices which will be received with the payment. + * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. + * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / + * `htlc_maximum_msat` *are* checked as they may change based on the receiving node. * - * Note that this field was added to the lightning specification more recently than - * [`Self::payment_secret`] and while nearly all lightning senders support secrets, metadata - * may not be supported as universally. - */ -void RecipientOnionFields_set_payment_metadata(struct LDKRecipientOnionFields *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); - -/** - * Creates a copy of the RecipientOnionFields - */ -struct LDKRecipientOnionFields RecipientOnionFields_clone(const struct LDKRecipientOnionFields *NONNULL_PTR orig); - -/** - * Checks if two RecipientOnionFieldss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. - */ -bool RecipientOnionFields_eq(const struct LDKRecipientOnionFields *NONNULL_PTR a, const struct LDKRecipientOnionFields *NONNULL_PTR b); - -/** - * Serialize the RecipientOnionFields object into a byte array which can be read by RecipientOnionFields_read + * # Panics + * + * Panics if first_hops contains channels without `short_channel_id`s; + * [`ChannelManager::list_usable_channels`] will never include such channels. + * + * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels + * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed + * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph + * + * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKCVec_u8Z RecipientOnionFields_write(const struct LDKRecipientOnionFields *NONNULL_PTR obj); +struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); /** - * Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write + * Construct a route from us (payer) to the target node (payee) via the given hops (which should + * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. + * + * Re-uses logic from `find_route`, so the restrictions described there also apply here. */ -struct LDKCResult_RecipientOnionFieldsDecodeErrorZ RecipientOnionFields_read(struct LDKu8slice ser); +struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); /** - * Creates a [`RecipientOnionFields`] from only a [`PaymentSecret`]. This is the most common - * set of onion fields for today's BOLT11 invoices - most nodes require a [`PaymentSecret`] - * but do not require or provide any further data. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_secret_only(struct LDKThirtyTwoBytes payment_secret); +void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); /** - * Creates a new [`RecipientOnionFields`] with no fields. This generally does not create - * payable HTLCs except for single-path spontaneous payments, i.e. this should generally - * only be used for calls to [`ChannelManager::send_spontaneous_payment`]. If you are sending - * a spontaneous MPP this will not work as all MPP require payment secrets; you may - * instead want to use [`RecipientOnionFields::secret_only`]. - * - * [`ChannelManager::send_spontaneous_payment`]: super::channelmanager::ChannelManager::send_spontaneous_payment - * [`RecipientOnionFields::secret_only`]: RecipientOnionFields::secret_only + * Calls the free function if one is set */ -MUST_USE_RES struct LDKRecipientOnionFields RecipientOnionFields_spontaneous_empty(void); +void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); /** - * Creates a new [`RecipientOnionFields`] from an existing one, adding custom TLVs. Each - * TLV is provided as a `(u64, Vec)` for the type number and serialized value - * respectively. TLV type numbers must be unique and within the range - * reserved for custom types, i.e. >= 2^16, otherwise this method will return `Err(())`. - * - * This method will also error for types in the experimental range which have been - * standardized within the protocol, which only includes 5482373484 (keysend) for now. - * - * See [`Self::custom_tlvs`] for more info. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKCResult_RecipientOnionFieldsNoneZ RecipientOnionFields_with_custom_tlvs(struct LDKRecipientOnionFields this_arg, struct LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs); +void Score_free(struct LDKScore this_ptr); /** - * Gets the custom TLVs that will be sent or have been received. - * - * Custom TLVs allow sending extra application-specific data with a payment. They provide - * additional flexibility on top of payment metadata, as while other implementations may - * require `payment_metadata` to reflect metadata provided in an invoice, custom TLVs - * do not have this restriction. - * - * Note that if this field is non-empty, it will contain strictly increasing TLVs, each - * represented by a `(u64, Vec)` for its type number and serialized value respectively. - * This is validated when setting this field using [`Self::with_custom_tlvs`]. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKCVec_C2Tuple_u64CVec_u8ZZZ RecipientOnionFields_custom_tlvs(const struct LDKRecipientOnionFields *NONNULL_PTR this_arg); +void LockableScore_free(struct LDKLockableScore this_ptr); /** * Calls the free function if one is set */ -void CustomMessageReader_free(struct LDKCustomMessageReader this_ptr); +void WriteableScore_free(struct LDKWriteableScore this_ptr); /** - * Creates a copy of a Type + * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. */ -struct LDKType Type_clone(const struct LDKType *NONNULL_PTR orig); +void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); /** - * Calls the free function if one is set + * Constructs a new LockableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is */ -void Type_free(struct LDKType this_ptr); +struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * Frees any resources used by the Offer, if is_owned is set and inner is non-NULL. + * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read */ -void Offer_free(struct LDKOffer this_obj); +struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); /** - * Creates a copy of the Offer + * Constructs a new WriteableScore which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is */ -struct LDKOffer Offer_clone(const struct LDKOffer *NONNULL_PTR orig); +struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ Offer_chains(const struct LDKOffer *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Offer_metadata(const struct LDKOffer *NONNULL_PTR this_arg); +void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); /** - * The minimum amount required for a successful payment of a single item. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKAmount Offer_amount(const struct LDKOffer *NONNULL_PTR this_arg); +void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -MUST_USE_RES struct LDKPrintableString Offer_description(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); /** - * Features pertaining to the offer. + * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read */ -MUST_USE_RES struct LDKOfferFeatures Offer_offer_features(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -MUST_USE_RES struct LDKCOption_u64Z Offer_absolute_expiry(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPrintableString Offer_issuer(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelUsage_free(struct LDKChannelUsage this_obj); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * The amount to send through the channel, denominated in millisatoshis. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Offer_paths(const struct LDKOffer *NONNULL_PTR this_arg); +uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * The quantity of items supported. + * The amount to send through the channel, denominated in millisatoshis. */ -MUST_USE_RES struct LDKQuantity Offer_supported_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * The public key used by the recipient to sign invoices. + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -MUST_USE_RES struct LDKPublicKey Offer_signing_pubkey(const struct LDKOffer *NONNULL_PTR this_arg); +uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Returns whether the given chain is supported by the offer. + * Total amount, denominated in millisatoshis, already allocated to send through the channel + * as part of a multi-path payment. */ -MUST_USE_RES bool Offer_supports_chain(const struct LDKOffer *NONNULL_PTR this_arg, struct LDKThirtyTwoBytes chain); +void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); /** - * Whether the offer has expired. + * The effective capacity of the channel. */ -MUST_USE_RES bool Offer_is_expired(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); /** - * Whether the offer has expired given the duration since the Unix epoch. + * The effective capacity of the channel. */ -MUST_USE_RES bool Offer_is_expired_no_std(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); /** - * Returns whether the given quantity is valid for the offer. + * Constructs a new ChannelUsage given each field */ -MUST_USE_RES bool Offer_is_valid_quantity(const struct LDKOffer *NONNULL_PTR this_arg, uint64_t quantity); +MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); /** - * Returns whether a quantity is expected in an [`InvoiceRequest`] for the offer. - * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * Creates a copy of the ChannelUsage */ -MUST_USE_RES bool Offer_expects_quantity(const struct LDKOffer *NONNULL_PTR this_arg); +struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); /** - * Serialize the Offer object into a byte array which can be read by Offer_read + * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z Offer_write(const struct LDKOffer *NONNULL_PTR obj); +void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); /** - * Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. + * Creates a copy of the FixedPenaltyScorer */ -void Amount_free(struct LDKAmount this_obj); +struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); /** - * Creates a copy of the Amount + * Creates a new scorer using `penalty_msat`. */ -struct LDKAmount Amount_clone(const struct LDKAmount *NONNULL_PTR orig); +MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); /** - * Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -void Quantity_free(struct LDKQuantity this_obj); +struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * Creates a copy of the Quantity + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -struct LDKQuantity Quantity_clone(const struct LDKQuantity *NONNULL_PTR orig); +struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); /** - * Read a Offer object from a string + * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read */ -struct LDKCResult_OfferBolt12ParseErrorZ Offer_from_str(struct LDKStr s); +struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); /** - * Frees any resources used by the UnsignedBolt12Invoice, if is_owned is set and inner is non-NULL. + * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write */ -void UnsignedBolt12Invoice_free(struct LDKUnsignedBolt12Invoice this_obj); +struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKTaggedHash UnsignedBolt12Invoice_tagged_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); /** - * Frees any resources used by the Bolt12Invoice, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. */ -void Bolt12Invoice_free(struct LDKBolt12Invoice this_obj); +void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); /** - * Creates a copy of the Bolt12Invoice + * A fixed penalty in msats to apply to each channel. + * + * Default value: 500 msat */ -struct LDKBolt12Invoice Bolt12Invoice_clone(const struct LDKBolt12Invoice *NONNULL_PTR orig); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. + * A fixed penalty in msats to apply to each channel. * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * Default value: 500 msat */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ UnsignedBolt12Invoice_offer_chains(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. + * A multiplier used with the total amount flowing over a channel to calculate a fixed penalty + * applied to each channel, in excess of the [`base_penalty_msat`]. * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the total amount flowing over a channel (i.e. the payment + * amount plus the amount of any other HTLCs flowing we sent over the same channel). * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain - */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_chain(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); - -/** - * Opaque bytes set by the originating [`Offer`]. + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. + * Default value: 8,192 msat * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * [`base_penalty_msat`]: Self::base_penalty_msat */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedBolt12Invoice_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of a single item. + * A multiplier used with the total amount flowing over a channel to calculate a fixed penalty + * applied to each channel, in excess of the [`base_penalty_msat`]. * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^30`ths of the total amount flowing over a channel (i.e. the payment + * amount plus the amount of any other HTLCs flowing we sent over the same channel). * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount + * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Default value: 8,192 msat + * + * [`base_penalty_msat`]: Self::base_penalty_msat */ -MUST_USE_RES struct LDKAmount UnsignedBolt12Invoice_amount(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Features pertaining to the originating [`Offer`]. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Default value: 30,000 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life */ -MUST_USE_RES struct LDKOfferFeatures UnsignedBolt12Invoice_offer_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * A complete description of the purpose of the originating offer or refund. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for a payment, as determined by our latest estimates of the channel's + * liquidity, to determine the liquidity penalty. * - * From [`Offer::description`] or [`Refund::description`]. + * The penalty is based in part on the knowledge learned from prior successful and unsuccessful + * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The + * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to + * lower bounding the success probability to `0.01`) when the amount falls within the + * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will + * result in a `u64::max_value` penalty, however. * - * [`Offer::description`]: crate::offers::offer::Offer::description + * `-log10(success_probability) * liquidity_penalty_multiplier_msat` + * + * Default value: 30,000 msat + * + * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_description(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Duration since the Unix epoch when an invoice should no longer be requested. + * A multiplier used in conjunction with the total amount flowing over a channel and the + * negative `log10` of the channel's success probability for the payment, as determined by our + * latest estimates of the channel's liquidity, to determine the amount penalty. * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the amount flowing over this channel, weighted by the negative + * `log10` of the success probability. * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` + * + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_absolute_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The issuer of the offer or refund. + * A multiplier used in conjunction with the total amount flowing over a channel and the + * negative `log10` of the channel's success probability for the payment, as determined by our + * latest estimates of the channel's liquidity, to determine the amount penalty. * - * From [`Offer::issuer`] or [`Refund::issuer`]. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., + * fees plus penalty) for large payments. The penalty is computed as the product of this + * multiplier and `2^20`ths of the amount flowing over this channel, weighted by the negative + * `log10` of the success probability. * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of + * the amount will result in a penalty of the multiplier. And, as the success probability + * decreases, the negative `log10` weighting will increase dramatically. For higher success + * probabilities, the multiplier will have a decreasing effect as the negative `log10` will + * fall below `1`. + * + * Default value: 192 msat */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_issuer(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Paths to the recipient originating from publicly reachable nodes. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. * - * From [`Offer::paths`] or [`Refund::paths`]. + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. * - * [`Offer::paths`]: crate::offers::offer::Offer::paths + * Default value: 10,000 msat + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -MUST_USE_RES struct LDKCVec_BlindedPathZ UnsignedBolt12Invoice_message_paths(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * The quantity of items supported. + * A multiplier used in conjunction with the negative `log10` of the channel's success + * probability for the payment, as determined based on the history of our estimates of the + * channel's available liquidity, to determine a penalty. * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. + * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using + * only our latest estimate for the current liquidity available in the channel, it estimates + * success probability based on the estimated liquidity available in the channel through + * history. Specifically, every time we update our liquidity bounds on a given channel, we + * track which of several buckets those bounds fall into, exponentially decaying the + * probability of each bucket as new samples are added. * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Default value: 10,000 msat * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat */ -MUST_USE_RES struct LDKQuantity UnsignedBolt12Invoice_supported_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * An unpredictable series of bytes from the payer. + * A multiplier used in conjunction with the total amount flowing over a channel and the + * negative `log10` of the channel's success probability for the payment, as determined based + * on the history of our estimates of the channel's available liquidity, to determine a + * penalty. * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and `2^20`ths + * of the amount flowing over this channel, weighted by the negative `log10` of the success + * probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -MUST_USE_RES struct LDKu8slice UnsignedBolt12Invoice_payer_metadata(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * A multiplier used in conjunction with the total amount flowing over a channel and the + * negative `log10` of the channel's success probability for the payment, as determined based + * on the history of our estimates of the channel's available liquidity, to determine a + * penalty. * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. + * The purpose of the amount penalty is to avoid having fees dominate the channel cost for + * large payments. The penalty is computed as the product of this multiplier and `2^20`ths + * of the amount flowing over this channel, weighted by the negative `log10` of the success + * probability. + * + * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead + * of using only our latest estimate for the current liquidity available in the channel, it + * estimates success probability based on the estimated liquidity available in the channel + * through history. Specifically, every time we update our liquidity bounds on a given + * channel, we track which of several buckets those bounds fall into, exponentially decaying + * the probability of each bucket as new samples are added. + * + * Default value: 64 msat + * + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedBolt12Invoice_invoice_request_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The quantity of items requested or refunded for. + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. + * Default value: 250 msat */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedBolt12Invoice_quantity(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. + * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the + * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us + * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially + * as this makes balance discovery attacks harder to execute, thereby creating an incentive + * to restrict `htlc_maximum_msat` and improve privacy. * - * [`message_paths`]: Self::message_paths + * Default value: 250 msat */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_payer_id(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * A payer-provided note reflected back in the invoice. + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -MUST_USE_RES struct LDKPrintableString UnsignedBolt12Invoice_payer_note(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Duration since the Unix epoch when the invoice was created. + * This penalty is applied when the total amount flowing over a channel exceeds our current + * estimate of the channel's available liquidity. The total amount is the amount of the + * current HTLC plus any HTLCs which we've sent over the same channel. + * + * Note that in this case all other penalties, including the + * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based + * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if + * applicable, are still included in the overall penalty. + * + * If you wish to avoid creating paths with such channels entirely, setting this to a value of + * `u64::max_value()` will guarantee that. + * + * Default value: 1_0000_0000_000 msat (1 Bitcoin) + * + * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * [`base_penalty_msat`]: Self::base_penalty_msat + * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_created_at(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore - * should no longer be paid. + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. + * + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. + * + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. + * + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. + * + * Default value: false */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_relative_expiry(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); /** - * Whether the invoice has expired. + * In order to calculate most of the scores above, we must first convert a lower and upper + * bound on the available liquidity in a channel into the probability that we think a payment + * will succeed. That probability is derived from a Probability Density Function for where we + * think the liquidity in a channel likely lies, given such bounds. + * + * If this flag is set, that PDF is simply a constant - we assume that the actual available + * liquidity in a channel is just as likely to be at any point between our lower and upper + * bounds. + * + * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an + * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This + * matches experimental results - most routing nodes do not aggressively rebalance their + * channels and flows in the network are often unbalanced, leaving liquidity usually + * unavailable. + * + * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number + * of floating-point multiplications in the hottest routing code, which may lead to routing + * performance degradation on some machines. + * + * Default value: false */ -MUST_USE_RES bool UnsignedBolt12Invoice_is_expired(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); /** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * Creates a copy of the ProbabilisticScoringFeeParameters */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedBolt12Invoice_payment_hash(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); /** - * The minimum amount required for a successful payment of the invoice. + * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES uint64_t UnsignedBolt12Invoice_amount_msats(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); /** - * Features pertaining to paying an invoice. + * Marks the node with the given `node_id` as banned, + * i.e it will be avoided during path finding. */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures UnsignedBolt12Invoice_invoice_features(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The public key corresponding to the key used to sign the invoice. + * Marks all nodes in the given list as banned, i.e., + * they will be avoided during path finding. */ -MUST_USE_RES struct LDKPublicKey UnsignedBolt12Invoice_signing_pubkey(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); /** - * The chains that may be used when paying a requested invoice. - * - * From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. - * - * [`Offer::chains`]: crate::offers::offer::Offer::chains + * Removes the node with the given `node_id` from the list of nodes to avoid. */ -MUST_USE_RES struct LDKCOption_CVec_ThirtyTwoBytesZZ Bolt12Invoice_offer_chains(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The chain that must be used when paying the invoice; selected from [`offer_chains`] if the - * invoice originated from an offer. - * - * From [`InvoiceRequest::chain`] or [`Refund::chain`]. - * - * [`offer_chains`]: Self::offer_chains - * [`InvoiceRequest::chain`]: crate::offers::invoice_request::InvoiceRequest::chain + * Sets a manual penalty for the given node. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_chain(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); /** - * Opaque bytes set by the originating [`Offer`]. - * - * From [`Offer::metadata`]; `None` if the invoice was created in response to a [`Refund`] or - * if the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::metadata`]: crate::offers::offer::Offer::metadata + * Removes the node with the given `node_id` from the list of manual penalties. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ Bolt12Invoice_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); /** - * The minimum amount required for a successful payment of a single item. - * - * From [`Offer::amount`]; `None` if the invoice was created in response to a [`Refund`] or if - * the [`Offer`] did not set it. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::amount`]: crate::offers::offer::Offer::amount - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Clears the list of manual penalties that are applied during path finding. */ -MUST_USE_RES struct LDKAmount Bolt12Invoice_amount(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); /** - * Features pertaining to the originating [`Offer`]. - * - * From [`Offer::offer_features`]; `None` if the invoice was created in response to a - * [`Refund`]. - * - * [`Offer`]: crate::offers::offer::Offer - * [`Offer::offer_features`]: crate::offers::offer::Offer::offer_features - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKOfferFeatures Bolt12Invoice_offer_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); /** - * A complete description of the purpose of the originating offer or refund. - * - * From [`Offer::description`] or [`Refund::description`]. + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] * - * [`Offer::description`]: crate::offers::offer::Offer::description - */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_description(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * Duration since the Unix epoch when an invoice should no longer be requested. + * Note that after 16 or more half lives all historical data will be completely gone. * - * From [`Offer::absolute_expiry`] or [`Refund::absolute_expiry`]. + * Default value: 14 days * - * [`Offer::absolute_expiry`]: crate::offers::offer::Offer::absolute_expiry + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_absolute_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * The issuer of the offer or refund. + * If we aren't learning any new datapoints for a channel, the historical liquidity bounds + * tracking can simply live on with increasingly stale data. Instead, when a channel has not + * seen a liquidity estimate update for this amount of time, the historical datapoints are + * decayed by half. + * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] * - * From [`Offer::issuer`] or [`Refund::issuer`]. + * Note that after 16 or more half lives all historical data will be completely gone. * - * [`Offer::issuer`]: crate::offers::offer::Offer::issuer + * Default value: 14 days * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_issuer(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * Paths to the recipient originating from publicly reachable nodes. - * - * From [`Offer::paths`] or [`Refund::paths`]. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. * - * [`Offer::paths`]: crate::offers::offer::Offer::paths - */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Bolt12Invoice_message_paths(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * The quantity of items supported. + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. * - * From [`Offer::supported_quantity`]; `None` if the invoice was created in response to a - * [`Refund`]. + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. * - * [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity + * Default value: 6 hours * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKQuantity Bolt12Invoice_supported_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * An unpredictable series of bytes from the payer. + * # Note * - * From [`InvoiceRequest::payer_metadata`] or [`Refund::payer_metadata`]. + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -MUST_USE_RES struct LDKu8slice Bolt12Invoice_payer_metadata(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, + * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on + * the available liquidity is halved and the upper-bound moves half-way to the channel's total + * capacity. * - * From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. - */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Bolt12Invoice_invoice_request_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * The quantity of items requested or refunded for. + * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, + * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] + * struct documentation for more info on the way the liquidity bounds are used. * - * From [`InvoiceRequest::quantity`] or [`Refund::quantity`]. - */ -MUST_USE_RES struct LDKCOption_u64Z Bolt12Invoice_quantity(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * A possibly transient pubkey used to sign the invoice request or to send an invoice for a - * refund in case there are no [`message_paths`]. + * For example, if the channel's capacity is 1 million sats, and the current upper and lower + * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper + * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. * - * [`message_paths`]: Self::message_paths - */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_payer_id(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * A payer-provided note reflected back in the invoice. + * Default value: 6 hours * - * From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. + * # Note * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None - */ -MUST_USE_RES struct LDKPrintableString Bolt12Invoice_payer_note(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * Duration since the Unix epoch when the invoice was created. - */ -MUST_USE_RES uint64_t Bolt12Invoice_created_at(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore - * should no longer be paid. - */ -MUST_USE_RES uint64_t Bolt12Invoice_relative_expiry(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * Whether the invoice has expired. - */ -MUST_USE_RES bool Bolt12Invoice_is_expired(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); - -/** - * SHA256 hash of the payment preimage that will be given in return for paying the invoice. + * When built with the `no-std` feature, time will never elapse. Therefore, the channel + * liquidity knowledge will never decay except when the bounds cross. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_payment_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The minimum amount required for a successful payment of the invoice. + * Constructs a new ProbabilisticScoringDecayParameters given each field */ -MUST_USE_RES uint64_t Bolt12Invoice_amount_msats(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); /** - * Features pertaining to paying an invoice. + * Creates a copy of the ProbabilisticScoringDecayParameters */ -MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12Invoice_invoice_features(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); /** - * The public key corresponding to the key used to sign the invoice. + * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. */ -MUST_USE_RES struct LDKPublicKey Bolt12Invoice_signing_pubkey(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); /** - * Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. + * Creates a new scorer using the given scoring parameters for sending payments from a node + * through a network graph. */ -MUST_USE_RES struct LDKSchnorrSignature Bolt12Invoice_signature(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); /** - * Hash that was used for signing the invoice. + * Dump the contents of this scorer into the configured logger. + * + * Note that this writes roughly one line per channel for which we have a liquidity estimate, + * which may be a substantial amount of log output. */ -MUST_USE_RES struct LDKThirtyTwoBytes Bolt12Invoice_signable_hash(const struct LDKBolt12Invoice *NONNULL_PTR this_arg); +void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Verifies that the invoice was for a request or refund created using the given key. Returns - * the associated [`PaymentId`] to use when sending the payment. + * Query the estimated minimum and maximum liquidity available for sending a payment over the + * channel with `scid` towards the given `target` node. */ -MUST_USE_RES struct LDKCResult_ThirtyTwoBytesNoneZ Bolt12Invoice_verify(const struct LDKBolt12Invoice *NONNULL_PTR this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read + * Query the historical estimated minimum and maximum liquidity available for sending a + * payment over the channel with `scid` towards the given `target` node. + * + * Returns two sets of 32 buckets. The first set describes the lower-bound liquidity history, + * the second set describes the upper-bound liquidity history. Each bucket describes the + * relative frequency at which we've seen a liquidity bound in the bucket's range relative to + * the channel's total capacity, on an arbitrary scale. Because the values are slowly decayed, + * more recent data points are weighted more heavily than older datapoints. + * + * Note that the range of each bucket varies by its location to provide more granular results + * at the edges of a channel's capacity, where it is more likely to sit. + * + * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket + * is calculated by dividing that bucket's value with the total value of all buckets. + * + * For example, using a lower bucket count for illustrative purposes, a value of + * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very + * close to the channel's capacity to be 100%, and have never (recently) seen it in any other + * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both + * in the top and bottom bucket, and roughly with similar (recent) frequency. + * + * Because the datapoints are decayed slowly over time, values will eventually return to + * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. + * + * In order to fetch a single success probability from the buckets provided here, as used in + * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. */ -struct LDKCVec_u8Z UnsignedBolt12Invoice_write(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); /** - * Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read + * Query the probability of payment success sending the given `amount_msat` over the channel + * with `scid` towards the given `target` node, based on the historical estimated liquidity + * bounds. + * + * These are the same bounds as returned by + * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by + * [`Self::estimated_channel_liquidity_range`]). */ -struct LDKCVec_u8Z Bolt12Invoice_write(const struct LDKBolt12Invoice *NONNULL_PTR obj); +MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); /** - * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. + * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is */ -void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); +struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is */ -uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for the entire blinded path. + * Constructs a new Score which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is */ -void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read */ -uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); /** - * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path - * (i.e., 10,000 is 1%). + * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write */ -void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded - * path. + * The outpoint which is spendable. */ -void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); +struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * The outpoint which is spendable. */ -uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Per commitment point to derive the delayed payment key by key holder. */ -void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * Per commitment point to derive the delayed payment key by key holder. */ -uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the - * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as - * seen by the recipient. + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); +uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in + * the witness_script. */ -struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); +void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); /** - * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an - * onion payload. + * The output which is referenced by the given outpoint. */ -void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Constructs a new BlindedPayInfo given each field + * The output which is referenced by the given outpoint. */ -MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); +void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Creates a copy of the BlindedPayInfo + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); +struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + * The revocation point specific to the commitment transaction which was broadcast. Used to + * derive the witnessScript for this output. */ -uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); +void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); /** - * Checks if two BlindedPayInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); +const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); +void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write + * The value of the channel which this output originated from, possibly indirectly. */ -struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); +uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the InvoiceError, if is_owned is set and inner is non-NULL. + * The value of the channel which this output originated from, possibly indirectly. */ -void InvoiceError_free(struct LDKInvoiceError this_obj); +void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKErroneousField InvoiceError_get_erroneous_field(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +struct LDKChannelTransactionParameters DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. + * The channel public keys and other parameters needed to generate a spending transaction or + * to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. * - * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. * * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InvoiceError_set_erroneous_field(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKErroneousField val); +void DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * An explanation of the error. + * Constructs a new DelayedPaymentOutputDescriptor given each field + * + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKUntrustedString InvoiceError_get_message(const struct LDKInvoiceError *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * An explanation of the error. + * Creates a copy of the DelayedPaymentOutputDescriptor */ -void InvoiceError_set_message(struct LDKInvoiceError *NONNULL_PTR this_ptr, struct LDKUntrustedString val); +struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Constructs a new InvoiceError given each field - * - * Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. */ -MUST_USE_RES struct LDKInvoiceError InvoiceError_new(struct LDKErroneousField erroneous_field_arg, struct LDKUntrustedString message_arg); +uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); /** - * Creates a copy of the InvoiceError + * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKInvoiceError InvoiceError_clone(const struct LDKInvoiceError *NONNULL_PTR orig); +bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); /** - * Frees any resources used by the ErroneousField, if is_owned is set and inner is non-NULL. + * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read */ -void ErroneousField_free(struct LDKErroneousField this_obj); +struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); /** - * The type number of the TLV field containing the error. + * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write */ -uint64_t ErroneousField_get_tlv_fieldnum(const struct LDKErroneousField *NONNULL_PTR this_ptr); +struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * The type number of the TLV field containing the error. + * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. */ -void ErroneousField_set_tlv_fieldnum(struct LDKErroneousField *NONNULL_PTR this_ptr, uint64_t val); +void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); /** - * A value to use for the TLV field to avoid the error. - * - * Returns a copy of the field. + * The outpoint which is spendable. */ -struct LDKCOption_CVec_u8ZZ ErroneousField_get_suggested_value(const struct LDKErroneousField *NONNULL_PTR this_ptr); +struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * A value to use for the TLV field to avoid the error. + * The outpoint which is spendable. */ -void ErroneousField_set_suggested_value(struct LDKErroneousField *NONNULL_PTR this_ptr, struct LDKCOption_CVec_u8ZZ val); +void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Constructs a new ErroneousField given each field + * The output which is referenced by the given outpoint. */ -MUST_USE_RES struct LDKErroneousField ErroneousField_new(uint64_t tlv_fieldnum_arg, struct LDKCOption_CVec_u8ZZ suggested_value_arg); +struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Creates a copy of the ErroneousField + * The output which is referenced by the given outpoint. */ -struct LDKErroneousField ErroneousField_clone(const struct LDKErroneousField *NONNULL_PTR orig); +void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * Creates an [`InvoiceError`] with the given message. + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -MUST_USE_RES struct LDKInvoiceError InvoiceError_from_string(struct LDKStr s); +const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; /** - * Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read + * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. + * This may be useful in re-deriving keys used in the channel to spend the output. */ -struct LDKCVec_u8Z InvoiceError_write(const struct LDKInvoiceError *NONNULL_PTR obj); +void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a InvoiceError from a byte array, created by InvoiceError_write + * The value of the channel which this transactions spends. */ -struct LDKCResult_InvoiceErrorDecodeErrorZ InvoiceError_read(struct LDKu8slice ser); +uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the UnsignedInvoiceRequest, if is_owned is set and inner is non-NULL. + * The value of the channel which this transactions spends. */ -void UnsignedInvoiceRequest_free(struct LDKUnsignedInvoiceRequest this_obj); +void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the [`TaggedHash`] of the invoice to sign. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKTaggedHash UnsignedInvoiceRequest_tagged_hash(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); /** - * Frees any resources used by the InvoiceRequest, if is_owned is set and inner is non-NULL. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. + * + * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void InvoiceRequest_free(struct LDKInvoiceRequest this_obj); +void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Creates a copy of the InvoiceRequest + * Constructs a new StaticPaymentOutputDescriptor given each field + * + * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKInvoiceRequest InvoiceRequest_clone(const struct LDKInvoiceRequest *NONNULL_PTR orig); +MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); /** - * Frees any resources used by the VerifiedInvoiceRequest, if is_owned is set and inner is non-NULL. + * Creates a copy of the StaticPaymentOutputDescriptor */ -void VerifiedInvoiceRequest_free(struct LDKVerifiedInvoiceRequest this_obj); +struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); /** - * Keys used for signing a [`Bolt12Invoice`] if they can be derived. - * - * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call - * [`respond_with`]. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`respond_using_derived_keys`]: Self::respond_using_derived_keys - * [`respond_with`]: Self::respond_with + * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. */ -struct LDKCOption_SecretKeyZ VerifiedInvoiceRequest_get_keys(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr); +uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); /** - * Keys used for signing a [`Bolt12Invoice`] if they can be derived. - * - * If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call - * [`respond_with`]. + * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); + +/** + * Returns the `witness_script` of the spendable output. * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice - * [`respond_using_derived_keys`]: Self::respond_using_derived_keys - * [`respond_with`]: Self::respond_with + * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that + * originated from an anchor outputs channel, as they take the form of a P2WSH script. */ -void VerifiedInvoiceRequest_set_keys(struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_ptr, struct LDKCOption_SecretKeyZ val); +MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * Creates a copy of the VerifiedInvoiceRequest + * The maximum length a well-formed witness spending one of these should have. + * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte + * shorter. */ -struct LDKVerifiedInvoiceRequest VerifiedInvoiceRequest_clone(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR orig); +MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ UnsignedInvoiceRequest_chains(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ UnsignedInvoiceRequest_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); /** - * The minimum amount required for a successful payment of a single item. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the SpendableOutputDescriptor */ -MUST_USE_RES struct LDKAmount UnsignedInvoiceRequest_amount(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Creates a copy of the SpendableOutputDescriptor */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_description(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); /** - * Features pertaining to the offer. + * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor */ -MUST_USE_RES struct LDKOfferFeatures UnsignedInvoiceRequest_offer_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_absolute_expiry(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_issuer(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ UnsignedInvoiceRequest_paths(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); /** - * The quantity of items supported. + * Checks if two SpendableOutputDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKQuantity UnsignedInvoiceRequest_supported_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); /** - * The public key used by the recipient to sign invoices. + * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_signing_pubkey(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. + * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + */ +struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); + +/** + * Creates an unsigned [`Psbt`] which spends the given descriptors to + * the given outputs, plus an output to the given change destination (if sufficient + * change value remains). The PSBT will have a feerate, at least, of the given value. * - * [`payer_id`]: Self::payer_id + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. + * + * Returns the PSBT and expected max transaction weight. + * + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. + * + * We do not enforce that outputs meet the dust limit or that any output scripts are standard. */ -MUST_USE_RES struct LDKu8slice UnsignedInvoiceRequest_payer_metadata(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKThirtyTwoBytes UnsignedInvoiceRequest_chain(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. - * - * [`chain`]: Self::chain + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_amount_msats(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * The value in satoshis of the channel we're attempting to spend the anchor output of. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures UnsignedInvoiceRequest_invoice_request_features(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The unique identifier to re-derive the signer for the associated channel. */ -MUST_USE_RES struct LDKCOption_u64Z UnsignedInvoiceRequest_quantity(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; /** - * A possibly transient pubkey used to sign the invoice request. + * The unique identifier to re-derive the signer for the associated channel. */ -MUST_USE_RES struct LDKPublicKey UnsignedInvoiceRequest_payer_id(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -MUST_USE_RES struct LDKPrintableString UnsignedInvoiceRequest_payer_note(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * The necessary channel parameters that need to be provided to the re-derived signer through + * [`ChannelSigner::provide_channel_parameters`]. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ InvoiceRequest_chains(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * Constructs a new ChannelDerivationParameters given each field */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ InvoiceRequest_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); /** - * The minimum amount required for a successful payment of a single item. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelDerivationParameters */ -MUST_USE_RES struct LDKAmount InvoiceRequest_amount(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Checks if two ChannelDerivationParameterss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_description(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); /** - * Features pertaining to the offer. + * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read */ -MUST_USE_RES struct LDKOfferFeatures InvoiceRequest_offer_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_absolute_expiry(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_issuer(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * The parameters required to derive the signer for the HTLC input. */ -MUST_USE_RES struct LDKCVec_BlindedPathZ InvoiceRequest_paths(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The quantity of items supported. + * The parameters required to derive the signer for the HTLC input. */ -MUST_USE_RES struct LDKQuantity InvoiceRequest_supported_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); /** - * The public key used by the recipient to sign invoices. + * The txid of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_signing_pubkey(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +const uint8_t (*HTLCDescriptor_get_commitment_txid(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr))[32]; /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * The txid of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKu8slice InvoiceRequest_payer_metadata(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_commitment_txid(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * The number of the commitment transaction in which the HTLC output lives. */ -MUST_USE_RES struct LDKThirtyTwoBytes InvoiceRequest_chain(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. + * The number of the commitment transaction in which the HTLC output lives. + */ +void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); + +/** + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. * - * [`chain`]: Self::chain + * See for more info. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_amount_msats(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Features pertaining to requesting an invoice. + * The key tweak corresponding to the number of the commitment transaction in which the HTLC + * output lives. This tweak is applied to all the basepoints for both parties in the channel to + * arrive at unique keys per commitment. + * + * See for more info. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequest_invoice_request_features(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES struct LDKCOption_u64Z InvoiceRequest_quantity(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * A possibly transient pubkey used to sign the invoice request. + * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs + * originating from a channel supporting anchor outputs, otherwise it is the channel's + * negotiated feerate at the time the commitment transaction was built. */ -MUST_USE_RES struct LDKPublicKey InvoiceRequest_payer_id(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The details of the HTLC as it appears in the commitment transaction. */ -MUST_USE_RES struct LDKPrintableString InvoiceRequest_payer_note(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * Signature of the invoice request using [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * The details of the HTLC as it appears in the commitment transaction. */ -MUST_USE_RES struct LDKSchnorrSignature InvoiceRequest_signature(const struct LDKInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); /** - * Verifies that the request was for an offer created using the given key. Returns the verified - * request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request - * if they could be extracted from the metadata. - * - * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -MUST_USE_RES struct LDKCResult_VerifiedInvoiceRequestNoneZ InvoiceRequest_verify(struct LDKInvoiceRequest this_arg, const struct LDKExpandedKey *NONNULL_PTR key); +struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). - * Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) - * for the selected chain. + * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be + * taken. */ -MUST_USE_RES struct LDKCVec_ThirtyTwoBytesZ VerifiedInvoiceRequest_chains(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); /** - * Opaque bytes set by the originator. Useful for authentication and validating fields since it - * is reflected in `invoice_request` messages along with all the other fields from the `offer`. + * The counterparty's signature required to spend the HTLC output. */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ VerifiedInvoiceRequest_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); /** - * The minimum amount required for a successful payment of a single item. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The counterparty's signature required to spend the HTLC output. */ -MUST_USE_RES struct LDKAmount VerifiedInvoiceRequest_amount(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); /** - * A complete description of the purpose of the payment. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Constructs a new HTLCDescriptor given each field */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_description(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKHTLCDescriptor HTLCDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKThirtyTwoBytes commitment_txid_arg, uint64_t per_commitment_number_arg, struct LDKPublicKey per_commitment_point_arg, uint32_t feerate_per_kw_arg, struct LDKHTLCOutputInCommitment htlc_arg, struct LDKCOption_ThirtyTwoBytesZ preimage_arg, struct LDKECDSASignature counterparty_sig_arg); /** - * Features pertaining to the offer. + * Creates a copy of the HTLCDescriptor */ -MUST_USE_RES struct LDKOfferFeatures VerifiedInvoiceRequest_offer_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); /** - * Duration since the Unix epoch when an invoice should no longer be requested. - * - * If `None`, the offer does not expire. + * Checks if two HTLCDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_absolute_expiry(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); /** - * The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_issuer(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); /** - * Paths to the recipient originating from publicly reachable nodes. Blinded paths provide - * recipient privacy by obfuscating its node id. + * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write */ -MUST_USE_RES struct LDKCVec_BlindedPathZ VerifiedInvoiceRequest_paths(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); /** - * The quantity of items supported. + * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint + * being spent by the HTLC input in the HTLC transaction. */ -MUST_USE_RES struct LDKQuantity VerifiedInvoiceRequest_supported_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * The public key used by the recipient to sign invoices. + * Returns the UTXO to be spent by the HTLC input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_signing_pubkey(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * Returns the unsigned transaction input spending the HTLC output in the commitment + * transaction. */ -MUST_USE_RES struct LDKu8slice VerifiedInvoiceRequest_payer_metadata(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * A chain from [`Offer::chains`] that the offer is valid for. + * Returns the delayed output created as a result of spending the HTLC output in the commitment + * transaction. */ -MUST_USE_RES struct LDKThirtyTwoBytes VerifiedInvoiceRequest_chain(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * The amount to pay in msats (i.e., the minimum lightning-payable unit for [`chain`]), which - * must be greater than or equal to [`Offer::amount`], converted if necessary. - * - * [`chain`]: Self::chain + * Returns the witness script of the HTLC output in the commitment transaction. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_amount_msats(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); /** - * Features pertaining to requesting an invoice. + * Returns the fully signed witness required to spend the HTLC output in the commitment + * transaction. */ -MUST_USE_RES struct LDKInvoiceRequestFeatures VerifiedInvoiceRequest_invoice_request_features(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); /** - * The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. + * Derives the channel signer required to sign the HTLC input. */ -MUST_USE_RES struct LDKCOption_u64Z VerifiedInvoiceRequest_quantity(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * A possibly transient pubkey used to sign the invoice request. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKPublicKey VerifiedInvoiceRequest_payer_id(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +void ChannelSigner_free(struct LDKChannelSigner this_ptr); /** - * A payer-provided note which will be seen by the recipient and reflected back in the invoice - * response. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the Recipient */ -MUST_USE_RES struct LDKPrintableString VerifiedInvoiceRequest_payer_note(const struct LDKVerifiedInvoiceRequest *NONNULL_PTR this_arg); +enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); /** - * Serialize the UnsignedInvoiceRequest object into a byte array which can be read by UnsignedInvoiceRequest_read + * Utility method to constructs a new Node-variant Recipient */ -struct LDKCVec_u8Z UnsignedInvoiceRequest_write(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR obj); +enum LDKRecipient Recipient_node(void); /** - * Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read + * Utility method to constructs a new PhantomNode-variant Recipient */ -struct LDKCVec_u8Z InvoiceRequest_write(const struct LDKInvoiceRequest *NONNULL_PTR obj); +enum LDKRecipient Recipient_phantom_node(void); /** - * Frees any resources used by the TaggedHash, if is_owned is set and inner is non-NULL. + * Calls the free function if one is set */ -void TaggedHash_free(struct LDKTaggedHash this_obj); +void EntropySource_free(struct LDKEntropySource this_ptr); /** - * Creates a copy of the TaggedHash + * Calls the free function if one is set */ -struct LDKTaggedHash TaggedHash_clone(const struct LDKTaggedHash *NONNULL_PTR orig); +void NodeSigner_free(struct LDKNodeSigner this_ptr); /** - * Returns the digest to sign. + * Calls the free function if one is set */ -MUST_USE_RES const uint8_t (*TaggedHash_as_digest(const struct LDKTaggedHash *NONNULL_PTR this_arg))[32]; +void OutputSpender_free(struct LDKOutputSpender this_ptr); /** - * Returns the tag used in the tagged hash. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKStr TaggedHash_tag(const struct LDKTaggedHash *NONNULL_PTR this_arg); +void SignerProvider_free(struct LDKSignerProvider this_ptr); /** - * Returns the merkle root used in the tagged hash. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKThirtyTwoBytes TaggedHash_merkle_root(const struct LDKTaggedHash *NONNULL_PTR this_arg); +void ChangeDestinationSource_free(struct LDKChangeDestinationSource this_ptr); /** - * Frees any resources used by the Bolt12ParseError, if is_owned is set and inner is non-NULL. + * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. */ -void Bolt12ParseError_free(struct LDKBolt12ParseError this_obj); +void InMemorySigner_free(struct LDKInMemorySigner this_obj); /** - * Creates a copy of the Bolt12ParseError + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -struct LDKBolt12ParseError Bolt12ParseError_clone(const struct LDKBolt12ParseError *NONNULL_PTR orig); +const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Creates a copy of the Bolt12SemanticError + * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the + * holder's anchor output in a commitment transaction, if one is present. */ -enum LDKBolt12SemanticError Bolt12SemanticError_clone(const enum LDKBolt12SemanticError *NONNULL_PTR orig); +void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new AlreadyExpired-variant Bolt12SemanticError + * Holder secret key for blinded revocation pubkey. */ -enum LDKBolt12SemanticError Bolt12SemanticError_already_expired(void); +const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new UnsupportedChain-variant Bolt12SemanticError + * Holder secret key for blinded revocation pubkey. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_chain(void); +void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new UnexpectedChain-variant Bolt12SemanticError + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_chain(void); +const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new MissingAmount-variant Bolt12SemanticError + * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_amount(void); +void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new InvalidAmount-variant Bolt12SemanticError + * Holder secret key used in an HTLC transaction. */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_amount(void); +const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new InsufficientAmount-variant Bolt12SemanticError + * Holder secret key used in an HTLC transaction. */ -enum LDKBolt12SemanticError Bolt12SemanticError_insufficient_amount(void); +void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new UnexpectedAmount-variant Bolt12SemanticError + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_amount(void); +const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new UnsupportedCurrency-variant Bolt12SemanticError + * Holder HTLC secret key used in commitment transaction HTLC outputs. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unsupported_currency(void); +void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); /** - * Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12SemanticError + * Commitment seed. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unknown_required_features(void); +const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; /** - * Utility method to constructs a new UnexpectedFeatures-variant Bolt12SemanticError + * Commitment seed. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_features(void); +void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Utility method to constructs a new MissingDescription-variant Bolt12SemanticError + * Creates a copy of the InMemorySigner */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_description(void); +struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); /** - * Utility method to constructs a new MissingSigningPubkey-variant Bolt12SemanticError + * Creates a new [`InMemorySigner`]. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signing_pubkey(void); +MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); /** - * Utility method to constructs a new InvalidSigningPubkey-variant Bolt12SemanticError + * Returns the counterparty's pubkeys. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_signing_pubkey(void); +MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedSigningPubkey-variant Bolt12SemanticError + * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable + * transactions, i.e., the amount of time that we have to wait to recover our funds if we + * broadcast a transaction. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_signing_pubkey(void); +MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingQuantity-variant Bolt12SemanticError + * Returns the `contest_delay` value specified by us and applied on transactions broadcastable + * by our counterparty, i.e., the amount of time that they have to wait to recover their funds + * if they broadcast a transaction. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_quantity(void); +MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidQuantity-variant Bolt12SemanticError + * Returns whether the holder is the initiator. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_quantity(void); +MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedQuantity-variant Bolt12SemanticError + * Funding outpoint + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_quantity(void); +MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidMetadata-variant Bolt12SemanticError + * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or + * building transactions. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_metadata(void); +MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedMetadata-variant Bolt12SemanticError + * Returns the channel type features of the channel parameters. Should be helpful for + * determining a channel's category, i. e. legacy/anchors/taproot/etc. + * + * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. + * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -enum LDKBolt12SemanticError Bolt12SemanticError_unexpected_metadata(void); +MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingPayerMetadata-variant Bolt12SemanticError + * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described + * by `descriptor`, returning the witness stack for the input. + * + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], + * or if an output descriptor `script_pubkey` does not match the one we can spend. + * + * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_metadata(void); +MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Utility method to constructs a new MissingPayerId-variant Bolt12SemanticError + * Sign the single input of `spend_tx` at index `input_idx` which spends the output + * described by `descriptor`, returning the witness stack for the input. + * + * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, + * is not spending the outpoint described by [`descriptor.outpoint`], does not have a + * sequence set to [`descriptor.to_self_delay`], or if an output descriptor + * `script_pubkey` does not match the one we can spend. + * + * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint + * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payer_id(void); +MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); /** - * Utility method to constructs a new DuplicatePaymentId-variant Bolt12SemanticError + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -enum LDKBolt12SemanticError Bolt12SemanticError_duplicate_payment_id(void); +struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingPaths-variant Bolt12SemanticError + * Constructs a new ChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_paths(void); +struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError + * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is */ -enum LDKBolt12SemanticError Bolt12SemanticError_invalid_pay_info(void); +struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); /** - * Utility method to constructs a new MissingCreationTime-variant Bolt12SemanticError + * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_creation_time(void); +struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); /** - * Utility method to constructs a new MissingPaymentHash-variant Bolt12SemanticError + * Read a InMemorySigner from a byte array, created by InMemorySigner_write */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_payment_hash(void); +struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); /** - * Utility method to constructs a new MissingSignature-variant Bolt12SemanticError + * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. */ -enum LDKBolt12SemanticError Bolt12SemanticError_missing_signature(void); +void KeysManager_free(struct LDKKeysManager this_obj); /** - * Frees any resources used by the Refund, if is_owned is set and inner is non-NULL. + * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., + * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). + * `starting_time` isn't strictly required to actually be a time, but it must absolutely, + * without a doubt, be unique to this instance. ie if you start multiple times with the same + * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this + * is to simply use the current time (with very high precision). + * + * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, + * obviously, `starting_time` should be unique every time you reload the library - it is only + * used to generate new ephemeral key data (which will be stored by the individual channel if + * necessary). + * + * Note that the seed is required to recover certain on-chain funds independent of + * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required + * for any channel, and some on-chain during-closing funds. + * + * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor */ -void Refund_free(struct LDKRefund this_obj); +MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); /** - * Creates a copy of the Refund + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -struct LDKRefund Refund_clone(const struct LDKRefund *NONNULL_PTR orig); +MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * A complete description of the purpose of the refund. Intended to be displayed to the user - * but with the caveat that it has not been verified in any way. + * Derive an old [`EcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. */ -MUST_USE_RES struct LDKPrintableString Refund_description(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Duration since the Unix epoch when an invoice should no longer be sent. + * Signs the given [`Psbt`] which spends the given [`SpendableOutputDescriptor`]s. + * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there + * are no other inputs that need signing. * - * If `None`, the refund does not expire. + * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. + * + * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used + * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. */ -MUST_USE_RES struct LDKCOption_u64Z Refund_absolute_expiry(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); /** - * Whether the refund has expired. + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -MUST_USE_RES bool Refund_is_expired(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Whether the refund has expired given the duration since the Unix epoch. + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is */ -MUST_USE_RES bool Refund_is_expired_no_std(const struct LDKRefund *NONNULL_PTR this_arg, uint64_t duration_since_epoch); +struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be - * displayed to the user but with the caveat that it has not been verified in any way. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -MUST_USE_RES struct LDKPrintableString Refund_issuer(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKOutputSpender KeysManager_as_OutputSpender(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * Paths to the sender originating from publicly reachable nodes. Blinded paths provide sender - * privacy by obfuscating its node id. + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is */ -MUST_USE_RES struct LDKCVec_BlindedPathZ Refund_paths(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); /** - * An unpredictable series of bytes, typically containing information about the derivation of - * [`payer_id`]. - * - * [`payer_id`]: Self::payer_id + * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKu8slice Refund_payer_metadata(const struct LDKRefund *NONNULL_PTR this_arg); +void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); /** - * A chain that the refund is valid for. + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -MUST_USE_RES struct LDKThirtyTwoBytes Refund_chain(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The amount to refund in msats (i.e., the minimum lightning-payable unit for [`chain`]). - * - * [`chain`]: Self::chain + * Constructs a new NodeSigner which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is */ -MUST_USE_RES uint64_t Refund_amount_msats(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Features pertaining to requesting an invoice. + * Constructs a new OutputSpender which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is */ -MUST_USE_RES struct LDKInvoiceRequestFeatures Refund_features(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKOutputSpender PhantomKeysManager_as_OutputSpender(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * The quantity of an item that refund is for. + * Constructs a new SignerProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is */ -MUST_USE_RES struct LDKCOption_u64Z Refund_quantity(const struct LDKRefund *NONNULL_PTR this_arg); +struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * A public node id to send to in the case where there are no [`paths`]. Otherwise, a possibly - * transient pubkey. + * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` + * that is shared across all nodes that intend to participate in [phantom node payments] + * together. * - * [`paths`]: Self::paths + * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and + * `starting_time_nanos`. + * + * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the + * same across restarts, or else inbound payments may fail. + * + * [phantom node payments]: PhantomKeysManager */ -MUST_USE_RES struct LDKPublicKey Refund_payer_id(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); /** - * Payer provided note to include in the invoice. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * See [`KeysManager::derive_channel_keys`] for documentation on this method. */ -MUST_USE_RES struct LDKPrintableString Refund_payer_note(const struct LDKRefund *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); /** - * Serialize the Refund object into a byte array which can be read by Refund_read + * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. */ -struct LDKCVec_u8Z Refund_write(const struct LDKRefund *NONNULL_PTR obj); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Read a Refund object from a string + * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the + * last-hop onion data, etc. */ -struct LDKCResult_RefundBolt12ParseErrorZ Refund_from_str(struct LDKStr s); +MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); /** - * Creates a copy of the UtxoLookupError + * Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. */ -enum LDKUtxoLookupError UtxoLookupError_clone(const enum LDKUtxoLookupError *NONNULL_PTR orig); +void RandomBytes_free(struct LDKRandomBytes this_obj); /** - * Utility method to constructs a new UnknownChain-variant UtxoLookupError + * Creates a new instance using the given seed. */ -enum LDKUtxoLookupError UtxoLookupError_unknown_chain(void); +MUST_USE_RES struct LDKRandomBytes RandomBytes_new(struct LDKThirtyTwoBytes seed); /** - * Utility method to constructs a new UnknownTx-variant UtxoLookupError + * Constructs a new EntropySource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is */ -enum LDKUtxoLookupError UtxoLookupError_unknown_tx(void); +struct LDKEntropySource RandomBytes_as_EntropySource(const struct LDKRandomBytes *NONNULL_PTR this_arg); /** - * Frees any resources used by the UtxoResult + * Creates a copy of a EcdsaChannelSigner */ -void UtxoResult_free(struct LDKUtxoResult this_ptr); +struct LDKEcdsaChannelSigner EcdsaChannelSigner_clone(const struct LDKEcdsaChannelSigner *NONNULL_PTR orig); /** - * Creates a copy of the UtxoResult + * Calls the free function if one is set */ -struct LDKUtxoResult UtxoResult_clone(const struct LDKUtxoResult *NONNULL_PTR orig); +void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); /** - * Utility method to constructs a new Sync-variant UtxoResult + * Calls the free function if one is set */ -struct LDKUtxoResult UtxoResult_sync(struct LDKCResult_TxOutUtxoLookupErrorZ a); +void AsyncPaymentsMessageHandler_free(struct LDKAsyncPaymentsMessageHandler this_ptr); /** - * Utility method to constructs a new Async-variant UtxoResult + * Frees any resources used by the AsyncPaymentsMessage */ -struct LDKUtxoResult UtxoResult_async(struct LDKUtxoFuture a); +void AsyncPaymentsMessage_free(struct LDKAsyncPaymentsMessage this_ptr); /** - * Calls the free function if one is set + * Creates a copy of the AsyncPaymentsMessage */ -void UtxoLookup_free(struct LDKUtxoLookup this_ptr); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_clone(const struct LDKAsyncPaymentsMessage *NONNULL_PTR orig); /** - * Frees any resources used by the UtxoFuture, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage */ -void UtxoFuture_free(struct LDKUtxoFuture this_obj); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_held_htlc_available(struct LDKHeldHtlcAvailable a); /** - * Creates a copy of the UtxoFuture + * Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage */ -struct LDKUtxoFuture UtxoFuture_clone(const struct LDKUtxoFuture *NONNULL_PTR orig); +struct LDKAsyncPaymentsMessage AsyncPaymentsMessage_release_held_htlc(struct LDKReleaseHeldHtlc a); /** - * Builds a new future for later resolution. + * Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKUtxoFuture UtxoFuture_new(void); +void HeldHtlcAvailable_free(struct LDKHeldHtlcAvailable this_obj); /** - * Resolves this future against the given `graph` and with the given `result`. - * - * This is identical to calling [`UtxoFuture::resolve`] with a dummy `gossip`, disabling - * forwarding the validated gossip message onwards to peers. - * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. - * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * The secret that will be used by the recipient of this message to release the held HTLC. */ -void UtxoFuture_resolve_without_forwarding(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, struct LDKCResult_TxOutUtxoLookupErrorZ result); +const uint8_t (*HeldHtlcAvailable_get_payment_release_secret(const struct LDKHeldHtlcAvailable *NONNULL_PTR this_ptr))[32]; /** - * Resolves this future against the given `graph` and with the given `result`. - * - * The given `gossip` is used to broadcast any validated messages onwards to all peers which - * have available buffer space. - * - * Because this may cause the [`NetworkGraph`]'s [`processing_queue_high`] to flip, in order - * to allow us to interact with peers again, you should call [`PeerManager::process_events`] - * after this. - * - * [`processing_queue_high`]: crate::ln::msgs::RoutingMessageHandler::processing_queue_high - * [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events + * The secret that will be used by the recipient of this message to release the held HTLC. */ -void UtxoFuture_resolve(const struct LDKUtxoFuture *NONNULL_PTR this_arg, const struct LDKNetworkGraph *NONNULL_PTR graph, const struct LDKP2PGossipSync *NONNULL_PTR gossip, struct LDKCResult_TxOutUtxoLookupErrorZ result); +void HeldHtlcAvailable_set_payment_release_secret(struct LDKHeldHtlcAvailable *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Frees any resources used by the NodeId, if is_owned is set and inner is non-NULL. + * Constructs a new HeldHtlcAvailable given each field */ -void NodeId_free(struct LDKNodeId this_obj); +MUST_USE_RES struct LDKHeldHtlcAvailable HeldHtlcAvailable_new(struct LDKThirtyTwoBytes payment_release_secret_arg); /** - * Creates a copy of the NodeId + * Creates a copy of the HeldHtlcAvailable */ -struct LDKNodeId NodeId_clone(const struct LDKNodeId *NONNULL_PTR orig); +struct LDKHeldHtlcAvailable HeldHtlcAvailable_clone(const struct LDKHeldHtlcAvailable *NONNULL_PTR orig); /** - * Create a new NodeId from a public key + * Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKNodeId NodeId_from_pubkey(struct LDKPublicKey pubkey); +void ReleaseHeldHtlc_free(struct LDKReleaseHeldHtlc this_obj); /** - * Get the public key slice from this NodeId + * Used to release the HTLC held upstream if it matches the corresponding + * [`HeldHtlcAvailable::payment_release_secret`]. */ -MUST_USE_RES struct LDKu8slice NodeId_as_slice(const struct LDKNodeId *NONNULL_PTR this_arg); +const uint8_t (*ReleaseHeldHtlc_get_payment_release_secret(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_ptr))[32]; /** - * Get the public key as an array from this NodeId + * Used to release the HTLC held upstream if it matches the corresponding + * [`HeldHtlcAvailable::payment_release_secret`]. */ -MUST_USE_RES const uint8_t (*NodeId_as_array(const struct LDKNodeId *NONNULL_PTR this_arg))[33]; +void ReleaseHeldHtlc_set_payment_release_secret(struct LDKReleaseHeldHtlc *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Get the public key from this NodeId + * Constructs a new ReleaseHeldHtlc given each field */ -MUST_USE_RES struct LDKCResult_PublicKeySecp256k1ErrorZ NodeId_as_pubkey(const struct LDKNodeId *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKReleaseHeldHtlc ReleaseHeldHtlc_new(struct LDKThirtyTwoBytes payment_release_secret_arg); /** - * Generates a non-cryptographic 64-bit hash of the NodeId. + * Creates a copy of the ReleaseHeldHtlc */ -uint64_t NodeId_hash(const struct LDKNodeId *NONNULL_PTR o); +struct LDKReleaseHeldHtlc ReleaseHeldHtlc_clone(const struct LDKReleaseHeldHtlc *NONNULL_PTR orig); /** - * Serialize the NodeId object into a byte array which can be read by NodeId_read + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKCVec_u8Z NodeId_write(const struct LDKNodeId *NONNULL_PTR obj); +struct LDKOnionMessageContents ReleaseHeldHtlc_as_OnionMessageContents(const struct LDKReleaseHeldHtlc *NONNULL_PTR this_arg); /** - * Read a NodeId from a byte array, created by NodeId_write + * Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read */ -struct LDKCResult_NodeIdDecodeErrorZ NodeId_read(struct LDKu8slice ser); +struct LDKCVec_u8Z HeldHtlcAvailable_write(const struct LDKHeldHtlcAvailable *NONNULL_PTR obj); /** - * Frees any resources used by the NetworkGraph, if is_owned is set and inner is non-NULL. + * Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write */ -void NetworkGraph_free(struct LDKNetworkGraph this_obj); +struct LDKCResult_HeldHtlcAvailableDecodeErrorZ HeldHtlcAvailable_read(struct LDKu8slice ser); /** - * Frees any resources used by the ReadOnlyNetworkGraph, if is_owned is set and inner is non-NULL. + * Serialize the ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read */ -void ReadOnlyNetworkGraph_free(struct LDKReadOnlyNetworkGraph this_obj); +struct LDKCVec_u8Z ReleaseHeldHtlc_write(const struct LDKReleaseHeldHtlc *NONNULL_PTR obj); /** - * Frees any resources used by the NetworkUpdate + * Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write */ -void NetworkUpdate_free(struct LDKNetworkUpdate this_ptr); +struct LDKCResult_ReleaseHeldHtlcDecodeErrorZ ReleaseHeldHtlc_read(struct LDKu8slice ser); /** - * Creates a copy of the NetworkUpdate + * Returns whether `tlv_type` corresponds to a TLV record for async payment messages. */ -struct LDKNetworkUpdate NetworkUpdate_clone(const struct LDKNetworkUpdate *NONNULL_PTR orig); +MUST_USE_RES bool AsyncPaymentsMessage_is_known_type(uint64_t tlv_type); /** - * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKNetworkUpdate NetworkUpdate_channel_update_message(struct LDKChannelUpdate msg); +struct LDKOnionMessageContents AsyncPaymentsMessage_as_OnionMessageContents(const struct LDKAsyncPaymentsMessage *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelFailure-variant NetworkUpdate + * Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read */ -struct LDKNetworkUpdate NetworkUpdate_channel_failure(uint64_t short_channel_id, bool is_permanent); +struct LDKCVec_u8Z AsyncPaymentsMessage_write(const struct LDKAsyncPaymentsMessage *NONNULL_PTR obj); /** - * Utility method to constructs a new NodeFailure-variant NetworkUpdate + * Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write */ -struct LDKNetworkUpdate NetworkUpdate_node_failure(struct LDKPublicKey node_id, bool is_permanent); +struct LDKCResult_AsyncPaymentsMessageDecodeErrorZ AsyncPaymentsMessage_read(struct LDKu8slice ser, uint64_t arg); /** - * Checks if two NetworkUpdates contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. */ -bool NetworkUpdate_eq(const struct LDKNetworkUpdate *NONNULL_PTR a, const struct LDKNetworkUpdate *NONNULL_PTR b); +void OnionMessenger_free(struct LDKOnionMessenger this_obj); /** - * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read + * Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z NetworkUpdate_write(const struct LDKNetworkUpdate *NONNULL_PTR obj); +void Responder_free(struct LDKResponder this_obj); /** - * Read a NetworkUpdate from a byte array, created by NetworkUpdate_write + * Creates a copy of the Responder */ -struct LDKCResult_COption_NetworkUpdateZDecodeErrorZ NetworkUpdate_read(struct LDKu8slice ser); +struct LDKResponder Responder_clone(const struct LDKResponder *NONNULL_PTR orig); /** - * Frees any resources used by the P2PGossipSync, if is_owned is set and inner is non-NULL. + * Checks if two Responders contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void P2PGossipSync_free(struct LDKP2PGossipSync this_obj); +bool Responder_eq(const struct LDKResponder *NONNULL_PTR a, const struct LDKResponder *NONNULL_PTR b); -/** - * Creates a new tracker of the actual state of the network of channels and nodes, - * assuming an existing [`NetworkGraph`]. - * UTXO lookup is used to make sure announced channels exist on-chain, channel data is - * correct, and the announcement is signed with channel owners' keys. +/** + * Serialize the Responder object into a byte array which can be read by Responder_read */ -MUST_USE_RES struct LDKP2PGossipSync P2PGossipSync_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCOption_UtxoLookupZ utxo_lookup, struct LDKLogger logger); +struct LDKCVec_u8Z Responder_write(const struct LDKResponder *NONNULL_PTR obj); /** - * Adds a provider used to check new announcements. Does not affect - * existing announcements unless they are updated. - * Add, update or remove the provider would replace the current one. + * Read a Responder from a byte array, created by Responder_write */ -void P2PGossipSync_add_utxo_lookup(const struct LDKP2PGossipSync *NONNULL_PTR this_arg, struct LDKCOption_UtxoLookupZ utxo_lookup); +struct LDKCResult_ResponderDecodeErrorZ Responder_read(struct LDKu8slice ser); /** - * Handles any network updates originating from [`Event`]s. - * Note that this will skip applying any [`NetworkUpdate::ChannelUpdateMessage`] to avoid - * leaking possibly identifying information of the sender to the public network. + * Creates a [`ResponseInstruction`] for responding without including a reply path. * - * [`Event`]: crate::events::Event + * Use when the recipient doesn't need to send back a reply to us. */ -void NetworkGraph_handle_network_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNetworkUpdate *NONNULL_PTR network_update); +MUST_USE_RES struct LDKResponseInstruction Responder_respond(struct LDKResponder this_arg); /** - * Gets the chain hash for this network graph. + * Creates a [`ResponseInstruction`] for responding including a reply path. + * + * Use when the recipient needs to send back a reply to us. */ -MUST_USE_RES struct LDKThirtyTwoBytes NetworkGraph_get_chain_hash(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKResponseInstruction Responder_respond_with_reply_path(struct LDKResponder this_arg, struct LDKMessageContext context); /** - * Verifies the signature of a [`NodeAnnouncement`]. - * - * Returns an error if it is invalid. + * Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_NoneLightningErrorZ verify_node_announcement(const struct LDKNodeAnnouncement *NONNULL_PTR msg); +void ResponseInstruction_free(struct LDKResponseInstruction this_obj); /** - * Verifies all signatures included in a [`ChannelAnnouncement`]. - * - * Returns an error if one of the signatures is invalid. + * Creates a copy of the ResponseInstruction */ -struct LDKCResult_NoneLightningErrorZ verify_channel_announcement(const struct LDKChannelAnnouncement *NONNULL_PTR msg); +struct LDKResponseInstruction ResponseInstruction_clone(const struct LDKResponseInstruction *NONNULL_PTR orig); /** - * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + * Frees any resources used by the MessageSendInstructions */ -struct LDKRoutingMessageHandler P2PGossipSync_as_RoutingMessageHandler(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +void MessageSendInstructions_free(struct LDKMessageSendInstructions this_ptr); /** - * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + * Creates a copy of the MessageSendInstructions */ -struct LDKMessageSendEventsProvider P2PGossipSync_as_MessageSendEventsProvider(const struct LDKP2PGossipSync *NONNULL_PTR this_arg); +struct LDKMessageSendInstructions MessageSendInstructions_clone(const struct LDKMessageSendInstructions *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelUpdateInfo, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions */ -void ChannelUpdateInfo_free(struct LDKChannelUpdateInfo this_obj); +struct LDKMessageSendInstructions MessageSendInstructions_with_specified_reply_path(struct LDKDestination destination, struct LDKBlindedMessagePath reply_path); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * Utility method to constructs a new WithReplyPath-variant MessageSendInstructions */ -uint32_t ChannelUpdateInfo_get_last_update(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKMessageSendInstructions MessageSendInstructions_with_reply_path(struct LDKDestination destination, struct LDKMessageContext context); /** - * When the last update to the channel direction was issued. - * Value is opaque, as set in the announcement. + * Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions */ -void ChannelUpdateInfo_set_last_update(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKMessageSendInstructions MessageSendInstructions_without_reply_path(struct LDKDestination destination); /** - * Whether the channel can be currently used for payments (in this one direction). + * Utility method to constructs a new ForReply-variant MessageSendInstructions */ -bool ChannelUpdateInfo_get_enabled(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKMessageSendInstructions MessageSendInstructions_for_reply(struct LDKResponseInstruction instructions); /** - * Whether the channel can be currently used for payments (in this one direction). + * Calls the free function if one is set */ -void ChannelUpdateInfo_set_enabled(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, bool val); +void MessageRouter_free(struct LDKMessageRouter this_ptr); /** - * The difference in CLTV values that you must have when routing through this channel. + * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. */ -uint16_t ChannelUpdateInfo_get_cltv_expiry_delta(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); /** - * The difference in CLTV values that you must have when routing through this channel. + * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. */ -void ChannelUpdateInfo_set_cltv_expiry_delta(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint16_t val); +MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); /** - * The minimum value, which must be relayed to the next hop via the channel + * Constructs a new MessageRouter which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is */ -uint64_t ChannelUpdateInfo_get_htlc_minimum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); /** - * The minimum value, which must be relayed to the next hop via the channel + * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. */ -void ChannelUpdateInfo_set_htlc_minimum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); /** - * The maximum value which may be relayed to the next hop via the channel. + * Nodes on the path between the sender and the destination. + * + * Returns a copy of the field. */ -uint64_t ChannelUpdateInfo_get_htlc_maximum_msat(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * The maximum value which may be relayed to the next hop via the channel. + * Nodes on the path between the sender and the destination. */ -void ChannelUpdateInfo_set_htlc_maximum_msat(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, uint64_t val); +void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); /** - * Fees charged when the channel is used for routing + * The recipient of the message. */ -struct LDKRoutingFees ChannelUpdateInfo_get_fees(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Fees charged when the channel is used for routing + * The recipient of the message. */ -void ChannelUpdateInfo_set_fees(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. + * + * Returns a copy of the field. */ -struct LDKChannelUpdate ChannelUpdateInfo_get_last_update_message(const struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr); +struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); /** - * Most recent update for the channel received from the network - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. + * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use + * this to initiate such a connection. */ -void ChannelUpdateInfo_set_last_update_message(struct LDKChannelUpdateInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdate val); +void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); /** - * Constructs a new ChannelUpdateInfo given each field - * - * Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new OnionMessagePath given each field */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelUpdateInfo_new(uint32_t last_update_arg, bool enabled_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKRoutingFees fees_arg, struct LDKChannelUpdate last_update_message_arg); +MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); /** - * Creates a copy of the ChannelUpdateInfo + * Creates a copy of the OnionMessagePath */ -struct LDKChannelUpdateInfo ChannelUpdateInfo_clone(const struct LDKChannelUpdateInfo *NONNULL_PTR orig); +struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); /** - * Checks if two ChannelUpdateInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Returns the first node in the path. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -bool ChannelUpdateInfo_eq(const struct LDKChannelUpdateInfo *NONNULL_PTR a, const struct LDKChannelUpdateInfo *NONNULL_PTR b); +MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); /** - * Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read + * Frees any resources used by the Destination */ -struct LDKCVec_u8Z ChannelUpdateInfo_write(const struct LDKChannelUpdateInfo *NONNULL_PTR obj); +void Destination_free(struct LDKDestination this_ptr); /** - * Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write + * Creates a copy of the Destination */ -struct LDKCResult_ChannelUpdateInfoDecodeErrorZ ChannelUpdateInfo_read(struct LDKu8slice ser); +struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); /** - * Frees any resources used by the ChannelInfo, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Node-variant Destination */ -void ChannelInfo_free(struct LDKChannelInfo this_obj); +struct LDKDestination Destination_node(struct LDKPublicKey a); /** - * Protocol features of a channel communicated during its announcement + * Utility method to constructs a new BlindedPath-variant Destination */ -struct LDKChannelFeatures ChannelInfo_get_features(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKDestination Destination_blinded_path(struct LDKBlindedMessagePath a); /** - * Protocol features of a channel communicated during its announcement + * Generates a non-cryptographic 64-bit hash of the Destination. */ -void ChannelInfo_set_features(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +uint64_t Destination_hash(const struct LDKDestination *NONNULL_PTR o); /** - * Source node of the first direction of a channel + * Checks if two Destinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKNodeId ChannelInfo_get_node_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +bool Destination_eq(const struct LDKDestination *NONNULL_PTR a, const struct LDKDestination *NONNULL_PTR b); /** - * Source node of the first direction of a channel + * Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a + * [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the + * provided [`ReadOnlyNetworkGraph`]. */ -void ChannelInfo_set_node_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +void Destination_resolve(struct LDKDestination *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * Details about the first direction of a channel - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the SendSuccess */ -struct LDKChannelUpdateInfo ChannelInfo_get_one_to_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void SendSuccess_free(struct LDKSendSuccess this_ptr); /** - * Details about the first direction of a channel - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the SendSuccess */ -void ChannelInfo_set_one_to_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +struct LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); /** - * Source node of the second direction of a channel + * Utility method to constructs a new Buffered-variant SendSuccess */ -struct LDKNodeId ChannelInfo_get_node_two(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKSendSuccess SendSuccess_buffered(void); /** - * Source node of the second direction of a channel + * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess */ -void ChannelInfo_set_node_two(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKNodeId val); +struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); /** - * Details about the second direction of a channel - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the SendSuccess. */ -struct LDKChannelUpdateInfo ChannelInfo_get_two_to_one(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +uint64_t SendSuccess_hash(const struct LDKSendSuccess *NONNULL_PTR o); /** - * Details about the second direction of a channel - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Checks if two SendSuccesss contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void ChannelInfo_set_two_to_one(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelUpdateInfo val); +bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Frees any resources used by the SendError */ -struct LDKCOption_u64Z ChannelInfo_get_capacity_sats(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +void SendError_free(struct LDKSendError this_ptr); /** - * The channel capacity as seen on-chain, if chain lookup is available. + * Creates a copy of the SendError */ -void ChannelInfo_set_capacity_sats(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new Secp256k1-variant SendError */ -struct LDKChannelAnnouncement ChannelInfo_get_announcement_message(const struct LDKChannelInfo *NONNULL_PTR this_ptr); +struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); /** - * An initial announcement of the channel - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new TooBigPacket-variant SendError */ -void ChannelInfo_set_announcement_message(struct LDKChannelInfo *NONNULL_PTR this_ptr, struct LDKChannelAnnouncement val); +struct LDKSendError SendError_too_big_packet(void); /** - * Creates a copy of the ChannelInfo + * Utility method to constructs a new TooFewBlindedHops-variant SendError */ -struct LDKChannelInfo ChannelInfo_clone(const struct LDKChannelInfo *NONNULL_PTR orig); +struct LDKSendError SendError_too_few_blinded_hops(void); /** - * Checks if two ChannelInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new InvalidFirstHop-variant SendError */ -bool ChannelInfo_eq(const struct LDKChannelInfo *NONNULL_PTR a, const struct LDKChannelInfo *NONNULL_PTR b); +struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); /** - * Returns a [`ChannelUpdateInfo`] based on the direction implied by the channel_flag. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new PathNotFound-variant SendError */ -MUST_USE_RES struct LDKChannelUpdateInfo ChannelInfo_get_directional_info(const struct LDKChannelInfo *NONNULL_PTR this_arg, uint8_t channel_flags); +struct LDKSendError SendError_path_not_found(void); /** - * Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read + * Utility method to constructs a new InvalidMessage-variant SendError */ -struct LDKCVec_u8Z ChannelInfo_write(const struct LDKChannelInfo *NONNULL_PTR obj); +struct LDKSendError SendError_invalid_message(void); /** - * Read a ChannelInfo from a byte array, created by ChannelInfo_write + * Utility method to constructs a new BufferFull-variant SendError */ -struct LDKCResult_ChannelInfoDecodeErrorZ ChannelInfo_read(struct LDKu8slice ser); +struct LDKSendError SendError_buffer_full(void); /** - * Frees any resources used by the DirectedChannelInfo, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new GetNodeIdFailed-variant SendError */ -void DirectedChannelInfo_free(struct LDKDirectedChannelInfo this_obj); +struct LDKSendError SendError_get_node_id_failed(void); /** - * Creates a copy of the DirectedChannelInfo + * Utility method to constructs a new UnresolvedIntroductionNode-variant SendError */ -struct LDKDirectedChannelInfo DirectedChannelInfo_clone(const struct LDKDirectedChannelInfo *NONNULL_PTR orig); +struct LDKSendError SendError_unresolved_introduction_node(void); /** - * Returns information for the channel. + * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError */ -MUST_USE_RES struct LDKChannelInfo DirectedChannelInfo_channel(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +struct LDKSendError SendError_blinded_path_advance_failed(void); /** - * Returns the [`EffectiveCapacity`] of the channel in the direction. - * - * This is either the total capacity from the funding transaction, if known, or the - * `htlc_maximum_msat` for the direction as advertised by the gossip network, if known, - * otherwise. + * Generates a non-cryptographic 64-bit hash of the SendError. */ -MUST_USE_RES struct LDKEffectiveCapacity DirectedChannelInfo_effective_capacity(const struct LDKDirectedChannelInfo *NONNULL_PTR this_arg); +uint64_t SendError_hash(const struct LDKSendError *NONNULL_PTR o); /** - * Frees any resources used by the EffectiveCapacity + * Checks if two SendErrors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void EffectiveCapacity_free(struct LDKEffectiveCapacity this_ptr); +bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); /** - * Creates a copy of the EffectiveCapacity + * Calls the free function if one is set */ -struct LDKEffectiveCapacity EffectiveCapacity_clone(const struct LDKEffectiveCapacity *NONNULL_PTR orig); +void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); /** - * Utility method to constructs a new ExactLiquidity-variant EffectiveCapacity + * Frees any resources used by the PeeledOnion */ -struct LDKEffectiveCapacity EffectiveCapacity_exact_liquidity(uint64_t liquidity_msat); +void PeeledOnion_free(struct LDKPeeledOnion this_ptr); /** - * Utility method to constructs a new AdvertisedMaxHTLC-variant EffectiveCapacity + * Creates a copy of the PeeledOnion */ -struct LDKEffectiveCapacity EffectiveCapacity_advertised_max_htlc(uint64_t amount_msat); +struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); /** - * Utility method to constructs a new Total-variant EffectiveCapacity + * Utility method to constructs a new Forward-variant PeeledOnion */ -struct LDKEffectiveCapacity EffectiveCapacity_total(uint64_t capacity_msat, uint64_t htlc_maximum_msat); +struct LDKPeeledOnion PeeledOnion_forward(struct LDKNextMessageHop a, struct LDKOnionMessage b); /** - * Utility method to constructs a new Infinite-variant EffectiveCapacity + * Utility method to constructs a new Receive-variant PeeledOnion */ -struct LDKEffectiveCapacity EffectiveCapacity_infinite(void); +struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKCOption_MessageContextZ b, struct LDKBlindedMessagePath c); /** - * Utility method to constructs a new HintMaxHTLC-variant EffectiveCapacity + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`, first calling [`Destination::resolve`] on `path.destination` with the given + * [`ReadOnlyNetworkGraph`]. + * + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKEffectiveCapacity EffectiveCapacity_hint_max_htlc(uint64_t amount_msat); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message_resolving_destination(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * Utility method to constructs a new Unknown-variant EffectiveCapacity + * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of + * `path`. + * + * Returns the node id of the peer to send the message to, the message itself, and any addresses + * needed to connect to the first node. + * + * Returns [`SendError::UnresolvedIntroductionNode`] if: + * - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], + * - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. + * Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node + * first with a [`ReadOnlyNetworkGraph`]. + * + * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None */ -struct LDKEffectiveCapacity EffectiveCapacity_unknown(void); +struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedMessagePath reply_path); /** - * Returns the effective capacity denominated in millisatoshi. + * Decode one layer of an incoming [`OnionMessage`]. + * + * Returns either the next layer of the onion for forwarding or the decrypted content for the + * receiver. */ -MUST_USE_RES uint64_t EffectiveCapacity_as_msat(const struct LDKEffectiveCapacity *NONNULL_PTR this_arg); +struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); /** - * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. + * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to + * their respective handlers. */ -void RoutingFees_free(struct LDKRoutingFees this_obj); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKCustomOnionMessageHandler custom_handler); /** - * Flat routing fee in millisatoshis. + * Similar to [`Self::new`], but rather than dropping onion messages that are + * intended to be forwarded to offline peers, we will intercept them for + * later forwarding. + * + * Interception flow: + * 1. If an onion message for an offline peer is received, `OnionMessenger` will + * generate an [`Event::OnionMessageIntercepted`]. Event handlers can + * then choose to persist this onion message for later forwarding, or drop + * it. + * 2. When the offline peer later comes back online, `OnionMessenger` will + * generate an [`Event::OnionMessagePeerConnected`]. Event handlers will + * then fetch all previously intercepted onion messages for this peer. + * 3. Once the stored onion messages are fetched, they can finally be + * forwarded to the now-online peer via [`Self::forward_onion_message`]. + * + * # Note + * + * LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s + * are generated, so it is the caller's responsibility to limit how many + * onion messages are persisted and only persist onion messages for relevant + * peers. */ -uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new_with_offline_peer_interception(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKNodeIdLookUp node_id_lookup, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKAsyncPaymentsMessageHandler async_payments_handler, struct LDKCustomOnionMessageHandler custom_handler); /** - * Flat routing fee in millisatoshis. + * Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. */ -void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKMessageSendInstructions instructions); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized + * the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] + * and want to forward a previously intercepted onion message to a peer that + * has just come online. */ -uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneSendErrorZ OnionMessenger_forward_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessage message, struct LDKPublicKey peer_node_id); /** - * Liquidity-based routing fee in millionths of a routed amount. - * In other words, 10000 is 1%. + * Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], + * enqueueing any response for sending. + * + * This function is useful for asynchronous handling of [`OnionMessage`]s. + * Handlers have the option to return `None`, indicating that no immediate response should be + * sent. Then, they can transfer the associated [`Responder`] to another task responsible for + * generating the response asynchronously. Subsequently, when the response is prepared and + * ready for sending, that task can invoke this method to enqueue the response for delivery. */ -void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_handle_onion_message_response(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents response, struct LDKResponseInstruction instructions); /** - * Constructs a new RoutingFees given each field + * Gets a [`Future`] that completes when an event is available via + * [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. + * + * Note that callbacks registered on the [`Future`] MUST NOT call back into this + * [`OnionMessenger`] and should instead register actions to be taken later. + * + * [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events */ -MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); +MUST_USE_RES struct LDKFuture OnionMessenger_get_update_future(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Checks if two RoutingFeess contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new EventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is */ -bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); +struct LDKEventsProvider OnionMessenger_as_EventsProvider(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Creates a copy of the RoutingFees + * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is */ -struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); +struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); /** - * Generates a non-cryptographic 64-bit hash of the RoutingFees. + * Calls the free function if one is set */ -uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); +void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); /** - * Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read + * Frees any resources used by the OffersMessage */ -struct LDKCVec_u8Z RoutingFees_write(const struct LDKRoutingFees *NONNULL_PTR obj); +void OffersMessage_free(struct LDKOffersMessage this_ptr); /** - * Read a RoutingFees from a byte array, created by RoutingFees_write + * Creates a copy of the OffersMessage */ -struct LDKCResult_RoutingFeesDecodeErrorZ RoutingFees_read(struct LDKu8slice ser); +struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); /** - * Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new InvoiceRequest-variant OffersMessage */ -void NodeAnnouncementInfo_free(struct LDKNodeAnnouncementInfo this_obj); +struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); /** - * Protocol features the node announced support for + * Utility method to constructs a new Invoice-variant OffersMessage */ -struct LDKNodeFeatures NodeAnnouncementInfo_get_features(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); /** - * Protocol features the node announced support for + * Utility method to constructs a new InvoiceError-variant OffersMessage */ -void NodeAnnouncementInfo_set_features(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Returns whether `tlv_type` corresponds to a TLV record for Offers. */ -uint32_t NodeAnnouncementInfo_get_last_update(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); /** - * When the last known update to the node state was issued. - * Value is opaque, as set in the announcement. + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -void NodeAnnouncementInfo_set_last_update(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, uint32_t val); +struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); /** - * Color assigned to the node + * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read */ -const uint8_t (*NodeAnnouncementInfo_get_rgb(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr))[3]; +struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); /** - * Color assigned to the node + * Read a OffersMessage from a byte array, created by OffersMessage_write */ -void NodeAnnouncementInfo_set_rgb(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKThreeBytes val); +struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. */ -struct LDKNodeAlias NodeAnnouncementInfo_get_alias(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +void Packet_free(struct LDKPacket this_obj); /** - * Moniker assigned to the node. - * May be invalid or malicious (eg control chars), - * should not be exposed to the user. + * Bolt 04 version number */ -void NodeAnnouncementInfo_set_alias(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAlias val); +uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Bolt 04 version number */ -struct LDKNodeAnnouncement NodeAnnouncementInfo_get_announcement_message(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr); +void Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); /** - * An initial announcement of the node - * Mostly redundant with the data we store in fields explicitly. - * Everything else is useful only for sending out for initial routing sync. - * Not stored if contains excess data to prevent DoS. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data */ -void NodeAnnouncementInfo_set_announcement_message(struct LDKNodeAnnouncementInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncement val); +struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); + +/** + * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + */ +void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new NodeAnnouncementInfo given each field + * Encrypted payload for the next hop * - * Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Returns a copy of the field. */ -MUST_USE_RES struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_new(struct LDKNodeFeatures features_arg, uint32_t last_update_arg, struct LDKThreeBytes rgb_arg, struct LDKNodeAlias alias_arg, struct LDKNodeAnnouncement announcement_message_arg); +struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); /** - * Creates a copy of the NodeAnnouncementInfo + * Encrypted payload for the next hop */ -struct LDKNodeAnnouncementInfo NodeAnnouncementInfo_clone(const struct LDKNodeAnnouncementInfo *NONNULL_PTR orig); +void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Checks if two NodeAnnouncementInfos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * HMAC to verify the integrity of hop_data */ -bool NodeAnnouncementInfo_eq(const struct LDKNodeAnnouncementInfo *NONNULL_PTR a, const struct LDKNodeAnnouncementInfo *NONNULL_PTR b); +const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; /** - * Internet-level addresses via which one can connect to the node + * HMAC to verify the integrity of hop_data */ -MUST_USE_RES struct LDKCVec_SocketAddressZ NodeAnnouncementInfo_addresses(const struct LDKNodeAnnouncementInfo *NONNULL_PTR this_arg); +void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read + * Constructs a new Packet given each field */ -struct LDKCVec_u8Z NodeAnnouncementInfo_write(const struct LDKNodeAnnouncementInfo *NONNULL_PTR obj); +MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); /** - * Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write + * Creates a copy of the Packet */ -struct LDKCResult_NodeAnnouncementInfoDecodeErrorZ NodeAnnouncementInfo_read(struct LDKu8slice ser); +struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); /** - * Frees any resources used by the NodeAlias, if is_owned is set and inner is non-NULL. + * Generates a non-cryptographic 64-bit hash of the Packet. */ -void NodeAlias_free(struct LDKNodeAlias this_obj); +uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); -const uint8_t (*NodeAlias_get_a(const struct LDKNodeAlias *NONNULL_PTR this_ptr))[32]; +/** + * Checks if two Packets contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ +bool Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); -void NodeAlias_set_a(struct LDKNodeAlias *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +/** + * Serialize the Packet object into a byte array which can be read by Packet_read + */ +struct LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); /** - * Constructs a new NodeAlias given each field + * Frees any resources used by the ParsedOnionMessageContents */ -MUST_USE_RES struct LDKNodeAlias NodeAlias_new(struct LDKThirtyTwoBytes a_arg); +void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents this_ptr); /** - * Creates a copy of the NodeAlias + * Creates a copy of the ParsedOnionMessageContents */ -struct LDKNodeAlias NodeAlias_clone(const struct LDKNodeAlias *NONNULL_PTR orig); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the NodeAlias. + * Utility method to constructs a new Offers-variant ParsedOnionMessageContents */ -uint64_t NodeAlias_hash(const struct LDKNodeAlias *NONNULL_PTR o); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); /** - * Checks if two NodeAliass contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new Custom-variant ParsedOnionMessageContents */ -bool NodeAlias_eq(const struct LDKNodeAlias *NONNULL_PTR a, const struct LDKNodeAlias *NONNULL_PTR b); +struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); /** - * Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read + * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is */ -struct LDKCVec_u8Z NodeAlias_write(const struct LDKNodeAlias *NONNULL_PTR obj); +struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); /** - * Read a NodeAlias from a byte array, created by NodeAlias_write + * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read */ -struct LDKCResult_NodeAliasDecodeErrorZ NodeAlias_read(struct LDKu8slice ser); +struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); /** - * Frees any resources used by the NodeInfo, if is_owned is set and inner is non-NULL. + * Creates a copy of a OnionMessageContents */ -void NodeInfo_free(struct LDKNodeInfo this_obj); +struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); /** - * All valid channels a node has announced - * - * Returns a copy of the field. + * Calls the free function if one is set */ -struct LDKCVec_u64Z NodeInfo_get_channels(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); /** - * All valid channels a node has announced + * Frees any resources used by the IntroductionNode */ -void NodeInfo_set_channels(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +void IntroductionNode_free(struct LDKIntroductionNode this_ptr); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the IntroductionNode */ -struct LDKNodeAnnouncementInfo NodeInfo_get_announcement_info(const struct LDKNodeInfo *NONNULL_PTR this_ptr); +struct LDKIntroductionNode IntroductionNode_clone(const struct LDKIntroductionNode *NONNULL_PTR orig); /** - * More information about a node from node_announcement. - * Optional because we store a Node entry after learning about it from - * a channel announcement, but before receiving a node announcement. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new NodeId-variant IntroductionNode */ -void NodeInfo_set_announcement_info(struct LDKNodeInfo *NONNULL_PTR this_ptr, struct LDKNodeAnnouncementInfo val); +struct LDKIntroductionNode IntroductionNode_node_id(struct LDKPublicKey a); /** - * Constructs a new NodeInfo given each field - * - * Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode */ -MUST_USE_RES struct LDKNodeInfo NodeInfo_new(struct LDKCVec_u64Z channels_arg, struct LDKNodeAnnouncementInfo announcement_info_arg); +struct LDKIntroductionNode IntroductionNode_directed_short_channel_id(enum LDKDirection a, uint64_t b); /** - * Creates a copy of the NodeInfo + * Generates a non-cryptographic 64-bit hash of the IntroductionNode. */ -struct LDKNodeInfo NodeInfo_clone(const struct LDKNodeInfo *NONNULL_PTR orig); +uint64_t IntroductionNode_hash(const struct LDKIntroductionNode *NONNULL_PTR o); /** - * Checks if two NodeInfos contain equal inner contents. + * Checks if two IntroductionNodes contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool NodeInfo_eq(const struct LDKNodeInfo *NONNULL_PTR a, const struct LDKNodeInfo *NONNULL_PTR b); +bool IntroductionNode_eq(const struct LDKIntroductionNode *NONNULL_PTR a, const struct LDKIntroductionNode *NONNULL_PTR b); /** - * Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read + * Creates a copy of the Direction */ -struct LDKCVec_u8Z NodeInfo_write(const struct LDKNodeInfo *NONNULL_PTR obj); +enum LDKDirection Direction_clone(const enum LDKDirection *NONNULL_PTR orig); /** - * Read a NodeInfo from a byte array, created by NodeInfo_write + * Utility method to constructs a new NodeOne-variant Direction */ -struct LDKCResult_NodeInfoDecodeErrorZ NodeInfo_read(struct LDKu8slice ser); +enum LDKDirection Direction_node_one(void); /** - * Serialize the NetworkGraph object into a byte array which can be read by NetworkGraph_read + * Utility method to constructs a new NodeTwo-variant Direction */ -struct LDKCVec_u8Z NetworkGraph_write(const struct LDKNetworkGraph *NONNULL_PTR obj); +enum LDKDirection Direction_node_two(void); /** - * Read a NetworkGraph from a byte array, created by NetworkGraph_write + * Generates a non-cryptographic 64-bit hash of the Direction. */ -struct LDKCResult_NetworkGraphDecodeErrorZ NetworkGraph_read(struct LDKu8slice ser, struct LDKLogger arg); +uint64_t Direction_hash(const enum LDKDirection *NONNULL_PTR o); /** - * Creates a new, empty, network graph. + * Checks if two Directions contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -MUST_USE_RES struct LDKNetworkGraph NetworkGraph_new(enum LDKNetwork network, struct LDKLogger logger); +bool Direction_eq(const enum LDKDirection *NONNULL_PTR a, const enum LDKDirection *NONNULL_PTR b); /** - * Returns a read-only view of the network graph. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKReadOnlyNetworkGraph NetworkGraph_read_only(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void NodeIdLookUp_free(struct LDKNodeIdLookUp this_ptr); /** - * The unix timestamp provided by the most recent rapid gossip sync. - * It will be set by the rapid sync process after every sync completion. + * Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_u32Z NetworkGraph_get_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +void EmptyNodeIdLookUp_free(struct LDKEmptyNodeIdLookUp this_obj); /** - * Update the unix timestamp provided by the most recent rapid gossip sync. - * This should be done automatically by the rapid sync process after every sync completion. + * Constructs a new EmptyNodeIdLookUp given each field */ -void NetworkGraph_set_last_rapid_gossip_sync_timestamp(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint32_t last_rapid_gossip_sync_timestamp); +MUST_USE_RES struct LDKEmptyNodeIdLookUp EmptyNodeIdLookUp_new(void); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement. - * - * You probably don't want to call this directly, instead relying on a P2PGossipSync's - * RoutingMessageHandler implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. + * Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeAnnouncement *NONNULL_PTR msg); +struct LDKNodeIdLookUp EmptyNodeIdLookUp_as_NodeIdLookUp(const struct LDKEmptyNodeIdLookUp *NONNULL_PTR this_arg); /** - * For an already known node (from channel announcements), update its stored properties from a - * given node announcement without verifying the associated signatures. Because we aren't - * given the associated signatures here we cannot relay the node announcement to any of our - * peers. + * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_node_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedNodeAnnouncement *NONNULL_PTR msg); +void BlindedHop_free(struct LDKBlindedHop this_obj); /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * The blinded node id of this hop in a blinded path. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * Store or update channel info from a channel announcement. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * This will skip verification of if the channel is actually on-chain. + * The blinded node id of this hop in a blinded path. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_announcement_no_lookup(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelAnnouncement *NONNULL_PTR msg); +void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Store or update channel info from a channel announcement without verifying the associated - * signatures. Because we aren't given the associated signatures here we cannot relay the - * channel announcement to any of our peers. + * The encrypted payload intended for this hop in a blinded path. * - * If a [`UtxoLookup`] object is provided via `utxo_lookup`, it will be called to verify - * the corresponding UTXO exists on chain and is correctly-formatted. + * Returns a copy of the field. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_from_unsigned_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg, struct LDKCOption_UtxoLookupZ utxo_lookup); +struct LDKCVec_u8Z BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); /** - * Update channel from partial announcement data received via rapid gossip sync - * - * `timestamp: u64`: Timestamp emulating the backdated original announcement receipt (by the - * rapid gossip sync server) - * - * All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. + * The encrypted payload intended for this hop in a blinded path. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_add_channel_from_partial_announcement(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id, uint64_t timestamp, struct LDKChannelFeatures features, struct LDKPublicKey node_id_1, struct LDKPublicKey node_id_2); +void BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); /** - * Marks a channel in the graph as failed permanently. - * - * The channel and any node for which this was their last channel are removed from the graph. + * Constructs a new BlindedHop given each field */ -void NetworkGraph_channel_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); /** - * Marks a node in the graph as permanently failed, effectively removing it and its channels - * from local storage. + * Creates a copy of the BlindedHop */ -void NetworkGraph_node_failed_permanent(const struct LDKNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey node_id); +struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * Note that for users of the `lightning-background-processor` crate this method may be - * automatically called regularly for you. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This method is only available with the `std` feature. See - * [`NetworkGraph::remove_stale_channels_and_tracking_with_time`] for `no-std` use. + * Generates a non-cryptographic 64-bit hash of the BlindedHop. */ -void NetworkGraph_remove_stale_channels_and_tracking(const struct LDKNetworkGraph *NONNULL_PTR this_arg); +uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); /** - * Removes information about channels that we haven't heard any updates about in some time. - * This can be used regularly to prune the network graph of channels that likely no longer - * exist. - * - * While there is no formal requirement that nodes regularly re-broadcast their channel - * updates every two weeks, the non-normative section of BOLT 7 currently suggests that - * pruning occur for updates which are at least two weeks old, which we implement here. - * - * This method will also cause us to stop tracking removed nodes and channels if they have been - * in the map for a while so that these can be resynced from gossip in the future. - * - * This function takes the current unix time as an argument. For users with the `std` feature - * enabled, [`NetworkGraph::remove_stale_channels_and_tracking`] may be preferable. + * Checks if two BlindedHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void NetworkGraph_remove_stale_channels_and_tracking_with_time(const struct LDKNetworkGraph *NONNULL_PTR this_arg, uint64_t current_time_unix); +bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel. - * - * You probably don't want to call this directly, instead relying on a [`P2PGossipSync`]'s - * [`RoutingMessageHandler`] implementation to call it indirectly. This may be useful to accept - * routing messages from a source using a protocol other than the lightning P2P protocol. - * - * If built with `no-std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); /** - * For an already known (from announcement) channel, update info about one of the directions - * of the channel without verifying the associated signatures. Because we aren't given the - * associated signatures here we cannot relay the channel update to any of our peers. - * - * If built with `no-std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Read a BlindedHop from a byte array, created by BlindedHop_write */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_update_channel_unsigned(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKUnsignedChannelUpdate *NONNULL_PTR msg); +struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); /** - * For an already known (from announcement) channel, verify the given [`ChannelUpdate`]. - * - * This checks whether the update currently is applicable by [`Self::update_channel`]. - * - * If built with `no-std`, any updates with a timestamp more than two weeks in the past or - * materially in the future will be rejected. + * Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_NoneLightningErrorZ NetworkGraph_verify_channel_update(const struct LDKNetworkGraph *NONNULL_PTR this_arg, const struct LDKChannelUpdate *NONNULL_PTR msg); +void BlindedPayInfo_free(struct LDKBlindedPayInfo this_obj); /** - * Returns information on a channel with the given id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Base fee charged (in millisatoshi) for the entire blinded path. */ -MUST_USE_RES struct LDKChannelInfo ReadOnlyNetworkGraph_channel(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, uint64_t short_channel_id); +uint32_t BlindedPayInfo_get_fee_base_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Returns the list of channels in the graph + * Base fee charged (in millisatoshi) for the entire blinded path. */ -MUST_USE_RES struct LDKCVec_u64Z ReadOnlyNetworkGraph_list_channels(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +void BlindedPayInfo_set_fee_base_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Returns information on a node with the given id. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -MUST_USE_RES struct LDKNodeInfo ReadOnlyNetworkGraph_node(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +uint32_t BlindedPayInfo_get_fee_proportional_millionths(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Returns the list of nodes in the graph + * Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path + * (i.e., 10,000 is 1%). */ -MUST_USE_RES struct LDKCVec_NodeIdZ ReadOnlyNetworkGraph_list_nodes(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg); +void BlindedPayInfo_set_fee_proportional_millionths(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint32_t val); /** - * Get network addresses by node id. - * Returns None if the requested node is completely unknown, - * or if node announcement for the node was never received. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -MUST_USE_RES struct LDKCOption_CVec_SocketAddressZZ ReadOnlyNetworkGraph_get_addresses(const struct LDKReadOnlyNetworkGraph *NONNULL_PTR this_arg, struct LDKPublicKey pubkey); +uint16_t BlindedPayInfo_get_cltv_expiry_delta(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Frees any resources used by the DefaultRouter, if is_owned is set and inner is non-NULL. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded + * path. */ -void DefaultRouter_free(struct LDKDefaultRouter this_obj); +void BlindedPayInfo_set_cltv_expiry_delta(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint16_t val); /** - * Creates a new router. + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -MUST_USE_RES struct LDKDefaultRouter DefaultRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, struct LDKEntropySource entropy_source, struct LDKLockableScore scorer, struct LDKProbabilisticScoringFeeParameters score_params); +uint64_t BlindedPayInfo_get_htlc_minimum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Constructs a new Router which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Router must be freed before this_arg is + * The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -struct LDKRouter DefaultRouter_as_Router(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +void BlindedPayInfo_set_htlc_minimum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Constructs a new MessageRouter which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -struct LDKMessageRouter DefaultRouter_as_MessageRouter(const struct LDKDefaultRouter *NONNULL_PTR this_arg); +uint64_t BlindedPayInfo_get_htlc_maximum_msat(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Calls the free function if one is set + * The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the + * blinded path from the introduction node to the recipient, accounting for any fees, i.e., as + * seen by the recipient. */ -void Router_free(struct LDKRouter this_ptr); +void BlindedPayInfo_set_htlc_maximum_msat(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, uint64_t val); /** - * Frees any resources used by the ScorerAccountingForInFlightHtlcs, if is_owned is set and inner is non-NULL. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -void ScorerAccountingForInFlightHtlcs_free(struct LDKScorerAccountingForInFlightHtlcs this_obj); +struct LDKBlindedHopFeatures BlindedPayInfo_get_features(const struct LDKBlindedPayInfo *NONNULL_PTR this_ptr); /** - * Initialize a new `ScorerAccountingForInFlightHtlcs`. + * Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an + * onion payload. */ -MUST_USE_RES struct LDKScorerAccountingForInFlightHtlcs ScorerAccountingForInFlightHtlcs_new(struct LDKScoreLookUp scorer, const struct LDKInFlightHtlcs *NONNULL_PTR inflight_htlcs); +void BlindedPayInfo_set_features(struct LDKBlindedPayInfo *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Constructs a new BlindedPayInfo given each field */ -struct LDKScoreLookUp ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(const struct LDKScorerAccountingForInFlightHtlcs *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBlindedPayInfo BlindedPayInfo_new(uint32_t fee_base_msat_arg, uint32_t fee_proportional_millionths_arg, uint16_t cltv_expiry_delta_arg, uint64_t htlc_minimum_msat_arg, uint64_t htlc_maximum_msat_arg, struct LDKBlindedHopFeatures features_arg); /** - * Frees any resources used by the InFlightHtlcs, if is_owned is set and inner is non-NULL. + * Creates a copy of the BlindedPayInfo */ -void InFlightHtlcs_free(struct LDKInFlightHtlcs this_obj); +struct LDKBlindedPayInfo BlindedPayInfo_clone(const struct LDKBlindedPayInfo *NONNULL_PTR orig); /** - * Creates a copy of the InFlightHtlcs + * Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. */ -struct LDKInFlightHtlcs InFlightHtlcs_clone(const struct LDKInFlightHtlcs *NONNULL_PTR orig); +uint64_t BlindedPayInfo_hash(const struct LDKBlindedPayInfo *NONNULL_PTR o); /** - * Constructs an empty `InFlightHtlcs`. + * Checks if two BlindedPayInfos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKInFlightHtlcs InFlightHtlcs_new(void); +bool BlindedPayInfo_eq(const struct LDKBlindedPayInfo *NONNULL_PTR a, const struct LDKBlindedPayInfo *NONNULL_PTR b); /** - * Takes in a path with payer's node id and adds the path's details to `InFlightHtlcs`. + * Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read */ -void InFlightHtlcs_process_path(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKPath *NONNULL_PTR path, struct LDKPublicKey payer_node_id); +struct LDKCVec_u8Z BlindedPayInfo_write(const struct LDKBlindedPayInfo *NONNULL_PTR obj); /** - * Adds a known HTLC given the public key of the HTLC source, target, and short channel - * id. + * Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write */ -void InFlightHtlcs_add_inflight_htlc(struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid, uint64_t used_msat); +struct LDKCResult_BlindedPayInfoDecodeErrorZ BlindedPayInfo_read(struct LDKu8slice ser); /** - * Returns liquidity in msat given the public key of the HTLC source, target, and short channel - * id. + * Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCOption_u64Z InFlightHtlcs_used_liquidity_msat(const struct LDKInFlightHtlcs *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR source, const struct LDKNodeId *NONNULL_PTR target, uint64_t channel_scid); +void BlindedPaymentPath_free(struct LDKBlindedPaymentPath this_obj); /** - * Serialize the InFlightHtlcs object into a byte array which can be read by InFlightHtlcs_read + * The [`BlindedPayInfo`] used to pay this blinded path. */ -struct LDKCVec_u8Z InFlightHtlcs_write(const struct LDKInFlightHtlcs *NONNULL_PTR obj); +struct LDKBlindedPayInfo BlindedPaymentPath_get_payinfo(const struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr); /** - * Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write + * The [`BlindedPayInfo`] used to pay this blinded path. */ -struct LDKCResult_InFlightHtlcsDecodeErrorZ InFlightHtlcs_read(struct LDKu8slice ser); +void BlindedPaymentPath_set_payinfo(struct LDKBlindedPaymentPath *NONNULL_PTR this_ptr, struct LDKBlindedPayInfo val); /** - * Frees any resources used by the RouteHop, if is_owned is set and inner is non-NULL. + * Creates a copy of the BlindedPaymentPath */ -void RouteHop_free(struct LDKRouteHop this_obj); +struct LDKBlindedPaymentPath BlindedPaymentPath_clone(const struct LDKBlindedPaymentPath *NONNULL_PTR orig); /** - * The node_id of the node at this hop. + * Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. */ -struct LDKPublicKey RouteHop_get_pubkey(const struct LDKRouteHop *NONNULL_PTR this_ptr); +uint64_t BlindedPaymentPath_hash(const struct LDKBlindedPaymentPath *NONNULL_PTR o); /** - * The node_id of the node at this hop. + * Checks if two BlindedPaymentPaths contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void RouteHop_set_pubkey(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +bool BlindedPaymentPath_eq(const struct LDKBlindedPaymentPath *NONNULL_PTR a, const struct LDKBlindedPaymentPath *NONNULL_PTR b); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Create a one-hop blinded path for a payment. */ -struct LDKNodeFeatures RouteHop_get_node_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_one_hop(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); /** - * The node_announcement features of the node at this hop. For the last hop, these may be - * amended to match the features present in the invoice this node generated. + * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. + * + * Errors if: + * * a provided node id is invalid + * * [`BlindedPayInfo`] calculation results in an integer overflow + * * any unknown features are required in the provided [`ForwardTlvs`] */ -void RouteHop_set_node_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKNodeFeatures val); +MUST_USE_RES struct LDKCResult_BlindedPaymentPathNoneZ BlindedPaymentPath_new(struct LDKCVec_PaymentForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, uint16_t min_final_cltv_expiry_delta, struct LDKEntropySource entropy_source); /** - * The channel that should be used from the previous hop to reach this node. + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t RouteHop_get_short_channel_id(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKNodeId BlindedPaymentPath_public_introduction_node_id(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); /** - * The channel that should be used from the previous hop to reach this node. + * The [`IntroductionNode`] of the blinded path. */ -void RouteHop_set_short_channel_id(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKIntroductionNode BlindedPaymentPath_introduction_node(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. + * + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -struct LDKChannelFeatures RouteHop_get_channel_features(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKPublicKey BlindedPaymentPath_blinding_point(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The channel_announcement features of the channel that should be used from the previous hop - * to reach this node. + * The [`BlindedHop`]s within the blinded path. */ -void RouteHop_set_channel_features(struct LDKRouteHop *NONNULL_PTR this_ptr, struct LDKChannelFeatures val); +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedPaymentPath_blinded_hops(const struct LDKBlindedPaymentPath *NONNULL_PTR this_arg); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment + * Advance the blinded onion payment path by one hop, making the second hop into the new + * introduction node. * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Will only modify `self` when returning `Ok`. */ -uint64_t RouteHop_get_fee_msat(const struct LDKRouteHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedPaymentPath_advance_path_by_one(struct LDKBlindedPaymentPath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * The fee taken on this hop (for paying for the use of the *next* channel in the path). - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path - * * otherwise, this is the full value of this [`Path`]'s part of the payment - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. */ -void RouteHop_set_fee_msat(struct LDKRouteHop *NONNULL_PTR this_ptr, uint64_t val); +void PaymentForwardNode_free(struct LDKPaymentForwardNode this_obj); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path - * * otherwise, this is the CLTV delta expected at the destination - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -uint32_t RouteHop_get_cltv_expiry_delta(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKForwardTlvs PaymentForwardNode_get_tlvs(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * The CLTV delta added for this hop. - * If this is the last hop in [`Path::hops`]: - * * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path - * * otherwise, this is the CLTV delta expected at the destination - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also + * used for [`BlindedPayInfo`] construction. */ -void RouteHop_set_cltv_expiry_delta(struct LDKRouteHop *NONNULL_PTR this_ptr, uint32_t val); +void PaymentForwardNode_set_tlvs(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * This node's pubkey. */ -bool RouteHop_get_maybe_announced_channel(const struct LDKRouteHop *NONNULL_PTR this_ptr); +struct LDKPublicKey PaymentForwardNode_get_node_id(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Indicates whether this hop is possibly announced in the public network graph. - * - * Will be `true` if there is a possibility that the channel is publicly known, i.e., if we - * either know for sure it's announced in the public graph, or if any public channels exist - * for which the given `short_channel_id` could be an alias for. Will be `false` if we believe - * the channel to be unannounced. - * - * Will be `true` for objects serialized with LDK version 0.0.116 and before. + * This node's pubkey. */ -void RouteHop_set_maybe_announced_channel(struct LDKRouteHop *NONNULL_PTR this_ptr, bool val); +void PaymentForwardNode_set_node_id(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new RouteHop given each field + * The maximum value, in msat, that may be accepted by this node. */ -MUST_USE_RES struct LDKRouteHop RouteHop_new(struct LDKPublicKey pubkey_arg, struct LDKNodeFeatures node_features_arg, uint64_t short_channel_id_arg, struct LDKChannelFeatures channel_features_arg, uint64_t fee_msat_arg, uint32_t cltv_expiry_delta_arg, bool maybe_announced_channel_arg); +uint64_t PaymentForwardNode_get_htlc_maximum_msat(const struct LDKPaymentForwardNode *NONNULL_PTR this_ptr); /** - * Creates a copy of the RouteHop + * The maximum value, in msat, that may be accepted by this node. */ -struct LDKRouteHop RouteHop_clone(const struct LDKRouteHop *NONNULL_PTR orig); +void PaymentForwardNode_set_htlc_maximum_msat(struct LDKPaymentForwardNode *NONNULL_PTR this_ptr, uint64_t val); /** - * Generates a non-cryptographic 64-bit hash of the RouteHop. + * Constructs a new PaymentForwardNode given each field */ -uint64_t RouteHop_hash(const struct LDKRouteHop *NONNULL_PTR o); +MUST_USE_RES struct LDKPaymentForwardNode PaymentForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); /** - * Checks if two RouteHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the PaymentForwardNode */ -bool RouteHop_eq(const struct LDKRouteHop *NONNULL_PTR a, const struct LDKRouteHop *NONNULL_PTR b); +struct LDKPaymentForwardNode PaymentForwardNode_clone(const struct LDKPaymentForwardNode *NONNULL_PTR orig); /** - * Serialize the RouteHop object into a byte array which can be read by RouteHop_read + * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z RouteHop_write(const struct LDKRouteHop *NONNULL_PTR obj); +void ForwardTlvs_free(struct LDKForwardTlvs this_obj); /** - * Read a RouteHop from a byte array, created by RouteHop_write + * The short channel id this payment should be forwarded out over. */ -struct LDKCResult_RouteHopDecodeErrorZ RouteHop_read(struct LDKu8slice ser); +uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * Frees any resources used by the BlindedTail, if is_owned is set and inner is non-NULL. + * The short channel id this payment should be forwarded out over. */ -void BlindedTail_free(struct LDKBlindedTail this_obj); +void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); /** - * The hops of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -struct LDKCVec_BlindedHopZ BlindedTail_get_hops(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The hops of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Payment parameters for relaying over [`Self::short_channel_id`]. */ -void BlindedTail_set_hops(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Payment constraints for relaying over [`Self::short_channel_id`]. */ -struct LDKPublicKey BlindedTail_get_blinding_point(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The blinding point of the [`BlindedPath`] provided by the recipient. - * - * [`BlindedPath`]: crate::blinded_path::BlindedPath + * Payment constraints for relaying over [`Self::short_channel_id`]. */ -void BlindedTail_set_blinding_point(struct LDKBlindedTail *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. + * + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload */ -uint32_t BlindedTail_get_excess_final_cltv_expiry_delta(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * Excess CLTV delta added to the recipient's CLTV expiry to deter intermediate nodes from - * inferring the destination. May be 0. + * Supported and required features when relaying a payment onion containing this object's + * corresponding [`BlindedHop::encrypted_payload`]. + * + * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload */ -void BlindedTail_set_excess_final_cltv_expiry_delta(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint32_t val); +void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); /** - * The total amount paid on this [`Path`], excluding the fees. + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None */ -uint64_t BlindedTail_get_final_value_msat(const struct LDKBlindedTail *NONNULL_PTR this_ptr); +struct LDKPublicKey ForwardTlvs_get_next_blinding_override(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); /** - * The total amount paid on this [`Path`], excluding the fees. + * Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the + * [`BlindedPaymentPath::blinding_point`] of the appended blinded path. + * + * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None */ -void BlindedTail_set_final_value_msat(struct LDKBlindedTail *NONNULL_PTR this_ptr, uint64_t val); +void ForwardTlvs_set_next_blinding_override(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new BlindedTail given each field + * Constructs a new ForwardTlvs given each field + * + * Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None */ -MUST_USE_RES struct LDKBlindedTail BlindedTail_new(struct LDKCVec_BlindedHopZ hops_arg, struct LDKPublicKey blinding_point_arg, uint32_t excess_final_cltv_expiry_delta_arg, uint64_t final_value_msat_arg); +MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg, struct LDKPublicKey next_blinding_override_arg); /** - * Creates a copy of the BlindedTail + * Creates a copy of the ForwardTlvs */ -struct LDKBlindedTail BlindedTail_clone(const struct LDKBlindedTail *NONNULL_PTR orig); +struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the BlindedTail. + * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. */ -uint64_t BlindedTail_hash(const struct LDKBlindedTail *NONNULL_PTR o); +void ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); /** - * Checks if two BlindedTails contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -bool BlindedTail_eq(const struct LDKBlindedTail *NONNULL_PTR a, const struct LDKBlindedTail *NONNULL_PTR b); +const uint8_t (*ReceiveTlvs_get_payment_secret(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr))[32]; /** - * Serialize the BlindedTail object into a byte array which can be read by BlindedTail_read + * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. */ -struct LDKCVec_u8Z BlindedTail_write(const struct LDKBlindedTail *NONNULL_PTR obj); +void ReceiveTlvs_set_payment_secret(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); /** - * Read a BlindedTail from a byte array, created by BlindedTail_write + * Constraints for the receiver of this payment. */ -struct LDKCResult_BlindedTailDecodeErrorZ BlindedTail_read(struct LDKu8slice ser); +struct LDKPaymentConstraints ReceiveTlvs_get_payment_constraints(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); /** - * Frees any resources used by the Path, if is_owned is set and inner is non-NULL. + * Constraints for the receiver of this payment. */ -void Path_free(struct LDKPath this_obj); +void ReceiveTlvs_set_payment_constraints(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Context for the receiver of this payment. */ -struct LDKCVec_RouteHopZ Path_get_hops(const struct LDKPath *NONNULL_PTR this_ptr); +struct LDKPaymentContext ReceiveTlvs_get_payment_context(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); /** - * The list of unblinded hops in this [`Path`]. Must be at least length one. + * Context for the receiver of this payment. */ -void Path_set_hops(struct LDKPath *NONNULL_PTR this_ptr, struct LDKCVec_RouteHopZ val); +void ReceiveTlvs_set_payment_context(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentContext val); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Constructs a new ReceiveTlvs given each field */ -struct LDKBlindedTail Path_get_blinded_tail(const struct LDKPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKReceiveTlvs ReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKPaymentContext payment_context_arg); /** - * The blinded path at which this path terminates, if we're sending to one, and its metadata. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ReceiveTlvs */ -void Path_set_blinded_tail(struct LDKPath *NONNULL_PTR this_ptr, struct LDKBlindedTail val); +struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); /** - * Constructs a new Path given each field - * - * Note that blinded_tail_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPath Path_new(struct LDKCVec_RouteHopZ hops_arg, struct LDKBlindedTail blinded_tail_arg); +void PaymentRelay_free(struct LDKPaymentRelay this_obj); /** - * Creates a copy of the Path + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -struct LDKPath Path_clone(const struct LDKPath *NONNULL_PTR orig); +uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Generates a non-cryptographic 64-bit hash of the Path. + * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. */ -uint64_t Path_hash(const struct LDKPath *NONNULL_PTR o); +void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); /** - * Checks if two Paths contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -bool Path_eq(const struct LDKPath *NONNULL_PTR a, const struct LDKPath *NONNULL_PTR b); +uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Gets the fees for a given path, excluding any excess paid to the recipient. + * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over + * this [`BlindedHop`], (i.e., 10,000 is 1%). */ -MUST_USE_RES uint64_t Path_fee_msat(const struct LDKPath *NONNULL_PTR this_arg); +void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Gets the total amount paid on this [`Path`], excluding the fees. + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -MUST_USE_RES uint64_t Path_final_value_msat(const struct LDKPath *NONNULL_PTR this_arg); +uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); /** - * Gets the final hop's CLTV expiry delta. + * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. */ -MUST_USE_RES struct LDKCOption_u32Z Path_final_cltv_expiry_delta(const struct LDKPath *NONNULL_PTR this_arg); +void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the Route, if is_owned is set and inner is non-NULL. + * Constructs a new PaymentRelay given each field */ -void Route_free(struct LDKRoute this_obj); +MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * Creates a copy of the PaymentRelay */ -struct LDKCVec_PathZ Route_get_paths(const struct LDKRoute *NONNULL_PTR this_ptr); +struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); /** - * The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no - * [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be - * the same. + * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. */ -void Route_set_paths(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKCVec_PathZ val); +void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -struct LDKRouteParameters Route_get_route_params(const struct LDKRoute *NONNULL_PTR this_ptr); +uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * The `route_params` parameter passed to [`find_route`]. - * - * This is used by `ChannelManager` to track information which may be required for retries. - * - * Will be `None` for objects serialized with LDK versions prior to 0.0.117. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. */ -void Route_set_route_params(struct LDKRoute *NONNULL_PTR this_ptr, struct LDKRouteParameters val); +void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); /** - * Constructs a new Route given each field - * - * Note that route_params_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -MUST_USE_RES struct LDKRoute Route_new(struct LDKCVec_PathZ paths_arg, struct LDKRouteParameters route_params_arg); +uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); /** - * Creates a copy of the Route + * The minimum value, in msat, that may be accepted by the node corresponding to this + * [`BlindedHop`]. */ -struct LDKRoute Route_clone(const struct LDKRoute *NONNULL_PTR orig); +void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); /** - * Generates a non-cryptographic 64-bit hash of the Route. + * Constructs a new PaymentConstraints given each field */ -uint64_t Route_hash(const struct LDKRoute *NONNULL_PTR o); +MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); /** - * Checks if two Routes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Creates a copy of the PaymentConstraints */ -bool Route_eq(const struct LDKRoute *NONNULL_PTR a, const struct LDKRoute *NONNULL_PTR b); +struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); /** - * Returns the total amount of fees paid on this [`Route`]. - * - * For objects serialized with LDK 0.0.117 and after, this includes any extra payment made to - * the recipient, which can happen in excess of the amount passed to [`find_route`] via - * [`RouteParameters::final_value_msat`], if we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * Frees any resources used by the PaymentContext */ -MUST_USE_RES uint64_t Route_get_total_fees(const struct LDKRoute *NONNULL_PTR this_arg); +void PaymentContext_free(struct LDKPaymentContext this_ptr); /** - * Returns the total amount paid on this [`Route`], excluding the fees. - * - * Might be more than requested as part of the given [`RouteParameters::final_value_msat`] if - * we had to reach the [`htlc_minimum_msat`] limits. - * - * [`htlc_minimum_msat`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_update-message + * Creates a copy of the PaymentContext + */ +struct LDKPaymentContext PaymentContext_clone(const struct LDKPaymentContext *NONNULL_PTR orig); + +/** + * Utility method to constructs a new Unknown-variant PaymentContext */ -MUST_USE_RES uint64_t Route_get_total_amount(const struct LDKRoute *NONNULL_PTR this_arg); +struct LDKPaymentContext PaymentContext_unknown(struct LDKUnknownPaymentContext a); /** - * Serialize the Route object into a byte array which can be read by Route_read + * Utility method to constructs a new Bolt12Offer-variant PaymentContext */ -struct LDKCVec_u8Z Route_write(const struct LDKRoute *NONNULL_PTR obj); +struct LDKPaymentContext PaymentContext_bolt12_offer(struct LDKBolt12OfferContext a); /** - * Read a Route from a byte array, created by Route_write + * Utility method to constructs a new Bolt12Refund-variant PaymentContext */ -struct LDKCResult_RouteDecodeErrorZ Route_read(struct LDKu8slice ser); +struct LDKPaymentContext PaymentContext_bolt12_refund(struct LDKBolt12RefundContext a); /** - * Frees any resources used by the RouteParameters, if is_owned is set and inner is non-NULL. + * Checks if two PaymentContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void RouteParameters_free(struct LDKRouteParameters this_obj); +bool PaymentContext_eq(const struct LDKPaymentContext *NONNULL_PTR a, const struct LDKPaymentContext *NONNULL_PTR b); /** - * The parameters of the failed payment path. + * Frees any resources used by the UnknownPaymentContext, if is_owned is set and inner is non-NULL. */ -struct LDKPaymentParameters RouteParameters_get_payment_params(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +void UnknownPaymentContext_free(struct LDKUnknownPaymentContext this_obj); /** - * The parameters of the failed payment path. + * Creates a copy of the UnknownPaymentContext */ -void RouteParameters_set_payment_params(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKPaymentParameters val); +struct LDKUnknownPaymentContext UnknownPaymentContext_clone(const struct LDKUnknownPaymentContext *NONNULL_PTR orig); /** - * The amount in msats sent on the failed payment path. + * Checks if two UnknownPaymentContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -uint64_t RouteParameters_get_final_value_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +bool UnknownPaymentContext_eq(const struct LDKUnknownPaymentContext *NONNULL_PTR a, const struct LDKUnknownPaymentContext *NONNULL_PTR b); /** - * The amount in msats sent on the failed payment path. + * Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. */ -void RouteParameters_set_final_value_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, uint64_t val); +void Bolt12OfferContext_free(struct LDKBolt12OfferContext this_obj); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. - * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. + * The identifier of the [`Offer`]. * - * Note that values below a few sats may result in some paths being spuriously ignored. + * [`Offer`]: crate::offers::offer::Offer */ -struct LDKCOption_u64Z RouteParameters_get_max_total_routing_fee_msat(const struct LDKRouteParameters *NONNULL_PTR this_ptr); +struct LDKOfferId Bolt12OfferContext_get_offer_id(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * The maximum total fees, in millisatoshi, that may accrue during route finding. + * The identifier of the [`Offer`]. * - * This limit also applies to the total fees that may arise while retrying failed payment - * paths. + * [`Offer`]: crate::offers::offer::Offer + */ +void Bolt12OfferContext_set_offer_id(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKOfferId val); + +/** + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. * - * Note that values below a few sats may result in some paths being spuriously ignored. + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -void RouteParameters_set_max_total_routing_fee_msat(struct LDKRouteParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKInvoiceRequestFields Bolt12OfferContext_get_invoice_request(const struct LDKBolt12OfferContext *NONNULL_PTR this_ptr); /** - * Constructs a new RouteParameters given each field + * Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. + * + * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + * [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_new(struct LDKPaymentParameters payment_params_arg, uint64_t final_value_msat_arg, struct LDKCOption_u64Z max_total_routing_fee_msat_arg); +void Bolt12OfferContext_set_invoice_request(struct LDKBolt12OfferContext *NONNULL_PTR this_ptr, struct LDKInvoiceRequestFields val); /** - * Creates a copy of the RouteParameters + * Constructs a new Bolt12OfferContext given each field */ -struct LDKRouteParameters RouteParameters_clone(const struct LDKRouteParameters *NONNULL_PTR orig); +MUST_USE_RES struct LDKBolt12OfferContext Bolt12OfferContext_new(struct LDKOfferId offer_id_arg, struct LDKInvoiceRequestFields invoice_request_arg); /** - * Generates a non-cryptographic 64-bit hash of the RouteParameters. + * Creates a copy of the Bolt12OfferContext */ -uint64_t RouteParameters_hash(const struct LDKRouteParameters *NONNULL_PTR o); +struct LDKBolt12OfferContext Bolt12OfferContext_clone(const struct LDKBolt12OfferContext *NONNULL_PTR orig); /** - * Checks if two RouteParameterss contain equal inner contents. + * Checks if two Bolt12OfferContexts contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RouteParameters_eq(const struct LDKRouteParameters *NONNULL_PTR a, const struct LDKRouteParameters *NONNULL_PTR b); +bool Bolt12OfferContext_eq(const struct LDKBolt12OfferContext *NONNULL_PTR a, const struct LDKBolt12OfferContext *NONNULL_PTR b); /** - * Constructs [`RouteParameters`] from the given [`PaymentParameters`] and a payment amount. - * - * [`Self::max_total_routing_fee_msat`] defaults to 1% of the payment amount + 50 sats + * Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKRouteParameters RouteParameters_from_payment_params_and_value(struct LDKPaymentParameters payment_params, uint64_t final_value_msat); +void Bolt12RefundContext_free(struct LDKBolt12RefundContext this_obj); /** - * Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read + * Constructs a new Bolt12RefundContext given each field */ -struct LDKCVec_u8Z RouteParameters_write(const struct LDKRouteParameters *NONNULL_PTR obj); +MUST_USE_RES struct LDKBolt12RefundContext Bolt12RefundContext_new(void); /** - * Read a RouteParameters from a byte array, created by RouteParameters_write + * Creates a copy of the Bolt12RefundContext */ -struct LDKCResult_RouteParametersDecodeErrorZ RouteParameters_read(struct LDKu8slice ser); +struct LDKBolt12RefundContext Bolt12RefundContext_clone(const struct LDKBolt12RefundContext *NONNULL_PTR orig); /** - * Frees any resources used by the PaymentParameters, if is_owned is set and inner is non-NULL. + * Checks if two Bolt12RefundContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void PaymentParameters_free(struct LDKPaymentParameters this_obj); +bool Bolt12RefundContext_eq(const struct LDKBolt12RefundContext *NONNULL_PTR a, const struct LDKBolt12RefundContext *NONNULL_PTR b); /** - * Information about the payee, such as their features and route hints for their channels. + * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read */ -struct LDKPayee PaymentParameters_get_payee(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); /** - * Information about the payee, such as their features and route hints for their channels. + * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read */ -void PaymentParameters_set_payee(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKPayee val); +struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read */ -struct LDKCOption_u64Z PaymentParameters_get_expiry_time(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); /** - * Expiration of a payment to the payee, in seconds relative to the UNIX epoch. + * Read a PaymentRelay from a byte array, created by PaymentRelay_write */ -void PaymentParameters_set_expiry_time(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read */ -uint32_t PaymentParameters_get_max_total_cltv_expiry_delta(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); /** - * The maximum total CLTV delta we accept for the route. - * Defaults to [`DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA`]. + * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write */ -void PaymentParameters_set_max_total_cltv_expiry_delta(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint32_t val); +struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read */ -uint8_t PaymentParameters_get_max_path_count(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentContext_write(const struct LDKPaymentContext *NONNULL_PTR obj); /** - * The maximum number of paths that may be used by (MPP) payments. - * Defaults to [`DEFAULT_MAX_PATH_COUNT`]. + * Read a PaymentContext from a byte array, created by PaymentContext_write */ -void PaymentParameters_set_max_path_count(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +struct LDKCResult_PaymentContextDecodeErrorZ PaymentContext_read(struct LDKu8slice ser); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. - * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. - * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. - * - * Default value: 2 + * Serialize the UnknownPaymentContext object into a byte array which can be read by UnknownPaymentContext_read */ -uint8_t PaymentParameters_get_max_channel_saturation_power_of_half(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z UnknownPaymentContext_write(const struct LDKUnknownPaymentContext *NONNULL_PTR obj); /** - * Selects the maximum share of a channel's total capacity which will be sent over a channel, - * as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas - * a lower value prefers to send larger MPP parts, potentially saturating channels and - * increasing failure probability for those paths. - * - * Note that this restriction will be relaxed during pathfinding after paths which meet this - * restriction have been found. While paths which meet this criteria will be searched for, it - * is ultimately up to the scorer to select them over other paths. - * - * A value of 0 will allow payments up to and including a channel's total announced usable - * capacity, a value of one will only use up to half its capacity, two 1/4, etc. - * - * Default value: 2 + * Read a UnknownPaymentContext from a byte array, created by UnknownPaymentContext_write */ -void PaymentParameters_set_max_channel_saturation_power_of_half(struct LDKPaymentParameters *NONNULL_PTR this_ptr, uint8_t val); +struct LDKCResult_UnknownPaymentContextDecodeErrorZ UnknownPaymentContext_read(struct LDKu8slice ser); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. - * - * Returns a copy of the field. + * Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_channels(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Bolt12OfferContext_write(const struct LDKBolt12OfferContext *NONNULL_PTR obj); /** - * A list of SCIDs which this payment was previously attempted over and which caused the - * payment to fail. Future attempts for the same payment shouldn't be relayed through any of - * these SCIDs. + * Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write */ -void PaymentParameters_set_previously_failed_channels(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCResult_Bolt12OfferContextDecodeErrorZ Bolt12OfferContext_read(struct LDKu8slice ser); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this - * payment was previously attempted over and which caused the payment to fail. Future attempts - * for the same payment shouldn't be relayed through any of these blinded paths. - * - * Returns a copy of the field. + * Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read */ -struct LDKCVec_u64Z PaymentParameters_get_previously_failed_blinded_path_idxs(const struct LDKPaymentParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z Bolt12RefundContext_write(const struct LDKBolt12RefundContext *NONNULL_PTR obj); /** - * A list of indices corresponding to blinded paths in [`Payee::Blinded::route_hints`] which this - * payment was previously attempted over and which caused the payment to fail. Future attempts - * for the same payment shouldn't be relayed through any of these blinded paths. + * Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write */ -void PaymentParameters_set_previously_failed_blinded_path_idxs(struct LDKPaymentParameters *NONNULL_PTR this_ptr, struct LDKCVec_u64Z val); +struct LDKCResult_Bolt12RefundContextDecodeErrorZ Bolt12RefundContext_read(struct LDKu8slice ser); /** - * Constructs a new PaymentParameters given each field + * Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_new(struct LDKPayee payee_arg, struct LDKCOption_u64Z expiry_time_arg, uint32_t max_total_cltv_expiry_delta_arg, uint8_t max_path_count_arg, uint8_t max_channel_saturation_power_of_half_arg, struct LDKCVec_u64Z previously_failed_channels_arg, struct LDKCVec_u64Z previously_failed_blinded_path_idxs_arg); +void BlindedMessagePath_free(struct LDKBlindedMessagePath this_obj); /** - * Creates a copy of the PaymentParameters + * Creates a copy of the BlindedMessagePath */ -struct LDKPaymentParameters PaymentParameters_clone(const struct LDKPaymentParameters *NONNULL_PTR orig); +struct LDKBlindedMessagePath BlindedMessagePath_clone(const struct LDKBlindedMessagePath *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the PaymentParameters. + * Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. */ -uint64_t PaymentParameters_hash(const struct LDKPaymentParameters *NONNULL_PTR o); +uint64_t BlindedMessagePath_hash(const struct LDKBlindedMessagePath *NONNULL_PTR o); /** - * Checks if two PaymentParameterss contain equal inner contents. + * Checks if two BlindedMessagePaths contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool PaymentParameters_eq(const struct LDKPaymentParameters *NONNULL_PTR a, const struct LDKPaymentParameters *NONNULL_PTR b); +bool BlindedMessagePath_eq(const struct LDKBlindedMessagePath *NONNULL_PTR a, const struct LDKBlindedMessagePath *NONNULL_PTR b); /** - * Serialize the PaymentParameters object into a byte array which can be read by PaymentParameters_read + * Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read */ -struct LDKCVec_u8Z PaymentParameters_write(const struct LDKPaymentParameters *NONNULL_PTR obj); +struct LDKCVec_u8Z BlindedMessagePath_write(const struct LDKBlindedMessagePath *NONNULL_PTR obj); /** - * Read a PaymentParameters from a byte array, created by PaymentParameters_write + * Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write */ -struct LDKCResult_PaymentParametersDecodeErrorZ PaymentParameters_read(struct LDKu8slice ser, uint32_t arg); +struct LDKCResult_BlindedMessagePathDecodeErrorZ BlindedMessagePath_read(struct LDKu8slice ser); /** - * Creates a payee with the node id of the given `pubkey`. + * Create a one-hop blinded path for a message. + */ +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_one_hop(struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); + +/** + * Create a path for an onion message, to be forwarded along `node_pks`. The last node + * pubkey in `node_pks` will be the destination node. * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * Errors if no hops are provided or if `node_pk`(s) are invalid. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_node_id(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta); +MUST_USE_RES struct LDKCResult_BlindedMessagePathNoneZ BlindedMessagePath_new(struct LDKCVec_MessageForwardNodeZ intermediate_nodes, struct LDKPublicKey recipient_node_id, struct LDKMessageContext context, struct LDKEntropySource entropy_source); /** - * Creates a payee with the node id of the given `pubkey` to use for keysend payments. + * Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed + * short channel id from a channel in `network_graph` leading to the introduction node. * - * The `final_cltv_expiry_delta` should match the expected final CLTV delta the recipient has - * provided. + * While this may result in a smaller encoding, there is a trade off in that the path may + * become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, + * calling this may not be suitable for long-lived blinded paths. + */ +void BlindedMessagePath_use_compact_introduction_node(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); + +/** + * Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., + * it is found in the network graph). * - * Note that MPP keysend is not widely supported yet. The `allow_mpp` lets you choose - * whether your router will be allowed to find a multi-part route for this payment. If you - * set `allow_mpp` to true, you should ensure a payment secret is set on send, likely via - * [`RecipientOnionFields::secret_only`]. + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ +MUST_USE_RES struct LDKNodeId BlindedMessagePath_public_introduction_node_id(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKReadOnlyNetworkGraph *NONNULL_PTR network_graph); + +/** + * The [`IntroductionNode`] of the blinded path. + */ +MUST_USE_RES struct LDKIntroductionNode BlindedMessagePath_introduction_node(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); + +/** + * Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. * - * [`RecipientOnionFields::secret_only`]: crate::ln::channelmanager::RecipientOnionFields::secret_only + * [`encrypted_payload`]: BlindedHop::encrypted_payload */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_for_keysend(struct LDKPublicKey payee_pubkey, uint32_t final_cltv_expiry_delta, bool allow_mpp); +MUST_USE_RES struct LDKPublicKey BlindedMessagePath_blinding_point(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Creates parameters for paying to a blinded payee from the provided invoice. Sets - * [`Payee::Blinded::route_hints`], [`Payee::Blinded::features`], and - * [`PaymentParameters::expiry_time`]. + * The [`BlindedHop`]s within the blinded path. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_from_bolt12_invoice(const struct LDKBolt12Invoice *NONNULL_PTR invoice); +MUST_USE_RES struct LDKCVec_BlindedHopZ BlindedMessagePath_blinded_hops(const struct LDKBlindedMessagePath *NONNULL_PTR this_arg); /** - * Creates parameters for paying to a blinded payee from the provided blinded route hints. + * Advance the blinded onion message path by one hop, making the second hop into the new + * introduction node. + * + * Will only modify `self` when returning `Ok`. */ -MUST_USE_RES struct LDKPaymentParameters PaymentParameters_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_route_hints); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedMessagePath_advance_path_by_one(struct LDKBlindedMessagePath *NONNULL_PTR this_arg, const struct LDKNodeSigner *NONNULL_PTR node_signer, const struct LDKNodeIdLookUp *NONNULL_PTR node_id_lookup); /** - * Frees any resources used by the Payee + * Frees any resources used by the NextMessageHop */ -void Payee_free(struct LDKPayee this_ptr); +void NextMessageHop_free(struct LDKNextMessageHop this_ptr); /** - * Creates a copy of the Payee + * Creates a copy of the NextMessageHop */ -struct LDKPayee Payee_clone(const struct LDKPayee *NONNULL_PTR orig); +struct LDKNextMessageHop NextMessageHop_clone(const struct LDKNextMessageHop *NONNULL_PTR orig); /** - * Utility method to constructs a new Blinded-variant Payee + * Utility method to constructs a new NodeId-variant NextMessageHop */ -struct LDKPayee Payee_blinded(struct LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints, struct LDKBolt12InvoiceFeatures features); +struct LDKNextMessageHop NextMessageHop_node_id(struct LDKPublicKey a); /** - * Utility method to constructs a new Clear-variant Payee + * Utility method to constructs a new ShortChannelId-variant NextMessageHop */ -struct LDKPayee Payee_clear(struct LDKPublicKey node_id, struct LDKCVec_RouteHintZ route_hints, struct LDKBolt11InvoiceFeatures features, uint32_t final_cltv_expiry_delta); +struct LDKNextMessageHop NextMessageHop_short_channel_id(uint64_t a); /** - * Generates a non-cryptographic 64-bit hash of the Payee. + * Generates a non-cryptographic 64-bit hash of the NextMessageHop. */ -uint64_t Payee_hash(const struct LDKPayee *NONNULL_PTR o); +uint64_t NextMessageHop_hash(const struct LDKNextMessageHop *NONNULL_PTR o); /** - * Checks if two Payees contain equal inner contents. + * Checks if two NextMessageHops contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. */ -bool Payee_eq(const struct LDKPayee *NONNULL_PTR a, const struct LDKPayee *NONNULL_PTR b); +bool NextMessageHop_eq(const struct LDKNextMessageHop *NONNULL_PTR a, const struct LDKNextMessageHop *NONNULL_PTR b); /** - * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. + * Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. */ -void RouteHint_free(struct LDKRouteHint this_obj); +void MessageForwardNode_free(struct LDKMessageForwardNode this_obj); -struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); +/** + * This node's pubkey. + */ +struct LDKPublicKey MessageForwardNode_get_node_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); -void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); +/** + * This node's pubkey. + */ +void MessageForwardNode_set_node_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * Constructs a new RouteHint given each field + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); +struct LDKCOption_u64Z MessageForwardNode_get_short_channel_id(const struct LDKMessageForwardNode *NONNULL_PTR this_ptr); /** - * Creates a copy of the RouteHint + * The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s + * `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a + * more compact representation. */ -struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); +void MessageForwardNode_set_short_channel_id(struct LDKMessageForwardNode *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Generates a non-cryptographic 64-bit hash of the RouteHint. + * Constructs a new MessageForwardNode given each field */ -uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); +MUST_USE_RES struct LDKMessageForwardNode MessageForwardNode_new(struct LDKPublicKey node_id_arg, struct LDKCOption_u64Z short_channel_id_arg); /** - * Checks if two RouteHints contain equal inner contents. + * Creates a copy of the MessageForwardNode + */ +struct LDKMessageForwardNode MessageForwardNode_clone(const struct LDKMessageForwardNode *NONNULL_PTR orig); + +/** + * Generates a non-cryptographic 64-bit hash of the MessageForwardNode. + */ +uint64_t MessageForwardNode_hash(const struct LDKMessageForwardNode *NONNULL_PTR o); + +/** + * Checks if two MessageForwardNodes contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); +bool MessageForwardNode_eq(const struct LDKMessageForwardNode *NONNULL_PTR a, const struct LDKMessageForwardNode *NONNULL_PTR b); /** - * Serialize the RouteHint object into a byte array which can be read by RouteHint_read + * Frees any resources used by the MessageContext */ -struct LDKCVec_u8Z RouteHint_write(const struct LDKRouteHint *NONNULL_PTR obj); +void MessageContext_free(struct LDKMessageContext this_ptr); /** - * Read a RouteHint from a byte array, created by RouteHint_write + * Creates a copy of the MessageContext */ -struct LDKCResult_RouteHintDecodeErrorZ RouteHint_read(struct LDKu8slice ser); +struct LDKMessageContext MessageContext_clone(const struct LDKMessageContext *NONNULL_PTR orig); /** - * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Offers-variant MessageContext */ -void RouteHintHop_free(struct LDKRouteHintHop this_obj); +struct LDKMessageContext MessageContext_offers(struct LDKOffersContext a); /** - * The node_id of the non-target end of the route + * Utility method to constructs a new Custom-variant MessageContext */ -struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKMessageContext MessageContext_custom(struct LDKCVec_u8Z a); /** - * The node_id of the non-target end of the route + * Frees any resources used by the OffersContext */ -void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +void OffersContext_free(struct LDKOffersContext this_ptr); /** - * The short_channel_id of this channel + * Creates a copy of the OffersContext */ -uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKOffersContext OffersContext_clone(const struct LDKOffersContext *NONNULL_PTR orig); /** - * The short_channel_id of this channel + * Utility method to constructs a new InvoiceRequest-variant OffersContext */ -void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); +struct LDKOffersContext OffersContext_invoice_request(struct LDKNonce nonce); /** - * The fees which must be paid to use this channel + * Utility method to constructs a new OutboundPayment-variant OffersContext */ -struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKOffersContext OffersContext_outbound_payment(struct LDKThirtyTwoBytes payment_id, struct LDKNonce nonce, struct LDKThirtyTwoBytes hmac); /** - * The fees which must be paid to use this channel + * Utility method to constructs a new InboundPayment-variant OffersContext */ -void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); +struct LDKOffersContext OffersContext_inbound_payment(struct LDKThirtyTwoBytes payment_hash); /** - * The difference in CLTV values between this node and the next node. + * Checks if two OffersContexts contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +bool OffersContext_eq(const struct LDKOffersContext *NONNULL_PTR a, const struct LDKOffersContext *NONNULL_PTR b); /** - * The difference in CLTV values between this node and the next node. + * Serialize the MessageContext object into a byte array which can be read by MessageContext_read */ -void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); +struct LDKCVec_u8Z MessageContext_write(const struct LDKMessageContext *NONNULL_PTR obj); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Read a MessageContext from a byte array, created by MessageContext_write */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKCResult_MessageContextDecodeErrorZ MessageContext_read(struct LDKu8slice ser); /** - * The minimum value, in msat, which must be relayed to the next hop. + * Serialize the OffersContext object into a byte array which can be read by OffersContext_read */ -void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +struct LDKCVec_u8Z OffersContext_write(const struct LDKOffersContext *NONNULL_PTR obj); /** - * The maximum value in msat available for routing with a single HTLC. + * Read a OffersContext from a byte array, created by OffersContext_write */ -struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); +struct LDKCResult_OffersContextDecodeErrorZ OffersContext_read(struct LDKu8slice ser); /** - * The maximum value in msat available for routing with a single HTLC. + * Frees any resources used by the FundingInfo */ -void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); +void FundingInfo_free(struct LDKFundingInfo this_ptr); /** - * Constructs a new RouteHintHop given each field + * Creates a copy of the FundingInfo */ -MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); +struct LDKFundingInfo FundingInfo_clone(const struct LDKFundingInfo *NONNULL_PTR orig); /** - * Creates a copy of the RouteHintHop + * Utility method to constructs a new Tx-variant FundingInfo */ -struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); +struct LDKFundingInfo FundingInfo_tx(struct LDKTransaction transaction); /** - * Generates a non-cryptographic 64-bit hash of the RouteHintHop. + * Utility method to constructs a new OutPoint-variant FundingInfo */ -uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); +struct LDKFundingInfo FundingInfo_out_point(struct LDKOutPoint outpoint); /** - * Checks if two RouteHintHops contain equal inner contents. + * Checks if two FundingInfos contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); +bool FundingInfo_eq(const struct LDKFundingInfo *NONNULL_PTR a, const struct LDKFundingInfo *NONNULL_PTR b); /** - * Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read + * Serialize the FundingInfo object into a byte array which can be read by FundingInfo_read */ -struct LDKCVec_u8Z RouteHintHop_write(const struct LDKRouteHintHop *NONNULL_PTR obj); +struct LDKCVec_u8Z FundingInfo_write(const struct LDKFundingInfo *NONNULL_PTR obj); /** - * Read a RouteHintHop from a byte array, created by RouteHintHop_write + * Read a FundingInfo from a byte array, created by FundingInfo_write */ -struct LDKCResult_RouteHintHopDecodeErrorZ RouteHintHop_read(struct LDKu8slice ser); +struct LDKCResult_FundingInfoDecodeErrorZ FundingInfo_read(struct LDKu8slice ser); /** - * Frees any resources used by the FirstHopCandidate, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PaymentPurpose */ -void FirstHopCandidate_free(struct LDKFirstHopCandidate this_obj); +void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); /** - * Creates a copy of the FirstHopCandidate + * Creates a copy of the PaymentPurpose */ -struct LDKFirstHopCandidate FirstHopCandidate_clone(const struct LDKFirstHopCandidate *NONNULL_PTR orig); +struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); /** - * Frees any resources used by the PublicHopCandidate, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose */ -void PublicHopCandidate_free(struct LDKPublicHopCandidate this_obj); +struct LDKPaymentPurpose PaymentPurpose_bolt11_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose */ -uint64_t PublicHopCandidate_get_short_channel_id(const struct LDKPublicHopCandidate *NONNULL_PTR this_ptr); +struct LDKPaymentPurpose PaymentPurpose_bolt12_offer_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12OfferContext payment_context); /** - * The short channel ID of the channel, i.e. the identifier by which we refer to this - * channel. + * Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose */ -void PublicHopCandidate_set_short_channel_id(struct LDKPublicHopCandidate *NONNULL_PTR this_ptr, uint64_t val); +struct LDKPaymentPurpose PaymentPurpose_bolt12_refund_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret, struct LDKBolt12RefundContext payment_context); /** - * Creates a copy of the PublicHopCandidate + * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose */ -struct LDKPublicHopCandidate PublicHopCandidate_clone(const struct LDKPublicHopCandidate *NONNULL_PTR orig); +struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); /** - * Frees any resources used by the PrivateHopCandidate, if is_owned is set and inner is non-NULL. + * Checks if two PaymentPurposes contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void PrivateHopCandidate_free(struct LDKPrivateHopCandidate this_obj); +bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); /** - * Creates a copy of the PrivateHopCandidate + * Returns the preimage for this payment, if it is known. */ -struct LDKPrivateHopCandidate PrivateHopCandidate_clone(const struct LDKPrivateHopCandidate *NONNULL_PTR orig); +MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); /** - * Frees any resources used by the BlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read */ -void BlindedPathCandidate_free(struct LDKBlindedPathCandidate this_obj); +struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); /** - * Creates a copy of the BlindedPathCandidate + * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write */ -struct LDKBlindedPathCandidate BlindedPathCandidate_clone(const struct LDKBlindedPathCandidate *NONNULL_PTR orig); +struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); /** - * Frees any resources used by the OneHopBlindedPathCandidate, if is_owned is set and inner is non-NULL. + * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. */ -void OneHopBlindedPathCandidate_free(struct LDKOneHopBlindedPathCandidate this_obj); +void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); /** - * Creates a copy of the OneHopBlindedPathCandidate + * The `channel_id` of the channel over which the HTLC was received. */ -struct LDKOneHopBlindedPathCandidate OneHopBlindedPathCandidate_clone(const struct LDKOneHopBlindedPathCandidate *NONNULL_PTR orig); +struct LDKChannelId ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CandidateRouteHop + * The `channel_id` of the channel over which the HTLC was received. */ -void CandidateRouteHop_free(struct LDKCandidateRouteHop this_ptr); +void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKChannelId val); /** - * Creates a copy of the CandidateRouteHop + * The `user_channel_id` of the channel over which the HTLC was received. This is the value + * passed in to [`ChannelManager::create_channel`] for outbound channels, or to + * [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ -struct LDKCandidateRouteHop CandidateRouteHop_clone(const struct LDKCandidateRouteHop *NONNULL_PTR orig); +struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new FirstHop-variant CandidateRouteHop + * The `user_channel_id` of the channel over which the HTLC was received. This is the value + * passed in to [`ChannelManager::create_channel`] for outbound channels, or to + * [`ChannelManager::accept_inbound_channel`] for inbound channels if + * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise + * `user_channel_id` will be randomized for an inbound channel. + * + * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This + * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but + * was not actually claimed until after upgrading.) + * + * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel + * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels */ -struct LDKCandidateRouteHop CandidateRouteHop_first_hop(struct LDKFirstHopCandidate a); +void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); /** - * Utility method to constructs a new PublicHop-variant CandidateRouteHop + * The block height at which this HTLC expires. */ -struct LDKCandidateRouteHop CandidateRouteHop_public_hop(struct LDKPublicHopCandidate a); +uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new PrivateHop-variant CandidateRouteHop + * The block height at which this HTLC expires. */ -struct LDKCandidateRouteHop CandidateRouteHop_private_hop(struct LDKPrivateHopCandidate a); +void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); /** - * Utility method to constructs a new Blinded-variant CandidateRouteHop + * The amount (in msats) of this part of an MPP. */ -struct LDKCandidateRouteHop CandidateRouteHop_blinded(struct LDKBlindedPathCandidate a); +uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new OneHopBlinded-variant CandidateRouteHop + * The amount (in msats) of this part of an MPP. */ -struct LDKCandidateRouteHop CandidateRouteHop_one_hop_blinded(struct LDKOneHopBlindedPathCandidate a); +void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the globally unique short channel ID for this hop, if one is known. + * The extra fee our counterparty skimmed off the top of this HTLC, if any. * - * This only returns `Some` if the channel is public (either our own, or one we've learned - * from the public network graph), and thus the short channel ID we have for this channel is - * globally unique and identifies this channel in a global namespace. + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -MUST_USE_RES struct LDKCOption_u64Z CandidateRouteHop_globally_unique_short_channel_id(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); /** - * Returns the required difference in HTLC CLTV expiry between the [`Self::source`] and the - * next-hop for an HTLC taking this hop. + * The extra fee our counterparty skimmed off the top of this HTLC, if any. * - * This is the time that the node(s) in this hop have to claim the HTLC on-chain if the - * next-hop goes on chain with a payment preimage. + * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to + * 0.0.119. */ -MUST_USE_RES uint32_t CandidateRouteHop_cltv_expiry_delta(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); /** - * Returns the minimum amount that can be sent over this hop, in millisatoshis. + * Constructs a new ClaimedHTLC given each field */ -MUST_USE_RES uint64_t CandidateRouteHop_htlc_minimum_msat(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKChannelId channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_arg); /** - * Returns the fees that must be paid to route an HTLC over this channel. + * Creates a copy of the ClaimedHTLC */ -MUST_USE_RES struct LDKRoutingFees CandidateRouteHop_fees(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); /** - * Returns the source node id of current hop. - * - * Source node id refers to the node forwarding the HTLC through this hop. - * - * For [`Self::FirstHop`] we return payer's node id. + * Checks if two ClaimedHTLCs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_source(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +bool ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); /** - * Returns the target node id of this hop, if known. - * - * Target node id refers to the node receiving the HTLC after this hop. - * - * For [`Self::Blinded`] we return `None` because the ultimate destination after the blinded - * path is unknown. - * - * For [`Self::OneHopBlinded`] we return `None` because the target is the same as the source, - * and such a return value would be somewhat nonsensical. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read */ -MUST_USE_RES struct LDKNodeId CandidateRouteHop_target(const struct LDKCandidateRouteHop *NONNULL_PTR this_arg); +struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); /** - * Finds a route from us (payer) to the given target node (payee). - * - * If the payee provided features in their invoice, they should be provided via the `payee` field - * in the given [`RouteParameters::payment_params`]. - * Without this, MPP will only be used if the payee's features are available in the network graph. - * - * Private routing paths between a public node and the target may be included in the `payee` field - * of [`RouteParameters::payment_params`]. - * - * If some channels aren't announced, it may be useful to fill in `first_hops` with the results - * from [`ChannelManager::list_usable_channels`]. If it is filled in, the view of these channels - * from `network_graph` will be ignored, and only those in `first_hops` will be used. - * - * The fees on channels from us to the next hop are ignored as they are assumed to all be equal. - * However, the enabled/disabled bit on such channels as well as the `htlc_minimum_msat` / - * `htlc_maximum_msat` *are* checked as they may change based on the receiving node. - * - * # Panics - * - * Panics if first_hops contains channels without `short_channel_id`s; - * [`ChannelManager::list_usable_channels`] will never include such channels. - * - * [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels - * [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed - * [`NetworkGraph`]: crate::routing::gossip::NetworkGraph - * - * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None + * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write */ -struct LDKCResult_RouteLightningErrorZ find_route(struct LDKPublicKey our_node_pubkey, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKLogger logger, const struct LDKScoreLookUp *NONNULL_PTR scorer, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params, const uint8_t (*random_seed_bytes)[32]); +struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); /** - * Construct a route from us (payer) to the target node (payee) via the given hops (which should - * exclude the payer, but include the payee). This may be useful, e.g., for probing the chosen path. - * - * Re-uses logic from `find_route`, so the restrictions described there also apply here. + * Frees any resources used by the PathFailure */ -struct LDKCResult_RouteLightningErrorZ build_route_from_hops(struct LDKPublicKey our_node_pubkey, struct LDKCVec_PublicKeyZ hops, const struct LDKRouteParameters *NONNULL_PTR route_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger, const uint8_t (*random_seed_bytes)[32]); +void PathFailure_free(struct LDKPathFailure this_ptr); /** - * Calls the free function if one is set + * Creates a copy of the PathFailure */ -void ScoreLookUp_free(struct LDKScoreLookUp this_ptr); +struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); /** - * Calls the free function if one is set + * Utility method to constructs a new InitialSend-variant PathFailure */ -void ScoreUpdate_free(struct LDKScoreUpdate this_ptr); +struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); /** - * Calls the free function if one is set + * Utility method to constructs a new OnPath-variant PathFailure */ -void Score_free(struct LDKScore this_ptr); +struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); /** - * Calls the free function if one is set + * Checks if two PathFailures contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void LockableScore_free(struct LDKLockableScore this_ptr); +bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); /** - * Calls the free function if one is set + * Serialize the PathFailure object into a byte array which can be read by PathFailure_read */ -void WriteableScore_free(struct LDKWriteableScore this_ptr); +struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); /** - * Frees any resources used by the MultiThreadedLockableScore, if is_owned is set and inner is non-NULL. + * Read a PathFailure from a byte array, created by PathFailure_write */ -void MultiThreadedLockableScore_free(struct LDKMultiThreadedLockableScore this_obj); +struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); /** - * Constructs a new LockableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned LockableScore must be freed before this_arg is + * Frees any resources used by the ClosureReason */ -struct LDKLockableScore MultiThreadedLockableScore_as_LockableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +void ClosureReason_free(struct LDKClosureReason this_ptr); /** - * Serialize the MultiThreadedLockableScore object into a byte array which can be read by MultiThreadedLockableScore_read + * Creates a copy of the ClosureReason */ -struct LDKCVec_u8Z MultiThreadedLockableScore_write(const struct LDKMultiThreadedLockableScore *NONNULL_PTR obj); +struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); /** - * Constructs a new WriteableScore which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned WriteableScore must be freed before this_arg is + * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason */ -struct LDKWriteableScore MultiThreadedLockableScore_as_WriteableScore(const struct LDKMultiThreadedLockableScore *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); /** - * Creates a new [`MultiThreadedLockableScore`] given an underlying [`Score`]. + * Utility method to constructs a new HolderForceClosed-variant ClosureReason */ -MUST_USE_RES struct LDKMultiThreadedLockableScore MultiThreadedLockableScore_new(struct LDKScore score); +struct LDKClosureReason ClosureReason_holder_force_closed(struct LDKCOption_boolZ broadcasted_latest_txn); /** - * Frees any resources used by the MultiThreadedScoreLockRead, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason */ -void MultiThreadedScoreLockRead_free(struct LDKMultiThreadedScoreLockRead this_obj); +struct LDKClosureReason ClosureReason_legacy_cooperative_closure(void); /** - * Frees any resources used by the MultiThreadedScoreLockWrite, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason */ -void MultiThreadedScoreLockWrite_free(struct LDKMultiThreadedScoreLockWrite this_obj); +struct LDKClosureReason ClosureReason_counterparty_initiated_cooperative_closure(void); + +/** + * Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_locally_initiated_cooperative_closure(void); + +/** + * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); + +/** + * Utility method to constructs a new FundingTimedOut-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_funding_timed_out(void); + +/** + * Utility method to constructs a new ProcessingError-variant ClosureReason + */ +struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Utility method to constructs a new DisconnectedPeer-variant ClosureReason */ -struct LDKScoreLookUp MultiThreadedScoreLockRead_as_ScoreLookUp(const struct LDKMultiThreadedScoreLockRead *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_disconnected_peer(void); /** - * Serialize the MultiThreadedScoreLockWrite object into a byte array which can be read by MultiThreadedScoreLockWrite_read + * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason */ -struct LDKCVec_u8Z MultiThreadedScoreLockWrite_write(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR obj); +struct LDKClosureReason ClosureReason_outdated_channel_manager(void); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason */ -struct LDKScoreUpdate MultiThreadedScoreLockWrite_as_ScoreUpdate(const struct LDKMultiThreadedScoreLockWrite *NONNULL_PTR this_arg); +struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); /** - * Frees any resources used by the ChannelUsage, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new FundingBatchClosure-variant ClosureReason */ -void ChannelUsage_free(struct LDKChannelUsage this_obj); +struct LDKClosureReason ClosureReason_funding_batch_closure(void); /** - * The amount to send through the channel, denominated in millisatoshis. + * Utility method to constructs a new HTLCsTimedOut-variant ClosureReason */ -uint64_t ChannelUsage_get_amount_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +struct LDKClosureReason ClosureReason_htlcs_timed_out(void); /** - * The amount to send through the channel, denominated in millisatoshis. + * Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason */ -void ChannelUsage_set_amount_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +struct LDKClosureReason ClosureReason_peer_feerate_too_low(uint32_t peer_feerate_sat_per_kw, uint32_t required_feerate_sat_per_kw); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Checks if two ClosureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -uint64_t ChannelUsage_get_inflight_htlc_msat(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); /** - * Total amount, denominated in millisatoshis, already allocated to send through the channel - * as part of a multi-path payment. + * Get the string representation of a ClosureReason object */ -void ChannelUsage_set_inflight_htlc_msat(struct LDKChannelUsage *NONNULL_PTR this_ptr, uint64_t val); +struct LDKStr ClosureReason_to_str(const struct LDKClosureReason *NONNULL_PTR o); /** - * The effective capacity of the channel. + * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read */ -struct LDKEffectiveCapacity ChannelUsage_get_effective_capacity(const struct LDKChannelUsage *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); /** - * The effective capacity of the channel. + * Read a ClosureReason from a byte array, created by ClosureReason_write */ -void ChannelUsage_set_effective_capacity(struct LDKChannelUsage *NONNULL_PTR this_ptr, struct LDKEffectiveCapacity val); +struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); /** - * Constructs a new ChannelUsage given each field + * Frees any resources used by the HTLCDestination */ -MUST_USE_RES struct LDKChannelUsage ChannelUsage_new(uint64_t amount_msat_arg, uint64_t inflight_htlc_msat_arg, struct LDKEffectiveCapacity effective_capacity_arg); +void HTLCDestination_free(struct LDKHTLCDestination this_ptr); /** - * Creates a copy of the ChannelUsage + * Creates a copy of the HTLCDestination */ -struct LDKChannelUsage ChannelUsage_clone(const struct LDKChannelUsage *NONNULL_PTR orig); +struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); /** - * Frees any resources used by the FixedPenaltyScorer, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new NextHopChannel-variant HTLCDestination */ -void FixedPenaltyScorer_free(struct LDKFixedPenaltyScorer this_obj); +struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKChannelId channel_id); /** - * Creates a copy of the FixedPenaltyScorer + * Utility method to constructs a new UnknownNextHop-variant HTLCDestination */ -struct LDKFixedPenaltyScorer FixedPenaltyScorer_clone(const struct LDKFixedPenaltyScorer *NONNULL_PTR orig); +struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); /** - * Creates a new scorer using `penalty_msat`. + * Utility method to constructs a new InvalidForward-variant HTLCDestination */ -MUST_USE_RES struct LDKFixedPenaltyScorer FixedPenaltyScorer_with_penalty(uint64_t penalty_msat); +struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Utility method to constructs a new InvalidOnion-variant HTLCDestination */ -struct LDKScoreLookUp FixedPenaltyScorer_as_ScoreLookUp(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +struct LDKHTLCDestination HTLCDestination_invalid_onion(void); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Utility method to constructs a new FailedPayment-variant HTLCDestination */ -struct LDKScoreUpdate FixedPenaltyScorer_as_ScoreUpdate(const struct LDKFixedPenaltyScorer *NONNULL_PTR this_arg); +struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); /** - * Serialize the FixedPenaltyScorer object into a byte array which can be read by FixedPenaltyScorer_read + * Checks if two HTLCDestinations contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKCVec_u8Z FixedPenaltyScorer_write(const struct LDKFixedPenaltyScorer *NONNULL_PTR obj); +bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); /** - * Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write + * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read */ -struct LDKCResult_FixedPenaltyScorerDecodeErrorZ FixedPenaltyScorer_read(struct LDKu8slice ser, uint64_t arg); +struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); /** - * Frees any resources used by the ProbabilisticScorer, if is_owned is set and inner is non-NULL. + * Read a HTLCDestination from a byte array, created by HTLCDestination_write */ -void ProbabilisticScorer_free(struct LDKProbabilisticScorer this_obj); +struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); /** - * Frees any resources used by the ProbabilisticScoringFeeParameters, if is_owned is set and inner is non-NULL. + * Creates a copy of the PaymentFailureReason */ -void ProbabilisticScoringFeeParameters_free(struct LDKProbabilisticScoringFeeParameters this_obj); +enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); /** - * A fixed penalty in msats to apply to each channel. - * - * Default value: 500 msat + * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); /** - * A fixed penalty in msats to apply to each channel. - * - * Default value: 500 msat + * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason */ -void ProbabilisticScoringFeeParameters_set_base_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); /** - * A multiplier used with the total amount flowing over a channel to calculate a fixed penalty - * applied to each channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the total amount flowing over a channel (i.e. the payment - * amount plus the amount of any other HTLCs flowing we sent over the same channel). - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * Default value: 8,192 msat - * - * [`base_penalty_msat`]: Self::base_penalty_msat + * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason */ -uint64_t ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); /** - * A multiplier used with the total amount flowing over a channel to calculate a fixed penalty - * applied to each channel, in excess of the [`base_penalty_msat`]. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^30`ths of the total amount flowing over a channel (i.e. the payment - * amount plus the amount of any other HTLCs flowing we sent over the same channel). - * - * ie `base_penalty_amount_multiplier_msat * amount_msat / 2^30` - * - * Default value: 8,192 msat - * - * [`base_penalty_msat`]: Self::base_penalty_msat + * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason */ -void ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * Default value: 30,000 msat - * - * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life + * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for a payment, as determined by our latest estimates of the channel's - * liquidity, to determine the liquidity penalty. - * - * The penalty is based in part on the knowledge learned from prior successful and unsuccessful - * payments. This knowledge is decayed over time based on [`liquidity_offset_half_life`]. The - * penalty is effectively limited to `2 * liquidity_penalty_multiplier_msat` (corresponding to - * lower bounding the success probability to `0.01`) when the amount falls within the - * uncertainty bounds of the channel liquidity balance. Amounts above the upper bound will - * result in a `u64::max_value` penalty, however. - * - * `-log10(success_probability) * liquidity_penalty_multiplier_msat` - * - * Default value: 30,000 msat - * - * [`liquidity_offset_half_life`]: ProbabilisticScoringDecayParameters::liquidity_offset_half_life + * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); /** - * A multiplier used in conjunction with the total amount flowing over a channel and the - * negative `log10` of the channel's success probability for the payment, as determined by our - * latest estimates of the channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the amount flowing over this channel, weighted by the negative - * `log10` of the success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * Default value: 192 msat + * Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason */ -uint64_t ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_unknown_required_features(void); /** - * A multiplier used in conjunction with the total amount flowing over a channel and the - * negative `log10` of the channel's success probability for the payment, as determined by our - * latest estimates of the channel's liquidity, to determine the amount penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost (i.e., - * fees plus penalty) for large payments. The penalty is computed as the product of this - * multiplier and `2^20`ths of the amount flowing over this channel, weighted by the negative - * `log10` of the success probability. - * - * `-log10(success_probability) * liquidity_penalty_amount_multiplier_msat * amount_msat / 2^20` - * - * In practice, this means for 0.1 success probability (`-log10(0.1) == 1`) each `2^20`th of - * the amount will result in a penalty of the multiplier. And, as the success probability - * decreases, the negative `log10` weighting will increase dramatically. For higher success - * probabilities, the multiplier will have a decreasing effect as the negative `log10` will - * fall below `1`. - * - * Default value: 192 msat + * Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason */ -void ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_expired(void); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. - * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. - * - * Default value: 10,000 msat - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +enum LDKPaymentFailureReason PaymentFailureReason_invoice_request_rejected(void); /** - * A multiplier used in conjunction with the negative `log10` of the channel's success - * probability for the payment, as determined based on the history of our estimates of the - * channel's available liquidity, to determine a penalty. - * - * This penalty is similar to [`liquidity_penalty_multiplier_msat`], however, instead of using - * only our latest estimate for the current liquidity available in the channel, it estimates - * success probability based on the estimated liquidity available in the channel through - * history. Specifically, every time we update our liquidity bounds on a given channel, we - * track which of several buckets those bounds fall into, exponentially decaying the - * probability of each bucket as new samples are added. - * - * Default value: 10,000 msat - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat + * Checks if two PaymentFailureReasons contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); /** - * A multiplier used in conjunction with the total amount flowing over a channel and the - * negative `log10` of the channel's success probability for the payment, as determined based - * on the history of our estimates of the channel's available liquidity, to determine a - * penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and `2^20`ths - * of the amount flowing over this channel, weighted by the negative `log10` of the success - * probability. - * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. - * - * Default value: 64 msat - * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read */ -uint64_t ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); /** - * A multiplier used in conjunction with the total amount flowing over a channel and the - * negative `log10` of the channel's success probability for the payment, as determined based - * on the history of our estimates of the channel's available liquidity, to determine a - * penalty. - * - * The purpose of the amount penalty is to avoid having fees dominate the channel cost for - * large payments. The penalty is computed as the product of this multiplier and `2^20`ths - * of the amount flowing over this channel, weighted by the negative `log10` of the success - * probability. - * - * This penalty is similar to [`liquidity_penalty_amount_multiplier_msat`], however, instead - * of using only our latest estimate for the current liquidity available in the channel, it - * estimates success probability based on the estimated liquidity available in the channel - * through history. Specifically, every time we update our liquidity bounds on a given - * channel, we track which of several buckets those bounds fall into, exponentially decaying - * the probability of each bucket as new samples are added. - * - * Default value: 64 msat - * - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat + * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write */ -void ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us - * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially - * as this makes balance discovery attacks harder to execute, thereby creating an incentive - * to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Frees any resources used by the Event */ -uint64_t ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +void Event_free(struct LDKEvent this_ptr); /** - * This penalty is applied when `htlc_maximum_msat` is equal to or larger than half of the - * channel's capacity, (ie. htlc_maximum_msat >= 0.5 * channel_capacity) which makes us - * prefer nodes with a smaller `htlc_maximum_msat`. We treat such nodes preferentially - * as this makes balance discovery attacks harder to execute, thereby creating an incentive - * to restrict `htlc_maximum_msat` and improve privacy. - * - * Default value: 250 msat + * Creates a copy of the Event */ -void ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. - * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. - * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * Utility method to constructs a new FundingGenerationReady-variant Event */ -uint64_t ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_funding_generation_ready(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); /** - * This penalty is applied when the total amount flowing over a channel exceeds our current - * estimate of the channel's available liquidity. The total amount is the amount of the - * current HTLC plus any HTLCs which we've sent over the same channel. - * - * Note that in this case all other penalties, including the - * [`liquidity_penalty_multiplier_msat`] and [`liquidity_penalty_amount_multiplier_msat`]-based - * penalties, as well as the [`base_penalty_msat`] and the [`anti_probing_penalty_msat`], if - * applicable, are still included in the overall penalty. - * - * If you wish to avoid creating paths with such channels entirely, setting this to a value of - * `u64::max_value()` will guarantee that. - * - * Default value: 1_0000_0000_000 msat (1 Bitcoin) - * - * [`liquidity_penalty_multiplier_msat`]: Self::liquidity_penalty_multiplier_msat - * [`liquidity_penalty_amount_multiplier_msat`]: Self::liquidity_penalty_amount_multiplier_msat - * [`base_penalty_msat`]: Self::base_penalty_msat - * [`anti_probing_penalty_msat`]: Self::anti_probing_penalty_msat + * Utility method to constructs a new FundingTxBroadcastSafe-variant Event */ -void ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEvent Event_funding_tx_broadcast_safe(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKOutPoint funding_txo, struct LDKPublicKey counterparty_node_id, struct LDKChannelId former_temporary_channel_id); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Utility method to constructs a new PaymentClaimable-variant Event */ -bool ProbabilisticScoringFeeParameters_get_linear_success_probability(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, uint64_t counterparty_skimmed_fee_msat, struct LDKPaymentPurpose purpose, struct LDKChannelId via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); /** - * In order to calculate most of the scores above, we must first convert a lower and upper - * bound on the available liquidity in a channel into the probability that we think a payment - * will succeed. That probability is derived from a Probability Density Function for where we - * think the liquidity in a channel likely lies, given such bounds. - * - * If this flag is set, that PDF is simply a constant - we assume that the actual available - * liquidity in a channel is just as likely to be at any point between our lower and upper - * bounds. - * - * If this flag is *not* set, that PDF is `(x - 0.5*capacity) ^ 2`. That is, we use an - * exponential curve which expects the liquidity of a channel to lie \"at the edges\". This - * matches experimental results - most routing nodes do not aggressively rebalance their - * channels and flows in the network are often unbalanced, leaving liquidity usually - * unavailable. - * - * Thus, for the \"best\" routes, leave this flag `false`. However, the flag does imply a number - * of floating-point multiplications in the hottest routing code, which may lead to routing - * performance degradation on some machines. - * - * Default value: false + * Utility method to constructs a new PaymentClaimed-variant Event */ -void ProbabilisticScoringFeeParameters_set_linear_success_probability(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_ptr, bool val); +struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat, struct LDKRecipientOnionFields onion_fields); /** - * Creates a copy of the ProbabilisticScoringFeeParameters + * Utility method to constructs a new ConnectionNeeded-variant Event */ -struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_clone(const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR orig); +struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); /** - * Creates a "default" ProbabilisticScoringFeeParameters. See struct and individual field documentaiton for details on which values are used. + * Utility method to constructs a new InvoiceReceived-variant Event */ -MUST_USE_RES struct LDKProbabilisticScoringFeeParameters ProbabilisticScoringFeeParameters_default(void); +struct LDKEvent Event_invoice_received(struct LDKThirtyTwoBytes payment_id, struct LDKBolt12Invoice invoice, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** - * Marks the node with the given `node_id` as banned, - * i.e it will be avoided during path finding. + * Utility method to constructs a new PaymentSent-variant Event */ -void ProbabilisticScoringFeeParameters_add_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); /** - * Marks all nodes in the given list as banned, i.e., - * they will be avoided during path finding. + * Utility method to constructs a new PaymentFailed-variant Event */ -void ProbabilisticScoringFeeParameters_add_banned_from_list(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, struct LDKCVec_NodeIdZ node_ids); +struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); /** - * Removes the node with the given `node_id` from the list of nodes to avoid. + * Utility method to constructs a new PaymentPathSuccessful-variant Event */ -void ProbabilisticScoringFeeParameters_remove_banned(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); /** - * Sets a manual penalty for the given node. + * Utility method to constructs a new PaymentPathFailed-variant Event */ -void ProbabilisticScoringFeeParameters_set_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id, uint64_t penalty); +struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * Removes the node with the given `node_id` from the list of manual penalties. + * Utility method to constructs a new ProbeSuccessful-variant Event */ -void ProbabilisticScoringFeeParameters_remove_manual_penalty(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg, const struct LDKNodeId *NONNULL_PTR node_id); +struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); /** - * Clears the list of manual penalties that are applied during path finding. + * Utility method to constructs a new ProbeFailed-variant Event */ -void ProbabilisticScoringFeeParameters_clear_manual_penalties(struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR this_arg); +struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); /** - * Frees any resources used by the ProbabilisticScoringDecayParameters, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new PendingHTLCsForwardable-variant Event */ -void ProbabilisticScoringDecayParameters_free(struct LDKProbabilisticScoringDecayParameters this_obj); +struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days - * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * Utility method to constructs a new HTLCIntercepted-variant Event */ -uint64_t ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); /** - * If we aren't learning any new datapoints for a channel, the historical liquidity bounds - * tracking can simply live on with increasingly stale data. Instead, when a channel has not - * seen a liquidity estimate update for this amount of time, the historical datapoints are - * decayed by half. - * For an example of historical_no_updates_half_life being used see [`historical_estimated_channel_liquidity_probabilities`] - * - * Note that after 16 or more half lives all historical data will be completely gone. - * - * Default value: 14 days - * - * [`historical_estimated_channel_liquidity_probabilities`]: ProbabilisticScorer::historical_estimated_channel_liquidity_probabilities + * Utility method to constructs a new SpendableOutputs-variant Event */ -void ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKChannelId channel_id); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 6 hours - * - * # Note - * - * When built with the `no-std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Utility method to constructs a new PaymentForwarded-variant Event */ -uint64_t ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr); +struct LDKEvent Event_payment_forwarded(struct LDKChannelId prev_channel_id, struct LDKChannelId next_channel_id, struct LDKCOption_U128Z prev_user_channel_id, struct LDKCOption_U128Z next_user_channel_id, struct LDKCOption_u64Z total_fee_earned_msat, struct LDKCOption_u64Z skimmed_fee_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); /** - * Whenever this amount of time elapses since the last update to a channel's liquidity bounds, - * the distance from the bounds to \"zero\" is cut in half. In other words, the lower-bound on - * the available liquidity is halved and the upper-bound moves half-way to the channel's total - * capacity. - * - * Because halving the liquidity bounds grows the uncertainty on the channel's liquidity, - * the penalty for an amount within the new bounds may change. See the [`ProbabilisticScorer`] - * struct documentation for more info on the way the liquidity bounds are used. - * - * For example, if the channel's capacity is 1 million sats, and the current upper and lower - * liquidity bounds are 200,000 sats and 600,000 sats, after this amount of time the upper - * and lower liquidity bounds will be decayed to 100,000 and 800,000 sats. - * - * Default value: 6 hours - * - * # Note - * - * When built with the `no-std` feature, time will never elapse. Therefore, the channel - * liquidity knowledge will never decay except when the bounds cross. + * Utility method to constructs a new ChannelPending-variant Event */ -void ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR this_ptr, uint64_t val); +struct LDKEvent Event_channel_pending(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKChannelId former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo, struct LDKChannelTypeFeatures channel_type); /** - * Constructs a new ProbabilisticScoringDecayParameters given each field + * Utility method to constructs a new ChannelReady-variant Event */ -MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_new(uint64_t historical_no_updates_half_life_arg, uint64_t liquidity_offset_half_life_arg); +struct LDKEvent Event_channel_ready(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); /** - * Creates a copy of the ProbabilisticScoringDecayParameters + * Utility method to constructs a new ChannelClosed-variant Event */ -struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_clone(const struct LDKProbabilisticScoringDecayParameters *NONNULL_PTR orig); +struct LDKEvent Event_channel_closed(struct LDKChannelId channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo); /** - * Creates a "default" ProbabilisticScoringDecayParameters. See struct and individual field documentaiton for details on which values are used. + * Utility method to constructs a new DiscardFunding-variant Event */ -MUST_USE_RES struct LDKProbabilisticScoringDecayParameters ProbabilisticScoringDecayParameters_default(void); +struct LDKEvent Event_discard_funding(struct LDKChannelId channel_id, struct LDKFundingInfo funding_info); /** - * Creates a new scorer using the given scoring parameters for sending payments from a node - * through a network graph. + * Utility method to constructs a new OpenChannelRequest-variant Event */ -MUST_USE_RES struct LDKProbabilisticScorer ProbabilisticScorer_new(struct LDKProbabilisticScoringDecayParameters decay_params, const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKLogger logger); +struct LDKEvent Event_open_channel_request(struct LDKChannelId temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type, bool is_announced, struct LDKChannelParameters params); /** - * Dump the contents of this scorer into the configured logger. - * - * Note that this writes roughly one line per channel for which we have a liquidity estimate, - * which may be a substantial amount of log output. + * Utility method to constructs a new HTLCHandlingFailed-variant Event */ -void ProbabilisticScorer_debug_log_liquidity_stats(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKEvent Event_htlchandling_failed(struct LDKChannelId prev_channel_id, struct LDKHTLCDestination failed_next_destination); /** - * Query the estimated minimum and maximum liquidity available for sending a payment over the - * channel with `scid` towards the given `target` node. + * Utility method to constructs a new BumpTransaction-variant Event */ -MUST_USE_RES struct LDKCOption_C2Tuple_u64u64ZZ ProbabilisticScorer_estimated_channel_liquidity_range(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); /** - * Query the historical estimated minimum and maximum liquidity available for sending a - * payment over the channel with `scid` towards the given `target` node. - * - * Returns two sets of 32 buckets. The first set describes the lower-bound liquidity history, - * the second set describes the upper-bound liquidity history. Each bucket describes the - * relative frequency at which we've seen a liquidity bound in the bucket's range relative to - * the channel's total capacity, on an arbitrary scale. Because the values are slowly decayed, - * more recent data points are weighted more heavily than older datapoints. - * - * Note that the range of each bucket varies by its location to provide more granular results - * at the edges of a channel's capacity, where it is more likely to sit. - * - * When scoring, the estimated probability that an upper-/lower-bound lies in a given bucket - * is calculated by dividing that bucket's value with the total value of all buckets. - * - * For example, using a lower bucket count for illustrative purposes, a value of - * `[0, 0, 0, ..., 0, 32]` indicates that we believe the probability of a bound being very - * close to the channel's capacity to be 100%, and have never (recently) seen it in any other - * bucket. A value of `[31, 0, 0, ..., 0, 0, 32]` indicates we've seen the bound being both - * in the top and bottom bucket, and roughly with similar (recent) frequency. - * - * Because the datapoints are decayed slowly over time, values will eventually return to - * `Some(([0; 32], [0; 32]))` or `None` if no data remains for a channel. - * - * In order to fetch a single success probability from the buckets provided here, as used in - * the scoring model, see [`Self::historical_estimated_payment_success_probability`]. + * Utility method to constructs a new OnionMessageIntercepted-variant Event */ -MUST_USE_RES struct LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target); +struct LDKEvent Event_onion_message_intercepted(struct LDKPublicKey peer_node_id, struct LDKOnionMessage message); /** - * Query the probability of payment success sending the given `amount_msat` over the channel - * with `scid` towards the given `target` node, based on the historical estimated liquidity - * bounds. - * - * These are the same bounds as returned by - * [`Self::historical_estimated_channel_liquidity_probabilities`] (but not those returned by - * [`Self::estimated_channel_liquidity_range`]). + * Utility method to constructs a new OnionMessagePeerConnected-variant Event */ -MUST_USE_RES struct LDKCOption_f64Z ProbabilisticScorer_historical_estimated_payment_success_probability(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg, uint64_t scid, const struct LDKNodeId *NONNULL_PTR target, uint64_t amount_msat, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR params); +struct LDKEvent Event_onion_message_peer_connected(struct LDKPublicKey peer_node_id); /** - * Constructs a new ScoreLookUp which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreLookUp must be freed before this_arg is + * Checks if two Events contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. */ -struct LDKScoreLookUp ProbabilisticScorer_as_ScoreLookUp(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); /** - * Constructs a new ScoreUpdate which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ScoreUpdate must be freed before this_arg is + * Serialize the Event object into a byte array which can be read by Event_read */ -struct LDKScoreUpdate ProbabilisticScorer_as_ScoreUpdate(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); /** - * Constructs a new Score which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned Score must be freed before this_arg is + * Read a Event from a byte array, created by Event_write */ -struct LDKScore ProbabilisticScorer_as_Score(const struct LDKProbabilisticScorer *NONNULL_PTR this_arg); +struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); /** - * Serialize the ProbabilisticScorer object into a byte array which can be read by ProbabilisticScorer_read + * Frees any resources used by the MessageSendEvent */ -struct LDKCVec_u8Z ProbabilisticScorer_write(const struct LDKProbabilisticScorer *NONNULL_PTR obj); +void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); /** - * Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write + * Creates a copy of the MessageSendEvent */ -struct LDKCResult_ProbabilisticScorerDecodeErrorZ ProbabilisticScorer_read(struct LDKu8slice ser, struct LDKProbabilisticScoringDecayParameters arg_a, const struct LDKNetworkGraph *NONNULL_PTR arg_b, struct LDKLogger arg_c); +struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); /** - * Frees any resources used by the DelayedPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_free(struct LDKDelayedPaymentOutputDescriptor this_obj); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); /** - * The outpoint which is spendable. + * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent */ -struct LDKOutPoint DelayedPaymentOutputDescriptor_get_outpoint(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); /** - * The outpoint which is spendable. + * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_outpoint(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); /** - * Per commitment point to derive the delayed payment key by key holder. + * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent */ -struct LDKPublicKey DelayedPaymentOutputDescriptor_get_per_commitment_point(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); /** - * Per commitment point to derive the delayed payment key by key holder. + * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_per_commitment_point(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent */ -uint16_t DelayedPaymentOutputDescriptor_get_to_self_delay(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); /** - * The `nSequence` value which must be set in the spending input to satisfy the `OP_CSV` in - * the witness_script. + * Utility method to constructs a new SendStfu-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_to_self_delay(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint16_t val); +struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new SendSpliceInit-variant MessageSendEvent */ -struct LDKTxOut DelayedPaymentOutputDescriptor_get_output(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_splice_init(struct LDKPublicKey node_id, struct LDKSpliceInit msg); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_output(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent */ -struct LDKRevocationKey DelayedPaymentOutputDescriptor_get_revocation_pubkey(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); /** - * The revocation point specific to the commitment transaction which was broadcast. Used to - * derive the witnessScript for this output. + * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_revocation_pubkey(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKRevocationKey val); +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent */ -const uint8_t (*DelayedPaymentOutputDescriptor_get_channel_keys_id(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_channel_keys_id(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); /** - * The value of the channel which this output originated from, possibly indirectly. + * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent */ -uint64_t DelayedPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); /** - * The value of the channel which this output originated from, possibly indirectly. + * Utility method to constructs a new SendTxComplete-variant MessageSendEvent */ -void DelayedPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); /** - * Constructs a new DelayedPaymentOutputDescriptor given each field + * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent */ -MUST_USE_RES struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKPublicKey per_commitment_point_arg, uint16_t to_self_delay_arg, struct LDKTxOut output_arg, struct LDKRevocationKey revocation_pubkey_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg); +struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); /** - * Creates a copy of the DelayedPaymentOutputDescriptor + * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent */ -struct LDKDelayedPaymentOutputDescriptor DelayedPaymentOutputDescriptor_clone(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); /** - * Generates a non-cryptographic 64-bit hash of the DelayedPaymentOutputDescriptor. + * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent */ -uint64_t DelayedPaymentOutputDescriptor_hash(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); /** - * Checks if two DelayedPaymentOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new SendTxAbort-variant MessageSendEvent */ -bool DelayedPaymentOutputDescriptor_eq(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR b); +struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); /** - * Serialize the DelayedPaymentOutputDescriptor object into a byte array which can be read by DelayedPaymentOutputDescriptor_read + * Utility method to constructs a new SendChannelReady-variant MessageSendEvent */ -struct LDKCVec_u8Z DelayedPaymentOutputDescriptor_write(const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR obj); +struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); /** - * Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write + * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent */ -struct LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ DelayedPaymentOutputDescriptor_read(struct LDKu8slice ser); +struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); /** - * Frees any resources used by the StaticPaymentOutputDescriptor, if is_owned is set and inner is non-NULL. + * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_free(struct LDKStaticPaymentOutputDescriptor this_obj); +struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); /** - * The outpoint which is spendable. + * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent */ -struct LDKOutPoint StaticPaymentOutputDescriptor_get_outpoint(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); /** - * The outpoint which is spendable. + * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_set_outpoint(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new SendShutdown-variant MessageSendEvent */ -struct LDKTxOut StaticPaymentOutputDescriptor_get_output(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); /** - * The output which is referenced by the given outpoint. + * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_set_output(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent */ -const uint8_t (*StaticPaymentOutputDescriptor_get_channel_keys_id(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr))[32]; +struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * Arbitrary identification information returned by a call to [`ChannelSigner::channel_keys_id`]. - * This may be useful in re-deriving keys used in the channel to spend the output. + * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_set_channel_keys_id(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); /** - * The value of the channel which this transactions spends. + * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent */ -uint64_t StaticPaymentOutputDescriptor_get_channel_value_satoshis(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); /** - * The value of the channel which this transactions spends. + * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_set_channel_value_satoshis(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, uint64_t val); +struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent */ -struct LDKChannelTransactionParameters StaticPaymentOutputDescriptor_get_channel_transaction_parameters(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr); +struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. - * - * Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. - * - * Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new HandleError-variant MessageSendEvent */ -void StaticPaymentOutputDescriptor_set_channel_transaction_parameters(struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); /** - * Constructs a new StaticPaymentOutputDescriptor given each field - * - * Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None + * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent */ -MUST_USE_RES struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, struct LDKThirtyTwoBytes channel_keys_id_arg, uint64_t channel_value_satoshis_arg, struct LDKChannelTransactionParameters channel_transaction_parameters_arg); +struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); /** - * Creates a copy of the StaticPaymentOutputDescriptor + * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent */ -struct LDKStaticPaymentOutputDescriptor StaticPaymentOutputDescriptor_clone(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR orig); +struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); /** - * Generates a non-cryptographic 64-bit hash of the StaticPaymentOutputDescriptor. + * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent */ -uint64_t StaticPaymentOutputDescriptor_hash(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR o); +struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); /** - * Checks if two StaticPaymentOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent */ -bool StaticPaymentOutputDescriptor_eq(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR a, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR b); +struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); /** - * Returns the `witness_script` of the spendable output. - * - * Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that - * originated from an anchor outputs channel, as they take the form of a P2WSH script. + * Calls the free function if one is set */ -MUST_USE_RES struct LDKCOption_CVec_u8ZZ StaticPaymentOutputDescriptor_witness_script(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); +void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); /** - * The maximum length a well-formed witness spending one of these should have. - * Note: If you have the grind_signatures feature enabled, this will be at least 1 byte - * shorter. + * Calls the free function if one is set */ -MUST_USE_RES uint64_t StaticPaymentOutputDescriptor_max_witness_length(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR this_arg); +void EventsProvider_free(struct LDKEventsProvider this_ptr); /** - * Serialize the StaticPaymentOutputDescriptor object into a byte array which can be read by StaticPaymentOutputDescriptor_read + * Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z StaticPaymentOutputDescriptor_write(const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR obj); +void ReplayEvent_free(struct LDKReplayEvent this_obj); /** - * Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write + * Constructs a new ReplayEvent given each field */ -struct LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ StaticPaymentOutputDescriptor_read(struct LDKu8slice ser); +MUST_USE_RES struct LDKReplayEvent ReplayEvent_new(void); /** - * Frees any resources used by the SpendableOutputDescriptor + * Creates a copy of the ReplayEvent */ -void SpendableOutputDescriptor_free(struct LDKSpendableOutputDescriptor this_ptr); +struct LDKReplayEvent ReplayEvent_clone(const struct LDKReplayEvent *NONNULL_PTR orig); /** - * Creates a copy of the SpendableOutputDescriptor + * Calls the free function if one is set */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_clone(const struct LDKSpendableOutputDescriptor *NONNULL_PTR orig); +void EventHandler_free(struct LDKEventHandler this_ptr); /** - * Utility method to constructs a new StaticOutput-variant SpendableOutputDescriptor + * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_output(struct LDKOutPoint outpoint, struct LDKTxOut output, struct LDKThirtyTwoBytes channel_keys_id); +void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); /** - * Utility method to constructs a new DelayedPaymentOutput-variant SpendableOutputDescriptor + * The parameters required to derive the signer for the anchor input. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_delayed_payment_output(struct LDKDelayedPaymentOutputDescriptor a); +struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); /** - * Utility method to constructs a new StaticPaymentOutput-variant SpendableOutputDescriptor + * The parameters required to derive the signer for the anchor input. */ -struct LDKSpendableOutputDescriptor SpendableOutputDescriptor_static_payment_output(struct LDKStaticPaymentOutputDescriptor a); +void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); /** - * Generates a non-cryptographic 64-bit hash of the SpendableOutputDescriptor. + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -uint64_t SpendableOutputDescriptor_hash(const struct LDKSpendableOutputDescriptor *NONNULL_PTR o); +struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); /** - * Checks if two SpendableOutputDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * The transaction input's outpoint corresponding to the commitment transaction's anchor + * output. */ -bool SpendableOutputDescriptor_eq(const struct LDKSpendableOutputDescriptor *NONNULL_PTR a, const struct LDKSpendableOutputDescriptor *NONNULL_PTR b); +void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * Serialize the SpendableOutputDescriptor object into a byte array which can be read by SpendableOutputDescriptor_read + * Constructs a new AnchorDescriptor given each field */ -struct LDKCVec_u8Z SpendableOutputDescriptor_write(const struct LDKSpendableOutputDescriptor *NONNULL_PTR obj); +MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); /** - * Read a SpendableOutputDescriptor from a byte array, created by SpendableOutputDescriptor_write + * Creates a copy of the AnchorDescriptor */ -struct LDKCResult_SpendableOutputDescriptorDecodeErrorZ SpendableOutputDescriptor_read(struct LDKu8slice ser); +struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); /** - * Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to - * the given outputs, plus an output to the given change destination (if sufficient - * change value remains). The PSBT will have a feerate, at least, of the given value. - * - * The `locktime` argument is used to set the transaction's locktime. If `None`, the - * transaction will have a locktime of 0. It it recommended to set this to the current block - * height to avoid fee sniping, unless you have some specific reason to use a different - * locktime. - * - * Returns the PSBT and expected max transaction weight. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee, - * if a descriptor was duplicated, or if an output descriptor `script_pubkey` - * does not match the one we can spend. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. + * Checks if two AnchorDescriptors contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKCResult_C2Tuple_CVec_u8Zu64ZNoneZ SpendableOutputDescriptor_create_spendable_outputs_psbt(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); +bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); /** - * Frees any resources used by the ChannelDerivationParameters, if is_owned is set and inner is non-NULL. + * Returns the UTXO to be spent by the anchor input, which can be obtained via + * [`Self::unsigned_tx_input`]. */ -void ChannelDerivationParameters_free(struct LDKChannelDerivationParameters this_obj); +MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * Returns the unsigned transaction input spending the anchor output in the commitment + * transaction. */ -uint64_t ChannelDerivationParameters_get_value_satoshis(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * The value in satoshis of the channel we're attempting to spend the anchor output of. + * Returns the witness script of the anchor output in the commitment transaction. */ -void ChannelDerivationParameters_set_value_satoshis(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); /** - * The unique identifier to re-derive the signer for the associated channel. + * Returns the fully signed witness required to spend the anchor output in the commitment + * transaction. */ -const uint8_t (*ChannelDerivationParameters_get_keys_id(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); /** - * The unique identifier to re-derive the signer for the associated channel. + * Derives the channel signer required to sign the anchor input. */ -void ChannelDerivationParameters_set_keys_id(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Frees any resources used by the BumpTransactionEvent */ -struct LDKChannelTransactionParameters ChannelDerivationParameters_get_transaction_parameters(const struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr); +void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); /** - * The necessary channel parameters that need to be provided to the re-derived signer through - * [`ChannelSigner::provide_channel_parameters`]. + * Creates a copy of the BumpTransactionEvent */ -void ChannelDerivationParameters_set_transaction_parameters(struct LDKChannelDerivationParameters *NONNULL_PTR this_ptr, struct LDKChannelTransactionParameters val); +struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); /** - * Constructs a new ChannelDerivationParameters given each field + * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent */ -MUST_USE_RES struct LDKChannelDerivationParameters ChannelDerivationParameters_new(uint64_t value_satoshis_arg, struct LDKThirtyTwoBytes keys_id_arg, struct LDKChannelTransactionParameters transaction_parameters_arg); +struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t package_target_feerate_sat_per_1000_weight, struct LDKTransaction commitment_tx, uint64_t commitment_tx_fee_satoshis, struct LDKAnchorDescriptor anchor_descriptor, struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs); /** - * Creates a copy of the ChannelDerivationParameters + * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent */ -struct LDKChannelDerivationParameters ChannelDerivationParameters_clone(const struct LDKChannelDerivationParameters *NONNULL_PTR orig); +struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKChannelId channel_id, struct LDKPublicKey counterparty_node_id, struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); /** - * Checks if two ChannelDerivationParameterss contain equal inner contents. + * Checks if two BumpTransactionEvents contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. */ -bool ChannelDerivationParameters_eq(const struct LDKChannelDerivationParameters *NONNULL_PTR a, const struct LDKChannelDerivationParameters *NONNULL_PTR b); +bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); /** - * Serialize the ChannelDerivationParameters object into a byte array which can be read by ChannelDerivationParameters_read + * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. */ -struct LDKCVec_u8Z ChannelDerivationParameters_write(const struct LDKChannelDerivationParameters *NONNULL_PTR obj); +void Input_free(struct LDKInput this_obj); /** - * Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write + * The unique identifier of the input. */ -struct LDKCResult_ChannelDerivationParametersDecodeErrorZ ChannelDerivationParameters_read(struct LDKu8slice ser); +struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); /** - * Frees any resources used by the HTLCDescriptor, if is_owned is set and inner is non-NULL. + * The unique identifier of the input. */ -void HTLCDescriptor_free(struct LDKHTLCDescriptor this_obj); +void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * The parameters required to derive the signer for the HTLC input. + * The UTXO being spent by the input. */ -struct LDKChannelDerivationParameters HTLCDescriptor_get_channel_derivation_parameters(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); /** - * The parameters required to derive the signer for the HTLC input. + * The UTXO being spent by the input. */ -void HTLCDescriptor_set_channel_derivation_parameters(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * The number of the commitment transaction in which the HTLC output lives. + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. */ -uint64_t HTLCDescriptor_get_per_commitment_number(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); /** - * The number of the commitment transaction in which the HTLC output lives. + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and + * [`TxIn::witness`], each with their lengths included, required to satisfy the output's + * script. */ -void HTLCDescriptor_set_per_commitment_number(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint64_t val); +void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); /** - * The key tweak corresponding to the number of the commitment transaction in which the HTLC - * output lives. This tweak is applied to all the basepoints for both parties in the channel to - * arrive at unique keys per commitment. - * - * See for more info. + * Constructs a new Input given each field */ -struct LDKPublicKey HTLCDescriptor_get_per_commitment_point(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); /** - * The key tweak corresponding to the number of the commitment transaction in which the HTLC - * output lives. This tweak is applied to all the basepoints for both parties in the channel to - * arrive at unique keys per commitment. - * - * See for more info. + * Creates a copy of the Input */ -void HTLCDescriptor_set_per_commitment_point(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKPublicKey val); +struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Generates a non-cryptographic 64-bit hash of the Input. */ -uint32_t HTLCDescriptor_get_feerate_per_kw(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); /** - * The feerate to use on the HTLC claiming transaction. This is always `0` for HTLCs - * originating from a channel supporting anchor outputs, otherwise it is the channel's - * negotiated feerate at the time the commitment transaction was built. + * Checks if two Inputs contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void HTLCDescriptor_set_feerate_per_kw(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, uint32_t val); +bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); /** - * The details of the HTLC as it appears in the commitment transaction. + * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. */ -struct LDKHTLCOutputInCommitment HTLCDescriptor_get_htlc(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +void Utxo_free(struct LDKUtxo this_obj); /** - * The details of the HTLC as it appears in the commitment transaction. + * The unique identifier of the output. */ -void HTLCDescriptor_set_htlc(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKHTLCOutputInCommitment val); +struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * The unique identifier of the output. */ -struct LDKCOption_ThirtyTwoBytesZ HTLCDescriptor_get_preimage(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); /** - * The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be - * taken. + * The output to spend. */ -void HTLCDescriptor_set_preimage(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKCOption_ThirtyTwoBytesZ val); +struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * The counterparty's signature required to spend the HTLC output. + * The output to spend. */ -struct LDKECDSASignature HTLCDescriptor_get_counterparty_sig(const struct LDKHTLCDescriptor *NONNULL_PTR this_ptr); +void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); /** - * The counterparty's signature required to spend the HTLC output. + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. */ -void HTLCDescriptor_set_counterparty_sig(struct LDKHTLCDescriptor *NONNULL_PTR this_ptr, struct LDKECDSASignature val); +uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); /** - * Creates a copy of the HTLCDescriptor + * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each + * with their lengths included, required to satisfy the output's script. The weight consumed by + * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. */ -struct LDKHTLCDescriptor HTLCDescriptor_clone(const struct LDKHTLCDescriptor *NONNULL_PTR orig); +void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); /** - * Checks if two HTLCDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Constructs a new Utxo given each field */ -bool HTLCDescriptor_eq(const struct LDKHTLCDescriptor *NONNULL_PTR a, const struct LDKHTLCDescriptor *NONNULL_PTR b); +MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); /** - * Serialize the HTLCDescriptor object into a byte array which can be read by HTLCDescriptor_read + * Creates a copy of the Utxo */ -struct LDKCVec_u8Z HTLCDescriptor_write(const struct LDKHTLCDescriptor *NONNULL_PTR obj); +struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); /** - * Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write + * Generates a non-cryptographic 64-bit hash of the Utxo. */ -struct LDKCResult_HTLCDescriptorDecodeErrorZ HTLCDescriptor_read(struct LDKu8slice ser); +uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); /** - * Returns the outpoint of the HTLC output in the commitment transaction. This is the outpoint - * being spent by the HTLC input in the HTLC transaction. + * Checks if two Utxos contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -MUST_USE_RES struct LDKOutPoint HTLCDescriptor_outpoint(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); /** - * Returns the UTXO to be spent by the HTLC input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_previous_utxo(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); /** - * Returns the unsigned transaction input spending the HTLC output in the commitment - * transaction. + * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKTxIn HTLCDescriptor_unsigned_tx_input(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +void CoinSelection_free(struct LDKCoinSelection this_obj); /** - * Returns the delayed output created as a result of spending the HTLC output in the commitment - * transaction. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -MUST_USE_RES struct LDKTxOut HTLCDescriptor_tx_output(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * Returns the witness script of the HTLC output in the commitment transaction. + * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction + * requiring additional fees. */ -MUST_USE_RES struct LDKCVec_u8Z HTLCDescriptor_witness_script(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg); +void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); /** - * Returns the fully signed witness required to spend the HTLC output in the commitment - * transaction. + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. */ -MUST_USE_RES struct LDKWitness HTLCDescriptor_tx_input_witness(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature, struct LDKu8slice witness_script); +struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); /** - * Derives the channel signer required to sign the HTLC input. + * An additional output tracking whether any change remained after coin selection. This output + * should always have a value above dust for its given `script_pubkey`. It should not be + * spent until the transaction it belongs to confirms to ensure mempool descendant limits are + * not met. This implies no other party should be able to spend it except us. */ -MUST_USE_RES struct LDKWriteableEcdsaChannelSigner HTLCDescriptor_derive_channel_signer(const struct LDKHTLCDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); /** - * Calls the free function if one is set + * Constructs a new CoinSelection given each field */ -void ChannelSigner_free(struct LDKChannelSigner this_ptr); +MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); /** - * Creates a copy of the Recipient + * Creates a copy of the CoinSelection */ -enum LDKRecipient Recipient_clone(const enum LDKRecipient *NONNULL_PTR orig); +struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); /** - * Utility method to constructs a new Node-variant Recipient + * Calls the free function if one is set */ -enum LDKRecipient Recipient_node(void); +void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); /** - * Utility method to constructs a new PhantomNode-variant Recipient + * Calls the free function if one is set + */ +void WalletSource_free(struct LDKWalletSource this_ptr); + +/** + * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. */ -enum LDKRecipient Recipient_phantom_node(void); +void Wallet_free(struct LDKWallet this_obj); /** - * Calls the free function if one is set + * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation + * of [`CoinSelectionSource`]. */ -void EntropySource_free(struct LDKEntropySource this_ptr); +MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); /** - * Calls the free function if one is set + * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is */ -void NodeSigner_free(struct LDKNodeSigner this_ptr); +struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. */ -void SignerProvider_free(struct LDKSignerProvider this_ptr); +void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); /** - * Frees any resources used by the InMemorySigner, if is_owned is set and inner is non-NULL. + * Returns a new instance capable of handling [`Event::BumpTransaction`] events. + * + * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction */ -void InMemorySigner_free(struct LDKInMemorySigner this_obj); +MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Handles all variants of [`BumpTransactionEvent`]. */ -const uint8_t (*InMemorySigner_get_funding_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); /** - * Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the - * holder's anchor output in a commitment transaction, if one is present. + * Checks if two InitFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_funding_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool InitFeatures_eq(const struct LDKInitFeatures *NONNULL_PTR a, const struct LDKInitFeatures *NONNULL_PTR b); /** - * Holder secret key for blinded revocation pubkey. + * Checks if two NodeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const uint8_t (*InMemorySigner_get_revocation_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +bool NodeFeatures_eq(const struct LDKNodeFeatures *NONNULL_PTR a, const struct LDKNodeFeatures *NONNULL_PTR b); /** - * Holder secret key for blinded revocation pubkey. + * Checks if two ChannelFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_revocation_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool ChannelFeatures_eq(const struct LDKChannelFeatures *NONNULL_PTR a, const struct LDKChannelFeatures *NONNULL_PTR b); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Checks if two Bolt11InvoiceFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const uint8_t (*InMemorySigner_get_payment_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +bool Bolt11InvoiceFeatures_eq(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR b); /** - * Holder secret key used for our balance in counterparty-broadcasted commitment transactions. + * Checks if two OfferFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_payment_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool OfferFeatures_eq(const struct LDKOfferFeatures *NONNULL_PTR a, const struct LDKOfferFeatures *NONNULL_PTR b); /** - * Holder secret key used in an HTLC transaction. + * Checks if two InvoiceRequestFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const uint8_t (*InMemorySigner_get_delayed_payment_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +bool InvoiceRequestFeatures_eq(const struct LDKInvoiceRequestFeatures *NONNULL_PTR a, const struct LDKInvoiceRequestFeatures *NONNULL_PTR b); /** - * Holder secret key used in an HTLC transaction. + * Checks if two Bolt12InvoiceFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_delayed_payment_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool Bolt12InvoiceFeatures_eq(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR a, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR b); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Checks if two BlindedHopFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -const uint8_t (*InMemorySigner_get_htlc_base_key(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +bool BlindedHopFeatures_eq(const struct LDKBlindedHopFeatures *NONNULL_PTR a, const struct LDKBlindedHopFeatures *NONNULL_PTR b); /** - * Holder HTLC secret key used in commitment transaction HTLC outputs. + * Checks if two ChannelTypeFeaturess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void InMemorySigner_set_htlc_base_key(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKSecretKey val); +bool ChannelTypeFeatures_eq(const struct LDKChannelTypeFeatures *NONNULL_PTR a, const struct LDKChannelTypeFeatures *NONNULL_PTR b); /** - * Commitment seed. + * Creates a copy of the InitFeatures */ -const uint8_t (*InMemorySigner_get_commitment_seed(const struct LDKInMemorySigner *NONNULL_PTR this_ptr))[32]; +struct LDKInitFeatures InitFeatures_clone(const struct LDKInitFeatures *NONNULL_PTR orig); /** - * Commitment seed. + * Creates a copy of the NodeFeatures */ -void InMemorySigner_set_commitment_seed(struct LDKInMemorySigner *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +struct LDKNodeFeatures NodeFeatures_clone(const struct LDKNodeFeatures *NONNULL_PTR orig); /** - * Creates a copy of the InMemorySigner + * Creates a copy of the ChannelFeatures */ -struct LDKInMemorySigner InMemorySigner_clone(const struct LDKInMemorySigner *NONNULL_PTR orig); +struct LDKChannelFeatures ChannelFeatures_clone(const struct LDKChannelFeatures *NONNULL_PTR orig); /** - * Creates a new [`InMemorySigner`]. + * Creates a copy of the Bolt11InvoiceFeatures */ -MUST_USE_RES struct LDKInMemorySigner InMemorySigner_new(struct LDKSecretKey funding_key, struct LDKSecretKey revocation_base_key, struct LDKSecretKey payment_key, struct LDKSecretKey delayed_payment_base_key, struct LDKSecretKey htlc_base_key, struct LDKThirtyTwoBytes commitment_seed, uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id, struct LDKThirtyTwoBytes rand_bytes_unique_start); +struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_clone(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR orig); /** - * Returns the counterparty's pubkeys. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the OfferFeatures */ -MUST_USE_RES struct LDKChannelPublicKeys InMemorySigner_counterparty_pubkeys(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKOfferFeatures OfferFeatures_clone(const struct LDKOfferFeatures *NONNULL_PTR orig); /** - * Returns the `contest_delay` value specified by our counterparty and applied on holder-broadcastable - * transactions, i.e., the amount of time that we have to wait to recover our funds if we - * broadcast a transaction. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Creates a copy of the InvoiceRequestFeatures */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_counterparty_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_clone(const struct LDKInvoiceRequestFeatures *NONNULL_PTR orig); /** - * Returns the `contest_delay` value specified by us and applied on transactions broadcastable - * by our counterparty, i.e., the amount of time that they have to wait to recover their funds - * if they broadcast a transaction. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Creates a copy of the Bolt12InvoiceFeatures */ -MUST_USE_RES struct LDKCOption_u16Z InMemorySigner_holder_selected_contest_delay(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_clone(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR orig); /** - * Returns whether the holder is the initiator. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. + * Creates a copy of the BlindedHopFeatures */ -MUST_USE_RES struct LDKCOption_boolZ InMemorySigner_is_outbound(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKBlindedHopFeatures BlindedHopFeatures_clone(const struct LDKBlindedHopFeatures *NONNULL_PTR orig); /** - * Funding outpoint - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Creates a copy of the ChannelTypeFeatures */ -MUST_USE_RES struct LDKOutPoint InMemorySigner_funding_outpoint(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +struct LDKChannelTypeFeatures ChannelTypeFeatures_clone(const struct LDKChannelTypeFeatures *NONNULL_PTR orig); /** - * Returns a [`ChannelTransactionParameters`] for this channel, to be used when verifying or - * building transactions. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the InitFeatures. */ -MUST_USE_RES struct LDKChannelTransactionParameters InMemorySigner_get_channel_parameters(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t InitFeatures_hash(const struct LDKInitFeatures *NONNULL_PTR o); /** - * Returns the channel type features of the channel parameters. Should be helpful for - * determining a channel's category, i. e. legacy/anchors/taproot/etc. - * - * Will return `None` if [`ChannelSigner::provide_channel_parameters`] has not been called. - * In general, this is safe to `unwrap` only in [`ChannelSigner`] implementation. - * - * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + * Generates a non-cryptographic 64-bit hash of the NodeFeatures. */ -MUST_USE_RES struct LDKChannelTypeFeatures InMemorySigner_channel_type_features(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t NodeFeatures_hash(const struct LDKNodeFeatures *NONNULL_PTR o); /** - * Sign the single input of `spend_tx` at index `input_idx`, which spends the output described - * by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], - * or if an output descriptor `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: StaticPaymentOutputDescriptor::outpoint + * Generates a non-cryptographic 64-bit hash of the ChannelFeatures. */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_counterparty_payment_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKStaticPaymentOutputDescriptor *NONNULL_PTR descriptor); +uint64_t ChannelFeatures_hash(const struct LDKChannelFeatures *NONNULL_PTR o); /** - * Sign the single input of `spend_tx` at index `input_idx` which spends the output - * described by `descriptor`, returning the witness stack for the input. - * - * Returns an error if the input at `input_idx` does not exist, has a non-empty `script_sig`, - * is not spending the outpoint described by [`descriptor.outpoint`], does not have a - * sequence set to [`descriptor.to_self_delay`], or if an output descriptor - * `script_pubkey` does not match the one we can spend. - * - * [`descriptor.outpoint`]: DelayedPaymentOutputDescriptor::outpoint - * [`descriptor.to_self_delay`]: DelayedPaymentOutputDescriptor::to_self_delay + * Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. */ -MUST_USE_RES struct LDKCResult_WitnessNoneZ InMemorySigner_sign_dynamic_p2wsh_input(const struct LDKInMemorySigner *NONNULL_PTR this_arg, struct LDKTransaction spend_tx, uintptr_t input_idx, const struct LDKDelayedPaymentOutputDescriptor *NONNULL_PTR descriptor); +uint64_t Bolt11InvoiceFeatures_hash(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR o); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Generates a non-cryptographic 64-bit hash of the OfferFeatures. */ -struct LDKEntropySource InMemorySigner_as_EntropySource(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t OfferFeatures_hash(const struct LDKOfferFeatures *NONNULL_PTR o); /** - * Constructs a new ChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned ChannelSigner must be freed before this_arg is + * Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. */ -struct LDKChannelSigner InMemorySigner_as_ChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t InvoiceRequestFeatures_hash(const struct LDKInvoiceRequestFeatures *NONNULL_PTR o); /** - * Constructs a new EcdsaChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EcdsaChannelSigner must be freed before this_arg is + * Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. */ -struct LDKEcdsaChannelSigner InMemorySigner_as_EcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t Bolt12InvoiceFeatures_hash(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR o); /** - * Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is + * Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. */ -struct LDKWriteableEcdsaChannelSigner InMemorySigner_as_WriteableEcdsaChannelSigner(const struct LDKInMemorySigner *NONNULL_PTR this_arg); +uint64_t BlindedHopFeatures_hash(const struct LDKBlindedHopFeatures *NONNULL_PTR o); /** - * Serialize the InMemorySigner object into a byte array which can be read by InMemorySigner_read + * Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. */ -struct LDKCVec_u8Z InMemorySigner_write(const struct LDKInMemorySigner *NONNULL_PTR obj); +uint64_t ChannelTypeFeatures_hash(const struct LDKChannelTypeFeatures *NONNULL_PTR o); /** - * Read a InMemorySigner from a byte array, created by InMemorySigner_write + * Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKCResult_InMemorySignerDecodeErrorZ InMemorySigner_read(struct LDKu8slice ser, struct LDKEntropySource arg); +void InitFeatures_free(struct LDKInitFeatures this_obj); /** - * Frees any resources used by the KeysManager, if is_owned is set and inner is non-NULL. + * Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. */ -void KeysManager_free(struct LDKKeysManager this_obj); +void NodeFeatures_free(struct LDKNodeFeatures this_obj); /** - * Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., - * your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). - * `starting_time` isn't strictly required to actually be a time, but it must absolutely, - * without a doubt, be unique to this instance. ie if you start multiple times with the same - * `seed`, `starting_time` must be unique to each run. Thus, the easiest way to achieve this - * is to simply use the current time (with very high precision). - * - * The `seed` MUST be backed up safely prior to use so that the keys can be re-created, however, - * obviously, `starting_time` should be unique every time you reload the library - it is only - * used to generate new ephemeral key data (which will be stored by the individual channel if - * necessary). - * - * Note that the seed is required to recover certain on-chain funds independent of - * [`ChannelMonitor`] data, though a current copy of [`ChannelMonitor`] data is also required - * for any channel, and some on-chain during-closing funds. - * - * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKKeysManager KeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos); +void ChannelFeatures_free(struct LDKChannelFeatures this_obj); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKSecretKey KeysManager_get_node_secret_key(const struct LDKKeysManager *NONNULL_PTR this_arg); +void Bolt11InvoiceFeatures_free(struct LDKBolt11InvoiceFeatures this_obj); /** - * Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. + * Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKInMemorySigner KeysManager_derive_channel_keys(const struct LDKKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +void OfferFeatures_free(struct LDKOfferFeatures this_obj); /** - * Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s. - * The resulting inputs will be finalized and the PSBT will be ready for broadcast if there - * are no other inputs that need signing. - * - * Returns `Err(())` if the PSBT is missing a descriptor or if we fail to sign. - * - * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used - * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. + * Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_CVec_u8ZNoneZ KeysManager_sign_spendable_outputs_psbt(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_u8Z psbt); +void InvoiceRequestFeatures_free(struct LDKInvoiceRequestFeatures this_obj); /** - * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an - * output to the given change destination (if sufficient change value remains). The - * transaction will have a feerate, at least, of the given value. - * - * The `locktime` argument is used to set the transaction's locktime. If `None`, the - * transaction will have a locktime of 0. It it recommended to set this to the current block - * height to avoid fee sniping, unless you have some specific reason to use a different - * locktime. - * - * Returns `Err(())` if the output value is greater than the input value minus required fee, - * if a descriptor was duplicated, or if an output descriptor `script_pubkey` - * does not match the one we can spend. - * - * We do not enforce that outputs meet the dust limit or that any output scripts are standard. - * - * May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used - * this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. + * Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ KeysManager_spend_spendable_outputs(const struct LDKKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); +void Bolt12InvoiceFeatures_free(struct LDKBolt12InvoiceFeatures this_obj); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKEntropySource KeysManager_as_EntropySource(const struct LDKKeysManager *NONNULL_PTR this_arg); +void BlindedHopFeatures_free(struct LDKBlindedHopFeatures this_obj); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. */ -struct LDKNodeSigner KeysManager_as_NodeSigner(const struct LDKKeysManager *NONNULL_PTR this_arg); +void ChannelTypeFeatures_free(struct LDKChannelTypeFeatures this_obj); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * Getting a route for a keysend payment to a private node requires providing the payee's + * features (since they were not announced in a node announcement). However, keysend payments + * don't have an invoice to pull the payee's features from, so this method is provided for use + * when a [`Bolt11InvoiceFeatures`] is required in a route. + * + * MPP keysend is not widely supported yet, so we parameterize support to allow the user to + * choose whether their router should find multi-part routes. */ -struct LDKSignerProvider KeysManager_as_SignerProvider(const struct LDKKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_for_keysend(bool allow_mpp); /** - * Frees any resources used by the PhantomKeysManager, if is_owned is set and inner is non-NULL. + * Constructs a ChannelTypeFeatures with only static_remotekey set */ -void PhantomKeysManager_free(struct LDKPhantomKeysManager this_obj); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_only_static_remote_key(void); /** - * Constructs a new EntropySource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is + * Constructs a ChannelTypeFeatures with anchors support */ -struct LDKEntropySource PhantomKeysManager_as_EntropySource(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies(void); /** - * Constructs a new NodeSigner which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned NodeSigner must be freed before this_arg is + * Create a blank Features with no features set */ -struct LDKNodeSigner PhantomKeysManager_as_NodeSigner(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKInitFeatures InitFeatures_empty(void); /** - * Constructs a new SignerProvider which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned SignerProvider must be freed before this_arg is + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKSignerProvider PhantomKeysManager_as_SignerProvider(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKu8slice InitFeatures_le_flags(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a [`PhantomKeysManager`] given a 32-byte seed and an additional `cross_node_seed` - * that is shared across all nodes that intend to participate in [phantom node payments] - * together. - * - * See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and - * `starting_time_nanos`. - * - * `cross_node_seed` must be the same across all phantom payment-receiving nodes and also the - * same across restarts, or else inbound payments may fail. - * - * [phantom node payments]: PhantomKeysManager + * Returns true if this `Features` has any optional flags set */ -MUST_USE_RES struct LDKPhantomKeysManager PhantomKeysManager_new(const uint8_t (*seed)[32], uint64_t starting_time_secs, uint32_t starting_time_nanos, const uint8_t (*cross_node_seed)[32]); +MUST_USE_RES bool InitFeatures_supports_any_optional_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * See [`KeysManager::spend_spendable_outputs`] for documentation on this method. + * Returns true if this `Features` object contains required features unknown by `other`. */ -MUST_USE_RES struct LDKCResult_TransactionNoneZ PhantomKeysManager_spend_spendable_outputs(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); +MUST_USE_RES bool InitFeatures_requires_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * See [`KeysManager::derive_channel_keys`] for documentation on this method. + * Returns the set of required features unknown by `other`, as their bit position. */ -MUST_USE_RES struct LDKInMemorySigner PhantomKeysManager_derive_channel_keys(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg, uint64_t channel_value_satoshis, const uint8_t (*params)[32]); +MUST_USE_RES struct LDKCVec_u64Z InitFeatures_required_unknown_bits_from(const struct LDKInitFeatures *NONNULL_PTR this_arg, const struct LDKInitFeatures *NONNULL_PTR other); /** - * Gets the \"node_id\" secret key used to sign gossip announcements, decode onion data, etc. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_requires_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Gets the \"node_id\" secret key of the phantom node used to sign invoices, decode the - * last-hop onion data, etc. + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES struct LDKSecretKey PhantomKeysManager_get_phantom_node_secret_key(const struct LDKPhantomKeysManager *NONNULL_PTR this_arg); +MUST_USE_RES bool InitFeatures_supports_unknown_bits(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void EcdsaChannelSigner_free(struct LDKEcdsaChannelSigner this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of a WriteableEcdsaChannelSigner + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKWriteableEcdsaChannelSigner WriteableEcdsaChannelSigner_clone(const struct LDKWriteableEcdsaChannelSigner *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_feature_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Calls the free function if one is set + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void WriteableEcdsaChannelSigner_free(struct LDKWriteableEcdsaChannelSigner this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_required_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the OnionMessenger, if is_owned is set and inner is non-NULL. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void OnionMessenger_free(struct LDKOnionMessenger this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ InitFeatures_set_optional_custom_bit(struct LDKInitFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Calls the free function if one is set + * Create a blank Features with no features set */ -void MessageRouter_free(struct LDKMessageRouter this_ptr); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_empty(void); /** - * Frees any resources used by the DefaultMessageRouter, if is_owned is set and inner is non-NULL. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void DefaultMessageRouter_free(struct LDKDefaultMessageRouter this_obj); +MUST_USE_RES struct LDKu8slice NodeFeatures_le_flags(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. + * Returns true if this `Features` has any optional flags set */ -MUST_USE_RES struct LDKDefaultMessageRouter DefaultMessageRouter_new(const struct LDKNetworkGraph *NONNULL_PTR network_graph, struct LDKEntropySource entropy_source); +MUST_USE_RES bool NodeFeatures_supports_any_optional_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new MessageRouter which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned MessageRouter must be freed before this_arg is + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKMessageRouter DefaultMessageRouter_as_MessageRouter(const struct LDKDefaultMessageRouter *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * Frees any resources used by the OnionMessagePath, if is_owned is set and inner is non-NULL. + * Returns the set of required features unknown by `other`, as their bit position. */ -void OnionMessagePath_free(struct LDKOnionMessagePath this_obj); +MUST_USE_RES struct LDKCVec_u64Z NodeFeatures_required_unknown_bits_from(const struct LDKNodeFeatures *NONNULL_PTR this_arg, const struct LDKNodeFeatures *NONNULL_PTR other); /** - * Nodes on the path between the sender and the destination. - * - * Returns a copy of the field. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKCVec_PublicKeyZ OnionMessagePath_get_intermediate_nodes(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Nodes on the path between the sender and the destination. + * Returns true if this `Features` supports any bits which we do not know of */ -void OnionMessagePath_set_intermediate_nodes(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCVec_PublicKeyZ val); +MUST_USE_RES bool NodeFeatures_supports_unknown_bits(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The recipient of the message. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKDestination OnionMessagePath_get_destination(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The recipient of the message. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void OnionMessagePath_set_destination(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKDestination val); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_feature_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * Returns a copy of the field. + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCOption_CVec_SocketAddressZZ OnionMessagePath_get_first_node_addresses(const struct LDKOnionMessagePath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_required_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Addresses that may be used to connect to [`OnionMessagePath::first_node`]. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use - * this to initiate such a connection. + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void OnionMessagePath_set_first_node_addresses(struct LDKOnionMessagePath *NONNULL_PTR this_ptr, struct LDKCOption_CVec_SocketAddressZZ val); +MUST_USE_RES struct LDKCResult_NoneNoneZ NodeFeatures_set_optional_custom_bit(struct LDKNodeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new OnionMessagePath given each field + * Create a blank Features with no features set */ -MUST_USE_RES struct LDKOnionMessagePath OnionMessagePath_new(struct LDKCVec_PublicKeyZ intermediate_nodes_arg, struct LDKDestination destination_arg, struct LDKCOption_CVec_SocketAddressZZ first_node_addresses_arg); +MUST_USE_RES struct LDKChannelFeatures ChannelFeatures_empty(void); /** - * Creates a copy of the OnionMessagePath + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKOnionMessagePath OnionMessagePath_clone(const struct LDKOnionMessagePath *NONNULL_PTR orig); +MUST_USE_RES struct LDKu8slice ChannelFeatures_le_flags(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Returns the first node in the path. + * Returns true if this `Features` has any optional flags set */ -MUST_USE_RES struct LDKPublicKey OnionMessagePath_first_node(const struct LDKOnionMessagePath *NONNULL_PTR this_arg); +MUST_USE_RES bool ChannelFeatures_supports_any_optional_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Destination + * Returns true if this `Features` object contains required features unknown by `other`. */ -void Destination_free(struct LDKDestination this_ptr); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Creates a copy of the Destination + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKDestination Destination_clone(const struct LDKDestination *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u64Z ChannelFeatures_required_unknown_bits_from(const struct LDKChannelFeatures *NONNULL_PTR this_arg, const struct LDKChannelFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Node-variant Destination + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKDestination Destination_node(struct LDKPublicKey a); +MUST_USE_RES bool ChannelFeatures_requires_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BlindedPath-variant Destination + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKDestination Destination_blinded_path(struct LDKBlindedPath a); +MUST_USE_RES bool ChannelFeatures_supports_unknown_bits(const struct LDKChannelFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the SendSuccess + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void SendSuccess_free(struct LDKSendSuccess this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the SendSuccess + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKSendSuccess SendSuccess_clone(const struct LDKSendSuccess *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_feature_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new Buffered-variant SendSuccess + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKSendSuccess SendSuccess_buffered(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_required_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKSendSuccess SendSuccess_buffered_awaiting_connection(struct LDKPublicKey a); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelFeatures_set_optional_custom_bit(struct LDKChannelFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Checks if two SendSuccesss contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Create a blank Features with no features set */ -bool SendSuccess_eq(const struct LDKSendSuccess *NONNULL_PTR a, const struct LDKSendSuccess *NONNULL_PTR b); +MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11InvoiceFeatures_empty(void); /** - * Frees any resources used by the SendError + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void SendError_free(struct LDKSendError this_ptr); +MUST_USE_RES struct LDKu8slice Bolt11InvoiceFeatures_le_flags(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the SendError + * Returns true if this `Features` has any optional flags set */ -struct LDKSendError SendError_clone(const struct LDKSendError *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Secp256k1-variant SendError + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKSendError SendError_secp256k1(enum LDKSecp256k1Error a); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new TooBigPacket-variant SendError + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKSendError SendError_too_big_packet(void); +MUST_USE_RES struct LDKCVec_u64Z Bolt11InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt11InvoiceFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new TooFewBlindedHops-variant SendError + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKSendError SendError_too_few_blinded_hops(void); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidFirstHop-variant SendError + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKSendError SendError_invalid_first_hop(struct LDKPublicKey a); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_unknown_bits(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PathNotFound-variant SendError + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKSendError SendError_path_not_found(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new InvalidMessage-variant SendError + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKSendError SendError_invalid_message(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_feature_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new BufferFull-variant SendError + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKSendError SendError_buffer_full(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_required_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new GetNodeIdFailed-variant SendError + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKSendError SendError_get_node_id_failed(void); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt11InvoiceFeatures_set_optional_custom_bit(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError + * Create a blank Features with no features set */ -struct LDKSendError SendError_blinded_path_advance_failed(void); +MUST_USE_RES struct LDKOfferFeatures OfferFeatures_empty(void); /** - * Checks if two SendErrors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -bool SendError_eq(const struct LDKSendError *NONNULL_PTR a, const struct LDKSendError *NONNULL_PTR b); +MUST_USE_RES struct LDKu8slice OfferFeatures_le_flags(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Returns true if this `Features` has any optional flags set */ -void CustomOnionMessageHandler_free(struct LDKCustomOnionMessageHandler this_ptr); +MUST_USE_RES bool OfferFeatures_supports_any_optional_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PeeledOnion + * Returns true if this `Features` object contains required features unknown by `other`. */ -void PeeledOnion_free(struct LDKPeeledOnion this_ptr); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Creates a copy of the PeeledOnion + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKPeeledOnion PeeledOnion_clone(const struct LDKPeeledOnion *NONNULL_PTR orig); +MUST_USE_RES struct LDKCVec_u64Z OfferFeatures_required_unknown_bits_from(const struct LDKOfferFeatures *NONNULL_PTR this_arg, const struct LDKOfferFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Forward-variant PeeledOnion + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKPeeledOnion PeeledOnion_forward(struct LDKPublicKey a, struct LDKOnionMessage b); +MUST_USE_RES bool OfferFeatures_requires_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new Receive-variant PeeledOnion + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKPeeledOnion PeeledOnion_receive(struct LDKParsedOnionMessageContents a, struct LDKThirtyTwoBytes b, struct LDKBlindedPath c); +MUST_USE_RES bool OfferFeatures_supports_unknown_bits(const struct LDKOfferFeatures *NONNULL_PTR this_arg); /** - * Creates an [`OnionMessage`] with the given `contents` for sending to the destination of - * `path`. + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * Returns the node id of the peer to send the message to, the message itself, and any addresses - * need to connect to the first node. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ create_onion_message(const struct LDKEntropySource *NONNULL_PTR entropy_source, const struct LDKNodeSigner *NONNULL_PTR node_signer, struct LDKOnionMessagePath path, struct LDKOnionMessageContents contents, struct LDKBlindedPath reply_path); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Decode one layer of an incoming [`OnionMessage`]. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. * - * Returns either the next layer of the onion for forwarding or the decrypted content for the - * receiver. - */ -struct LDKCResult_PeeledOnionNoneZ peel_onion_message(const struct LDKOnionMessage *NONNULL_PTR msg, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKCustomOnionMessageHandler custom_handler); - -/** - * Constructs a new `OnionMessenger` to send, forward, and delegate received onion messages to - * their respective handlers. + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKOnionMessenger OnionMessenger_new(struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, struct LDKMessageRouter message_router, struct LDKOffersMessageHandler offers_handler, struct LDKCustomOnionMessageHandler custom_handler); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_feature_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Sends an [`OnionMessage`] with the given `contents` to `destination`. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. * - * See [`OnionMessenger`] for example usage. + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). * - * Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -MUST_USE_RES struct LDKCResult_SendSuccessSendErrorZ OnionMessenger_send_onion_message(const struct LDKOnionMessenger *NONNULL_PTR this_arg, struct LDKOnionMessageContents contents, struct LDKDestination destination, struct LDKBlindedPath reply_path); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_required_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new OnionMessageHandler which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageHandler must be freed before this_arg is + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKOnionMessageHandler OnionMessenger_as_OnionMessageHandler(const struct LDKOnionMessenger *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ OfferFeatures_set_optional_custom_bit(struct LDKOfferFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Calls the free function if one is set + * Create a blank Features with no features set */ -void OffersMessageHandler_free(struct LDKOffersMessageHandler this_ptr); +MUST_USE_RES struct LDKInvoiceRequestFeatures InvoiceRequestFeatures_empty(void); /** - * Frees any resources used by the OffersMessage + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void OffersMessage_free(struct LDKOffersMessage this_ptr); +MUST_USE_RES struct LDKu8slice InvoiceRequestFeatures_le_flags(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the OffersMessage + * Returns true if this `Features` has any optional flags set */ -struct LDKOffersMessage OffersMessage_clone(const struct LDKOffersMessage *NONNULL_PTR orig); +MUST_USE_RES bool InvoiceRequestFeatures_supports_any_optional_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequest-variant OffersMessage + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKOffersMessage OffersMessage_invoice_request(struct LDKInvoiceRequest a); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Invoice-variant OffersMessage + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKOffersMessage OffersMessage_invoice(struct LDKBolt12Invoice a); +MUST_USE_RES struct LDKCVec_u64Z InvoiceRequestFeatures_required_unknown_bits_from(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, const struct LDKInvoiceRequestFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new InvoiceError-variant OffersMessage + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKOffersMessage OffersMessage_invoice_error(struct LDKInvoiceError a); +MUST_USE_RES bool InvoiceRequestFeatures_requires_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Returns whether `tlv_type` corresponds to a TLV record for Offers. + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES bool OffersMessage_is_known_type(uint64_t tlv_type); +MUST_USE_RES bool InvoiceRequestFeatures_supports_unknown_bits(const struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKOnionMessageContents OffersMessage_as_OnionMessageContents(const struct LDKOffersMessage *NONNULL_PTR this_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Serialize the OffersMessage object into a byte array which can be read by OffersMessage_read + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_u8Z OffersMessage_write(const struct LDKOffersMessage *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_feature_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Read a OffersMessage from a byte array, created by OffersMessage_write + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKCResult_OffersMessageDecodeErrorZ OffersMessage_read(struct LDKu8slice ser, uint64_t arg_a, const struct LDKLogger *NONNULL_PTR arg_b); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_required_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the Packet, if is_owned is set and inner is non-NULL. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void Packet_free(struct LDKPacket this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ InvoiceRequestFeatures_set_optional_custom_bit(struct LDKInvoiceRequestFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Bolt 04 version number + * Create a blank Features with no features set */ -uint8_t Packet_get_version(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKBolt12InvoiceFeatures Bolt12InvoiceFeatures_empty(void); /** - * Bolt 04 version number + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void Packet_set_version(struct LDKPacket *NONNULL_PTR this_ptr, uint8_t val); +MUST_USE_RES struct LDKu8slice Bolt12InvoiceFeatures_le_flags(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Returns true if this `Features` has any optional flags set */ -struct LDKPublicKey Packet_get_public_key(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_any_optional_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data + * Returns true if this `Features` object contains required features unknown by `other`. */ -void Packet_set_public_key(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Encrypted payload for the next hop - * - * Returns a copy of the field. + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKCVec_u8Z Packet_get_hop_data(const struct LDKPacket *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u64Z Bolt12InvoiceFeatures_required_unknown_bits_from(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, const struct LDKBolt12InvoiceFeatures *NONNULL_PTR other); /** - * Encrypted payload for the next hop + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void Packet_set_hop_data(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * HMAC to verify the integrity of hop_data + * Returns true if this `Features` supports any bits which we do not know of */ -const uint8_t (*Packet_get_hmac(const struct LDKPacket *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_unknown_bits(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * HMAC to verify the integrity of hop_data + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -void Packet_set_hmac(struct LDKPacket *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Constructs a new Packet given each field + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -MUST_USE_RES struct LDKPacket Packet_new(uint8_t version_arg, struct LDKPublicKey public_key_arg, struct LDKCVec_u8Z hop_data_arg, struct LDKThirtyTwoBytes hmac_arg); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_feature_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of the Packet + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -struct LDKPacket Packet_clone(const struct LDKPacket *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_required_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the Packet. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -uint64_t Packet_hash(const struct LDKPacket *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_NoneNoneZ Bolt12InvoiceFeatures_set_optional_custom_bit(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Checks if two Packets contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Create a blank Features with no features set */ -bool Packet_eq(const struct LDKPacket *NONNULL_PTR a, const struct LDKPacket *NONNULL_PTR b); +MUST_USE_RES struct LDKBlindedHopFeatures BlindedHopFeatures_empty(void); /** - * Serialize the Packet object into a byte array which can be read by Packet_read + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -struct LDKCVec_u8Z Packet_write(const struct LDKPacket *NONNULL_PTR obj); +MUST_USE_RES struct LDKu8slice BlindedHopFeatures_le_flags(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ParsedOnionMessageContents + * Returns true if this `Features` has any optional flags set */ -void ParsedOnionMessageContents_free(struct LDKParsedOnionMessageContents this_ptr); +MUST_USE_RES bool BlindedHopFeatures_supports_any_optional_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ParsedOnionMessageContents + * Returns true if this `Features` object contains required features unknown by `other`. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_clone(const struct LDKParsedOnionMessageContents *NONNULL_PTR orig); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Offers-variant ParsedOnionMessageContents + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_offers(struct LDKOffersMessage a); +MUST_USE_RES struct LDKCVec_u64Z BlindedHopFeatures_required_unknown_bits_from(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, const struct LDKBlindedHopFeatures *NONNULL_PTR other); /** - * Utility method to constructs a new Custom-variant ParsedOnionMessageContents + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -struct LDKParsedOnionMessageContents ParsedOnionMessageContents_custom(struct LDKOnionMessageContents a); +MUST_USE_RES bool BlindedHopFeatures_requires_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Constructs a new OnionMessageContents which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is + * Returns true if this `Features` supports any bits which we do not know of */ -struct LDKOnionMessageContents ParsedOnionMessageContents_as_OnionMessageContents(const struct LDKParsedOnionMessageContents *NONNULL_PTR this_arg); +MUST_USE_RES bool BlindedHopFeatures_supports_unknown_bits(const struct LDKBlindedHopFeatures *NONNULL_PTR this_arg); /** - * Serialize the ParsedOnionMessageContents object into a byte array which can be read by ParsedOnionMessageContents_read + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKCVec_u8Z ParsedOnionMessageContents_write(const struct LDKParsedOnionMessageContents *NONNULL_PTR obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Creates a copy of a OnionMessageContents + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKOnionMessageContents OnionMessageContents_clone(const struct LDKOnionMessageContents *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_feature_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Calls the free function if one is set + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void OnionMessageContents_free(struct LDKOnionMessageContents this_ptr); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_required_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void BlindedPath_free(struct LDKBlindedPath this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ BlindedHopFeatures_set_optional_custom_bit(struct LDKBlindedHopFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * To send to a blinded path, the sender first finds a route to the unblinded - * `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion - * message or payment's next hop and forward it along. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Create a blank Features with no features set */ -struct LDKPublicKey BlindedPath_get_introduction_node_id(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKChannelTypeFeatures ChannelTypeFeatures_empty(void); /** - * To send to a blinded path, the sender first finds a route to the unblinded - * `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion - * message or payment's next hop and forward it along. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order + * from most on-the-wire encodings. */ -void BlindedPath_set_introduction_node_id(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKu8slice ChannelTypeFeatures_le_flags(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion - * message or payment. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns true if this `Features` has any optional flags set */ -struct LDKPublicKey BlindedPath_get_blinding_point(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_supports_any_optional_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion - * message or payment. - * - * [`encrypted_payload`]: BlindedHop::encrypted_payload + * Returns true if this `Features` object contains required features unknown by `other`. */ -void BlindedPath_set_blinding_point(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * The hops composing the blinded path. + * Returns the set of required features unknown by `other`, as their bit position. */ -struct LDKCVec_BlindedHopZ BlindedPath_get_blinded_hops(const struct LDKBlindedPath *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKCVec_u64Z ChannelTypeFeatures_required_unknown_bits_from(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, const struct LDKChannelTypeFeatures *NONNULL_PTR other); /** - * The hops composing the blinded path. + * Returns true if this `Features` object contains unknown feature flags which are set as + * \"required\". */ -void BlindedPath_set_blinded_hops(struct LDKBlindedPath *NONNULL_PTR this_ptr, struct LDKCVec_BlindedHopZ val); +MUST_USE_RES bool ChannelTypeFeatures_requires_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new BlindedPath given each field + * Returns true if this `Features` supports any bits which we do not know of */ -MUST_USE_RES struct LDKBlindedPath BlindedPath_new(struct LDKPublicKey introduction_node_id_arg, struct LDKPublicKey blinding_point_arg, struct LDKCVec_BlindedHopZ blinded_hops_arg); +MUST_USE_RES bool ChannelTypeFeatures_supports_unknown_bits(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BlindedPath + * Sets a required feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -struct LDKBlindedPath BlindedPath_clone(const struct LDKBlindedPath *NONNULL_PTR orig); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Generates a non-cryptographic 64-bit hash of the BlindedPath. + * Sets an optional feature bit. Errors if `bit` is outside the feature range as defined + * by [BOLT 9]. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md */ -uint64_t BlindedPath_hash(const struct LDKBlindedPath *NONNULL_PTR o); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_feature_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Checks if two BlindedPaths contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Required bits are even. If an odd bit is given, then the corresponding even bit will + * be set instead (i.e., `bit - 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -bool BlindedPath_eq(const struct LDKBlindedPath *NONNULL_PTR a, const struct LDKBlindedPath *NONNULL_PTR b); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_required_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * Frees any resources used by the BlindedHop, if is_owned is set and inner is non-NULL. + * Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined + * by [bLIP 2] or if it is a known `T` feature. + * + * Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be + * set instead (i.e., `bit + 1`). + * + * [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits */ -void BlindedHop_free(struct LDKBlindedHop this_obj); +MUST_USE_RES struct LDKCResult_NoneNoneZ ChannelTypeFeatures_set_optional_custom_bit(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg, uintptr_t bit); /** - * The blinded node id of this hop in a [`BlindedPath`]. + * Unsets the `upfront_shutdown_script` feature */ -struct LDKPublicKey BlindedHop_get_blinded_node_id(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_upfront_shutdown_script(struct LDKInitFeatures this_arg); /** - * The blinded node id of this hop in a [`BlindedPath`]. + * Unsets the `upfront_shutdown_script` feature */ -void BlindedHop_set_blinded_node_id(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_upfront_shutdown_script(struct LDKNodeFeatures this_arg); /** - * The encrypted payload intended for this hop in a [`BlindedPath`]. - * - * Returns a copy of the field. + * Unsets the `shutdown_anysegwit` feature */ -struct LDKCVec_u8Z BlindedHop_get_encrypted_payload(const struct LDKBlindedHop *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_shutdown_anysegwit(struct LDKInitFeatures this_arg); /** - * The encrypted payload intended for this hop in a [`BlindedPath`]. + * Unsets the `shutdown_anysegwit` feature */ -void BlindedHop_set_encrypted_payload(struct LDKBlindedHop *NONNULL_PTR this_ptr, struct LDKCVec_u8Z val); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_shutdown_anysegwit(struct LDKNodeFeatures this_arg); /** - * Constructs a new BlindedHop given each field + * Unsets the `wumbo` feature */ -MUST_USE_RES struct LDKBlindedHop BlindedHop_new(struct LDKPublicKey blinded_node_id_arg, struct LDKCVec_u8Z encrypted_payload_arg); +MUST_USE_RES struct LDKInitFeatures InitFeatures_clear_wumbo(struct LDKInitFeatures this_arg); /** - * Creates a copy of the BlindedHop + * Unsets the `wumbo` feature */ -struct LDKBlindedHop BlindedHop_clone(const struct LDKBlindedHop *NONNULL_PTR orig); +MUST_USE_RES struct LDKNodeFeatures NodeFeatures_clear_wumbo(struct LDKNodeFeatures this_arg); /** - * Generates a non-cryptographic 64-bit hash of the BlindedHop. + * Unsets the `scid_privacy` feature */ -uint64_t BlindedHop_hash(const struct LDKBlindedHop *NONNULL_PTR o); +void InitFeatures_clear_scid_privacy(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two BlindedHops contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Unsets the `scid_privacy` feature */ -bool BlindedHop_eq(const struct LDKBlindedHop *NONNULL_PTR a, const struct LDKBlindedHop *NONNULL_PTR b); +void NodeFeatures_clear_scid_privacy(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a one-hop blinded path for a message. + * Unsets the `scid_privacy` feature */ -MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_one_hop_for_message(struct LDKPublicKey recipient_node_id, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void ChannelTypeFeatures_clear_scid_privacy(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node - * pubkey in `node_pks` will be the destination node. - * - * Errors if no hops are provided or if `node_pk`(s) are invalid. + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -MUST_USE_RES struct LDKCResult_BlindedPathNoneZ BlindedPath_new_for_message(struct LDKCVec_PublicKeyZ node_pks, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void InitFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Create a one-hop blinded path for a payment. + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -MUST_USE_RES struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_one_hop_for_payment(struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void NodeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. - * - * Errors if: - * * a provided node id is invalid - * * [`BlindedPayInfo`] calculation results in an integer overflow - * * any unknown features are required in the provided [`ForwardTlvs`] - * - * [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs + * Unsets the `anchors_zero_fee_htlc_tx` feature */ -MUST_USE_RES struct LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ BlindedPath_new_for_payment(struct LDKCVec_ForwardNodeZ intermediate_nodes, struct LDKPublicKey payee_node_id, struct LDKReceiveTlvs payee_tlvs, uint64_t htlc_maximum_msat, const struct LDKEntropySource *NONNULL_PTR entropy_source); +void ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read + * Unsets the `route_blinding` feature */ -struct LDKCVec_u8Z BlindedPath_write(const struct LDKBlindedPath *NONNULL_PTR obj); +void InitFeatures_clear_route_blinding(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a BlindedPath from a byte array, created by BlindedPath_write + * Unsets the `route_blinding` feature */ -struct LDKCResult_BlindedPathDecodeErrorZ BlindedPath_read(struct LDKu8slice ser); +void NodeFeatures_clear_route_blinding(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read + * Set this feature as optional. */ -struct LDKCVec_u8Z BlindedHop_write(const struct LDKBlindedHop *NONNULL_PTR obj); +void InitFeatures_set_data_loss_protect_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a BlindedHop from a byte array, created by BlindedHop_write + * Set this feature as required. */ -struct LDKCResult_BlindedHopDecodeErrorZ BlindedHop_read(struct LDKu8slice ser); +void InitFeatures_set_data_loss_protect_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ForwardNode, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void ForwardNode_free(struct LDKForwardNode this_obj); +MUST_USE_RES bool InitFeatures_supports_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Set this feature as optional. */ -struct LDKForwardTlvs ForwardNode_get_tlvs(const struct LDKForwardNode *NONNULL_PTR this_ptr); +void NodeFeatures_set_data_loss_protect_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also - * used for [`BlindedPayInfo`] construction. + * Set this feature as required. */ -void ForwardNode_set_tlvs(struct LDKForwardNode *NONNULL_PTR this_ptr, struct LDKForwardTlvs val); +void NodeFeatures_set_data_loss_protect_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * This node's pubkey. + * Checks if this feature is supported. */ -struct LDKPublicKey ForwardNode_get_node_id(const struct LDKForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * This node's pubkey. + * Checks if this feature is required. */ -void ForwardNode_set_node_id(struct LDKForwardNode *NONNULL_PTR this_ptr, struct LDKPublicKey val); +MUST_USE_RES bool InitFeatures_requires_data_loss_protect(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The maximum value, in msat, that may be accepted by this node. + * Checks if this feature is required. */ -uint64_t ForwardNode_get_htlc_maximum_msat(const struct LDKForwardNode *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_data_loss_protect(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The maximum value, in msat, that may be accepted by this node. + * Set this feature as optional. */ -void ForwardNode_set_htlc_maximum_msat(struct LDKForwardNode *NONNULL_PTR this_ptr, uint64_t val); +void InitFeatures_set_initial_routing_sync_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ForwardNode given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKForwardNode ForwardNode_new(struct LDKForwardTlvs tlvs_arg, struct LDKPublicKey node_id_arg, uint64_t htlc_maximum_msat_arg); +void InitFeatures_set_initial_routing_sync_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ForwardNode + * Checks if this feature is supported. */ -struct LDKForwardNode ForwardNode_clone(const struct LDKForwardNode *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_initial_routing_sync(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ForwardTlvs, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ForwardTlvs_free(struct LDKForwardTlvs this_obj); +void InitFeatures_set_upfront_shutdown_script_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The short channel id this payment should be forwarded out over. + * Set this feature as required. */ -uint64_t ForwardTlvs_get_short_channel_id(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +void InitFeatures_set_upfront_shutdown_script_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The short channel id this payment should be forwarded out over. + * Checks if this feature is supported. */ -void ForwardTlvs_set_short_channel_id(struct LDKForwardTlvs *NONNULL_PTR this_ptr, uint64_t val); +MUST_USE_RES bool InitFeatures_supports_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Set this feature as optional. */ -struct LDKPaymentRelay ForwardTlvs_get_payment_relay(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +void NodeFeatures_set_upfront_shutdown_script_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Payment parameters for relaying over [`Self::short_channel_id`]. + * Set this feature as required. */ -void ForwardTlvs_set_payment_relay(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentRelay val); +void NodeFeatures_set_upfront_shutdown_script_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Checks if this feature is supported. */ -struct LDKPaymentConstraints ForwardTlvs_get_payment_constraints(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Payment constraints for relaying over [`Self::short_channel_id`]. + * Checks if this feature is required. */ -void ForwardTlvs_set_payment_constraints(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +MUST_USE_RES bool InitFeatures_requires_upfront_shutdown_script(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. - * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload + * Checks if this feature is required. */ -struct LDKBlindedHopFeatures ForwardTlvs_get_features(const struct LDKForwardTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_requires_upfront_shutdown_script(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Supported and required features when relaying a payment onion containing this object's - * corresponding [`BlindedHop::encrypted_payload`]. - * - * [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload + * Set this feature as optional. */ -void ForwardTlvs_set_features(struct LDKForwardTlvs *NONNULL_PTR this_ptr, struct LDKBlindedHopFeatures val); +void InitFeatures_set_gossip_queries_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ForwardTlvs given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKForwardTlvs ForwardTlvs_new(uint64_t short_channel_id_arg, struct LDKPaymentRelay payment_relay_arg, struct LDKPaymentConstraints payment_constraints_arg, struct LDKBlindedHopFeatures features_arg); +void InitFeatures_set_gossip_queries_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ForwardTlvs + * Checks if this feature is supported. */ -struct LDKForwardTlvs ForwardTlvs_clone(const struct LDKForwardTlvs *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_supports_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ReceiveTlvs, if is_owned is set and inner is non-NULL. + * Set this feature as optional. */ -void ReceiveTlvs_free(struct LDKReceiveTlvs this_obj); +void NodeFeatures_set_gossip_queries_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * Set this feature as required. */ -const uint8_t (*ReceiveTlvs_get_payment_secret(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr))[32]; +void NodeFeatures_set_gossip_queries_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. + * Checks if this feature is supported. */ -void ReceiveTlvs_set_payment_secret(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES bool NodeFeatures_supports_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constraints for the receiver of this payment. + * Checks if this feature is required. */ -struct LDKPaymentConstraints ReceiveTlvs_get_payment_constraints(const struct LDKReceiveTlvs *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_requires_gossip_queries(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constraints for the receiver of this payment. + * Checks if this feature is required. */ -void ReceiveTlvs_set_payment_constraints(struct LDKReceiveTlvs *NONNULL_PTR this_ptr, struct LDKPaymentConstraints val); +MUST_USE_RES bool NodeFeatures_requires_gossip_queries(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ReceiveTlvs given each field + * Set this feature as optional. */ -MUST_USE_RES struct LDKReceiveTlvs ReceiveTlvs_new(struct LDKThirtyTwoBytes payment_secret_arg, struct LDKPaymentConstraints payment_constraints_arg); +void InitFeatures_set_variable_length_onion_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ReceiveTlvs + * Set this feature as required. */ -struct LDKReceiveTlvs ReceiveTlvs_clone(const struct LDKReceiveTlvs *NONNULL_PTR orig); +void InitFeatures_set_variable_length_onion_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentRelay, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void PaymentRelay_free(struct LDKPaymentRelay this_obj); +MUST_USE_RES bool InitFeatures_supports_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Set this feature as optional. */ -uint16_t PaymentRelay_get_cltv_expiry_delta(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +void NodeFeatures_set_variable_length_onion_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. + * Set this feature as required. */ -void PaymentRelay_set_cltv_expiry_delta(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint16_t val); +void NodeFeatures_set_variable_length_onion_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Checks if this feature is supported. */ -uint32_t PaymentRelay_get_fee_proportional_millionths(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Liquidity fee charged (in millionths of the amount transferred) for relaying a payment over - * this [`BlindedHop`], (i.e., 10,000 is 1%). + * Set this feature as optional. */ -void PaymentRelay_set_fee_proportional_millionths(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +void Bolt11InvoiceFeatures_set_variable_length_onion_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Set this feature as required. */ -uint32_t PaymentRelay_get_fee_base_msat(const struct LDKPaymentRelay *NONNULL_PTR this_ptr); +void Bolt11InvoiceFeatures_set_variable_length_onion_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Base fee charged (in millisatoshi) for relaying a payment over this [`BlindedHop`]. + * Checks if this feature is supported. */ -void PaymentRelay_set_fee_base_msat(struct LDKPaymentRelay *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Constructs a new PaymentRelay given each field + * Checks if this feature is required. */ -MUST_USE_RES struct LDKPaymentRelay PaymentRelay_new(uint16_t cltv_expiry_delta_arg, uint32_t fee_proportional_millionths_arg, uint32_t fee_base_msat_arg); +MUST_USE_RES bool InitFeatures_requires_variable_length_onion(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentRelay + * Checks if this feature is required. */ -struct LDKPaymentRelay PaymentRelay_clone(const struct LDKPaymentRelay *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_variable_length_onion(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentConstraints, if is_owned is set and inner is non-NULL. + * Checks if this feature is required. */ -void PaymentConstraints_free(struct LDKPaymentConstraints this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_variable_length_onion(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Set this feature as optional. */ -uint32_t PaymentConstraints_get_max_cltv_expiry(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +void InitFeatures_set_static_remote_key_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. + * Set this feature as required. */ -void PaymentConstraints_set_max_cltv_expiry(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint32_t val); +void InitFeatures_set_static_remote_key_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Checks if this feature is supported. */ -uint64_t PaymentConstraints_get_htlc_minimum_msat(const struct LDKPaymentConstraints *NONNULL_PTR this_ptr); +MUST_USE_RES bool InitFeatures_supports_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The minimum value, in msat, that may be accepted by the node corresponding to this - * [`BlindedHop`]. + * Set this feature as optional. */ -void PaymentConstraints_set_htlc_minimum_msat(struct LDKPaymentConstraints *NONNULL_PTR this_ptr, uint64_t val); +void NodeFeatures_set_static_remote_key_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Constructs a new PaymentConstraints given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKPaymentConstraints PaymentConstraints_new(uint32_t max_cltv_expiry_arg, uint64_t htlc_minimum_msat_arg); +void NodeFeatures_set_static_remote_key_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentConstraints + * Checks if this feature is supported. */ -struct LDKPaymentConstraints PaymentConstraints_clone(const struct LDKPaymentConstraints *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read + * Set this feature as optional. */ -struct LDKCVec_u8Z ForwardTlvs_write(const struct LDKForwardTlvs *NONNULL_PTR obj); +void ChannelTypeFeatures_set_static_remote_key_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read + * Set this feature as required. */ -struct LDKCVec_u8Z ReceiveTlvs_write(const struct LDKReceiveTlvs *NONNULL_PTR obj); +void ChannelTypeFeatures_set_static_remote_key_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z PaymentRelay_write(const struct LDKPaymentRelay *NONNULL_PTR obj); +MUST_USE_RES bool ChannelTypeFeatures_supports_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentRelay from a byte array, created by PaymentRelay_write + * Checks if this feature is required. */ -struct LDKCResult_PaymentRelayDecodeErrorZ PaymentRelay_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_static_remote_key(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentConstraints object into a byte array which can be read by PaymentConstraints_read + * Checks if this feature is required. */ -struct LDKCVec_u8Z PaymentConstraints_write(const struct LDKPaymentConstraints *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_requires_static_remote_key(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentConstraints from a byte array, created by PaymentConstraints_write + * Checks if this feature is required. */ -struct LDKCResult_PaymentConstraintsDecodeErrorZ PaymentConstraints_read(struct LDKu8slice ser); +MUST_USE_RES bool ChannelTypeFeatures_requires_static_remote_key(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PaymentPurpose + * Set this feature as optional. */ -void PaymentPurpose_free(struct LDKPaymentPurpose this_ptr); +void InitFeatures_set_payment_secret_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentPurpose + * Set this feature as required. */ -struct LDKPaymentPurpose PaymentPurpose_clone(const struct LDKPaymentPurpose *NONNULL_PTR orig); +void InitFeatures_set_payment_secret_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoicePayment-variant PaymentPurpose + * Checks if this feature is supported. */ -struct LDKPaymentPurpose PaymentPurpose_invoice_payment(struct LDKCOption_ThirtyTwoBytesZ payment_preimage, struct LDKThirtyTwoBytes payment_secret); +MUST_USE_RES bool InitFeatures_supports_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose + * Set this feature as optional. */ -struct LDKPaymentPurpose PaymentPurpose_spontaneous_payment(struct LDKThirtyTwoBytes a); +void NodeFeatures_set_payment_secret_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentPurposes contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool PaymentPurpose_eq(const struct LDKPaymentPurpose *NONNULL_PTR a, const struct LDKPaymentPurpose *NONNULL_PTR b); +void NodeFeatures_set_payment_secret_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the preimage for this payment, if it is known. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKCOption_ThirtyTwoBytesZ PaymentPurpose_preimage(const struct LDKPaymentPurpose *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentPurpose object into a byte array which can be read by PaymentPurpose_read + * Set this feature as optional. */ -struct LDKCVec_u8Z PaymentPurpose_write(const struct LDKPaymentPurpose *NONNULL_PTR obj); +void Bolt11InvoiceFeatures_set_payment_secret_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentPurpose from a byte array, created by PaymentPurpose_write + * Set this feature as required. */ -struct LDKCResult_PaymentPurposeDecodeErrorZ PaymentPurpose_read(struct LDKu8slice ser); +void Bolt11InvoiceFeatures_set_payment_secret_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClaimedHTLC, if is_owned is set and inner is non-NULL. + * Checks if this feature is supported. */ -void ClaimedHTLC_free(struct LDKClaimedHTLC this_obj); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Checks if this feature is required. */ -const uint8_t (*ClaimedHTLC_get_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr))[32]; +MUST_USE_RES bool InitFeatures_requires_payment_secret(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The `channel_id` of the channel over which the HTLC was received. + * Checks if this feature is required. */ -void ClaimedHTLC_set_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKThirtyTwoBytes val); +MUST_USE_RES bool NodeFeatures_requires_payment_secret(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the value - * passed in to [`ChannelManager::create_channel`] for outbound channels, or to - * [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Checks if this feature is required. */ -struct LDKU128 ClaimedHTLC_get_user_channel_id(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_secret(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * The `user_channel_id` of the channel over which the HTLC was received. This is the value - * passed in to [`ChannelManager::create_channel`] for outbound channels, or to - * [`ChannelManager::accept_inbound_channel`] for inbound channels if - * [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise - * `user_channel_id` will be randomized for an inbound channel. - * - * This field will be zero for a payment that was serialized prior to LDK version 0.0.117. (This - * should only happen in the case that a payment was claimable prior to LDK version 0.0.117, but - * was not actually claimed until after upgrading.) - * - * [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel - * [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel - * [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + * Set this feature as optional. */ -void ClaimedHTLC_set_user_channel_id(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, struct LDKU128 val); +void InitFeatures_set_basic_mpp_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Set this feature as required. */ -uint32_t ClaimedHTLC_get_cltv_expiry(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void InitFeatures_set_basic_mpp_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The block height at which this HTLC expires. + * Checks if this feature is supported. */ -void ClaimedHTLC_set_cltv_expiry(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint32_t val); +MUST_USE_RES bool InitFeatures_supports_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Set this feature as optional. */ -uint64_t ClaimedHTLC_get_value_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +void NodeFeatures_set_basic_mpp_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The amount (in msats) of this part of an MPP. + * Set this feature as required. */ -void ClaimedHTLC_set_value_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void NodeFeatures_set_basic_mpp_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Checks if this feature is supported. */ -uint64_t ClaimedHTLC_get_counterparty_skimmed_fee_msat(const struct LDKClaimedHTLC *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The extra fee our counterparty skimmed off the top of this HTLC, if any. - * - * This value will always be 0 for [`ClaimedHTLC`]s serialized with LDK versions prior to - * 0.0.119. + * Set this feature as optional. */ -void ClaimedHTLC_set_counterparty_skimmed_fee_msat(struct LDKClaimedHTLC *NONNULL_PTR this_ptr, uint64_t val); +void Bolt11InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Constructs a new ClaimedHTLC given each field + * Set this feature as required. */ -MUST_USE_RES struct LDKClaimedHTLC ClaimedHTLC_new(struct LDKThirtyTwoBytes channel_id_arg, struct LDKU128 user_channel_id_arg, uint32_t cltv_expiry_arg, uint64_t value_msat_arg, uint64_t counterparty_skimmed_fee_msat_arg); +void Bolt11InvoiceFeatures_set_basic_mpp_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClaimedHTLC + * Checks if this feature is supported. */ -struct LDKClaimedHTLC ClaimedHTLC_clone(const struct LDKClaimedHTLC *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClaimedHTLCs contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as optional. */ -bool ClaimedHTLC_eq(const struct LDKClaimedHTLC *NONNULL_PTR a, const struct LDKClaimedHTLC *NONNULL_PTR b); +void Bolt12InvoiceFeatures_set_basic_mpp_optional(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClaimedHTLC object into a byte array which can be read by ClaimedHTLC_read + * Set this feature as required. */ -struct LDKCVec_u8Z ClaimedHTLC_write(const struct LDKClaimedHTLC *NONNULL_PTR obj); +void Bolt12InvoiceFeatures_set_basic_mpp_required(struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write + * Checks if this feature is supported. */ -struct LDKCResult_ClaimedHTLCDecodeErrorZ ClaimedHTLC_read(struct LDKu8slice ser); +MUST_USE_RES bool Bolt12InvoiceFeatures_supports_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the PathFailure + * Checks if this feature is required. */ -void PathFailure_free(struct LDKPathFailure this_ptr); +MUST_USE_RES bool InitFeatures_requires_basic_mpp(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PathFailure + * Checks if this feature is required. */ -struct LDKPathFailure PathFailure_clone(const struct LDKPathFailure *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_requires_basic_mpp(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InitialSend-variant PathFailure + * Checks if this feature is required. */ -struct LDKPathFailure PathFailure_initial_send(struct LDKAPIError err); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_basic_mpp(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OnPath-variant PathFailure + * Checks if this feature is required. */ -struct LDKPathFailure PathFailure_on_path(struct LDKCOption_NetworkUpdateZ network_update); +MUST_USE_RES bool Bolt12InvoiceFeatures_requires_basic_mpp(const struct LDKBolt12InvoiceFeatures *NONNULL_PTR this_arg); /** - * Checks if two PathFailures contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as optional. */ -bool PathFailure_eq(const struct LDKPathFailure *NONNULL_PTR a, const struct LDKPathFailure *NONNULL_PTR b); +void InitFeatures_set_wumbo_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PathFailure object into a byte array which can be read by PathFailure_read + * Set this feature as required. */ -struct LDKCVec_u8Z PathFailure_write(const struct LDKPathFailure *NONNULL_PTR obj); +void InitFeatures_set_wumbo_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a PathFailure from a byte array, created by PathFailure_write + * Checks if this feature is supported. */ -struct LDKCResult_COption_PathFailureZDecodeErrorZ PathFailure_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_supports_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the ClosureReason + * Set this feature as optional. */ -void ClosureReason_free(struct LDKClosureReason this_ptr); +void NodeFeatures_set_wumbo_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_clone(const struct LDKClosureReason *NONNULL_PTR orig); +void NodeFeatures_set_wumbo_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_counterparty_force_closed(struct LDKUntrustedString peer_msg); +MUST_USE_RES bool NodeFeatures_supports_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HolderForceClosed-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_holder_force_closed(void); +MUST_USE_RES bool InitFeatures_requires_wumbo(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CooperativeClosure-variant ClosureReason + * Checks if this feature is required. */ -struct LDKClosureReason ClosureReason_cooperative_closure(void); +MUST_USE_RES bool NodeFeatures_requires_wumbo(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_commitment_tx_confirmed(void); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingTimedOut-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_funding_timed_out(void); +void InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProcessingError-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_processing_error(struct LDKStr err); +MUST_USE_RES bool InitFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DisconnectedPeer-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_disconnected_peer(void); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OutdatedChannelManager-variant ClosureReason + * Set this feature as required. */ -struct LDKClosureReason ClosureReason_outdated_channel_manager(void); +void NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new CounterpartyCoopClosedUnfundedChannel-variant ClosureReason + * Checks if this feature is supported. */ -struct LDKClosureReason ClosureReason_counterparty_coop_closed_unfunded_channel(void); +MUST_USE_RES bool NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingBatchClosure-variant ClosureReason + * Set this feature as optional. */ -struct LDKClosureReason ClosureReason_funding_batch_closure(void); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Checks if two ClosureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool ClosureReason_eq(const struct LDKClosureReason *NONNULL_PTR a, const struct LDKClosureReason *NONNULL_PTR b); +void ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z ClosureReason_write(const struct LDKClosureReason *NONNULL_PTR obj); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Read a ClosureReason from a byte array, created by ClosureReason_write + * Checks if this feature is required. */ -struct LDKCResult_COption_ClosureReasonZDecodeErrorZ ClosureReason_read(struct LDKu8slice ser); +MUST_USE_RES bool InitFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the HTLCDestination + * Checks if this feature is required. */ -void HTLCDestination_free(struct LDKHTLCDestination this_ptr); +MUST_USE_RES bool NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the HTLCDestination + * Checks if this feature is required. */ -struct LDKHTLCDestination HTLCDestination_clone(const struct LDKHTLCDestination *NONNULL_PTR orig); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new NextHopChannel-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_next_hop_channel(struct LDKPublicKey node_id, struct LDKThirtyTwoBytes channel_id); +void InitFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnknownNextHop-variant HTLCDestination + * Set this feature as required. */ -struct LDKHTLCDestination HTLCDestination_unknown_next_hop(uint64_t requested_forward_scid); +void InitFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvalidForward-variant HTLCDestination + * Checks if this feature is supported. */ -struct LDKHTLCDestination HTLCDestination_invalid_forward(uint64_t requested_forward_scid); +MUST_USE_RES bool InitFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FailedPayment-variant HTLCDestination + * Set this feature as optional. */ -struct LDKHTLCDestination HTLCDestination_failed_payment(struct LDKThirtyTwoBytes payment_hash); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two HTLCDestinations contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool HTLCDestination_eq(const struct LDKHTLCDestination *NONNULL_PTR a, const struct LDKHTLCDestination *NONNULL_PTR b); +void NodeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Serialize the HTLCDestination object into a byte array which can be read by HTLCDestination_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z HTLCDestination_write(const struct LDKHTLCDestination *NONNULL_PTR obj); +MUST_USE_RES bool NodeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a HTLCDestination from a byte array, created by HTLCDestination_write + * Set this feature as optional. */ -struct LDKCResult_COption_HTLCDestinationZDecodeErrorZ HTLCDestination_read(struct LDKu8slice ser); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_clone(const enum LDKPaymentFailureReason *NONNULL_PTR orig); +void ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RecipientRejected-variant PaymentFailureReason + * Checks if this feature is supported. */ -enum LDKPaymentFailureReason PaymentFailureReason_recipient_rejected(void); +MUST_USE_RES bool ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UserAbandoned-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_user_abandoned(void); +MUST_USE_RES bool InitFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RetriesExhausted-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_retries_exhausted(void); +MUST_USE_RES bool NodeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentExpired-variant PaymentFailureReason + * Checks if this feature is required. */ -enum LDKPaymentFailureReason PaymentFailureReason_payment_expired(void); +MUST_USE_RES bool ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new RouteNotFound-variant PaymentFailureReason + * Set this feature as optional. */ -enum LDKPaymentFailureReason PaymentFailureReason_route_not_found(void); +void InitFeatures_set_route_blinding_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UnexpectedError-variant PaymentFailureReason + * Set this feature as required. */ -enum LDKPaymentFailureReason PaymentFailureReason_unexpected_error(void); +void InitFeatures_set_route_blinding_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two PaymentFailureReasons contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Checks if this feature is supported. */ -bool PaymentFailureReason_eq(const enum LDKPaymentFailureReason *NONNULL_PTR a, const enum LDKPaymentFailureReason *NONNULL_PTR b); +MUST_USE_RES bool InitFeatures_supports_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the PaymentFailureReason object into a byte array which can be read by PaymentFailureReason_read + * Set this feature as optional. */ -struct LDKCVec_u8Z PaymentFailureReason_write(const enum LDKPaymentFailureReason *NONNULL_PTR obj); +void NodeFeatures_set_route_blinding_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write + * Set this feature as required. */ -struct LDKCResult_PaymentFailureReasonDecodeErrorZ PaymentFailureReason_read(struct LDKu8slice ser); +void NodeFeatures_set_route_blinding_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the Event + * Checks if this feature is supported. */ -void Event_free(struct LDKEvent this_ptr); +MUST_USE_RES bool NodeFeatures_supports_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the Event + * Checks if this feature is required. */ -struct LDKEvent Event_clone(const struct LDKEvent *NONNULL_PTR orig); +MUST_USE_RES bool InitFeatures_requires_route_blinding(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new FundingGenerationReady-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_funding_generation_ready(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t channel_value_satoshis, struct LDKCVec_u8Z output_script, struct LDKU128 user_channel_id); +MUST_USE_RES bool NodeFeatures_requires_route_blinding(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimable-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_payment_claimable(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, struct LDKRecipientOnionFields onion_fields, uint64_t amount_msat, uint64_t counterparty_skimmed_fee_msat, struct LDKPaymentPurpose purpose, struct LDKCOption_ThirtyTwoBytesZ via_channel_id, struct LDKCOption_U128Z via_user_channel_id, struct LDKCOption_u32Z claim_deadline); +void InitFeatures_set_shutdown_any_segwit_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentClaimed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_claimed(struct LDKPublicKey receiver_node_id, struct LDKThirtyTwoBytes payment_hash, uint64_t amount_msat, struct LDKPaymentPurpose purpose, struct LDKCVec_ClaimedHTLCZ htlcs, struct LDKCOption_u64Z sender_intended_total_msat); +void InitFeatures_set_shutdown_any_segwit_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ConnectionNeeded-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_connection_needed(struct LDKPublicKey node_id, struct LDKCVec_SocketAddressZ addresses); +MUST_USE_RES bool InitFeatures_supports_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new InvoiceRequestFailed-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_invoice_request_failed(struct LDKThirtyTwoBytes payment_id); +void NodeFeatures_set_shutdown_any_segwit_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentSent-variant Event + * Set this feature as required. */ -struct LDKEvent Event_payment_sent(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_preimage, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u64Z fee_paid_msat); +void NodeFeatures_set_shutdown_any_segwit_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentFailed-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_payment_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_PaymentFailureReasonZ reason); +MUST_USE_RES bool NodeFeatures_supports_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathSuccessful-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_path_successful(struct LDKThirtyTwoBytes payment_id, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKPath path); +MUST_USE_RES bool InitFeatures_requires_shutdown_anysegwit(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentPathFailed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_payment_path_failed(struct LDKCOption_ThirtyTwoBytesZ payment_id, struct LDKThirtyTwoBytes payment_hash, bool payment_failed_permanently, struct LDKPathFailure failure, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +MUST_USE_RES bool NodeFeatures_requires_shutdown_anysegwit(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeSuccessful-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_probe_successful(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path); +void InitFeatures_set_taproot_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ProbeFailed-variant Event + * Set this feature as required. */ -struct LDKEvent Event_probe_failed(struct LDKThirtyTwoBytes payment_id, struct LDKThirtyTwoBytes payment_hash, struct LDKPath path, struct LDKCOption_u64Z short_channel_id); +void InitFeatures_set_taproot_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PendingHTLCsForwardable-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_pending_htlcs_forwardable(uint64_t time_forwardable); +MUST_USE_RES bool InitFeatures_supports_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCIntercepted-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_htlcintercepted(struct LDKThirtyTwoBytes intercept_id, uint64_t requested_next_hop_scid, struct LDKThirtyTwoBytes payment_hash, uint64_t inbound_amount_msat, uint64_t expected_outbound_amount_msat); +void NodeFeatures_set_taproot_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SpendableOutputs-variant Event + * Set this feature as required. */ -struct LDKEvent Event_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ outputs, struct LDKCOption_ThirtyTwoBytesZ channel_id); +void NodeFeatures_set_taproot_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new PaymentForwarded-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_payment_forwarded(struct LDKCOption_ThirtyTwoBytesZ prev_channel_id, struct LDKCOption_ThirtyTwoBytesZ next_channel_id, struct LDKCOption_u64Z fee_earned_msat, bool claim_from_onchain_tx, struct LDKCOption_u64Z outbound_amount_forwarded_msat); +MUST_USE_RES bool NodeFeatures_supports_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelPending-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_channel_pending(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKCOption_ThirtyTwoBytesZ former_temporary_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKOutPoint funding_txo); +void ChannelTypeFeatures_set_taproot_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelReady-variant Event + * Set this feature as required. */ -struct LDKEvent Event_channel_ready(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKPublicKey counterparty_node_id, struct LDKChannelTypeFeatures channel_type); +void ChannelTypeFeatures_set_taproot_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClosed-variant Event + * Checks if this feature is supported. */ -struct LDKEvent Event_channel_closed(struct LDKThirtyTwoBytes channel_id, struct LDKU128 user_channel_id, struct LDKClosureReason reason, struct LDKPublicKey counterparty_node_id, struct LDKCOption_u64Z channel_capacity_sats, struct LDKOutPoint channel_funding_txo); +MUST_USE_RES bool ChannelTypeFeatures_supports_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new DiscardFunding-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_discard_funding(struct LDKThirtyTwoBytes channel_id, struct LDKTransaction transaction); +MUST_USE_RES bool InitFeatures_requires_taproot(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new OpenChannelRequest-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_open_channel_request(struct LDKThirtyTwoBytes temporary_channel_id, struct LDKPublicKey counterparty_node_id, uint64_t funding_satoshis, uint64_t push_msat, struct LDKChannelTypeFeatures channel_type); +MUST_USE_RES bool NodeFeatures_requires_taproot(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HTLCHandlingFailed-variant Event + * Checks if this feature is required. */ -struct LDKEvent Event_htlchandling_failed(struct LDKThirtyTwoBytes prev_channel_id, struct LDKHTLCDestination failed_next_destination); +MUST_USE_RES bool ChannelTypeFeatures_requires_taproot(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BumpTransaction-variant Event + * Set this feature as optional. */ -struct LDKEvent Event_bump_transaction(struct LDKBumpTransactionEvent a); +void InitFeatures_set_onion_messages_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Checks if two Events contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Set this feature as required. */ -bool Event_eq(const struct LDKEvent *NONNULL_PTR a, const struct LDKEvent *NONNULL_PTR b); +void InitFeatures_set_onion_messages_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Serialize the Event object into a byte array which can be read by Event_read + * Checks if this feature is supported. */ -struct LDKCVec_u8Z Event_write(const struct LDKEvent *NONNULL_PTR obj); +MUST_USE_RES bool InitFeatures_supports_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Read a Event from a byte array, created by Event_write + * Set this feature as optional. */ -struct LDKCResult_COption_EventZDecodeErrorZ Event_read(struct LDKu8slice ser); +void NodeFeatures_set_onion_messages_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the MessageSendEvent + * Set this feature as required. */ -void MessageSendEvent_free(struct LDKMessageSendEvent this_ptr); +void NodeFeatures_set_onion_messages_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_clone(const struct LDKMessageSendEvent *NONNULL_PTR orig); +MUST_USE_RES bool NodeFeatures_supports_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannel-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel(struct LDKPublicKey node_id, struct LDKAcceptChannel msg); +MUST_USE_RES bool InitFeatures_requires_onion_messages(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAcceptChannelV2-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_accept_channel_v2(struct LDKPublicKey node_id, struct LDKAcceptChannelV2 msg); +MUST_USE_RES bool NodeFeatures_requires_onion_messages(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannel-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel(struct LDKPublicKey node_id, struct LDKOpenChannel msg); +void InitFeatures_set_channel_type_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendOpenChannelV2-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_open_channel_v2(struct LDKPublicKey node_id, struct LDKOpenChannelV2 msg); +void InitFeatures_set_channel_type_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingCreated-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_created(struct LDKPublicKey node_id, struct LDKFundingCreated msg); +MUST_USE_RES bool InitFeatures_supports_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendFundingSigned-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_funding_signed(struct LDKPublicKey node_id, struct LDKFundingSigned msg); +void NodeFeatures_set_channel_type_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendStfu-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_stfu(struct LDKPublicKey node_id, struct LDKStfu msg); +void NodeFeatures_set_channel_type_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSplice-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice(struct LDKPublicKey node_id, struct LDKSplice msg); +MUST_USE_RES bool NodeFeatures_supports_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceAck-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_ack(struct LDKPublicKey node_id, struct LDKSpliceAck msg); +MUST_USE_RES bool InitFeatures_requires_channel_type(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendSpliceLocked-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_splice_locked(struct LDKPublicKey node_id, struct LDKSpliceLocked msg); +MUST_USE_RES bool NodeFeatures_requires_channel_type(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddInput-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_input(struct LDKPublicKey node_id, struct LDKTxAddInput msg); +void InitFeatures_set_scid_privacy_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAddOutput-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_add_output(struct LDKPublicKey node_id, struct LDKTxAddOutput msg); +void InitFeatures_set_scid_privacy_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveInput-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_input(struct LDKPublicKey node_id, struct LDKTxRemoveInput msg); +MUST_USE_RES bool InitFeatures_supports_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxRemoveOutput-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_remove_output(struct LDKPublicKey node_id, struct LDKTxRemoveOutput msg); +void NodeFeatures_set_scid_privacy_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxComplete-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_complete(struct LDKPublicKey node_id, struct LDKTxComplete msg); +void NodeFeatures_set_scid_privacy_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxSignatures-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_signatures(struct LDKPublicKey node_id, struct LDKTxSignatures msg); +MUST_USE_RES bool NodeFeatures_supports_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxInitRbf-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_init_rbf(struct LDKPublicKey node_id, struct LDKTxInitRbf msg); +void ChannelTypeFeatures_set_scid_privacy_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAckRbf-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_ack_rbf(struct LDKPublicKey node_id, struct LDKTxAckRbf msg); +void ChannelTypeFeatures_set_scid_privacy_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendTxAbort-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_tx_abort(struct LDKPublicKey node_id, struct LDKTxAbort msg); +MUST_USE_RES bool ChannelTypeFeatures_supports_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReady-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_ready(struct LDKPublicKey node_id, struct LDKChannelReady msg); +MUST_USE_RES bool InitFeatures_requires_scid_privacy(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendAnnouncementSignatures-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_announcement_signatures(struct LDKPublicKey node_id, struct LDKAnnouncementSignatures msg); +MUST_USE_RES bool NodeFeatures_requires_scid_privacy(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new UpdateHTLCs-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_update_htlcs(struct LDKPublicKey node_id, struct LDKCommitmentUpdate updates); +MUST_USE_RES bool ChannelTypeFeatures_requires_scid_privacy(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendRevokeAndACK-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_revoke_and_ack(struct LDKPublicKey node_id, struct LDKRevokeAndACK msg); +void Bolt11InvoiceFeatures_set_payment_metadata_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendClosingSigned-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_closing_signed(struct LDKPublicKey node_id, struct LDKClosingSigned msg); +void Bolt11InvoiceFeatures_set_payment_metadata_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShutdown-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_shutdown(struct LDKPublicKey node_id, struct LDKShutdown msg); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelReestablish-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_reestablish(struct LDKPublicKey node_id, struct LDKChannelReestablish msg); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_payment_metadata(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_announcement(struct LDKPublicKey node_id, struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_zero_conf_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelAnnouncement-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_announcement(struct LDKChannelAnnouncement msg, struct LDKChannelUpdate update_msg); +void InitFeatures_set_zero_conf_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastChannelUpdate-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_channel_update(struct LDKChannelUpdate msg); +MUST_USE_RES bool InitFeatures_supports_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new BroadcastNodeAnnouncement-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_broadcast_node_announcement(struct LDKNodeAnnouncement msg); +void NodeFeatures_set_zero_conf_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelUpdate-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_update(struct LDKPublicKey node_id, struct LDKChannelUpdate msg); +void NodeFeatures_set_zero_conf_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new HandleError-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_handle_error(struct LDKPublicKey node_id, struct LDKErrorAction action); +MUST_USE_RES bool NodeFeatures_supports_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendChannelRangeQuery-variant MessageSendEvent + * Set this feature as optional. */ -struct LDKMessageSendEvent MessageSendEvent_send_channel_range_query(struct LDKPublicKey node_id, struct LDKQueryChannelRange msg); +void ChannelTypeFeatures_set_zero_conf_optional(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendShortIdsQuery-variant MessageSendEvent + * Set this feature as required. */ -struct LDKMessageSendEvent MessageSendEvent_send_short_ids_query(struct LDKPublicKey node_id, struct LDKQueryShortChannelIds msg); +void ChannelTypeFeatures_set_zero_conf_required(struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendReplyChannelRange-variant MessageSendEvent + * Checks if this feature is supported. */ -struct LDKMessageSendEvent MessageSendEvent_send_reply_channel_range(struct LDKPublicKey node_id, struct LDKReplyChannelRange msg); +MUST_USE_RES bool ChannelTypeFeatures_supports_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new SendGossipTimestampFilter-variant MessageSendEvent + * Checks if this feature is required. */ -struct LDKMessageSendEvent MessageSendEvent_send_gossip_timestamp_filter(struct LDKPublicKey node_id, struct LDKGossipTimestampFilter msg); +MUST_USE_RES bool InitFeatures_requires_zero_conf(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is required. */ -void MessageSendEventsProvider_free(struct LDKMessageSendEventsProvider this_ptr); +MUST_USE_RES bool NodeFeatures_requires_zero_conf(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Checks if this feature is required. */ -void EventsProvider_free(struct LDKEventsProvider this_ptr); +MUST_USE_RES bool ChannelTypeFeatures_requires_zero_conf(const struct LDKChannelTypeFeatures *NONNULL_PTR this_arg); /** - * Calls the free function if one is set + * Set this feature as optional. */ -void EventHandler_free(struct LDKEventHandler this_ptr); +void NodeFeatures_set_keysend_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the AnchorDescriptor, if is_owned is set and inner is non-NULL. + * Set this feature as required. */ -void AnchorDescriptor_free(struct LDKAnchorDescriptor this_obj); +void NodeFeatures_set_keysend_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Checks if this feature is supported. */ -struct LDKChannelDerivationParameters AnchorDescriptor_get_channel_derivation_parameters(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +MUST_USE_RES bool NodeFeatures_supports_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The parameters required to derive the signer for the anchor input. + * Checks if this feature is required. */ -void AnchorDescriptor_set_channel_derivation_parameters(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKChannelDerivationParameters val); +MUST_USE_RES bool NodeFeatures_requires_keysend(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as optional. */ -struct LDKOutPoint AnchorDescriptor_get_outpoint(const struct LDKAnchorDescriptor *NONNULL_PTR this_ptr); +void InitFeatures_set_trampoline_routing_optional(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * The transaction input's outpoint corresponding to the commitment transaction's anchor - * output. + * Set this feature as required. */ -void AnchorDescriptor_set_outpoint(struct LDKAnchorDescriptor *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void InitFeatures_set_trampoline_routing_required(struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Constructs a new AnchorDescriptor given each field + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKAnchorDescriptor AnchorDescriptor_new(struct LDKChannelDerivationParameters channel_derivation_parameters_arg, struct LDKOutPoint outpoint_arg); +MUST_USE_RES bool InitFeatures_supports_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the AnchorDescriptor + * Set this feature as optional. */ -struct LDKAnchorDescriptor AnchorDescriptor_clone(const struct LDKAnchorDescriptor *NONNULL_PTR orig); +void NodeFeatures_set_trampoline_routing_optional(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Checks if two AnchorDescriptors contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * Set this feature as required. */ -bool AnchorDescriptor_eq(const struct LDKAnchorDescriptor *NONNULL_PTR a, const struct LDKAnchorDescriptor *NONNULL_PTR b); +void NodeFeatures_set_trampoline_routing_required(struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the UTXO to be spent by the anchor input, which can be obtained via - * [`Self::unsigned_tx_input`]. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKTxOut AnchorDescriptor_previous_utxo(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +MUST_USE_RES bool NodeFeatures_supports_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Returns the unsigned transaction input spending the anchor output in the commitment - * transaction. + * Set this feature as optional. */ -MUST_USE_RES struct LDKTxIn AnchorDescriptor_unsigned_tx_input(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +void Bolt11InvoiceFeatures_set_trampoline_routing_optional(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns the witness script of the anchor output in the commitment transaction. + * Set this feature as required. */ -MUST_USE_RES struct LDKCVec_u8Z AnchorDescriptor_witness_script(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg); +void Bolt11InvoiceFeatures_set_trampoline_routing_required(struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Returns the fully signed witness required to spend the anchor output in the commitment - * transaction. + * Checks if this feature is supported. */ -MUST_USE_RES struct LDKWitness AnchorDescriptor_tx_input_witness(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, struct LDKECDSASignature signature); +MUST_USE_RES bool Bolt11InvoiceFeatures_supports_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Derives the channel signer required to sign the anchor input. + * Checks if this feature is required. */ -MUST_USE_RES struct LDKWriteableEcdsaChannelSigner AnchorDescriptor_derive_channel_signer(const struct LDKAnchorDescriptor *NONNULL_PTR this_arg, const struct LDKSignerProvider *NONNULL_PTR signer_provider); +MUST_USE_RES bool InitFeatures_requires_trampoline_routing(const struct LDKInitFeatures *NONNULL_PTR this_arg); /** - * Frees any resources used by the BumpTransactionEvent + * Checks if this feature is required. */ -void BumpTransactionEvent_free(struct LDKBumpTransactionEvent this_ptr); +MUST_USE_RES bool NodeFeatures_requires_trampoline_routing(const struct LDKNodeFeatures *NONNULL_PTR this_arg); /** - * Creates a copy of the BumpTransactionEvent + * Checks if this feature is required. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_clone(const struct LDKBumpTransactionEvent *NONNULL_PTR orig); +MUST_USE_RES bool Bolt11InvoiceFeatures_requires_trampoline_routing(const struct LDKBolt11InvoiceFeatures *NONNULL_PTR this_arg); /** - * Utility method to constructs a new ChannelClose-variant BumpTransactionEvent + * Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_channel_close(struct LDKThirtyTwoBytes claim_id, uint32_t package_target_feerate_sat_per_1000_weight, struct LDKTransaction commitment_tx, uint64_t commitment_tx_fee_satoshis, struct LDKAnchorDescriptor anchor_descriptor, struct LDKCVec_HTLCOutputInCommitmentZ pending_htlcs); +void RoutingFees_free(struct LDKRoutingFees this_obj); /** - * Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent + * Flat routing fee in millisatoshis. */ -struct LDKBumpTransactionEvent BumpTransactionEvent_htlcresolution(struct LDKThirtyTwoBytes claim_id, uint32_t target_feerate_sat_per_1000_weight, struct LDKCVec_HTLCDescriptorZ htlc_descriptors, uint32_t tx_lock_time); +uint32_t RoutingFees_get_base_msat(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * Checks if two BumpTransactionEvents contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. + * Flat routing fee in millisatoshis. */ -bool BumpTransactionEvent_eq(const struct LDKBumpTransactionEvent *NONNULL_PTR a, const struct LDKBumpTransactionEvent *NONNULL_PTR b); +void RoutingFees_set_base_msat(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * Frees any resources used by the Input, if is_owned is set and inner is non-NULL. + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -void Input_free(struct LDKInput this_obj); +uint32_t RoutingFees_get_proportional_millionths(const struct LDKRoutingFees *NONNULL_PTR this_ptr); /** - * The unique identifier of the input. + * Liquidity-based routing fee in millionths of a routed amount. + * In other words, 10000 is 1%. */ -struct LDKOutPoint Input_get_outpoint(const struct LDKInput *NONNULL_PTR this_ptr); +void RoutingFees_set_proportional_millionths(struct LDKRoutingFees *NONNULL_PTR this_ptr, uint32_t val); /** - * The unique identifier of the input. + * Constructs a new RoutingFees given each field */ -void Input_set_outpoint(struct LDKInput *NONNULL_PTR this_ptr, struct LDKOutPoint val); +MUST_USE_RES struct LDKRoutingFees RoutingFees_new(uint32_t base_msat_arg, uint32_t proportional_millionths_arg); /** - * The UTXO being spent by the input. + * Checks if two RoutingFeess contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -struct LDKTxOut Input_get_previous_utxo(const struct LDKInput *NONNULL_PTR this_ptr); +bool RoutingFees_eq(const struct LDKRoutingFees *NONNULL_PTR a, const struct LDKRoutingFees *NONNULL_PTR b); /** - * The UTXO being spent by the input. + * Creates a copy of the RoutingFees */ -void Input_set_previous_utxo(struct LDKInput *NONNULL_PTR this_ptr, struct LDKTxOut val); +struct LDKRoutingFees RoutingFees_clone(const struct LDKRoutingFees *NONNULL_PTR orig); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and - * [`TxIn::witness`], each with their lengths included, required to satisfy the output's - * script. + * Generates a non-cryptographic 64-bit hash of the RoutingFees. */ -uint64_t Input_get_satisfaction_weight(const struct LDKInput *NONNULL_PTR this_ptr); +uint64_t RoutingFees_hash(const struct LDKRoutingFees *NONNULL_PTR o); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and - * [`TxIn::witness`], each with their lengths included, required to satisfy the output's - * script. + * Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. */ -void Input_set_satisfaction_weight(struct LDKInput *NONNULL_PTR this_ptr, uint64_t val); +void RouteHint_free(struct LDKRouteHint this_obj); + +struct LDKCVec_RouteHintHopZ RouteHint_get_a(const struct LDKRouteHint *NONNULL_PTR this_ptr); + +void RouteHint_set_a(struct LDKRouteHint *NONNULL_PTR this_ptr, struct LDKCVec_RouteHintHopZ val); /** - * Constructs a new Input given each field + * Constructs a new RouteHint given each field */ -MUST_USE_RES struct LDKInput Input_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut previous_utxo_arg, uint64_t satisfaction_weight_arg); +MUST_USE_RES struct LDKRouteHint RouteHint_new(struct LDKCVec_RouteHintHopZ a_arg); /** - * Creates a copy of the Input + * Creates a copy of the RouteHint */ -struct LDKInput Input_clone(const struct LDKInput *NONNULL_PTR orig); +struct LDKRouteHint RouteHint_clone(const struct LDKRouteHint *NONNULL_PTR orig); /** - * Generates a non-cryptographic 64-bit hash of the Input. + * Generates a non-cryptographic 64-bit hash of the RouteHint. */ -uint64_t Input_hash(const struct LDKInput *NONNULL_PTR o); +uint64_t RouteHint_hash(const struct LDKRouteHint *NONNULL_PTR o); /** - * Checks if two Inputs contain equal inner contents. + * Checks if two RouteHints contain equal inner contents. * This ignores pointers and is_owned flags and looks at the values in fields. * Two objects with NULL inner values will be considered "equal" here. */ -bool Input_eq(const struct LDKInput *NONNULL_PTR a, const struct LDKInput *NONNULL_PTR b); +bool RouteHint_eq(const struct LDKRouteHint *NONNULL_PTR a, const struct LDKRouteHint *NONNULL_PTR b); /** - * Frees any resources used by the Utxo, if is_owned is set and inner is non-NULL. + * Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. */ -void Utxo_free(struct LDKUtxo this_obj); +void RouteHintHop_free(struct LDKRouteHintHop this_obj); /** - * The unique identifier of the output. + * The node_id of the non-target end of the route */ -struct LDKOutPoint Utxo_get_outpoint(const struct LDKUtxo *NONNULL_PTR this_ptr); +struct LDKPublicKey RouteHintHop_get_src_node_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The unique identifier of the output. + * The node_id of the non-target end of the route */ -void Utxo_set_outpoint(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKOutPoint val); +void RouteHintHop_set_src_node_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKPublicKey val); /** - * The output to spend. + * The short_channel_id of this channel */ -struct LDKTxOut Utxo_get_output(const struct LDKUtxo *NONNULL_PTR this_ptr); +uint64_t RouteHintHop_get_short_channel_id(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The output to spend. + * The short_channel_id of this channel */ -void Utxo_set_output(struct LDKUtxo *NONNULL_PTR this_ptr, struct LDKTxOut val); +void RouteHintHop_set_short_channel_id(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint64_t val); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each - * with their lengths included, required to satisfy the output's script. The weight consumed by - * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + * The fees which must be paid to use this channel */ -uint64_t Utxo_get_satisfaction_weight(const struct LDKUtxo *NONNULL_PTR this_ptr); +struct LDKRoutingFees RouteHintHop_get_fees(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * The upper-bound weight consumed by the input's full [`TxIn::script_sig`] and [`TxIn::witness`], each - * with their lengths included, required to satisfy the output's script. The weight consumed by - * the input's `script_sig` must account for [`WITNESS_SCALE_FACTOR`]. + * The fees which must be paid to use this channel */ -void Utxo_set_satisfaction_weight(struct LDKUtxo *NONNULL_PTR this_ptr, uint64_t val); +void RouteHintHop_set_fees(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKRoutingFees val); /** - * Constructs a new Utxo given each field + * The difference in CLTV values between this node and the next node. */ -MUST_USE_RES struct LDKUtxo Utxo_new(struct LDKOutPoint outpoint_arg, struct LDKTxOut output_arg, uint64_t satisfaction_weight_arg); +uint16_t RouteHintHop_get_cltv_expiry_delta(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Creates a copy of the Utxo + * The difference in CLTV values between this node and the next node. */ -struct LDKUtxo Utxo_clone(const struct LDKUtxo *NONNULL_PTR orig); +void RouteHintHop_set_cltv_expiry_delta(struct LDKRouteHintHop *NONNULL_PTR this_ptr, uint16_t val); /** - * Generates a non-cryptographic 64-bit hash of the Utxo. + * The minimum value, in msat, which must be relayed to the next hop. */ -uint64_t Utxo_hash(const struct LDKUtxo *NONNULL_PTR o); +struct LDKCOption_u64Z RouteHintHop_get_htlc_minimum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Checks if two Utxos contain equal inner contents. - * This ignores pointers and is_owned flags and looks at the values in fields. - * Two objects with NULL inner values will be considered "equal" here. + * The minimum value, in msat, which must be relayed to the next hop. */ -bool Utxo_eq(const struct LDKUtxo *NONNULL_PTR a, const struct LDKUtxo *NONNULL_PTR b); +void RouteHintHop_set_htlc_minimum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * Returns a `Utxo` with the `satisfaction_weight` estimate for a legacy P2PKH output. + * The maximum value in msat available for routing with a single HTLC. */ -MUST_USE_RES struct LDKUtxo Utxo_new_p2pkh(struct LDKOutPoint outpoint, uint64_t value, const uint8_t (*pubkey_hash)[20]); +struct LDKCOption_u64Z RouteHintHop_get_htlc_maximum_msat(const struct LDKRouteHintHop *NONNULL_PTR this_ptr); /** - * Frees any resources used by the CoinSelection, if is_owned is set and inner is non-NULL. + * The maximum value in msat available for routing with a single HTLC. */ -void CoinSelection_free(struct LDKCoinSelection this_obj); +void RouteHintHop_set_htlc_maximum_msat(struct LDKRouteHintHop *NONNULL_PTR this_ptr, struct LDKCOption_u64Z val); /** - * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Constructs a new RouteHintHop given each field */ -struct LDKCVec_UtxoZ CoinSelection_get_confirmed_utxos(const struct LDKCoinSelection *NONNULL_PTR this_ptr); +MUST_USE_RES struct LDKRouteHintHop RouteHintHop_new(struct LDKPublicKey src_node_id_arg, uint64_t short_channel_id_arg, struct LDKRoutingFees fees_arg, uint16_t cltv_expiry_delta_arg, struct LDKCOption_u64Z htlc_minimum_msat_arg, struct LDKCOption_u64Z htlc_maximum_msat_arg); /** - * The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction - * requiring additional fees. + * Creates a copy of the RouteHintHop */ -void CoinSelection_set_confirmed_utxos(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCVec_UtxoZ val); +struct LDKRouteHintHop RouteHintHop_clone(const struct LDKRouteHintHop *NONNULL_PTR orig); /** - * An additional output tracking whether any change remained after coin selection. This output - * should always have a value above dust for its given `script_pubkey`. It should not be - * spent until the transaction it belongs to confirms to ensure mempool descendant limits are - * not met. This implies no other party should be able to spend it except us. + * Generates a non-cryptographic 64-bit hash of the RouteHintHop. */ -struct LDKCOption_TxOutZ CoinSelection_get_change_output(const struct LDKCoinSelection *NONNULL_PTR this_ptr); +uint64_t RouteHintHop_hash(const struct LDKRouteHintHop *NONNULL_PTR o); /** - * An additional output tracking whether any change remained after coin selection. This output - * should always have a value above dust for its given `script_pubkey`. It should not be - * spent until the transaction it belongs to confirms to ensure mempool descendant limits are - * not met. This implies no other party should be able to spend it except us. + * Checks if two RouteHintHops contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void CoinSelection_set_change_output(struct LDKCoinSelection *NONNULL_PTR this_ptr, struct LDKCOption_TxOutZ val); +bool RouteHintHop_eq(const struct LDKRouteHintHop *NONNULL_PTR a, const struct LDKRouteHintHop *NONNULL_PTR b); /** - * Constructs a new CoinSelection given each field + * Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. */ -MUST_USE_RES struct LDKCoinSelection CoinSelection_new(struct LDKCVec_UtxoZ confirmed_utxos_arg, struct LDKCOption_TxOutZ change_output_arg); +void UntrustedString_free(struct LDKUntrustedString this_obj); -/** - * Creates a copy of the CoinSelection - */ -struct LDKCoinSelection CoinSelection_clone(const struct LDKCoinSelection *NONNULL_PTR orig); +struct LDKStr UntrustedString_get_a(const struct LDKUntrustedString *NONNULL_PTR this_ptr); + +void UntrustedString_set_a(struct LDKUntrustedString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Calls the free function if one is set + * Constructs a new UntrustedString given each field */ -void CoinSelectionSource_free(struct LDKCoinSelectionSource this_ptr); +MUST_USE_RES struct LDKUntrustedString UntrustedString_new(struct LDKStr a_arg); /** - * Calls the free function if one is set + * Creates a copy of the UntrustedString */ -void WalletSource_free(struct LDKWalletSource this_ptr); +struct LDKUntrustedString UntrustedString_clone(const struct LDKUntrustedString *NONNULL_PTR orig); /** - * Frees any resources used by the Wallet, if is_owned is set and inner is non-NULL. + * Checks if two UntrustedStrings contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. */ -void Wallet_free(struct LDKWallet this_obj); +bool UntrustedString_eq(const struct LDKUntrustedString *NONNULL_PTR a, const struct LDKUntrustedString *NONNULL_PTR b); /** - * Returns a new instance backed by the given [`WalletSource`] that serves as an implementation - * of [`CoinSelectionSource`]. + * Generates a non-cryptographic 64-bit hash of the UntrustedString. */ -MUST_USE_RES struct LDKWallet Wallet_new(struct LDKWalletSource source, struct LDKLogger logger); +uint64_t UntrustedString_hash(const struct LDKUntrustedString *NONNULL_PTR o); /** - * Constructs a new CoinSelectionSource which calls the relevant methods on this_arg. - * This copies the `inner` pointer in this_arg and thus the returned CoinSelectionSource must be freed before this_arg is + * Get the string representation of a UntrustedString object */ -struct LDKCoinSelectionSource Wallet_as_CoinSelectionSource(const struct LDKWallet *NONNULL_PTR this_arg); +struct LDKStr UntrustedString_to_str(const struct LDKUntrustedString *NONNULL_PTR o); /** - * Frees any resources used by the BumpTransactionEventHandler, if is_owned is set and inner is non-NULL. + * Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. */ -void BumpTransactionEventHandler_free(struct LDKBumpTransactionEventHandler this_obj); +void PrintableString_free(struct LDKPrintableString this_obj); + +struct LDKStr PrintableString_get_a(const struct LDKPrintableString *NONNULL_PTR this_ptr); + +void PrintableString_set_a(struct LDKPrintableString *NONNULL_PTR this_ptr, struct LDKStr val); /** - * Returns a new instance capable of handling [`Event::BumpTransaction`] events. - * - * [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction + * Constructs a new PrintableString given each field */ -MUST_USE_RES struct LDKBumpTransactionEventHandler BumpTransactionEventHandler_new(struct LDKBroadcasterInterface broadcaster, struct LDKCoinSelectionSource utxo_source, struct LDKSignerProvider signer_provider, struct LDKLogger logger); +MUST_USE_RES struct LDKPrintableString PrintableString_new(struct LDKStr a_arg); /** - * Handles all variants of [`BumpTransactionEvent`]. + * Get the string representation of a PrintableString object */ -void BumpTransactionEventHandler_handle_event(const struct LDKBumpTransactionEventHandler *NONNULL_PTR this_arg, const struct LDKBumpTransactionEvent *NONNULL_PTR event); +struct LDKStr PrintableString_to_str(const struct LDKPrintableString *NONNULL_PTR o); /** * Frees any resources used by the FilesystemStore, if is_owned is set and inner is non-NULL. @@ -49986,7 +60208,7 @@ struct LDKGossipSync GossipSync_none(void); * [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph * [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable */ -MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); +MUST_USE_RES struct LDKBackgroundProcessor BackgroundProcessor_start(struct LDKPersister persister, struct LDKEventHandler event_handler, const struct LDKChainMonitor *NONNULL_PTR chain_monitor, const struct LDKChannelManager *NONNULL_PTR channel_manager, const struct LDKOnionMessenger *NONNULL_PTR onion_messenger, struct LDKGossipSync gossip_sync, const struct LDKPeerManager *NONNULL_PTR peer_manager, struct LDKLogger logger, struct LDKCOption_WriteableScoreZ scorer); /** * Join `BackgroundProcessor`'s thread, returning any error that occurred while persisting @@ -50534,6 +60756,15 @@ bool Fallback_eq(const struct LDKFallback *NONNULL_PTR a, const struct LDKFallba */ void Bolt11InvoiceSignature_free(struct LDKBolt11InvoiceSignature this_obj); +struct LDKRecoverableSignature Bolt11InvoiceSignature_get_a(const struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr); + +void Bolt11InvoiceSignature_set_a(struct LDKBolt11InvoiceSignature *NONNULL_PTR this_ptr, struct LDKRecoverableSignature val); + +/** + * Constructs a new Bolt11InvoiceSignature given each field + */ +MUST_USE_RES struct LDKBolt11InvoiceSignature Bolt11InvoiceSignature_new(struct LDKRecoverableSignature a_arg); + /** * Creates a copy of the Bolt11InvoiceSignature */ @@ -50660,6 +60891,9 @@ MUST_USE_RES struct LDKBolt11InvoiceFeatures RawBolt11Invoice_features(const str MUST_USE_RES struct LDKCVec_PrivateRouteZ RawBolt11Invoice_private_routes(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); +/** + * Returns `None` if no amount is set or on overflow. + */ MUST_USE_RES struct LDKCOption_u64Z RawBolt11Invoice_amount_pico_btc(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); MUST_USE_RES enum LDKCurrency RawBolt11Invoice_currency(const struct LDKRawBolt11Invoice *NONNULL_PTR this_arg); @@ -50789,6 +61023,12 @@ MUST_USE_RES struct LDKBolt11InvoiceFeatures Bolt11Invoice_features(const struct */ MUST_USE_RES struct LDKPublicKey Bolt11Invoice_recover_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); +/** + * Recover the payee's public key if one was included in the invoice, otherwise return the + * recovered public key from the signature + */ +MUST_USE_RES struct LDKPublicKey Bolt11Invoice_get_payee_pub_key(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); + /** * Returns the Duration since the Unix epoch at which the invoice expires. * Returning None if overflow occurred. @@ -50854,8 +61094,8 @@ MUST_USE_RES enum LDKCurrency Bolt11Invoice_currency(const struct LDKBolt11Invoi MUST_USE_RES struct LDKCOption_u64Z Bolt11Invoice_amount_milli_satoshis(const struct LDKBolt11Invoice *NONNULL_PTR this_arg); /** - * Creates a new `Description` if `description` is at most 1023 __bytes__ long, - * returns [`CreationError::DescriptionTooLong`] otherwise + * Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) + * long, and returns [`CreationError::DescriptionTooLong`] otherwise. * * Please note that single characters may use more than one byte due to UTF8 encoding. */ @@ -50866,6 +61106,11 @@ MUST_USE_RES struct LDKCResult_DescriptionCreationErrorZ Description_new(struct */ MUST_USE_RES struct LDKUntrustedString Description_into_inner(struct LDKDescription this_arg); +/** + * Get a reference to the underlying description [`UntrustedString`] + */ +MUST_USE_RES struct LDKUntrustedString Description_as_inner(const struct LDKDescription *NONNULL_PTR this_arg); + /** * Get the string representation of a Description object */ @@ -51044,184 +61289,6 @@ bool SignOrCreationError_eq(const struct LDKSignOrCreationError *NONNULL_PTR a, */ struct LDKStr SignOrCreationError_to_str(const struct LDKSignOrCreationError *NONNULL_PTR o); -/** - * Builds the necessary parameters to pay or pre-flight probe the given zero-amount - * [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or - * [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has an amount specified, in which case - * [`payment_parameters_from_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes - */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_zero_amount_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice, uint64_t amount_msat); - -/** - * Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using - * [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. - * - * Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the - * same [`PaymentHash`] has never been paid before. - * - * Will always succeed unless the invoice has no amount specified, in which case - * [`payment_parameters_from_zero_amount_invoice`] should be used. - * - * [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment - * [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes - */ -struct LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ payment_parameters_from_invoice(const struct LDKBolt11Invoice *NONNULL_PTR invoice); - -/** - * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" - * See [`PhantomKeysManager`] for more information on phantom node payments. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * participating node - * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is - * updated when a channel becomes disabled or closes - * * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice - * may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared - * down - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager - * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints - * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - * - * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not - * available and the current time is supplied by the caller. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); - -/** - * Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" - * See [`PhantomKeysManager`] for more information on phantom node payments. - * - * `phantom_route_hints` parameter: - * * Contains channel info for all nodes participating in the phantom invoice - * * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each - * participating node - * * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is - * updated when a channel becomes disabled or closes - * * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum - * of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected - * in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node - * until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as - * desired, but note that some nodes will be trimmed if more than 3 nodes are provided. - * - * `description_hash` is a SHA-256 hash of the description text - * - * `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference - * between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). - * If `None` is provided for `payment_hash`, then one will be created. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * `duration_since_epoch` is the current time since epoch in seconds. - * - * Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom - * invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this - * requirement). - * - * [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager - * [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints - * [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment - * [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash - * [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels - * - * This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not - * available and the current time is supplied by the caller. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_phantom_invoice_with_description_hash(struct LDKCOption_u64Z amt_msat, struct LDKCOption_ThirtyTwoBytesZ payment_hash, uint32_t invoice_expiry_delta_secs, struct LDKSha256 description_hash, struct LDKCVec_PhantomRouteHintsZ phantom_route_hints, struct LDKEntropySource entropy_source, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u16Z min_final_cltv_expiry_delta, uint64_t duration_since_epoch); - -/** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - -/** - * Utility to construct an invoice. Generally, unless you want to do something like a custom - * cltv_expiry, this is what you should be using to create an invoice. The reason being, this - * method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user - * doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify - * that the payment secret is valid when the invoice is paid. - * Use this variant if you want to pass the `description_hash` to the invoice. - * - * `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for - * in excess of the current time. - * - * You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to - * [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - * Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block - * confirmations during routing. - * - * [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - -/** - * See [`create_invoice_from_channelmanager_with_description_hash`] - * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not - * available and the current time is supplied by the caller. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKSha256 description_hash, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - -/** - * See [`create_invoice_from_channelmanager`] - * This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not - * available and the current time is supplied by the caller. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - -/** - * See [`create_invoice_from_channelmanager_and_duration_since_epoch`] - * This version allows for providing a custom [`PaymentHash`] for the invoice. - * This may be useful if you're building an on-chain swap or involving another protocol where - * the payment hash is also involved outside the scope of lightning. - */ -struct LDKCResult_Bolt11InvoiceSignOrCreationErrorZ create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(const struct LDKChannelManager *NONNULL_PTR channelmanager, struct LDKNodeSigner node_signer, struct LDKLogger logger, enum LDKCurrency network, struct LDKCOption_u64Z amt_msat, struct LDKStr description, uint64_t duration_since_epoch, uint32_t invoice_expiry_delta_secs, struct LDKThirtyTwoBytes payment_hash, struct LDKCOption_u16Z min_final_cltv_expiry_delta); - /** * Read a SiPrefix object from a string */ diff --git a/lightning-c-bindings/include/lightningpp.hpp b/lightning-c-bindings/include/lightningpp.hpp index ed9eda2..0f8d1d7 100644 --- a/lightning-c-bindings/include/lightningpp.hpp +++ b/lightning-c-bindings/include/lightningpp.hpp @@ -2,15 +2,19 @@ namespace LDK { // Forward declarations class Str; +class RefundMaybeWithDerivedMetadataBuilder; class Refund; class Retry; class RetryableSendFailure; class PaymentSendFailure; +class Bolt12PaymentError; class ProbeSendFailure; class RecipientOnionFields; +class InvoiceWithExplicitSigningPubkeyBuilder; +class InvoiceWithDerivedSigningPubkeyBuilder; class UnsignedBolt12Invoice; +class SignBolt12InvoiceFn; class Bolt12Invoice; -class BlindedPayInfo; class DelayedPaymentOutputDescriptor; class StaticPaymentOutputDescriptor; class SpendableOutputDescriptor; @@ -20,10 +24,13 @@ class ChannelSigner; class Recipient; class EntropySource; class NodeSigner; +class OutputSpender; class SignerProvider; +class ChangeDestinationSource; class InMemorySigner; class KeysManager; class PhantomKeysManager; +class RandomBytes; class BackgroundProcessor; class GossipSync; class DefaultRouter; @@ -37,14 +44,14 @@ class Route; class RouteParameters; class PaymentParameters; class Payee; -class RouteHint; -class RouteHintHop; class FirstHopCandidate; class PublicHopCandidate; class PrivateHopCandidate; class BlindedPathCandidate; class OneHopBlindedPathCandidate; class CandidateRouteHop; +class UntrustedString; +class PrintableString; class ScoreLookUp; class ScoreUpdate; class Score; @@ -65,15 +72,9 @@ class ChannelMonitorUpdateStatus; class Watch; class Filter; class WatchedOutput; -class InitFeatures; -class NodeFeatures; -class ChannelFeatures; -class Bolt11InvoiceFeatures; -class OfferFeatures; -class InvoiceRequestFeatures; -class Bolt12InvoiceFeatures; -class BlindedHopFeatures; -class ChannelTypeFeatures; +class OfferId; +class OfferWithExplicitMetadataBuilder; +class OfferWithDerivedMetadataBuilder; class Offer; class Amount; class Quantity; @@ -86,10 +87,11 @@ class ChannelUpdateInfo; class ChannelInfo; class DirectedChannelInfo; class EffectiveCapacity; -class RoutingFees; +class NodeAnnouncementDetails; class NodeAnnouncementInfo; class NodeAlias; class NodeInfo; +class ShortChannelIdError; class InboundHTLCErr; class AnchorDescriptor; class BumpTransactionEvent; @@ -107,10 +109,6 @@ class BlindedFailure; class FailureCode; class ChannelManager; class ChainParameters; -class CounterpartyForwardingInfo; -class ChannelCounterparty; -class ChannelDetails; -class ChannelShutdownState; class RecentPaymentDetails; class PhantomRouteHints; class ChannelManagerReadArgs; @@ -122,11 +120,12 @@ class ChannelConfigUpdate; class UserConfig; class APIError; class TaggedHash; +class SignError; class EcdsaChannelSigner; -class WriteableEcdsaChannelSigner; class ChannelMonitorUpdate; class MonitorEvent; class HTLCUpdate; +class BalanceSource; class Balance; class ChannelMonitor; class ExpandedKey; @@ -135,6 +134,7 @@ class IgnoringMessageHandler; class ErroringMessageHandler; class MessageHandler; class SocketDescriptor; +class PeerDetails; class PeerHandleError; class PeerManager; class GraphSyncError; @@ -142,24 +142,31 @@ class RapidGossipSync; class KVStore; class Persister; class MonitorUpdatingPersister; +class InvoiceRequestWithExplicitPayerIdBuilder; +class InvoiceRequestWithDerivedPayerIdBuilder; class UnsignedInvoiceRequest; +class SignInvoiceRequestFn; class InvoiceRequest; class VerifiedInvoiceRequest; +class InvoiceRequestFields; class DecodeError; class Init; class ErrorMessage; class WarningMessage; class Ping; class Pong; +class CommonOpenChannelFields; +class ChannelParameters; class OpenChannel; class OpenChannelV2; +class CommonAcceptChannelFields; class AcceptChannel; class AcceptChannelV2; class FundingCreated; class FundingSigned; class ChannelReady; class Stfu; -class Splice; +class SpliceInit; class SpliceAck; class SpliceLocked; class TxAddInput; @@ -179,6 +186,7 @@ class OnionMessage; class UpdateFulfillHTLC; class UpdateFailHTLC; class UpdateFailMalformedHTLC; +class CommitmentSignedBatch; class CommitmentSigned; class RevokeAndACK; class UpdateFee; @@ -206,12 +214,25 @@ class RoutingMessageHandler; class OnionMessageHandler; class FinalOnionHopData; class OnionPacket; +class TrampolineOnionPacket; class Level; class Record; class Logger; +class InboundHTLCStateDetails; +class InboundHTLCDetails; +class OutboundHTLCStateDetails; +class OutboundHTLCDetails; +class CounterpartyForwardingInfo; +class ChannelCounterparty; +class ChannelDetails; +class ChannelShutdownState; class FutureCallback; class Future; class Sleeper; +class AsyncPaymentsMessageHandler; +class AsyncPaymentsMessage; +class HeldHtlcAvailable; +class ReleaseHeldHtlc; class OffersMessageHandler; class OffersMessage; class HTLCClaim; @@ -238,6 +259,7 @@ class FeeEstimator; class Packet; class ParsedOnionMessageContents; class OnionMessageContents; +class FundingInfo; class PaymentPurpose; class ClaimedHTLC; class PathFailure; @@ -248,7 +270,12 @@ class Event; class MessageSendEvent; class MessageSendEventsProvider; class EventsProvider; +class ReplayEvent; class EventHandler; +class Nonce; +class RoutingFees; +class RouteHint; +class RouteHintHop; class Bolt11ParseError; class ParseOrSemanticError; class Bolt11Invoice; @@ -273,20 +300,28 @@ class OutPoint; class BigSize; class Hostname; class TransactionU16LenLimited; -class UntrustedString; -class PrintableString; +class ChannelId; class CustomMessageReader; class Type; -class ForwardNode; +class BlindedPayInfo; +class BlindedPaymentPath; +class PaymentForwardNode; class ForwardTlvs; class ReceiveTlvs; class PaymentRelay; class PaymentConstraints; +class PaymentContext; +class UnknownPaymentContext; +class Bolt12OfferContext; +class Bolt12RefundContext; class UtxoLookupError; class UtxoResult; class UtxoLookup; class UtxoFuture; class OnionMessenger; +class Responder; +class ResponseInstruction; +class MessageSendInstructions; class MessageRouter; class DefaultMessageRouter; class OnionMessagePath; @@ -296,37 +331,59 @@ class SendError; class CustomOnionMessageHandler; class PeeledOnion; class FilesystemStore; -class BlindedPath; +class InitFeatures; +class NodeFeatures; +class ChannelFeatures; +class Bolt11InvoiceFeatures; +class OfferFeatures; +class InvoiceRequestFeatures; +class Bolt12InvoiceFeatures; +class BlindedHopFeatures; +class ChannelTypeFeatures; +class IntroductionNode; +class Direction; +class NodeIdLookUp; +class EmptyNodeIdLookUp; class BlindedHop; class InvoiceError; class ErroneousField; +class TrackedSpendableOutput; +class OutputSpendStatus; +class OutputSweeper; +class SpendingDelay; class DelayedPaymentBasepoint; class DelayedPaymentKey; class HtlcBasepoint; class HtlcKey; class RevocationBasepoint; class RevocationKey; -class MonitorUpdateId; class Persist; class LockedChannelMonitor; class ChainMonitor; +class BlindedMessagePath; +class NextMessageHop; +class MessageForwardNode; +class MessageContext; +class OffersContext; class CResult_HtlcKeyDecodeErrorZ; class CResult_TransactionU16LenLimitedNoneZ; +class CVec_TrackedSpendableOutputZ; class CResult_LockedChannelMonitorNoneZ; -class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ; class CResult_PhantomRouteHintsDecodeErrorZ; class CResult_FundingCreatedDecodeErrorZ; class CVec_C2Tuple_u32TxOutZZ; class CResult_RetryDecodeErrorZ; class CResult_BlindedForwardDecodeErrorZ; class CResult_ChannelInfoDecodeErrorZ; +class COption_PaymentContextZ; class COption_MaxDustHTLCExposureZ; -class COption_OffersMessageZ; +class CResult_NoneSendErrorZ; class CResult_CVec_u8ZPeerHandleErrorZ; +class CResult_OnionPacketDecodeErrorZ; class COption_NetworkUpdateZ; class COption_u64Z; -class CResult_OnionPacketDecodeErrorZ; class CResult_GossipTimestampFilterDecodeErrorZ; +class C2Tuple_OnionMessageContentsResponseInstructionZ; class CResult_RouteHintDecodeErrorZ; class COption_FilterZ; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ; @@ -338,126 +395,145 @@ class CResult_StaticPaymentOutputDescriptorDecodeErrorZ; class COption_u32Z; class CResult_RecipientOnionFieldsNoneZ; class C2Tuple__u1632_u1632Z; +class CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ; +class C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ; +class CResult_TransactionNoneZ; class CResult_CVec_StrZIOErrorZ; +class CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ; +class COption_ECDSASignatureZ; class CResult_ClosingSignedFeeRangeDecodeErrorZ; -class CResult_TransactionNoneZ; class CResult_CommitmentSignedDecodeErrorZ; class CResult_CommitmentTransactionDecodeErrorZ; +class CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ; class CResult_StfuDecodeErrorZ; class CResult_OpenChannelDecodeErrorZ; class CResult_ErrorMessageDecodeErrorZ; class COption_APIErrorZ; +class CVec_PeerDetailsZ; +class CResult_u64ShortChannelIdErrorZ; class CResult_QueryChannelRangeDecodeErrorZ; -class CVec_TransactionZ; class CVec_InputZ; class CResult_ChannelFeaturesDecodeErrorZ; class CResult_ChannelReadyDecodeErrorZ; -class CResult_RevocationBasepointDecodeErrorZ; +class CVec_TransactionZ; class CResult_UpdateFeeDecodeErrorZ; class CResult_NoneBolt11SemanticErrorZ; +class CResult_RevocationBasepointDecodeErrorZ; class COption_OnionMessageContentsZ; class CResult_NoneRetryableSendFailureZ; -class CResult_boolLightningErrorZ; +class CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ; class CResult_NodeIdDecodeErrorZ; +class CResult_boolLightningErrorZ; class CResult_ChannelShutdownStateDecodeErrorZ; -class CResult_HTLCOutputInCommitmentDecodeErrorZ; class CResult_NodeAnnouncementInfoDecodeErrorZ; -class CResult_ShutdownScriptInvalidShutdownScriptZ; +class CResult_InvoiceRequestBolt12SemanticErrorZ; class CResult_COption_NetworkUpdateZDecodeErrorZ; class CVec_UpdateFailMalformedHTLCZ; class CResult_ShutdownScriptNoneZ; class CResult_PendingHTLCInfoInboundHTLCErrZ; -class CResult_PendingHTLCInfoDecodeErrorZ; -class COption_HTLCDestinationZ; class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ; -class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ; +class CResult_PendingHTLCInfoDecodeErrorZ; +class CResult_SpliceInitDecodeErrorZ; +class CResult_HTLCOutputInCommitmentDecodeErrorZ; class CVec_RouteHopZ; -class C2Tuple_PublicKeyCVec_SocketAddressZZ; +class CResult_ShutdownScriptInvalidShutdownScriptZ; class CResult_CVec_UtxoZNoneZ; -class CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ; class CResult_CVec_u8ZIOErrorZ; -class C3Tuple_OffersMessageDestinationBlindedPathZ; +class COption_HTLCDestinationZ; +class CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ; class CVec_ThirtyTwoBytesZ; class CResult_ChannelMonitorUpdateStatusNoneZ; class CResult_ClosingSignedDecodeErrorZ; class CVec_CResult_NoneAPIErrorZZ; class CResult_SchnorrSignatureNoneZ; +class C2Tuple_ReleaseHeldHtlcResponseInstructionZ; class CResult_CounterpartyCommitmentSecretsDecodeErrorZ; class CResult_HTLCDescriptorDecodeErrorZ; class CVec_RecentPaymentDetailsZ; class CVec_RouteHintHopZ; -class CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ; class CResult_UntrustedStringDecodeErrorZ; class CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ; -class CVec_U5Z; class CResult_PaymentParametersDecodeErrorZ; +class CResult_DelayedPaymentBasepointDecodeErrorZ; class C2Tuple_ThirtyTwoBytesChannelMonitorZ; class COption_U128Z; -class CResult_DelayedPaymentBasepointDecodeErrorZ; class C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ; +class CVec_MessageForwardNodeZ; class CResult_TxAckRbfDecodeErrorZ; class CResult_Bolt11InvoiceBolt11SemanticErrorZ; class COption_UtxoLookupZ; +class CResult__u832NoneZ; class CResult_PongDecodeErrorZ; class CResult_UnsignedChannelAnnouncementDecodeErrorZ; -class C2Tuple_OutPointCVec_MonitorUpdateIdZZ; +class CResult_ChannelIdAPIErrorZ; class CResult_CVec_u8ZNoneZ; +class CVec_C2Tuple_ChannelIdPublicKeyZZ; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ; class CResult_ChannelTransactionParametersDecodeErrorZ; -class CResult_WriteableEcdsaChannelSignerDecodeErrorZ; +class CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ; class CResult_InFlightHtlcsDecodeErrorZ; +class CResult_CommitmentSignedBatchDecodeErrorZ; class CResult_COption_HTLCDestinationZDecodeErrorZ; +class CResult_Bolt12OfferContextDecodeErrorZ; class CResult_ThirtyTwoBytesNoneZ; -class C3Tuple_OnionMessageContentsDestinationBlindedPathZ; class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ; class CResult_SendSuccessSendErrorZ; -class CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ; +class CResult_NoneReplayEventZ; class C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ; class CResult_BlindedHopDecodeErrorZ; class CResult_NoneLightningErrorZ; class CResult_FixedPenaltyScorerDecodeErrorZ; -class CVec_BlindedPathZ; class CResult_NonePeerHandleErrorZ; -class CResult_FinalOnionHopDataDecodeErrorZ; class CResult_TrustedCommitmentTransactionNoneZ; +class CResult_FinalOnionHopDataDecodeErrorZ; class CResult_COption_EventZDecodeErrorZ; -class CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ; -class CResult_PaymentFailureReasonDecodeErrorZ; class COption_SocketAddressZ; class CResult_COption_MonitorEventZDecodeErrorZ; class COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ; -class CResult_DescriptionCreationErrorZ; +class CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ; class CResult_RoutingFeesDecodeErrorZ; class CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ; +class CResult_DescriptionCreationErrorZ; class CResult_PaymentRelayDecodeErrorZ; class CResult_QueryShortChannelIdsDecodeErrorZ; class CResult_VerifiedInvoiceRequestNoneZ; class CResult_UpdateAddHTLCDecodeErrorZ; +class COption_OutboundHTLCStateDetailsZ; class COption_MonitorEventZ; class COption_TypeZ; class CResult_COption_TypeZDecodeErrorZ; +class CResult_OfferDecodeErrorZ; class CResult_COption_PathFailureZDecodeErrorZ; class CResult_Bolt11InvoiceSignOrCreationErrorZ; +class CResult_BlindedMessagePathNoneZ; class CResult_UpdateFailHTLCDecodeErrorZ; -class CResult_CVec_BlindedPathZNoneZ; +class CResult_BlindedPaymentPathNoneZ; +class CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ; class CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ; -class CResult_RevokeAndACKDecodeErrorZ; class CResult_SpendableOutputDescriptorDecodeErrorZ; -class C2Tuple_PublicKeyCOption_SocketAddressZZ; +class CResult_RevokeAndACKDecodeErrorZ; class CResult_UnsignedChannelUpdateDecodeErrorZ; class CResult_PayeePubKeySecp256k1ErrorZ; class C2Tuple__u832u16Z; +class CResult_BlindedMessagePathDecodeErrorZ; +class CResult_CVec_BlindedMessagePathZNoneZ; class COption_BigEndianScalarZ; +class CVec_ChannelIdZ; class CResult_PublicKeySecp256k1ErrorZ; -class CResult_CVec_ECDSASignatureZNoneZ; +class C2Tuple_OnionMessageContentsMessageSendInstructionsZ; class CVec_BlindedHopZ; +class CResult_ReleaseHeldHtlcDecodeErrorZ; +class CResult_CVec_ECDSASignatureZNoneZ; class CResult_COption_ClosureReasonZDecodeErrorZ; -class CResult_InvoiceErrorDecodeErrorZ; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ; +class CResult_NonceDecodeErrorZ; class CResult_RouteParametersDecodeErrorZ; class CResult_PrivateRouteCreationErrorZ; +class CResult_InvoiceErrorDecodeErrorZ; class CResult_NodeAliasDecodeErrorZ; +class C2Tuple_BestBlockOutputSweeperZ; +class C2Tuple_OutPointCVec_u64ZZ; class CVec_UpdateFulfillHTLCZ; class CVec_C2Tuple_u32CVec_u8ZZZ; class C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ; @@ -470,28 +546,34 @@ class CResult_TxSignaturesDecodeErrorZ; class CVec_HTLCDescriptorZ; class CResult_ReplyShortChannelIdsEndDecodeErrorZ; class COption_PathFailureZ; -class CResult_StrSecp256k1ErrorZ; +class COption_MessageContextZ; class CVec_ECDSASignatureZ; class CResult_ChannelUpdateInfoDecodeErrorZ; class CVec_UpdateFailHTLCZ; class CVec_TxOutZ; +class CVec_InboundHTLCDetailsZ; +class CVec_OutboundHTLCDetailsZ; class CResult_BuiltCommitmentTransactionDecodeErrorZ; +class CVec_PaymentForwardNodeZ; +class CResult_TrackedSpendableOutputDecodeErrorZ; class CVec_SpendableOutputDescriptorZ; +class CResult_ResponderDecodeErrorZ; class C2Tuple_OutPointCVec_u8ZZ; class CResult_WitnessNoneZ; class COption_C2Tuple_u64u64ZZ; class CResult_ChannelAnnouncementDecodeErrorZ; class CResult_HTLCUpdateDecodeErrorZ; class CResult_TxAddInputDecodeErrorZ; -class CResult_PeeledOnionNoneZ; +class CResult_HeldHtlcAvailableDecodeErrorZ; class CResult_TxInitRbfDecodeErrorZ; class COption_WriteableScoreZ; class CVec_StrZ; -class CVec_OutPointZ; +class CResult_AsyncPaymentsMessageDecodeErrorZ; class CResult_SpliceAckDecodeErrorZ; class CResult_PositiveTimestampCreationErrorZ; +class CResult_PeeledOnionNoneZ; +class CVec_C2Tuple_OutPointChannelIdZZ; class CResult_ChannelMonitorUpdateDecodeErrorZ; -class C2Tuple_BlindedPayInfoBlindedPathZ; class CResult_ReplyChannelRangeDecodeErrorZ; class CResult_UnsignedNodeAnnouncementDecodeErrorZ; class CResult_TrustedClosingTransactionNoneZ; @@ -501,39 +583,46 @@ class CResult_TxRemoveOutputDecodeErrorZ; class CResult_ChannelReestablishDecodeErrorZ; class CResult_OnionMessageDecodeErrorZ; class CResult_Bolt11InvoiceParseOrSemanticErrorZ; +class CResult_MessageContextDecodeErrorZ; class CResult_InitFeaturesDecodeErrorZ; class CResult_PublicKeyNoneZ; class CResult_PingDecodeErrorZ; class CResult_RevocationKeyDecodeErrorZ; +class C2Tuple_OffersMessageMessageSendInstructionsZ; class CResult_BlindedHopFeaturesDecodeErrorZ; +class CResult_ChannelIdDecodeErrorZ; class CVec_TransactionOutputsZ; class COption_HTLCClaimZ; class COption_boolZ; -class CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ; +class CVec_BlindedPaymentPathZ; class CResult_ProbabilisticScorerDecodeErrorZ; class COption_StrZ; -class CResult_ShutdownScriptDecodeErrorZ; -class CResult_SiPrefixBolt11ParseErrorZ; +class CResult_CVec_BlindedPaymentPathZNoneZ; +class COption_C2Tuple_OffersMessageResponseInstructionZZ; class C2Tuple_usizeTransactionZ; +class COption_OffersContextZ; class CResult_NodeAnnouncementDecodeErrorZ; -class CVec_FutureZ; class CVec_ChannelMonitorZ; -class CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ; class CResult_AcceptChannelV2DecodeErrorZ; +class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ; class CResult_RouteHopDecodeErrorZ; +class CResult_OfferIdDecodeErrorZ; class CVec_HTLCOutputInCommitmentZ; class CResult_CoinSelectionNoneZ; -class C2Tuple_ThirtyTwoBytesPublicKeyZ; +class CVec_FutureZ; class CResult_TxCreationKeysDecodeErrorZ; -class CResult_BlindedPathDecodeErrorZ; -class CVec_BalanceZ; +class CResult_RefundBolt12SemanticErrorZ; class CResult_NoneIOErrorZ; class CResult_MaxDustHTLCExposureDecodeErrorZ; +class CVec_BalanceZ; class CVec_CommitmentTransactionZ; class CResult_FundingSignedDecodeErrorZ; class CResult_RecoverableSignatureNoneZ; class CResult_SocketAddressDecodeErrorZ; class C2Tuple_Z; +class CResult_ShutdownScriptDecodeErrorZ; +class CResult_InboundHTLCDetailsDecodeErrorZ; +class CResult_SiPrefixBolt11ParseErrorZ; class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ; class CVec_PathZ; class CResult_NetworkGraphDecodeErrorZ; @@ -547,36 +636,41 @@ class CResult_ChannelPublicKeysDecodeErrorZ; class CVec_ClaimedHTLCZ; class COption_CVec_ThirtyTwoBytesZZ; class CVec_SocketAddressZ; +class CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ; class CResult_ThirtyTwoBytesPaymentSendFailureZ; -class CResult_HolderCommitmentTransactionDecodeErrorZ; class CResult_WarningMessageDecodeErrorZ; class CResult_ChannelCounterpartyDecodeErrorZ; -class CVec_ForwardNodeZ; +class CResult_HolderCommitmentTransactionDecodeErrorZ; class CResult_DelayedPaymentKeyDecodeErrorZ; -class CResult_InitDecodeErrorZ; +class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; +class CResult_OfferBolt12SemanticErrorZ; class CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ; -class CResult_SpliceDecodeErrorZ; +class CResult_InitDecodeErrorZ; class CResult_PaymentPurposeDecodeErrorZ; class CResult_ClaimedHTLCDecodeErrorZ; -class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ; class CResult_OutPointDecodeErrorZ; class CVec_ChannelDetailsZ; -class CVec_MonitorUpdateIdZ; class CResult_Bolt11InvoiceFeaturesDecodeErrorZ; class CVec_MessageSendEventZ; +class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ; class CResult_RouteHintHopDecodeErrorZ; class CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ; class CResult_UpdateFailMalformedHTLCDecodeErrorZ; class CResult_BlindedPayInfoDecodeErrorZ; class CResult_ThirtyTwoBytesAPIErrorZ; class COption_ChannelShutdownStateZ; +class CResult_Bolt12InvoiceBolt12SemanticErrorZ; +class CResult_InvoiceRequestFieldsDecodeErrorZ; class CResult_AcceptChannelDecodeErrorZ; +class CResult_RefundDecodeErrorZ; class CResult_HostnameDecodeErrorZ; class C2Tuple_u64u16Z; class COption_ThirtyTwoBytesZ; class CVec_u64Z; class CResult_NoneBolt12SemanticErrorZ; -class COption_SecretKeyZ; +class CResult_UnknownPaymentContextDecodeErrorZ; +class COption_InboundHTLCStateDetailsZ; +class CResult_OutputSweeperDecodeErrorZ; class CResult_C2Tuple_CVec_u8Zu64ZNoneZ; class COption_EventZ; class CResult_ChannelTypeFeaturesDecodeErrorZ; @@ -584,43 +678,55 @@ class COption_CVec_SocketAddressZZ; class CVec_RouteHintZ; class COption_u16Z; class COption_PaymentFailureReasonZ; +class CResult_Bolt12RefundContextDecodeErrorZ; class CResult_ECDSASignatureNoneZ; -class CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ; -class CVec_WitnessZ; +class C2Tuple_ChannelIdPublicKeyZ; +class C2Tuple_OffersMessageResponseInstructionZ; +class CResult_EcdsaChannelSignerDecodeErrorZ; class CResult_BlindedTailDecodeErrorZ; -class CResult_SocketAddressSocketAddressParseErrorZ; +class CVec_WitnessZ; class COption_C2Tuple_u64u16ZZ; -class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; +class CResult_SocketAddressSocketAddressParseErrorZ; +class CResult_COption_PaymentFailureReasonZDecodeErrorZ; class CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ; class CResult_ChannelDerivationParametersDecodeErrorZ; -class CResult_PaymentConstraintsDecodeErrorZ; +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ; +class CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ; class CResult_OnionMessagePathNoneZ; class C2Tuple_u32CVec_u8ZZ; class CVec_C2Tuple_PublicKeyTypeZZ; +class CResult_OutboundHTLCDetailsDecodeErrorZ; class CResult_RefundBolt12ParseErrorZ; -class C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ; -class CVec_C2Tuple_u64CVec_u8ZZZ; class CResult_u32GraphSyncErrorZ; -class CVec_PhantomRouteHintsZ; +class CVec_C2Tuple_u64CVec_u8ZZZ; +class CResult_OffersMessageDecodeErrorZ; +class CResult_PaymentConstraintsDecodeErrorZ; class CResult_NoneAPIErrorZ; class CResult_Bolt12InvoiceFeaturesDecodeErrorZ; class COption_f64Z; -class CResult_ChannelDetailsDecodeErrorZ; +class CResult_TxRemoveInputDecodeErrorZ; class CVec_PublicKeyZ; class C2Tuple_CVec_u8Zu64Z; class CVec_C2Tuple_usizeTransactionZZ; class CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ; -class CResult_PendingHTLCRoutingDecodeErrorZ; +class CResult_Bolt12InvoiceDecodeErrorZ; class C2Tuple_u64u64Z; -class CResult_TxRemoveInputDecodeErrorZ; -class CResult_OffersMessageDecodeErrorZ; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; +class COption_NodeAnnouncementInfoZ; +class CResult_PendingHTLCRoutingDecodeErrorZ; +class COption_C2Tuple_OnionMessageContentsResponseInstructionZZ; class CResult_RecipientOnionFieldsDecodeErrorZ; class C2Tuple_u32TxOutZ; +class CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ; +class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ; +class CResult_ChannelDetailsDecodeErrorZ; class CVec_UtxoZ; +class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ; class CResult_ChannelConfigDecodeErrorZ; class CVec_PrivateRouteZ; class COption_i64Z; +class CResult_PaymentContextDecodeErrorZ; +class CVec_PhantomRouteHintsZ; +class CVec_C2Tuple_OutPointCVec_u64ZZZ; class C2Tuple_ThirtyTwoBytesChannelManagerZ; class CResult_COption_OnionMessageContentsZDecodeErrorZ; class C2Tuple_u64CVec_u8ZZ; @@ -630,29 +736,38 @@ class CVec_MonitorEventZ; class CResult_ShutdownDecodeErrorZ; class CResult_BigSizeDecodeErrorZ; class CResult_TxOutUtxoLookupErrorZ; -class CResult_BlindedPathNoneZ; class COption_usizeZ; -class CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ; +class CVec_BlindedMessagePathZ; +class CResult_OffersContextDecodeErrorZ; class CResult_NoneNoneZ; class CResult_boolPeerHandleErrorZ; class CResult_ChannelUpdateDecodeErrorZ; class CVec_APIErrorZ; class COption_TxOutZ; class COption_ClosureReasonZ; +class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ; class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ; class CResult_TransactionU16LenLimitedDecodeErrorZ; +class CResult_FundingInfoDecodeErrorZ; +class COption_AmountZ; +class COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ; class CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ; -class CResult_CounterpartyForwardingInfoDecodeErrorZ; class CResult_OpenChannelV2DecodeErrorZ; +class CResult_BestBlockDecodeErrorZ; class CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ; -class CResult_HtlcBasepointDecodeErrorZ; -class CResult_SpliceLockedDecodeErrorZ; +class CResult_CounterpartyForwardingInfoDecodeErrorZ; +class CResult_OutputSpendStatusDecodeErrorZ; +class C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ; class CResult_RouteDecodeErrorZ; class CResult_BlindedFailureDecodeErrorZ; class CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ; class COption_NoneZ; -class CResult_TxAddOutputDecodeErrorZ; +class CResult_SpliceLockedDecodeErrorZ; class COption_CVec_u8ZZ; +class COption_QuantityZ; +class CResult_TxAddOutputDecodeErrorZ; +class CResult_HtlcBasepointDecodeErrorZ; +class C2Tuple_OutPointChannelIdZ; class Str { private: @@ -669,6 +784,21 @@ public: const LDKStr* operator &() const { return &self; } const LDKStr* operator ->() const { return &self; } }; +class RefundMaybeWithDerivedMetadataBuilder { +private: + LDKRefundMaybeWithDerivedMetadataBuilder self; +public: + RefundMaybeWithDerivedMetadataBuilder(const RefundMaybeWithDerivedMetadataBuilder&) = delete; + RefundMaybeWithDerivedMetadataBuilder(RefundMaybeWithDerivedMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(RefundMaybeWithDerivedMetadataBuilder)); } + RefundMaybeWithDerivedMetadataBuilder(LDKRefundMaybeWithDerivedMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRefundMaybeWithDerivedMetadataBuilder)); } + operator LDKRefundMaybeWithDerivedMetadataBuilder() && { LDKRefundMaybeWithDerivedMetadataBuilder res = self; memset(&self, 0, sizeof(LDKRefundMaybeWithDerivedMetadataBuilder)); return res; } + ~RefundMaybeWithDerivedMetadataBuilder() { RefundMaybeWithDerivedMetadataBuilder_free(self); } + RefundMaybeWithDerivedMetadataBuilder& operator=(RefundMaybeWithDerivedMetadataBuilder&& o) { RefundMaybeWithDerivedMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(RefundMaybeWithDerivedMetadataBuilder)); return *this; } + LDKRefundMaybeWithDerivedMetadataBuilder* operator &() { return &self; } + LDKRefundMaybeWithDerivedMetadataBuilder* operator ->() { return &self; } + const LDKRefundMaybeWithDerivedMetadataBuilder* operator &() const { return &self; } + const LDKRefundMaybeWithDerivedMetadataBuilder* operator ->() const { return &self; } +}; class Refund { private: LDKRefund self; @@ -728,6 +858,21 @@ public: const LDKPaymentSendFailure* operator &() const { return &self; } const LDKPaymentSendFailure* operator ->() const { return &self; } }; +class Bolt12PaymentError { +private: + LDKBolt12PaymentError self; +public: + Bolt12PaymentError(const Bolt12PaymentError&) = delete; + Bolt12PaymentError(Bolt12PaymentError&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12PaymentError)); } + Bolt12PaymentError(LDKBolt12PaymentError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12PaymentError)); } + operator LDKBolt12PaymentError() && { LDKBolt12PaymentError res = self; memset(&self, 0, sizeof(LDKBolt12PaymentError)); return res; } + ~Bolt12PaymentError() { Bolt12PaymentError_free(self); } + Bolt12PaymentError& operator=(Bolt12PaymentError&& o) { Bolt12PaymentError_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12PaymentError)); return *this; } + LDKBolt12PaymentError* operator &() { return &self; } + LDKBolt12PaymentError* operator ->() { return &self; } + const LDKBolt12PaymentError* operator &() const { return &self; } + const LDKBolt12PaymentError* operator ->() const { return &self; } +}; class ProbeSendFailure { private: LDKProbeSendFailure self; @@ -758,6 +903,36 @@ public: const LDKRecipientOnionFields* operator &() const { return &self; } const LDKRecipientOnionFields* operator ->() const { return &self; } }; +class InvoiceWithExplicitSigningPubkeyBuilder { +private: + LDKInvoiceWithExplicitSigningPubkeyBuilder self; +public: + InvoiceWithExplicitSigningPubkeyBuilder(const InvoiceWithExplicitSigningPubkeyBuilder&) = delete; + InvoiceWithExplicitSigningPubkeyBuilder(InvoiceWithExplicitSigningPubkeyBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceWithExplicitSigningPubkeyBuilder)); } + InvoiceWithExplicitSigningPubkeyBuilder(LDKInvoiceWithExplicitSigningPubkeyBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceWithExplicitSigningPubkeyBuilder)); } + operator LDKInvoiceWithExplicitSigningPubkeyBuilder() && { LDKInvoiceWithExplicitSigningPubkeyBuilder res = self; memset(&self, 0, sizeof(LDKInvoiceWithExplicitSigningPubkeyBuilder)); return res; } + ~InvoiceWithExplicitSigningPubkeyBuilder() { InvoiceWithExplicitSigningPubkeyBuilder_free(self); } + InvoiceWithExplicitSigningPubkeyBuilder& operator=(InvoiceWithExplicitSigningPubkeyBuilder&& o) { InvoiceWithExplicitSigningPubkeyBuilder_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceWithExplicitSigningPubkeyBuilder)); return *this; } + LDKInvoiceWithExplicitSigningPubkeyBuilder* operator &() { return &self; } + LDKInvoiceWithExplicitSigningPubkeyBuilder* operator ->() { return &self; } + const LDKInvoiceWithExplicitSigningPubkeyBuilder* operator &() const { return &self; } + const LDKInvoiceWithExplicitSigningPubkeyBuilder* operator ->() const { return &self; } +}; +class InvoiceWithDerivedSigningPubkeyBuilder { +private: + LDKInvoiceWithDerivedSigningPubkeyBuilder self; +public: + InvoiceWithDerivedSigningPubkeyBuilder(const InvoiceWithDerivedSigningPubkeyBuilder&) = delete; + InvoiceWithDerivedSigningPubkeyBuilder(InvoiceWithDerivedSigningPubkeyBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceWithDerivedSigningPubkeyBuilder)); } + InvoiceWithDerivedSigningPubkeyBuilder(LDKInvoiceWithDerivedSigningPubkeyBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceWithDerivedSigningPubkeyBuilder)); } + operator LDKInvoiceWithDerivedSigningPubkeyBuilder() && { LDKInvoiceWithDerivedSigningPubkeyBuilder res = self; memset(&self, 0, sizeof(LDKInvoiceWithDerivedSigningPubkeyBuilder)); return res; } + ~InvoiceWithDerivedSigningPubkeyBuilder() { InvoiceWithDerivedSigningPubkeyBuilder_free(self); } + InvoiceWithDerivedSigningPubkeyBuilder& operator=(InvoiceWithDerivedSigningPubkeyBuilder&& o) { InvoiceWithDerivedSigningPubkeyBuilder_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceWithDerivedSigningPubkeyBuilder)); return *this; } + LDKInvoiceWithDerivedSigningPubkeyBuilder* operator &() { return &self; } + LDKInvoiceWithDerivedSigningPubkeyBuilder* operator ->() { return &self; } + const LDKInvoiceWithDerivedSigningPubkeyBuilder* operator &() const { return &self; } + const LDKInvoiceWithDerivedSigningPubkeyBuilder* operator ->() const { return &self; } +}; class UnsignedBolt12Invoice { private: LDKUnsignedBolt12Invoice self; @@ -773,6 +948,25 @@ public: const LDKUnsignedBolt12Invoice* operator &() const { return &self; } const LDKUnsignedBolt12Invoice* operator ->() const { return &self; } }; +class SignBolt12InvoiceFn { +private: + LDKSignBolt12InvoiceFn self; +public: + SignBolt12InvoiceFn(const SignBolt12InvoiceFn&) = delete; + SignBolt12InvoiceFn(SignBolt12InvoiceFn&& o) : self(o.self) { memset(&o, 0, sizeof(SignBolt12InvoiceFn)); } + SignBolt12InvoiceFn(LDKSignBolt12InvoiceFn&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignBolt12InvoiceFn)); } + operator LDKSignBolt12InvoiceFn() && { LDKSignBolt12InvoiceFn res = self; memset(&self, 0, sizeof(LDKSignBolt12InvoiceFn)); return res; } + ~SignBolt12InvoiceFn() { SignBolt12InvoiceFn_free(self); } + SignBolt12InvoiceFn& operator=(SignBolt12InvoiceFn&& o) { SignBolt12InvoiceFn_free(self); self = o.self; memset(&o, 0, sizeof(SignBolt12InvoiceFn)); return *this; } + LDKSignBolt12InvoiceFn* operator &() { return &self; } + LDKSignBolt12InvoiceFn* operator ->() { return &self; } + const LDKSignBolt12InvoiceFn* operator &() const { return &self; } + const LDKSignBolt12InvoiceFn* operator ->() const { return &self; } + /** + * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + */ + inline LDK::CResult_SchnorrSignatureNoneZ sign_invoice(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR message); +}; class Bolt12Invoice { private: LDKBolt12Invoice self; @@ -788,21 +982,6 @@ public: const LDKBolt12Invoice* operator &() const { return &self; } const LDKBolt12Invoice* operator ->() const { return &self; } }; -class BlindedPayInfo { -private: - LDKBlindedPayInfo self; -public: - BlindedPayInfo(const BlindedPayInfo&) = delete; - BlindedPayInfo(BlindedPayInfo&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPayInfo)); } - BlindedPayInfo(LDKBlindedPayInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPayInfo)); } - operator LDKBlindedPayInfo() && { LDKBlindedPayInfo res = self; memset(&self, 0, sizeof(LDKBlindedPayInfo)); return res; } - ~BlindedPayInfo() { BlindedPayInfo_free(self); } - BlindedPayInfo& operator=(BlindedPayInfo&& o) { BlindedPayInfo_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPayInfo)); return *this; } - LDKBlindedPayInfo* operator &() { return &self; } - LDKBlindedPayInfo* operator ->() { return &self; } - const LDKBlindedPayInfo* operator &() const { return &self; } - const LDKBlindedPayInfo* operator ->() const { return &self; } -}; class DelayedPaymentOutputDescriptor { private: LDKDelayedPaymentOutputDescriptor self; @@ -896,8 +1075,13 @@ public: * Gets the per-commitment point for a specific commitment number * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. + * + * If the signer returns `Err`, then the user is responsible for either force-closing the channel + * or calling `ChannelManager::signer_unblocked` (this method is only available when the + * `async_signing` cfg flag is enabled) once the signature is ready. + * */ - inline LDKPublicKey get_per_commitment_point(uint64_t idx); + inline LDK::CResult_PublicKeyNoneZ get_per_commitment_point(uint64_t idx); /** * Gets the commitment secret for a specific commitment number as part of the revocation process * @@ -908,7 +1092,7 @@ public: * * Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. */ - inline LDKThirtyTwoBytes release_commitment_secret(uint64_t idx); + inline LDK::CResult__u832NoneZ release_commitment_secret(uint64_t idx); /** * Validate the counterparty's signatures on the holder commitment transaction and HTLCs. * @@ -1044,7 +1228,7 @@ public: * * Errors if the [`Recipient`] variant is not supported by the implementation. */ - inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient); + inline LDK::CResult_RecoverableSignatureNoneZ sign_invoice(const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient); /** * Signs the [`TaggedHash`] of a BOLT 12 invoice request. * @@ -1083,6 +1267,36 @@ public: */ inline LDK::CResult_ECDSASignatureNoneZ sign_gossip_message(struct LDKUnsignedGossipMessage msg); }; +class OutputSpender { +private: + LDKOutputSpender self; +public: + OutputSpender(const OutputSpender&) = delete; + OutputSpender(OutputSpender&& o) : self(o.self) { memset(&o, 0, sizeof(OutputSpender)); } + OutputSpender(LDKOutputSpender&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutputSpender)); } + operator LDKOutputSpender() && { LDKOutputSpender res = self; memset(&self, 0, sizeof(LDKOutputSpender)); return res; } + ~OutputSpender() { OutputSpender_free(self); } + OutputSpender& operator=(OutputSpender&& o) { OutputSpender_free(self); self = o.self; memset(&o, 0, sizeof(OutputSpender)); return *this; } + LDKOutputSpender* operator &() { return &self; } + LDKOutputSpender* operator ->() { return &self; } + const LDKOutputSpender* operator &() const { return &self; } + const LDKOutputSpender* operator ->() const { return &self; } + /** + * Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an + * output to the given change destination (if sufficient change value remains). The + * transaction will have a feerate, at least, of the given value. + * + * The `locktime` argument is used to set the transaction's locktime. If `None`, the + * transaction will have a locktime of 0. It it recommended to set this to the current block + * height to avoid fee sniping, unless you have some specific reason to use a different + * locktime. + * + * Returns `Err(())` if the output value is greater than the input value minus required fee, + * if a descriptor was duplicated, or if an output descriptor `script_pubkey` + * does not match the one we can spend. + */ + inline LDK::CResult_TransactionNoneZ spend_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime); +}; class SignerProvider { private: LDKSignerProvider self; @@ -1114,11 +1328,11 @@ public: * re-derived from its `channel_keys_id`, which can be obtained through its trait method * [`ChannelSigner::channel_keys_id`]. */ - inline LDK::WriteableEcdsaChannelSigner derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); + inline LDK::EcdsaChannelSigner derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id); /** * Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. * This is only called during deserialization of other objects which contain - * [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + * [`EcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). * The bytes are exactly those which `::write()` writes, and * contain no versioning scheme. You may wish to include your own version prefix and ensure * you've read all of the provided bytes to ensure no corruption occurred. @@ -1130,7 +1344,7 @@ public: * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); + inline LDK::CResult_EcdsaChannelSignerDecodeErrorZ read_chan_signer(struct LDKu8slice reader); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -1153,6 +1367,29 @@ public: */ inline LDK::CResult_ShutdownScriptNoneZ get_shutdown_scriptpubkey(); }; +class ChangeDestinationSource { +private: + LDKChangeDestinationSource self; +public: + ChangeDestinationSource(const ChangeDestinationSource&) = delete; + ChangeDestinationSource(ChangeDestinationSource&& o) : self(o.self) { memset(&o, 0, sizeof(ChangeDestinationSource)); } + ChangeDestinationSource(LDKChangeDestinationSource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChangeDestinationSource)); } + operator LDKChangeDestinationSource() && { LDKChangeDestinationSource res = self; memset(&self, 0, sizeof(LDKChangeDestinationSource)); return res; } + ~ChangeDestinationSource() { ChangeDestinationSource_free(self); } + ChangeDestinationSource& operator=(ChangeDestinationSource&& o) { ChangeDestinationSource_free(self); self = o.self; memset(&o, 0, sizeof(ChangeDestinationSource)); return *this; } + LDKChangeDestinationSource* operator &() { return &self; } + LDKChangeDestinationSource* operator ->() { return &self; } + const LDKChangeDestinationSource* operator &() const { return &self; } + const LDKChangeDestinationSource* operator ->() const { return &self; } + /** + * Returns a script pubkey which can be used as a change destination for + * [`OutputSpender::spend_spendable_outputs`]. + * + * This method should return a different value each time it is called, to avoid linking + * on-chain funds controlled to the same user. + */ + inline LDK::CResult_CVec_u8ZNoneZ get_change_destination_script(); +}; class InMemorySigner { private: LDKInMemorySigner self; @@ -1198,6 +1435,21 @@ public: const LDKPhantomKeysManager* operator &() const { return &self; } const LDKPhantomKeysManager* operator ->() const { return &self; } }; +class RandomBytes { +private: + LDKRandomBytes self; +public: + RandomBytes(const RandomBytes&) = delete; + RandomBytes(RandomBytes&& o) : self(o.self) { memset(&o, 0, sizeof(RandomBytes)); } + RandomBytes(LDKRandomBytes&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRandomBytes)); } + operator LDKRandomBytes() && { LDKRandomBytes res = self; memset(&self, 0, sizeof(LDKRandomBytes)); return res; } + ~RandomBytes() { RandomBytes_free(self); } + RandomBytes& operator=(RandomBytes&& o) { RandomBytes_free(self); self = o.self; memset(&o, 0, sizeof(RandomBytes)); return *this; } + LDKRandomBytes* operator &() { return &self; } + LDKRandomBytes* operator ->() { return &self; } + const LDKRandomBytes* operator &() const { return &self; } + const LDKRandomBytes* operator ->() const { return &self; } +}; class BackgroundProcessor { private: LDKBackgroundProcessor self; @@ -1279,11 +1531,11 @@ public: */ inline LDK::CResult_RouteLightningErrorZ find_route_with_id(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs, struct LDKThirtyTwoBytes _payment_hash, struct LDKThirtyTwoBytes _payment_id); /** - * Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + * Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` * are assumed to be with the `recipient`'s peers. The payment secret and any constraints are * given in `tlvs`. */ - inline LDK::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); + inline LDK::CResult_CVec_BlindedPaymentPathZNoneZ create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats); }; class ScorerAccountingForInFlightHtlcs { private: @@ -1420,36 +1672,6 @@ public: const LDKPayee* operator &() const { return &self; } const LDKPayee* operator ->() const { return &self; } }; -class RouteHint { -private: - LDKRouteHint self; -public: - RouteHint(const RouteHint&) = delete; - RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); } - RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); } - operator LDKRouteHint() && { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; } - ~RouteHint() { RouteHint_free(self); } - RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } - LDKRouteHint* operator &() { return &self; } - LDKRouteHint* operator ->() { return &self; } - const LDKRouteHint* operator &() const { return &self; } - const LDKRouteHint* operator ->() const { return &self; } -}; -class RouteHintHop { -private: - LDKRouteHintHop self; -public: - RouteHintHop(const RouteHintHop&) = delete; - RouteHintHop(RouteHintHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHintHop)); } - RouteHintHop(LDKRouteHintHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHintHop)); } - operator LDKRouteHintHop() && { LDKRouteHintHop res = self; memset(&self, 0, sizeof(LDKRouteHintHop)); return res; } - ~RouteHintHop() { RouteHintHop_free(self); } - RouteHintHop& operator=(RouteHintHop&& o) { RouteHintHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHintHop)); return *this; } - LDKRouteHintHop* operator &() { return &self; } - LDKRouteHintHop* operator ->() { return &self; } - const LDKRouteHintHop* operator &() const { return &self; } - const LDKRouteHintHop* operator ->() const { return &self; } -}; class FirstHopCandidate { private: LDKFirstHopCandidate self; @@ -1540,6 +1762,36 @@ public: const LDKCandidateRouteHop* operator &() const { return &self; } const LDKCandidateRouteHop* operator ->() const { return &self; } }; +class UntrustedString { +private: + LDKUntrustedString self; +public: + UntrustedString(const UntrustedString&) = delete; + UntrustedString(UntrustedString&& o) : self(o.self) { memset(&o, 0, sizeof(UntrustedString)); } + UntrustedString(LDKUntrustedString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUntrustedString)); } + operator LDKUntrustedString() && { LDKUntrustedString res = self; memset(&self, 0, sizeof(LDKUntrustedString)); return res; } + ~UntrustedString() { UntrustedString_free(self); } + UntrustedString& operator=(UntrustedString&& o) { UntrustedString_free(self); self = o.self; memset(&o, 0, sizeof(UntrustedString)); return *this; } + LDKUntrustedString* operator &() { return &self; } + LDKUntrustedString* operator ->() { return &self; } + const LDKUntrustedString* operator &() const { return &self; } + const LDKUntrustedString* operator ->() const { return &self; } +}; +class PrintableString { +private: + LDKPrintableString self; +public: + PrintableString(const PrintableString&) = delete; + PrintableString(PrintableString&& o) : self(o.self) { memset(&o, 0, sizeof(PrintableString)); } + PrintableString(LDKPrintableString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrintableString)); } + operator LDKPrintableString() && { LDKPrintableString res = self; memset(&self, 0, sizeof(LDKPrintableString)); return res; } + ~PrintableString() { PrintableString_free(self); } + PrintableString& operator=(PrintableString&& o) { PrintableString_free(self); self = o.self; memset(&o, 0, sizeof(PrintableString)); return *this; } + LDKPrintableString* operator &() { return &self; } + LDKPrintableString* operator ->() { return &self; } + const LDKPrintableString* operator &() const { return &self; } + const LDKPrintableString* operator ->() const { return &self; } +}; class ScoreLookUp { private: LDKScoreLookUp self; @@ -1969,7 +2221,7 @@ public: * For details on asynchronous [`ChannelMonitor`] updating and returning * [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. */ - inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events(); + inline LDK::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events(); }; class Filter { private: @@ -1988,6 +2240,11 @@ public: /** * Registers interest in a transaction with `txid` and having an output with `script_pubkey` as * a spending condition. + * + * This may be used, for example, to monitor for when a funding transaction confirms. + * + * The `script_pubkey` is provided for informational purposes and may be useful for block + * sources which only support filtering on scripts. */ inline void register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey); /** @@ -1997,6 +2254,9 @@ public: * to ensure that also dependent output spents within an already connected block are correctly * handled, e.g., by re-scanning the block in question whenever new outputs have been * registered mid-processing. + * + * This may be used, for example, to monitor for when a funding output is spent (by any + * transaction). */ inline void register_output(struct LDKWatchedOutput output); }; @@ -2015,157 +2275,67 @@ public: const LDKWatchedOutput* operator &() const { return &self; } const LDKWatchedOutput* operator ->() const { return &self; } }; -class InitFeatures { +class OfferId { +private: + LDKOfferId self; +public: + OfferId(const OfferId&) = delete; + OfferId(OfferId&& o) : self(o.self) { memset(&o, 0, sizeof(OfferId)); } + OfferId(LDKOfferId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferId)); } + operator LDKOfferId() && { LDKOfferId res = self; memset(&self, 0, sizeof(LDKOfferId)); return res; } + ~OfferId() { OfferId_free(self); } + OfferId& operator=(OfferId&& o) { OfferId_free(self); self = o.self; memset(&o, 0, sizeof(OfferId)); return *this; } + LDKOfferId* operator &() { return &self; } + LDKOfferId* operator ->() { return &self; } + const LDKOfferId* operator &() const { return &self; } + const LDKOfferId* operator ->() const { return &self; } +}; +class OfferWithExplicitMetadataBuilder { +private: + LDKOfferWithExplicitMetadataBuilder self; +public: + OfferWithExplicitMetadataBuilder(const OfferWithExplicitMetadataBuilder&) = delete; + OfferWithExplicitMetadataBuilder(OfferWithExplicitMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); } + OfferWithExplicitMetadataBuilder(LDKOfferWithExplicitMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); } + operator LDKOfferWithExplicitMetadataBuilder() && { LDKOfferWithExplicitMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithExplicitMetadataBuilder)); return res; } + ~OfferWithExplicitMetadataBuilder() { OfferWithExplicitMetadataBuilder_free(self); } + OfferWithExplicitMetadataBuilder& operator=(OfferWithExplicitMetadataBuilder&& o) { OfferWithExplicitMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithExplicitMetadataBuilder)); return *this; } + LDKOfferWithExplicitMetadataBuilder* operator &() { return &self; } + LDKOfferWithExplicitMetadataBuilder* operator ->() { return &self; } + const LDKOfferWithExplicitMetadataBuilder* operator &() const { return &self; } + const LDKOfferWithExplicitMetadataBuilder* operator ->() const { return &self; } +}; +class OfferWithDerivedMetadataBuilder { +private: + LDKOfferWithDerivedMetadataBuilder self; +public: + OfferWithDerivedMetadataBuilder(const OfferWithDerivedMetadataBuilder&) = delete; + OfferWithDerivedMetadataBuilder(OfferWithDerivedMetadataBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); } + OfferWithDerivedMetadataBuilder(LDKOfferWithDerivedMetadataBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); } + operator LDKOfferWithDerivedMetadataBuilder() && { LDKOfferWithDerivedMetadataBuilder res = self; memset(&self, 0, sizeof(LDKOfferWithDerivedMetadataBuilder)); return res; } + ~OfferWithDerivedMetadataBuilder() { OfferWithDerivedMetadataBuilder_free(self); } + OfferWithDerivedMetadataBuilder& operator=(OfferWithDerivedMetadataBuilder&& o) { OfferWithDerivedMetadataBuilder_free(self); self = o.self; memset(&o, 0, sizeof(OfferWithDerivedMetadataBuilder)); return *this; } + LDKOfferWithDerivedMetadataBuilder* operator &() { return &self; } + LDKOfferWithDerivedMetadataBuilder* operator ->() { return &self; } + const LDKOfferWithDerivedMetadataBuilder* operator &() const { return &self; } + const LDKOfferWithDerivedMetadataBuilder* operator ->() const { return &self; } +}; +class Offer { private: - LDKInitFeatures self; + LDKOffer self; public: - InitFeatures(const InitFeatures&) = delete; - InitFeatures(InitFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InitFeatures)); } - InitFeatures(LDKInitFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInitFeatures)); } - operator LDKInitFeatures() && { LDKInitFeatures res = self; memset(&self, 0, sizeof(LDKInitFeatures)); return res; } - ~InitFeatures() { InitFeatures_free(self); } - InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } - LDKInitFeatures* operator &() { return &self; } - LDKInitFeatures* operator ->() { return &self; } - const LDKInitFeatures* operator &() const { return &self; } - const LDKInitFeatures* operator ->() const { return &self; } + Offer(const Offer&) = delete; + Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } + Offer(LDKOffer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffer)); } + operator LDKOffer() && { LDKOffer res = self; memset(&self, 0, sizeof(LDKOffer)); return res; } + ~Offer() { Offer_free(self); } + Offer& operator=(Offer&& o) { Offer_free(self); self = o.self; memset(&o, 0, sizeof(Offer)); return *this; } + LDKOffer* operator &() { return &self; } + LDKOffer* operator ->() { return &self; } + const LDKOffer* operator &() const { return &self; } + const LDKOffer* operator ->() const { return &self; } }; -class NodeFeatures { -private: - LDKNodeFeatures self; -public: - NodeFeatures(const NodeFeatures&) = delete; - NodeFeatures(NodeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(NodeFeatures)); } - NodeFeatures(LDKNodeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeFeatures)); } - operator LDKNodeFeatures() && { LDKNodeFeatures res = self; memset(&self, 0, sizeof(LDKNodeFeatures)); return res; } - ~NodeFeatures() { NodeFeatures_free(self); } - NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } - LDKNodeFeatures* operator &() { return &self; } - LDKNodeFeatures* operator ->() { return &self; } - const LDKNodeFeatures* operator &() const { return &self; } - const LDKNodeFeatures* operator ->() const { return &self; } -}; -class ChannelFeatures { -private: - LDKChannelFeatures self; -public: - ChannelFeatures(const ChannelFeatures&) = delete; - ChannelFeatures(ChannelFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelFeatures)); } - ChannelFeatures(LDKChannelFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelFeatures)); } - operator LDKChannelFeatures() && { LDKChannelFeatures res = self; memset(&self, 0, sizeof(LDKChannelFeatures)); return res; } - ~ChannelFeatures() { ChannelFeatures_free(self); } - ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } - LDKChannelFeatures* operator &() { return &self; } - LDKChannelFeatures* operator ->() { return &self; } - const LDKChannelFeatures* operator &() const { return &self; } - const LDKChannelFeatures* operator ->() const { return &self; } -}; -class Bolt11InvoiceFeatures { -private: - LDKBolt11InvoiceFeatures self; -public: - Bolt11InvoiceFeatures(const Bolt11InvoiceFeatures&) = delete; - Bolt11InvoiceFeatures(Bolt11InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); } - Bolt11InvoiceFeatures(LDKBolt11InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11InvoiceFeatures)); } - operator LDKBolt11InvoiceFeatures() && { LDKBolt11InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt11InvoiceFeatures)); return res; } - ~Bolt11InvoiceFeatures() { Bolt11InvoiceFeatures_free(self); } - Bolt11InvoiceFeatures& operator=(Bolt11InvoiceFeatures&& o) { Bolt11InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); return *this; } - LDKBolt11InvoiceFeatures* operator &() { return &self; } - LDKBolt11InvoiceFeatures* operator ->() { return &self; } - const LDKBolt11InvoiceFeatures* operator &() const { return &self; } - const LDKBolt11InvoiceFeatures* operator ->() const { return &self; } -}; -class OfferFeatures { -private: - LDKOfferFeatures self; -public: - OfferFeatures(const OfferFeatures&) = delete; - OfferFeatures(OfferFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(OfferFeatures)); } - OfferFeatures(LDKOfferFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferFeatures)); } - operator LDKOfferFeatures() && { LDKOfferFeatures res = self; memset(&self, 0, sizeof(LDKOfferFeatures)); return res; } - ~OfferFeatures() { OfferFeatures_free(self); } - OfferFeatures& operator=(OfferFeatures&& o) { OfferFeatures_free(self); self = o.self; memset(&o, 0, sizeof(OfferFeatures)); return *this; } - LDKOfferFeatures* operator &() { return &self; } - LDKOfferFeatures* operator ->() { return &self; } - const LDKOfferFeatures* operator &() const { return &self; } - const LDKOfferFeatures* operator ->() const { return &self; } -}; -class InvoiceRequestFeatures { -private: - LDKInvoiceRequestFeatures self; -public: - InvoiceRequestFeatures(const InvoiceRequestFeatures&) = delete; - InvoiceRequestFeatures(InvoiceRequestFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestFeatures)); } - InvoiceRequestFeatures(LDKInvoiceRequestFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestFeatures)); } - operator LDKInvoiceRequestFeatures() && { LDKInvoiceRequestFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceRequestFeatures)); return res; } - ~InvoiceRequestFeatures() { InvoiceRequestFeatures_free(self); } - InvoiceRequestFeatures& operator=(InvoiceRequestFeatures&& o) { InvoiceRequestFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestFeatures)); return *this; } - LDKInvoiceRequestFeatures* operator &() { return &self; } - LDKInvoiceRequestFeatures* operator ->() { return &self; } - const LDKInvoiceRequestFeatures* operator &() const { return &self; } - const LDKInvoiceRequestFeatures* operator ->() const { return &self; } -}; -class Bolt12InvoiceFeatures { -private: - LDKBolt12InvoiceFeatures self; -public: - Bolt12InvoiceFeatures(const Bolt12InvoiceFeatures&) = delete; - Bolt12InvoiceFeatures(Bolt12InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); } - Bolt12InvoiceFeatures(LDKBolt12InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12InvoiceFeatures)); } - operator LDKBolt12InvoiceFeatures() && { LDKBolt12InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt12InvoiceFeatures)); return res; } - ~Bolt12InvoiceFeatures() { Bolt12InvoiceFeatures_free(self); } - Bolt12InvoiceFeatures& operator=(Bolt12InvoiceFeatures&& o) { Bolt12InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); return *this; } - LDKBolt12InvoiceFeatures* operator &() { return &self; } - LDKBolt12InvoiceFeatures* operator ->() { return &self; } - const LDKBolt12InvoiceFeatures* operator &() const { return &self; } - const LDKBolt12InvoiceFeatures* operator ->() const { return &self; } -}; -class BlindedHopFeatures { -private: - LDKBlindedHopFeatures self; -public: - BlindedHopFeatures(const BlindedHopFeatures&) = delete; - BlindedHopFeatures(BlindedHopFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHopFeatures)); } - BlindedHopFeatures(LDKBlindedHopFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHopFeatures)); } - operator LDKBlindedHopFeatures() && { LDKBlindedHopFeatures res = self; memset(&self, 0, sizeof(LDKBlindedHopFeatures)); return res; } - ~BlindedHopFeatures() { BlindedHopFeatures_free(self); } - BlindedHopFeatures& operator=(BlindedHopFeatures&& o) { BlindedHopFeatures_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHopFeatures)); return *this; } - LDKBlindedHopFeatures* operator &() { return &self; } - LDKBlindedHopFeatures* operator ->() { return &self; } - const LDKBlindedHopFeatures* operator &() const { return &self; } - const LDKBlindedHopFeatures* operator ->() const { return &self; } -}; -class ChannelTypeFeatures { -private: - LDKChannelTypeFeatures self; -public: - ChannelTypeFeatures(const ChannelTypeFeatures&) = delete; - ChannelTypeFeatures(ChannelTypeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTypeFeatures)); } - ChannelTypeFeatures(LDKChannelTypeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTypeFeatures)); } - operator LDKChannelTypeFeatures() && { LDKChannelTypeFeatures res = self; memset(&self, 0, sizeof(LDKChannelTypeFeatures)); return res; } - ~ChannelTypeFeatures() { ChannelTypeFeatures_free(self); } - ChannelTypeFeatures& operator=(ChannelTypeFeatures&& o) { ChannelTypeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTypeFeatures)); return *this; } - LDKChannelTypeFeatures* operator &() { return &self; } - LDKChannelTypeFeatures* operator ->() { return &self; } - const LDKChannelTypeFeatures* operator &() const { return &self; } - const LDKChannelTypeFeatures* operator ->() const { return &self; } -}; -class Offer { -private: - LDKOffer self; -public: - Offer(const Offer&) = delete; - Offer(Offer&& o) : self(o.self) { memset(&o, 0, sizeof(Offer)); } - Offer(LDKOffer&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffer)); } - operator LDKOffer() && { LDKOffer res = self; memset(&self, 0, sizeof(LDKOffer)); return res; } - ~Offer() { Offer_free(self); } - Offer& operator=(Offer&& o) { Offer_free(self); self = o.self; memset(&o, 0, sizeof(Offer)); return *this; } - LDKOffer* operator &() { return &self; } - LDKOffer* operator ->() { return &self; } - const LDKOffer* operator &() const { return &self; } - const LDKOffer* operator ->() const { return &self; } -}; -class Amount { +class Amount { private: LDKAmount self; public: @@ -2330,20 +2500,20 @@ public: const LDKEffectiveCapacity* operator &() const { return &self; } const LDKEffectiveCapacity* operator ->() const { return &self; } }; -class RoutingFees { +class NodeAnnouncementDetails { private: - LDKRoutingFees self; + LDKNodeAnnouncementDetails self; public: - RoutingFees(const RoutingFees&) = delete; - RoutingFees(RoutingFees&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingFees)); } - RoutingFees(LDKRoutingFees&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingFees)); } - operator LDKRoutingFees() && { LDKRoutingFees res = self; memset(&self, 0, sizeof(LDKRoutingFees)); return res; } - ~RoutingFees() { RoutingFees_free(self); } - RoutingFees& operator=(RoutingFees&& o) { RoutingFees_free(self); self = o.self; memset(&o, 0, sizeof(RoutingFees)); return *this; } - LDKRoutingFees* operator &() { return &self; } - LDKRoutingFees* operator ->() { return &self; } - const LDKRoutingFees* operator &() const { return &self; } - const LDKRoutingFees* operator ->() const { return &self; } + NodeAnnouncementDetails(const NodeAnnouncementDetails&) = delete; + NodeAnnouncementDetails(NodeAnnouncementDetails&& o) : self(o.self) { memset(&o, 0, sizeof(NodeAnnouncementDetails)); } + NodeAnnouncementDetails(LDKNodeAnnouncementDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeAnnouncementDetails)); } + operator LDKNodeAnnouncementDetails() && { LDKNodeAnnouncementDetails res = self; memset(&self, 0, sizeof(LDKNodeAnnouncementDetails)); return res; } + ~NodeAnnouncementDetails() { NodeAnnouncementDetails_free(self); } + NodeAnnouncementDetails& operator=(NodeAnnouncementDetails&& o) { NodeAnnouncementDetails_free(self); self = o.self; memset(&o, 0, sizeof(NodeAnnouncementDetails)); return *this; } + LDKNodeAnnouncementDetails* operator &() { return &self; } + LDKNodeAnnouncementDetails* operator ->() { return &self; } + const LDKNodeAnnouncementDetails* operator &() const { return &self; } + const LDKNodeAnnouncementDetails* operator ->() const { return &self; } }; class NodeAnnouncementInfo { private: @@ -2390,6 +2560,20 @@ public: const LDKNodeInfo* operator &() const { return &self; } const LDKNodeInfo* operator ->() const { return &self; } }; +class ShortChannelIdError { +private: + LDKShortChannelIdError self; +public: + ShortChannelIdError(const ShortChannelIdError&) = delete; + ShortChannelIdError(ShortChannelIdError&& o) : self(o.self) { memset(&o, 0, sizeof(ShortChannelIdError)); } + ShortChannelIdError(LDKShortChannelIdError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKShortChannelIdError)); } + operator LDKShortChannelIdError() && { LDKShortChannelIdError res = self; memset(&self, 0, sizeof(LDKShortChannelIdError)); return res; } + ShortChannelIdError& operator=(ShortChannelIdError&& o) { self = o.self; memset(&o, 0, sizeof(ShortChannelIdError)); return *this; } + LDKShortChannelIdError* operator &() { return &self; } + LDKShortChannelIdError* operator ->() { return &self; } + const LDKShortChannelIdError* operator &() const { return &self; } + const LDKShortChannelIdError* operator ->() const { return &self; } +}; class InboundHTLCErr { private: LDKInboundHTLCErr self; @@ -2699,65 +2883,6 @@ public: const LDKChainParameters* operator &() const { return &self; } const LDKChainParameters* operator ->() const { return &self; } }; -class CounterpartyForwardingInfo { -private: - LDKCounterpartyForwardingInfo self; -public: - CounterpartyForwardingInfo(const CounterpartyForwardingInfo&) = delete; - CounterpartyForwardingInfo(CounterpartyForwardingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyForwardingInfo)); } - CounterpartyForwardingInfo(LDKCounterpartyForwardingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyForwardingInfo)); } - operator LDKCounterpartyForwardingInfo() && { LDKCounterpartyForwardingInfo res = self; memset(&self, 0, sizeof(LDKCounterpartyForwardingInfo)); return res; } - ~CounterpartyForwardingInfo() { CounterpartyForwardingInfo_free(self); } - CounterpartyForwardingInfo& operator=(CounterpartyForwardingInfo&& o) { CounterpartyForwardingInfo_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyForwardingInfo)); return *this; } - LDKCounterpartyForwardingInfo* operator &() { return &self; } - LDKCounterpartyForwardingInfo* operator ->() { return &self; } - const LDKCounterpartyForwardingInfo* operator &() const { return &self; } - const LDKCounterpartyForwardingInfo* operator ->() const { return &self; } -}; -class ChannelCounterparty { -private: - LDKChannelCounterparty self; -public: - ChannelCounterparty(const ChannelCounterparty&) = delete; - ChannelCounterparty(ChannelCounterparty&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelCounterparty)); } - ChannelCounterparty(LDKChannelCounterparty&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelCounterparty)); } - operator LDKChannelCounterparty() && { LDKChannelCounterparty res = self; memset(&self, 0, sizeof(LDKChannelCounterparty)); return res; } - ~ChannelCounterparty() { ChannelCounterparty_free(self); } - ChannelCounterparty& operator=(ChannelCounterparty&& o) { ChannelCounterparty_free(self); self = o.self; memset(&o, 0, sizeof(ChannelCounterparty)); return *this; } - LDKChannelCounterparty* operator &() { return &self; } - LDKChannelCounterparty* operator ->() { return &self; } - const LDKChannelCounterparty* operator &() const { return &self; } - const LDKChannelCounterparty* operator ->() const { return &self; } -}; -class ChannelDetails { -private: - LDKChannelDetails self; -public: - ChannelDetails(const ChannelDetails&) = delete; - ChannelDetails(ChannelDetails&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDetails)); } - ChannelDetails(LDKChannelDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDetails)); } - operator LDKChannelDetails() && { LDKChannelDetails res = self; memset(&self, 0, sizeof(LDKChannelDetails)); return res; } - ~ChannelDetails() { ChannelDetails_free(self); } - ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } - LDKChannelDetails* operator &() { return &self; } - LDKChannelDetails* operator ->() { return &self; } - const LDKChannelDetails* operator &() const { return &self; } - const LDKChannelDetails* operator ->() const { return &self; } -}; -class ChannelShutdownState { -private: - LDKChannelShutdownState self; -public: - ChannelShutdownState(const ChannelShutdownState&) = delete; - ChannelShutdownState(ChannelShutdownState&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelShutdownState)); } - ChannelShutdownState(LDKChannelShutdownState&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelShutdownState)); } - operator LDKChannelShutdownState() && { LDKChannelShutdownState res = self; memset(&self, 0, sizeof(LDKChannelShutdownState)); return res; } - ChannelShutdownState& operator=(ChannelShutdownState&& o) { self = o.self; memset(&o, 0, sizeof(ChannelShutdownState)); return *this; } - LDKChannelShutdownState* operator &() { return &self; } - LDKChannelShutdownState* operator ->() { return &self; } - const LDKChannelShutdownState* operator &() const { return &self; } - const LDKChannelShutdownState* operator ->() const { return &self; } -}; class RecentPaymentDetails { private: LDKRecentPaymentDetails self; @@ -2923,6 +3048,21 @@ public: const LDKTaggedHash* operator &() const { return &self; } const LDKTaggedHash* operator ->() const { return &self; } }; +class SignError { +private: + LDKSignError self; +public: + SignError(const SignError&) = delete; + SignError(SignError&& o) : self(o.self) { memset(&o, 0, sizeof(SignError)); } + SignError(LDKSignError&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignError)); } + operator LDKSignError() && { LDKSignError res = self; memset(&self, 0, sizeof(LDKSignError)); return res; } + ~SignError() { SignError_free(self); } + SignError& operator=(SignError&& o) { SignError_free(self); self = o.self; memset(&o, 0, sizeof(SignError)); return *this; } + LDKSignError* operator &() { return &self; } + LDKSignError* operator ->() { return &self; } + const LDKSignError* operator &() const { return &self; } + const LDKSignError* operator ->() const { return &self; } +}; class EcdsaChannelSigner { private: LDKEcdsaChannelSigner self; @@ -2964,6 +3104,13 @@ public: * This may be called multiple times for the same transaction. * * An external signer implementation should check that the commitment has not been revoked. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR commitment_tx); /** @@ -2981,6 +3128,13 @@ public: * revoked the state which they eventually broadcast. It's not a _holder_ secret key and does * not allow the spending of any funds by itself (you need our holder `revocation_secret` to do * so). + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_justice_revoked_output(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32]); /** @@ -3002,6 +3156,13 @@ public: * * `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script * (which is committed to in the BIP 143 signatures). + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_justice_revoked_htlc(struct LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (*per_commitment_key)[32], const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** @@ -3013,8 +3174,14 @@ public: * [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) * broadcasts it before receiving the update for the latest commitment transaction. * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * * [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All * [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_holder_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, const struct LDKHTLCDescriptor *NONNULL_PTR htlc_descriptor); /** @@ -3035,6 +3202,13 @@ public: * detected onchain. It has been generated by our counterparty and is used to derive * channel state keys, which are then included in the witness script and committed to in the * BIP 143 signature. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(struct LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, struct LDKPublicKey per_commitment_point, const struct LDKHTLCOutputInCommitment *NONNULL_PTR htlc); /** @@ -3047,6 +3221,13 @@ public: /** * Computes the signature for a commitment transaction's anchor output used as an * input within `anchor_tx`, which spends the commitment transaction, at index `input`. + * + * An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + * signature and should be retried later. Once the signer is ready to provide a signature after + * previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + * monitor. + * + * [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked */ inline LDK::CResult_ECDSASignatureNoneZ sign_holder_anchor_input(struct LDKTransaction anchor_tx, uintptr_t input); /** @@ -3064,21 +3245,6 @@ public: */ inline LDK::CResult_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(const struct LDKUnsignedChannelAnnouncement *NONNULL_PTR msg); }; -class WriteableEcdsaChannelSigner { -private: - LDKWriteableEcdsaChannelSigner self; -public: - WriteableEcdsaChannelSigner(const WriteableEcdsaChannelSigner&) = delete; - WriteableEcdsaChannelSigner(WriteableEcdsaChannelSigner&& o) : self(o.self) { memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); } - WriteableEcdsaChannelSigner(LDKWriteableEcdsaChannelSigner&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); } - operator LDKWriteableEcdsaChannelSigner() && { LDKWriteableEcdsaChannelSigner res = self; memset(&self, 0, sizeof(LDKWriteableEcdsaChannelSigner)); return res; } - ~WriteableEcdsaChannelSigner() { WriteableEcdsaChannelSigner_free(self); } - WriteableEcdsaChannelSigner& operator=(WriteableEcdsaChannelSigner&& o) { WriteableEcdsaChannelSigner_free(self); self = o.self; memset(&o, 0, sizeof(WriteableEcdsaChannelSigner)); return *this; } - LDKWriteableEcdsaChannelSigner* operator &() { return &self; } - LDKWriteableEcdsaChannelSigner* operator ->() { return &self; } - const LDKWriteableEcdsaChannelSigner* operator &() const { return &self; } - const LDKWriteableEcdsaChannelSigner* operator ->() const { return &self; } -}; class ChannelMonitorUpdate { private: LDKChannelMonitorUpdate self; @@ -3124,6 +3290,20 @@ public: const LDKHTLCUpdate* operator &() const { return &self; } const LDKHTLCUpdate* operator ->() const { return &self; } }; +class BalanceSource { +private: + LDKBalanceSource self; +public: + BalanceSource(const BalanceSource&) = delete; + BalanceSource(BalanceSource&& o) : self(o.self) { memset(&o, 0, sizeof(BalanceSource)); } + BalanceSource(LDKBalanceSource&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBalanceSource)); } + operator LDKBalanceSource() && { LDKBalanceSource res = self; memset(&self, 0, sizeof(LDKBalanceSource)); return res; } + BalanceSource& operator=(BalanceSource&& o) { self = o.self; memset(&o, 0, sizeof(BalanceSource)); return *this; } + LDKBalanceSource* operator &() { return &self; } + LDKBalanceSource* operator ->() { return &self; } + const LDKBalanceSource* operator &() const { return &self; } + const LDKBalanceSource* operator ->() const { return &self; } +}; class Balance { private: LDKBalance self; @@ -3195,6 +3375,18 @@ public: * connection to the node exists, then the message is simply not sent. */ inline LDK::CVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg(); + /** + * Indicates a peer disconnected. + */ + inline void peer_disconnected(struct LDKPublicKey their_node_id); + /** + * Handle a peer connecting. + * + * May return an `Err(())` if the features the peer supports are not sufficient to communicate + * with us. Implementors should be somewhat conservative about doing so, however, as other + * message handlers may still wish to communicate with this peer. + */ + inline LDK::CResult_NoneNoneZ peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound); /** * Gets the node feature flags which this handler itself supports. All available handlers are * queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] @@ -3306,6 +3498,21 @@ public: */ inline uint64_t hash(); }; +class PeerDetails { +private: + LDKPeerDetails self; +public: + PeerDetails(const PeerDetails&) = delete; + PeerDetails(PeerDetails&& o) : self(o.self) { memset(&o, 0, sizeof(PeerDetails)); } + PeerDetails(LDKPeerDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPeerDetails)); } + operator LDKPeerDetails() && { LDKPeerDetails res = self; memset(&self, 0, sizeof(LDKPeerDetails)); return res; } + ~PeerDetails() { PeerDetails_free(self); } + PeerDetails& operator=(PeerDetails&& o) { PeerDetails_free(self); self = o.self; memset(&o, 0, sizeof(PeerDetails)); return *this; } + LDKPeerDetails* operator &() { return &self; } + LDKPeerDetails* operator ->() { return &self; } + const LDKPeerDetails* operator &() const { return &self; } + const LDKPeerDetails* operator ->() const { return &self; } +}; class PeerHandleError { private: LDKPeerHandleError self; @@ -3440,6 +3647,8 @@ public: const LDKPersister* operator ->() const { return &self; } /** * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. + * + * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ inline LDK::CResult_NoneIOErrorZ persist_manager(const struct LDKChannelManager *NONNULL_PTR channel_manager); /** @@ -3466,6 +3675,36 @@ public: const LDKMonitorUpdatingPersister* operator &() const { return &self; } const LDKMonitorUpdatingPersister* operator ->() const { return &self; } }; +class InvoiceRequestWithExplicitPayerIdBuilder { +private: + LDKInvoiceRequestWithExplicitPayerIdBuilder self; +public: + InvoiceRequestWithExplicitPayerIdBuilder(const InvoiceRequestWithExplicitPayerIdBuilder&) = delete; + InvoiceRequestWithExplicitPayerIdBuilder(InvoiceRequestWithExplicitPayerIdBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestWithExplicitPayerIdBuilder)); } + InvoiceRequestWithExplicitPayerIdBuilder(LDKInvoiceRequestWithExplicitPayerIdBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestWithExplicitPayerIdBuilder)); } + operator LDKInvoiceRequestWithExplicitPayerIdBuilder() && { LDKInvoiceRequestWithExplicitPayerIdBuilder res = self; memset(&self, 0, sizeof(LDKInvoiceRequestWithExplicitPayerIdBuilder)); return res; } + ~InvoiceRequestWithExplicitPayerIdBuilder() { InvoiceRequestWithExplicitPayerIdBuilder_free(self); } + InvoiceRequestWithExplicitPayerIdBuilder& operator=(InvoiceRequestWithExplicitPayerIdBuilder&& o) { InvoiceRequestWithExplicitPayerIdBuilder_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestWithExplicitPayerIdBuilder)); return *this; } + LDKInvoiceRequestWithExplicitPayerIdBuilder* operator &() { return &self; } + LDKInvoiceRequestWithExplicitPayerIdBuilder* operator ->() { return &self; } + const LDKInvoiceRequestWithExplicitPayerIdBuilder* operator &() const { return &self; } + const LDKInvoiceRequestWithExplicitPayerIdBuilder* operator ->() const { return &self; } +}; +class InvoiceRequestWithDerivedPayerIdBuilder { +private: + LDKInvoiceRequestWithDerivedPayerIdBuilder self; +public: + InvoiceRequestWithDerivedPayerIdBuilder(const InvoiceRequestWithDerivedPayerIdBuilder&) = delete; + InvoiceRequestWithDerivedPayerIdBuilder(InvoiceRequestWithDerivedPayerIdBuilder&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestWithDerivedPayerIdBuilder)); } + InvoiceRequestWithDerivedPayerIdBuilder(LDKInvoiceRequestWithDerivedPayerIdBuilder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestWithDerivedPayerIdBuilder)); } + operator LDKInvoiceRequestWithDerivedPayerIdBuilder() && { LDKInvoiceRequestWithDerivedPayerIdBuilder res = self; memset(&self, 0, sizeof(LDKInvoiceRequestWithDerivedPayerIdBuilder)); return res; } + ~InvoiceRequestWithDerivedPayerIdBuilder() { InvoiceRequestWithDerivedPayerIdBuilder_free(self); } + InvoiceRequestWithDerivedPayerIdBuilder& operator=(InvoiceRequestWithDerivedPayerIdBuilder&& o) { InvoiceRequestWithDerivedPayerIdBuilder_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestWithDerivedPayerIdBuilder)); return *this; } + LDKInvoiceRequestWithDerivedPayerIdBuilder* operator &() { return &self; } + LDKInvoiceRequestWithDerivedPayerIdBuilder* operator ->() { return &self; } + const LDKInvoiceRequestWithDerivedPayerIdBuilder* operator &() const { return &self; } + const LDKInvoiceRequestWithDerivedPayerIdBuilder* operator ->() const { return &self; } +}; class UnsignedInvoiceRequest { private: LDKUnsignedInvoiceRequest self; @@ -3481,6 +3720,25 @@ public: const LDKUnsignedInvoiceRequest* operator &() const { return &self; } const LDKUnsignedInvoiceRequest* operator ->() const { return &self; } }; +class SignInvoiceRequestFn { +private: + LDKSignInvoiceRequestFn self; +public: + SignInvoiceRequestFn(const SignInvoiceRequestFn&) = delete; + SignInvoiceRequestFn(SignInvoiceRequestFn&& o) : self(o.self) { memset(&o, 0, sizeof(SignInvoiceRequestFn)); } + SignInvoiceRequestFn(LDKSignInvoiceRequestFn&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSignInvoiceRequestFn)); } + operator LDKSignInvoiceRequestFn() && { LDKSignInvoiceRequestFn res = self; memset(&self, 0, sizeof(LDKSignInvoiceRequestFn)); return res; } + ~SignInvoiceRequestFn() { SignInvoiceRequestFn_free(self); } + SignInvoiceRequestFn& operator=(SignInvoiceRequestFn&& o) { SignInvoiceRequestFn_free(self); self = o.self; memset(&o, 0, sizeof(SignInvoiceRequestFn)); return *this; } + LDKSignInvoiceRequestFn* operator &() { return &self; } + LDKSignInvoiceRequestFn* operator ->() { return &self; } + const LDKSignInvoiceRequestFn* operator &() const { return &self; } + const LDKSignInvoiceRequestFn* operator ->() const { return &self; } + /** + * Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + */ + inline LDK::CResult_SchnorrSignatureNoneZ sign_invoice_request(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR message); +}; class InvoiceRequest { private: LDKInvoiceRequest self; @@ -3511,9 +3769,24 @@ public: const LDKVerifiedInvoiceRequest* operator &() const { return &self; } const LDKVerifiedInvoiceRequest* operator ->() const { return &self; } }; -class DecodeError { +class InvoiceRequestFields { private: - LDKDecodeError self; + LDKInvoiceRequestFields self; +public: + InvoiceRequestFields(const InvoiceRequestFields&) = delete; + InvoiceRequestFields(InvoiceRequestFields&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestFields)); } + InvoiceRequestFields(LDKInvoiceRequestFields&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestFields)); } + operator LDKInvoiceRequestFields() && { LDKInvoiceRequestFields res = self; memset(&self, 0, sizeof(LDKInvoiceRequestFields)); return res; } + ~InvoiceRequestFields() { InvoiceRequestFields_free(self); } + InvoiceRequestFields& operator=(InvoiceRequestFields&& o) { InvoiceRequestFields_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestFields)); return *this; } + LDKInvoiceRequestFields* operator &() { return &self; } + LDKInvoiceRequestFields* operator ->() { return &self; } + const LDKInvoiceRequestFields* operator &() const { return &self; } + const LDKInvoiceRequestFields* operator ->() const { return &self; } +}; +class DecodeError { +private: + LDKDecodeError self; public: DecodeError(const DecodeError&) = delete; DecodeError(DecodeError&& o) : self(o.self) { memset(&o, 0, sizeof(DecodeError)); } @@ -3601,6 +3874,36 @@ public: const LDKPong* operator &() const { return &self; } const LDKPong* operator ->() const { return &self; } }; +class CommonOpenChannelFields { +private: + LDKCommonOpenChannelFields self; +public: + CommonOpenChannelFields(const CommonOpenChannelFields&) = delete; + CommonOpenChannelFields(CommonOpenChannelFields&& o) : self(o.self) { memset(&o, 0, sizeof(CommonOpenChannelFields)); } + CommonOpenChannelFields(LDKCommonOpenChannelFields&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommonOpenChannelFields)); } + operator LDKCommonOpenChannelFields() && { LDKCommonOpenChannelFields res = self; memset(&self, 0, sizeof(LDKCommonOpenChannelFields)); return res; } + ~CommonOpenChannelFields() { CommonOpenChannelFields_free(self); } + CommonOpenChannelFields& operator=(CommonOpenChannelFields&& o) { CommonOpenChannelFields_free(self); self = o.self; memset(&o, 0, sizeof(CommonOpenChannelFields)); return *this; } + LDKCommonOpenChannelFields* operator &() { return &self; } + LDKCommonOpenChannelFields* operator ->() { return &self; } + const LDKCommonOpenChannelFields* operator &() const { return &self; } + const LDKCommonOpenChannelFields* operator ->() const { return &self; } +}; +class ChannelParameters { +private: + LDKChannelParameters self; +public: + ChannelParameters(const ChannelParameters&) = delete; + ChannelParameters(ChannelParameters&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelParameters)); } + ChannelParameters(LDKChannelParameters&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelParameters)); } + operator LDKChannelParameters() && { LDKChannelParameters res = self; memset(&self, 0, sizeof(LDKChannelParameters)); return res; } + ~ChannelParameters() { ChannelParameters_free(self); } + ChannelParameters& operator=(ChannelParameters&& o) { ChannelParameters_free(self); self = o.self; memset(&o, 0, sizeof(ChannelParameters)); return *this; } + LDKChannelParameters* operator &() { return &self; } + LDKChannelParameters* operator ->() { return &self; } + const LDKChannelParameters* operator &() const { return &self; } + const LDKChannelParameters* operator ->() const { return &self; } +}; class OpenChannel { private: LDKOpenChannel self; @@ -3631,6 +3934,21 @@ public: const LDKOpenChannelV2* operator &() const { return &self; } const LDKOpenChannelV2* operator ->() const { return &self; } }; +class CommonAcceptChannelFields { +private: + LDKCommonAcceptChannelFields self; +public: + CommonAcceptChannelFields(const CommonAcceptChannelFields&) = delete; + CommonAcceptChannelFields(CommonAcceptChannelFields&& o) : self(o.self) { memset(&o, 0, sizeof(CommonAcceptChannelFields)); } + CommonAcceptChannelFields(LDKCommonAcceptChannelFields&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommonAcceptChannelFields)); } + operator LDKCommonAcceptChannelFields() && { LDKCommonAcceptChannelFields res = self; memset(&self, 0, sizeof(LDKCommonAcceptChannelFields)); return res; } + ~CommonAcceptChannelFields() { CommonAcceptChannelFields_free(self); } + CommonAcceptChannelFields& operator=(CommonAcceptChannelFields&& o) { CommonAcceptChannelFields_free(self); self = o.self; memset(&o, 0, sizeof(CommonAcceptChannelFields)); return *this; } + LDKCommonAcceptChannelFields* operator &() { return &self; } + LDKCommonAcceptChannelFields* operator ->() { return &self; } + const LDKCommonAcceptChannelFields* operator &() const { return &self; } + const LDKCommonAcceptChannelFields* operator ->() const { return &self; } +}; class AcceptChannel { private: LDKAcceptChannel self; @@ -3721,20 +4039,20 @@ public: const LDKStfu* operator &() const { return &self; } const LDKStfu* operator ->() const { return &self; } }; -class Splice { +class SpliceInit { private: - LDKSplice self; + LDKSpliceInit self; public: - Splice(const Splice&) = delete; - Splice(Splice&& o) : self(o.self) { memset(&o, 0, sizeof(Splice)); } - Splice(LDKSplice&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSplice)); } - operator LDKSplice() && { LDKSplice res = self; memset(&self, 0, sizeof(LDKSplice)); return res; } - ~Splice() { Splice_free(self); } - Splice& operator=(Splice&& o) { Splice_free(self); self = o.self; memset(&o, 0, sizeof(Splice)); return *this; } - LDKSplice* operator &() { return &self; } - LDKSplice* operator ->() { return &self; } - const LDKSplice* operator &() const { return &self; } - const LDKSplice* operator ->() const { return &self; } + SpliceInit(const SpliceInit&) = delete; + SpliceInit(SpliceInit&& o) : self(o.self) { memset(&o, 0, sizeof(SpliceInit)); } + SpliceInit(LDKSpliceInit&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpliceInit)); } + operator LDKSpliceInit() && { LDKSpliceInit res = self; memset(&self, 0, sizeof(LDKSpliceInit)); return res; } + ~SpliceInit() { SpliceInit_free(self); } + SpliceInit& operator=(SpliceInit&& o) { SpliceInit_free(self); self = o.self; memset(&o, 0, sizeof(SpliceInit)); return *this; } + LDKSpliceInit* operator &() { return &self; } + LDKSpliceInit* operator ->() { return &self; } + const LDKSpliceInit* operator &() const { return &self; } + const LDKSpliceInit* operator ->() const { return &self; } }; class SpliceAck { private: @@ -4021,6 +4339,21 @@ public: const LDKUpdateFailMalformedHTLC* operator &() const { return &self; } const LDKUpdateFailMalformedHTLC* operator ->() const { return &self; } }; +class CommitmentSignedBatch { +private: + LDKCommitmentSignedBatch self; +public: + CommitmentSignedBatch(const CommitmentSignedBatch&) = delete; + CommitmentSignedBatch(CommitmentSignedBatch&& o) : self(o.self) { memset(&o, 0, sizeof(CommitmentSignedBatch)); } + CommitmentSignedBatch(LDKCommitmentSignedBatch&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCommitmentSignedBatch)); } + operator LDKCommitmentSignedBatch() && { LDKCommitmentSignedBatch res = self; memset(&self, 0, sizeof(LDKCommitmentSignedBatch)); return res; } + ~CommitmentSignedBatch() { CommitmentSignedBatch_free(self); } + CommitmentSignedBatch& operator=(CommitmentSignedBatch&& o) { CommitmentSignedBatch_free(self); self = o.self; memset(&o, 0, sizeof(CommitmentSignedBatch)); return *this; } + LDKCommitmentSignedBatch* operator &() { return &self; } + LDKCommitmentSignedBatch* operator ->() { return &self; } + const LDKCommitmentSignedBatch* operator &() const { return &self; } + const LDKCommitmentSignedBatch* operator ->() const { return &self; } +}; class CommitmentSigned { private: LDKCommitmentSigned self; @@ -4404,18 +4737,6 @@ public: * Handle an incoming `stfu` message from the given peer. */ inline void handle_stfu(struct LDKPublicKey their_node_id, const struct LDKStfu *NONNULL_PTR msg); - /** - * Handle an incoming `splice` message from the given peer. - */ - inline void handle_splice(struct LDKPublicKey their_node_id, const struct LDKSplice *NONNULL_PTR msg); - /** - * Handle an incoming `splice_ack` message from the given peer. - */ - inline void handle_splice_ack(struct LDKPublicKey their_node_id, const struct LDKSpliceAck *NONNULL_PTR msg); - /** - * Handle an incoming `splice_locked` message from the given peer. - */ - inline void handle_splice_locked(struct LDKPublicKey their_node_id, const struct LDKSpliceLocked *NONNULL_PTR msg); /** * Handle an incoming `tx_add_input message` from the given peer. */ @@ -4644,16 +4965,6 @@ public: LDKOnionMessageHandler* operator ->() { return &self; } const LDKOnionMessageHandler* operator &() const { return &self; } const LDKOnionMessageHandler* operator ->() const { return &self; } - /** - * Because much of the lightning network does not yet support forwarding onion messages, we - * may need to directly connect to a node which will forward a message for us. In such a case, - * this method will return the set of nodes which need connection by node_id and the - * corresponding socket addresses where they may accept incoming connections. - * - * Thus, this method should be polled regularly to detect messages await such a direct - * connection. - */ - inline LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ get_and_clear_connections_needed(); /** * Handle an incoming `onion_message` message from the given peer. */ @@ -4728,6 +5039,21 @@ public: const LDKOnionPacket* operator &() const { return &self; } const LDKOnionPacket* operator ->() const { return &self; } }; +class TrampolineOnionPacket { +private: + LDKTrampolineOnionPacket self; +public: + TrampolineOnionPacket(const TrampolineOnionPacket&) = delete; + TrampolineOnionPacket(TrampolineOnionPacket&& o) : self(o.self) { memset(&o, 0, sizeof(TrampolineOnionPacket)); } + TrampolineOnionPacket(LDKTrampolineOnionPacket&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrampolineOnionPacket)); } + operator LDKTrampolineOnionPacket() && { LDKTrampolineOnionPacket res = self; memset(&self, 0, sizeof(LDKTrampolineOnionPacket)); return res; } + ~TrampolineOnionPacket() { TrampolineOnionPacket_free(self); } + TrampolineOnionPacket& operator=(TrampolineOnionPacket&& o) { TrampolineOnionPacket_free(self); self = o.self; memset(&o, 0, sizeof(TrampolineOnionPacket)); return *this; } + LDKTrampolineOnionPacket* operator &() { return &self; } + LDKTrampolineOnionPacket* operator ->() { return &self; } + const LDKTrampolineOnionPacket* operator &() const { return &self; } + const LDKTrampolineOnionPacket* operator ->() const { return &self; } +}; class Level { private: LDKLevel self; @@ -4776,6 +5102,123 @@ public: */ inline void log(struct LDKRecord record); }; +class InboundHTLCStateDetails { +private: + LDKInboundHTLCStateDetails self; +public: + InboundHTLCStateDetails(const InboundHTLCStateDetails&) = delete; + InboundHTLCStateDetails(InboundHTLCStateDetails&& o) : self(o.self) { memset(&o, 0, sizeof(InboundHTLCStateDetails)); } + InboundHTLCStateDetails(LDKInboundHTLCStateDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInboundHTLCStateDetails)); } + operator LDKInboundHTLCStateDetails() && { LDKInboundHTLCStateDetails res = self; memset(&self, 0, sizeof(LDKInboundHTLCStateDetails)); return res; } + InboundHTLCStateDetails& operator=(InboundHTLCStateDetails&& o) { self = o.self; memset(&o, 0, sizeof(InboundHTLCStateDetails)); return *this; } + LDKInboundHTLCStateDetails* operator &() { return &self; } + LDKInboundHTLCStateDetails* operator ->() { return &self; } + const LDKInboundHTLCStateDetails* operator &() const { return &self; } + const LDKInboundHTLCStateDetails* operator ->() const { return &self; } +}; +class InboundHTLCDetails { +private: + LDKInboundHTLCDetails self; +public: + InboundHTLCDetails(const InboundHTLCDetails&) = delete; + InboundHTLCDetails(InboundHTLCDetails&& o) : self(o.self) { memset(&o, 0, sizeof(InboundHTLCDetails)); } + InboundHTLCDetails(LDKInboundHTLCDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInboundHTLCDetails)); } + operator LDKInboundHTLCDetails() && { LDKInboundHTLCDetails res = self; memset(&self, 0, sizeof(LDKInboundHTLCDetails)); return res; } + ~InboundHTLCDetails() { InboundHTLCDetails_free(self); } + InboundHTLCDetails& operator=(InboundHTLCDetails&& o) { InboundHTLCDetails_free(self); self = o.self; memset(&o, 0, sizeof(InboundHTLCDetails)); return *this; } + LDKInboundHTLCDetails* operator &() { return &self; } + LDKInboundHTLCDetails* operator ->() { return &self; } + const LDKInboundHTLCDetails* operator &() const { return &self; } + const LDKInboundHTLCDetails* operator ->() const { return &self; } +}; +class OutboundHTLCStateDetails { +private: + LDKOutboundHTLCStateDetails self; +public: + OutboundHTLCStateDetails(const OutboundHTLCStateDetails&) = delete; + OutboundHTLCStateDetails(OutboundHTLCStateDetails&& o) : self(o.self) { memset(&o, 0, sizeof(OutboundHTLCStateDetails)); } + OutboundHTLCStateDetails(LDKOutboundHTLCStateDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutboundHTLCStateDetails)); } + operator LDKOutboundHTLCStateDetails() && { LDKOutboundHTLCStateDetails res = self; memset(&self, 0, sizeof(LDKOutboundHTLCStateDetails)); return res; } + OutboundHTLCStateDetails& operator=(OutboundHTLCStateDetails&& o) { self = o.self; memset(&o, 0, sizeof(OutboundHTLCStateDetails)); return *this; } + LDKOutboundHTLCStateDetails* operator &() { return &self; } + LDKOutboundHTLCStateDetails* operator ->() { return &self; } + const LDKOutboundHTLCStateDetails* operator &() const { return &self; } + const LDKOutboundHTLCStateDetails* operator ->() const { return &self; } +}; +class OutboundHTLCDetails { +private: + LDKOutboundHTLCDetails self; +public: + OutboundHTLCDetails(const OutboundHTLCDetails&) = delete; + OutboundHTLCDetails(OutboundHTLCDetails&& o) : self(o.self) { memset(&o, 0, sizeof(OutboundHTLCDetails)); } + OutboundHTLCDetails(LDKOutboundHTLCDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutboundHTLCDetails)); } + operator LDKOutboundHTLCDetails() && { LDKOutboundHTLCDetails res = self; memset(&self, 0, sizeof(LDKOutboundHTLCDetails)); return res; } + ~OutboundHTLCDetails() { OutboundHTLCDetails_free(self); } + OutboundHTLCDetails& operator=(OutboundHTLCDetails&& o) { OutboundHTLCDetails_free(self); self = o.self; memset(&o, 0, sizeof(OutboundHTLCDetails)); return *this; } + LDKOutboundHTLCDetails* operator &() { return &self; } + LDKOutboundHTLCDetails* operator ->() { return &self; } + const LDKOutboundHTLCDetails* operator &() const { return &self; } + const LDKOutboundHTLCDetails* operator ->() const { return &self; } +}; +class CounterpartyForwardingInfo { +private: + LDKCounterpartyForwardingInfo self; +public: + CounterpartyForwardingInfo(const CounterpartyForwardingInfo&) = delete; + CounterpartyForwardingInfo(CounterpartyForwardingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(CounterpartyForwardingInfo)); } + CounterpartyForwardingInfo(LDKCounterpartyForwardingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCounterpartyForwardingInfo)); } + operator LDKCounterpartyForwardingInfo() && { LDKCounterpartyForwardingInfo res = self; memset(&self, 0, sizeof(LDKCounterpartyForwardingInfo)); return res; } + ~CounterpartyForwardingInfo() { CounterpartyForwardingInfo_free(self); } + CounterpartyForwardingInfo& operator=(CounterpartyForwardingInfo&& o) { CounterpartyForwardingInfo_free(self); self = o.self; memset(&o, 0, sizeof(CounterpartyForwardingInfo)); return *this; } + LDKCounterpartyForwardingInfo* operator &() { return &self; } + LDKCounterpartyForwardingInfo* operator ->() { return &self; } + const LDKCounterpartyForwardingInfo* operator &() const { return &self; } + const LDKCounterpartyForwardingInfo* operator ->() const { return &self; } +}; +class ChannelCounterparty { +private: + LDKChannelCounterparty self; +public: + ChannelCounterparty(const ChannelCounterparty&) = delete; + ChannelCounterparty(ChannelCounterparty&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelCounterparty)); } + ChannelCounterparty(LDKChannelCounterparty&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelCounterparty)); } + operator LDKChannelCounterparty() && { LDKChannelCounterparty res = self; memset(&self, 0, sizeof(LDKChannelCounterparty)); return res; } + ~ChannelCounterparty() { ChannelCounterparty_free(self); } + ChannelCounterparty& operator=(ChannelCounterparty&& o) { ChannelCounterparty_free(self); self = o.self; memset(&o, 0, sizeof(ChannelCounterparty)); return *this; } + LDKChannelCounterparty* operator &() { return &self; } + LDKChannelCounterparty* operator ->() { return &self; } + const LDKChannelCounterparty* operator &() const { return &self; } + const LDKChannelCounterparty* operator ->() const { return &self; } +}; +class ChannelDetails { +private: + LDKChannelDetails self; +public: + ChannelDetails(const ChannelDetails&) = delete; + ChannelDetails(ChannelDetails&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelDetails)); } + ChannelDetails(LDKChannelDetails&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelDetails)); } + operator LDKChannelDetails() && { LDKChannelDetails res = self; memset(&self, 0, sizeof(LDKChannelDetails)); return res; } + ~ChannelDetails() { ChannelDetails_free(self); } + ChannelDetails& operator=(ChannelDetails&& o) { ChannelDetails_free(self); self = o.self; memset(&o, 0, sizeof(ChannelDetails)); return *this; } + LDKChannelDetails* operator &() { return &self; } + LDKChannelDetails* operator ->() { return &self; } + const LDKChannelDetails* operator &() const { return &self; } + const LDKChannelDetails* operator ->() const { return &self; } +}; +class ChannelShutdownState { +private: + LDKChannelShutdownState self; +public: + ChannelShutdownState(const ChannelShutdownState&) = delete; + ChannelShutdownState(ChannelShutdownState&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelShutdownState)); } + ChannelShutdownState(LDKChannelShutdownState&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelShutdownState)); } + operator LDKChannelShutdownState() && { LDKChannelShutdownState res = self; memset(&self, 0, sizeof(LDKChannelShutdownState)); return res; } + ChannelShutdownState& operator=(ChannelShutdownState&& o) { self = o.self; memset(&o, 0, sizeof(ChannelShutdownState)); return *this; } + LDKChannelShutdownState* operator &() { return &self; } + LDKChannelShutdownState* operator ->() { return &self; } + const LDKChannelShutdownState* operator &() const { return &self; } + const LDKChannelShutdownState* operator ->() const { return &self; } +}; class FutureCallback { private: LDKFutureCallback self; @@ -4825,6 +5268,85 @@ public: const LDKSleeper* operator &() const { return &self; } const LDKSleeper* operator ->() const { return &self; } }; +class AsyncPaymentsMessageHandler { +private: + LDKAsyncPaymentsMessageHandler self; +public: + AsyncPaymentsMessageHandler(const AsyncPaymentsMessageHandler&) = delete; + AsyncPaymentsMessageHandler(AsyncPaymentsMessageHandler&& o) : self(o.self) { memset(&o, 0, sizeof(AsyncPaymentsMessageHandler)); } + AsyncPaymentsMessageHandler(LDKAsyncPaymentsMessageHandler&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAsyncPaymentsMessageHandler)); } + operator LDKAsyncPaymentsMessageHandler() && { LDKAsyncPaymentsMessageHandler res = self; memset(&self, 0, sizeof(LDKAsyncPaymentsMessageHandler)); return res; } + ~AsyncPaymentsMessageHandler() { AsyncPaymentsMessageHandler_free(self); } + AsyncPaymentsMessageHandler& operator=(AsyncPaymentsMessageHandler&& o) { AsyncPaymentsMessageHandler_free(self); self = o.self; memset(&o, 0, sizeof(AsyncPaymentsMessageHandler)); return *this; } + LDKAsyncPaymentsMessageHandler* operator &() { return &self; } + LDKAsyncPaymentsMessageHandler* operator ->() { return &self; } + const LDKAsyncPaymentsMessageHandler* operator &() const { return &self; } + const LDKAsyncPaymentsMessageHandler* operator ->() const { return &self; } + /** + * Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + * the held funds. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ held_htlc_available(struct LDKHeldHtlcAvailable message, struct LDKResponder responder); + /** + * Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + * should be released to the corresponding payee. + */ + inline void release_held_htlc(struct LDKReleaseHeldHtlc message); + /** + * Release any [`AsyncPaymentsMessage`]s that need to be sent. + * + * Typically, this is used for messages initiating an async payment flow rather than in response + * to another message. + */ + inline LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ release_pending_messages(); +}; +class AsyncPaymentsMessage { +private: + LDKAsyncPaymentsMessage self; +public: + AsyncPaymentsMessage(const AsyncPaymentsMessage&) = delete; + AsyncPaymentsMessage(AsyncPaymentsMessage&& o) : self(o.self) { memset(&o, 0, sizeof(AsyncPaymentsMessage)); } + AsyncPaymentsMessage(LDKAsyncPaymentsMessage&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKAsyncPaymentsMessage)); } + operator LDKAsyncPaymentsMessage() && { LDKAsyncPaymentsMessage res = self; memset(&self, 0, sizeof(LDKAsyncPaymentsMessage)); return res; } + ~AsyncPaymentsMessage() { AsyncPaymentsMessage_free(self); } + AsyncPaymentsMessage& operator=(AsyncPaymentsMessage&& o) { AsyncPaymentsMessage_free(self); self = o.self; memset(&o, 0, sizeof(AsyncPaymentsMessage)); return *this; } + LDKAsyncPaymentsMessage* operator &() { return &self; } + LDKAsyncPaymentsMessage* operator ->() { return &self; } + const LDKAsyncPaymentsMessage* operator &() const { return &self; } + const LDKAsyncPaymentsMessage* operator ->() const { return &self; } +}; +class HeldHtlcAvailable { +private: + LDKHeldHtlcAvailable self; +public: + HeldHtlcAvailable(const HeldHtlcAvailable&) = delete; + HeldHtlcAvailable(HeldHtlcAvailable&& o) : self(o.self) { memset(&o, 0, sizeof(HeldHtlcAvailable)); } + HeldHtlcAvailable(LDKHeldHtlcAvailable&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKHeldHtlcAvailable)); } + operator LDKHeldHtlcAvailable() && { LDKHeldHtlcAvailable res = self; memset(&self, 0, sizeof(LDKHeldHtlcAvailable)); return res; } + ~HeldHtlcAvailable() { HeldHtlcAvailable_free(self); } + HeldHtlcAvailable& operator=(HeldHtlcAvailable&& o) { HeldHtlcAvailable_free(self); self = o.self; memset(&o, 0, sizeof(HeldHtlcAvailable)); return *this; } + LDKHeldHtlcAvailable* operator &() { return &self; } + LDKHeldHtlcAvailable* operator ->() { return &self; } + const LDKHeldHtlcAvailable* operator &() const { return &self; } + const LDKHeldHtlcAvailable* operator ->() const { return &self; } +}; +class ReleaseHeldHtlc { +private: + LDKReleaseHeldHtlc self; +public: + ReleaseHeldHtlc(const ReleaseHeldHtlc&) = delete; + ReleaseHeldHtlc(ReleaseHeldHtlc&& o) : self(o.self) { memset(&o, 0, sizeof(ReleaseHeldHtlc)); } + ReleaseHeldHtlc(LDKReleaseHeldHtlc&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReleaseHeldHtlc)); } + operator LDKReleaseHeldHtlc() && { LDKReleaseHeldHtlc res = self; memset(&self, 0, sizeof(LDKReleaseHeldHtlc)); return res; } + ~ReleaseHeldHtlc() { ReleaseHeldHtlc_free(self); } + ReleaseHeldHtlc& operator=(ReleaseHeldHtlc&& o) { ReleaseHeldHtlc_free(self); self = o.self; memset(&o, 0, sizeof(ReleaseHeldHtlc)); return *this; } + LDKReleaseHeldHtlc* operator &() { return &self; } + LDKReleaseHeldHtlc* operator ->() { return &self; } + const LDKReleaseHeldHtlc* operator &() const { return &self; } + const LDKReleaseHeldHtlc* operator ->() const { return &self; } +}; class OffersMessageHandler { private: LDKOffersMessageHandler self; @@ -4846,15 +5368,17 @@ public: * The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. * * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::COption_OffersMessageZ handle_message(struct LDKOffersMessage message); + inline LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ handle_message(struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder); /** * Releases any [`OffersMessage`]s that need to be sent. * * Typically, this is used for messages initiating a payment flow rather than in response to * another message. The latter should use the return value of [`Self::handle_message`]. */ - inline LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ release_pending_messages(); + inline LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ release_pending_messages(); }; class OffersMessage { private: @@ -5258,11 +5782,30 @@ public: * Returns the TLV type identifying the message contents. MUST be >= 64. */ inline uint64_t tlv_type(); + /** + * Returns the message type + */ + inline LDK::Str msg_type(); /** * Return a human-readable "debug" string describing this object */ inline LDK::Str debug_str(); }; +class FundingInfo { +private: + LDKFundingInfo self; +public: + FundingInfo(const FundingInfo&) = delete; + FundingInfo(FundingInfo&& o) : self(o.self) { memset(&o, 0, sizeof(FundingInfo)); } + FundingInfo(LDKFundingInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKFundingInfo)); } + operator LDKFundingInfo() && { LDKFundingInfo res = self; memset(&self, 0, sizeof(LDKFundingInfo)); return res; } + ~FundingInfo() { FundingInfo_free(self); } + FundingInfo& operator=(FundingInfo&& o) { FundingInfo_free(self); self = o.self; memset(&o, 0, sizeof(FundingInfo)); return *this; } + LDKFundingInfo* operator &() { return &self; } + LDKFundingInfo* operator ->() { return &self; } + const LDKFundingInfo* operator &() const { return &self; } + const LDKFundingInfo* operator ->() const { return &self; } +}; class PaymentPurpose { private: LDKPaymentPurpose self; @@ -5423,6 +5966,21 @@ public: */ inline void process_pending_events(struct LDKEventHandler handler); }; +class ReplayEvent { +private: + LDKReplayEvent self; +public: + ReplayEvent(const ReplayEvent&) = delete; + ReplayEvent(ReplayEvent&& o) : self(o.self) { memset(&o, 0, sizeof(ReplayEvent)); } + ReplayEvent(LDKReplayEvent&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKReplayEvent)); } + operator LDKReplayEvent() && { LDKReplayEvent res = self; memset(&self, 0, sizeof(LDKReplayEvent)); return res; } + ~ReplayEvent() { ReplayEvent_free(self); } + ReplayEvent& operator=(ReplayEvent&& o) { ReplayEvent_free(self); self = o.self; memset(&o, 0, sizeof(ReplayEvent)); return *this; } + LDKReplayEvent* operator &() { return &self; } + LDKReplayEvent* operator ->() { return &self; } + const LDKReplayEvent* operator &() const { return &self; } + const LDKReplayEvent* operator ->() const { return &self; } +}; class EventHandler { private: LDKEventHandler self; @@ -5442,7 +6000,67 @@ public: * * See [`EventsProvider`] for details that must be considered when implementing this method. */ - inline void handle_event(struct LDKEvent event); + inline LDK::CResult_NoneReplayEventZ handle_event(struct LDKEvent event); +}; +class Nonce { +private: + LDKNonce self; +public: + Nonce(const Nonce&) = delete; + Nonce(Nonce&& o) : self(o.self) { memset(&o, 0, sizeof(Nonce)); } + Nonce(LDKNonce&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNonce)); } + operator LDKNonce() && { LDKNonce res = self; memset(&self, 0, sizeof(LDKNonce)); return res; } + ~Nonce() { Nonce_free(self); } + Nonce& operator=(Nonce&& o) { Nonce_free(self); self = o.self; memset(&o, 0, sizeof(Nonce)); return *this; } + LDKNonce* operator &() { return &self; } + LDKNonce* operator ->() { return &self; } + const LDKNonce* operator &() const { return &self; } + const LDKNonce* operator ->() const { return &self; } +}; +class RoutingFees { +private: + LDKRoutingFees self; +public: + RoutingFees(const RoutingFees&) = delete; + RoutingFees(RoutingFees&& o) : self(o.self) { memset(&o, 0, sizeof(RoutingFees)); } + RoutingFees(LDKRoutingFees&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRoutingFees)); } + operator LDKRoutingFees() && { LDKRoutingFees res = self; memset(&self, 0, sizeof(LDKRoutingFees)); return res; } + ~RoutingFees() { RoutingFees_free(self); } + RoutingFees& operator=(RoutingFees&& o) { RoutingFees_free(self); self = o.self; memset(&o, 0, sizeof(RoutingFees)); return *this; } + LDKRoutingFees* operator &() { return &self; } + LDKRoutingFees* operator ->() { return &self; } + const LDKRoutingFees* operator &() const { return &self; } + const LDKRoutingFees* operator ->() const { return &self; } +}; +class RouteHint { +private: + LDKRouteHint self; +public: + RouteHint(const RouteHint&) = delete; + RouteHint(RouteHint&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHint)); } + RouteHint(LDKRouteHint&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHint)); } + operator LDKRouteHint() && { LDKRouteHint res = self; memset(&self, 0, sizeof(LDKRouteHint)); return res; } + ~RouteHint() { RouteHint_free(self); } + RouteHint& operator=(RouteHint&& o) { RouteHint_free(self); self = o.self; memset(&o, 0, sizeof(RouteHint)); return *this; } + LDKRouteHint* operator &() { return &self; } + LDKRouteHint* operator ->() { return &self; } + const LDKRouteHint* operator &() const { return &self; } + const LDKRouteHint* operator ->() const { return &self; } +}; +class RouteHintHop { +private: + LDKRouteHintHop self; +public: + RouteHintHop(const RouteHintHop&) = delete; + RouteHintHop(RouteHintHop&& o) : self(o.self) { memset(&o, 0, sizeof(RouteHintHop)); } + RouteHintHop(LDKRouteHintHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKRouteHintHop)); } + operator LDKRouteHintHop() && { LDKRouteHintHop res = self; memset(&self, 0, sizeof(LDKRouteHintHop)); return res; } + ~RouteHintHop() { RouteHintHop_free(self); } + RouteHintHop& operator=(RouteHintHop&& o) { RouteHintHop_free(self); self = o.self; memset(&o, 0, sizeof(RouteHintHop)); return *this; } + LDKRouteHintHop* operator &() { return &self; } + LDKRouteHintHop* operator ->() { return &self; } + const LDKRouteHintHop* operator &() const { return &self; } + const LDKRouteHintHop* operator ->() const { return &self; } }; class Bolt11ParseError { private: @@ -5800,35 +6418,20 @@ public: const LDKTransactionU16LenLimited* operator &() const { return &self; } const LDKTransactionU16LenLimited* operator ->() const { return &self; } }; -class UntrustedString { -private: - LDKUntrustedString self; -public: - UntrustedString(const UntrustedString&) = delete; - UntrustedString(UntrustedString&& o) : self(o.self) { memset(&o, 0, sizeof(UntrustedString)); } - UntrustedString(LDKUntrustedString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUntrustedString)); } - operator LDKUntrustedString() && { LDKUntrustedString res = self; memset(&self, 0, sizeof(LDKUntrustedString)); return res; } - ~UntrustedString() { UntrustedString_free(self); } - UntrustedString& operator=(UntrustedString&& o) { UntrustedString_free(self); self = o.self; memset(&o, 0, sizeof(UntrustedString)); return *this; } - LDKUntrustedString* operator &() { return &self; } - LDKUntrustedString* operator ->() { return &self; } - const LDKUntrustedString* operator &() const { return &self; } - const LDKUntrustedString* operator ->() const { return &self; } -}; -class PrintableString { +class ChannelId { private: - LDKPrintableString self; + LDKChannelId self; public: - PrintableString(const PrintableString&) = delete; - PrintableString(PrintableString&& o) : self(o.self) { memset(&o, 0, sizeof(PrintableString)); } - PrintableString(LDKPrintableString&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPrintableString)); } - operator LDKPrintableString() && { LDKPrintableString res = self; memset(&self, 0, sizeof(LDKPrintableString)); return res; } - ~PrintableString() { PrintableString_free(self); } - PrintableString& operator=(PrintableString&& o) { PrintableString_free(self); self = o.self; memset(&o, 0, sizeof(PrintableString)); return *this; } - LDKPrintableString* operator &() { return &self; } - LDKPrintableString* operator ->() { return &self; } - const LDKPrintableString* operator &() const { return &self; } - const LDKPrintableString* operator ->() const { return &self; } + ChannelId(const ChannelId&) = delete; + ChannelId(ChannelId&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelId)); } + ChannelId(LDKChannelId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelId)); } + operator LDKChannelId() && { LDKChannelId res = self; memset(&self, 0, sizeof(LDKChannelId)); return res; } + ~ChannelId() { ChannelId_free(self); } + ChannelId& operator=(ChannelId&& o) { ChannelId_free(self); self = o.self; memset(&o, 0, sizeof(ChannelId)); return *this; } + LDKChannelId* operator &() { return &self; } + LDKChannelId* operator ->() { return &self; } + const LDKChannelId* operator &() const { return &self; } + const LDKChannelId* operator ->() const { return &self; } }; class CustomMessageReader { private: @@ -5875,20 +6478,50 @@ public: */ inline LDK::Str debug_str(); }; -class ForwardNode { +class BlindedPayInfo { +private: + LDKBlindedPayInfo self; +public: + BlindedPayInfo(const BlindedPayInfo&) = delete; + BlindedPayInfo(BlindedPayInfo&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPayInfo)); } + BlindedPayInfo(LDKBlindedPayInfo&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPayInfo)); } + operator LDKBlindedPayInfo() && { LDKBlindedPayInfo res = self; memset(&self, 0, sizeof(LDKBlindedPayInfo)); return res; } + ~BlindedPayInfo() { BlindedPayInfo_free(self); } + BlindedPayInfo& operator=(BlindedPayInfo&& o) { BlindedPayInfo_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPayInfo)); return *this; } + LDKBlindedPayInfo* operator &() { return &self; } + LDKBlindedPayInfo* operator ->() { return &self; } + const LDKBlindedPayInfo* operator &() const { return &self; } + const LDKBlindedPayInfo* operator ->() const { return &self; } +}; +class BlindedPaymentPath { private: - LDKForwardNode self; + LDKBlindedPaymentPath self; public: - ForwardNode(const ForwardNode&) = delete; - ForwardNode(ForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(ForwardNode)); } - ForwardNode(LDKForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKForwardNode)); } - operator LDKForwardNode() && { LDKForwardNode res = self; memset(&self, 0, sizeof(LDKForwardNode)); return res; } - ~ForwardNode() { ForwardNode_free(self); } - ForwardNode& operator=(ForwardNode&& o) { ForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(ForwardNode)); return *this; } - LDKForwardNode* operator &() { return &self; } - LDKForwardNode* operator ->() { return &self; } - const LDKForwardNode* operator &() const { return &self; } - const LDKForwardNode* operator ->() const { return &self; } + BlindedPaymentPath(const BlindedPaymentPath&) = delete; + BlindedPaymentPath(BlindedPaymentPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPaymentPath)); } + BlindedPaymentPath(LDKBlindedPaymentPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPaymentPath)); } + operator LDKBlindedPaymentPath() && { LDKBlindedPaymentPath res = self; memset(&self, 0, sizeof(LDKBlindedPaymentPath)); return res; } + ~BlindedPaymentPath() { BlindedPaymentPath_free(self); } + BlindedPaymentPath& operator=(BlindedPaymentPath&& o) { BlindedPaymentPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPaymentPath)); return *this; } + LDKBlindedPaymentPath* operator &() { return &self; } + LDKBlindedPaymentPath* operator ->() { return &self; } + const LDKBlindedPaymentPath* operator &() const { return &self; } + const LDKBlindedPaymentPath* operator ->() const { return &self; } +}; +class PaymentForwardNode { +private: + LDKPaymentForwardNode self; +public: + PaymentForwardNode(const PaymentForwardNode&) = delete; + PaymentForwardNode(PaymentForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentForwardNode)); } + PaymentForwardNode(LDKPaymentForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentForwardNode)); } + operator LDKPaymentForwardNode() && { LDKPaymentForwardNode res = self; memset(&self, 0, sizeof(LDKPaymentForwardNode)); return res; } + ~PaymentForwardNode() { PaymentForwardNode_free(self); } + PaymentForwardNode& operator=(PaymentForwardNode&& o) { PaymentForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(PaymentForwardNode)); return *this; } + LDKPaymentForwardNode* operator &() { return &self; } + LDKPaymentForwardNode* operator ->() { return &self; } + const LDKPaymentForwardNode* operator &() const { return &self; } + const LDKPaymentForwardNode* operator ->() const { return &self; } }; class ForwardTlvs { private: @@ -5950,6 +6583,66 @@ public: const LDKPaymentConstraints* operator &() const { return &self; } const LDKPaymentConstraints* operator ->() const { return &self; } }; +class PaymentContext { +private: + LDKPaymentContext self; +public: + PaymentContext(const PaymentContext&) = delete; + PaymentContext(PaymentContext&& o) : self(o.self) { memset(&o, 0, sizeof(PaymentContext)); } + PaymentContext(LDKPaymentContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKPaymentContext)); } + operator LDKPaymentContext() && { LDKPaymentContext res = self; memset(&self, 0, sizeof(LDKPaymentContext)); return res; } + ~PaymentContext() { PaymentContext_free(self); } + PaymentContext& operator=(PaymentContext&& o) { PaymentContext_free(self); self = o.self; memset(&o, 0, sizeof(PaymentContext)); return *this; } + LDKPaymentContext* operator &() { return &self; } + LDKPaymentContext* operator ->() { return &self; } + const LDKPaymentContext* operator &() const { return &self; } + const LDKPaymentContext* operator ->() const { return &self; } +}; +class UnknownPaymentContext { +private: + LDKUnknownPaymentContext self; +public: + UnknownPaymentContext(const UnknownPaymentContext&) = delete; + UnknownPaymentContext(UnknownPaymentContext&& o) : self(o.self) { memset(&o, 0, sizeof(UnknownPaymentContext)); } + UnknownPaymentContext(LDKUnknownPaymentContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKUnknownPaymentContext)); } + operator LDKUnknownPaymentContext() && { LDKUnknownPaymentContext res = self; memset(&self, 0, sizeof(LDKUnknownPaymentContext)); return res; } + ~UnknownPaymentContext() { UnknownPaymentContext_free(self); } + UnknownPaymentContext& operator=(UnknownPaymentContext&& o) { UnknownPaymentContext_free(self); self = o.self; memset(&o, 0, sizeof(UnknownPaymentContext)); return *this; } + LDKUnknownPaymentContext* operator &() { return &self; } + LDKUnknownPaymentContext* operator ->() { return &self; } + const LDKUnknownPaymentContext* operator &() const { return &self; } + const LDKUnknownPaymentContext* operator ->() const { return &self; } +}; +class Bolt12OfferContext { +private: + LDKBolt12OfferContext self; +public: + Bolt12OfferContext(const Bolt12OfferContext&) = delete; + Bolt12OfferContext(Bolt12OfferContext&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12OfferContext)); } + Bolt12OfferContext(LDKBolt12OfferContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12OfferContext)); } + operator LDKBolt12OfferContext() && { LDKBolt12OfferContext res = self; memset(&self, 0, sizeof(LDKBolt12OfferContext)); return res; } + ~Bolt12OfferContext() { Bolt12OfferContext_free(self); } + Bolt12OfferContext& operator=(Bolt12OfferContext&& o) { Bolt12OfferContext_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12OfferContext)); return *this; } + LDKBolt12OfferContext* operator &() { return &self; } + LDKBolt12OfferContext* operator ->() { return &self; } + const LDKBolt12OfferContext* operator &() const { return &self; } + const LDKBolt12OfferContext* operator ->() const { return &self; } +}; +class Bolt12RefundContext { +private: + LDKBolt12RefundContext self; +public: + Bolt12RefundContext(const Bolt12RefundContext&) = delete; + Bolt12RefundContext(Bolt12RefundContext&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12RefundContext)); } + Bolt12RefundContext(LDKBolt12RefundContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12RefundContext)); } + operator LDKBolt12RefundContext() && { LDKBolt12RefundContext res = self; memset(&self, 0, sizeof(LDKBolt12RefundContext)); return res; } + ~Bolt12RefundContext() { Bolt12RefundContext_free(self); } + Bolt12RefundContext& operator=(Bolt12RefundContext&& o) { Bolt12RefundContext_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12RefundContext)); return *this; } + LDKBolt12RefundContext* operator &() { return &self; } + LDKBolt12RefundContext* operator ->() { return &self; } + const LDKBolt12RefundContext* operator &() const { return &self; } + const LDKBolt12RefundContext* operator ->() const { return &self; } +}; class UtxoLookupError { private: LDKUtxoLookupError self; @@ -6032,6 +6725,51 @@ public: const LDKOnionMessenger* operator &() const { return &self; } const LDKOnionMessenger* operator ->() const { return &self; } }; +class Responder { +private: + LDKResponder self; +public: + Responder(const Responder&) = delete; + Responder(Responder&& o) : self(o.self) { memset(&o, 0, sizeof(Responder)); } + Responder(LDKResponder&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKResponder)); } + operator LDKResponder() && { LDKResponder res = self; memset(&self, 0, sizeof(LDKResponder)); return res; } + ~Responder() { Responder_free(self); } + Responder& operator=(Responder&& o) { Responder_free(self); self = o.self; memset(&o, 0, sizeof(Responder)); return *this; } + LDKResponder* operator &() { return &self; } + LDKResponder* operator ->() { return &self; } + const LDKResponder* operator &() const { return &self; } + const LDKResponder* operator ->() const { return &self; } +}; +class ResponseInstruction { +private: + LDKResponseInstruction self; +public: + ResponseInstruction(const ResponseInstruction&) = delete; + ResponseInstruction(ResponseInstruction&& o) : self(o.self) { memset(&o, 0, sizeof(ResponseInstruction)); } + ResponseInstruction(LDKResponseInstruction&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKResponseInstruction)); } + operator LDKResponseInstruction() && { LDKResponseInstruction res = self; memset(&self, 0, sizeof(LDKResponseInstruction)); return res; } + ~ResponseInstruction() { ResponseInstruction_free(self); } + ResponseInstruction& operator=(ResponseInstruction&& o) { ResponseInstruction_free(self); self = o.self; memset(&o, 0, sizeof(ResponseInstruction)); return *this; } + LDKResponseInstruction* operator &() { return &self; } + LDKResponseInstruction* operator ->() { return &self; } + const LDKResponseInstruction* operator &() const { return &self; } + const LDKResponseInstruction* operator ->() const { return &self; } +}; +class MessageSendInstructions { +private: + LDKMessageSendInstructions self; +public: + MessageSendInstructions(const MessageSendInstructions&) = delete; + MessageSendInstructions(MessageSendInstructions&& o) : self(o.self) { memset(&o, 0, sizeof(MessageSendInstructions)); } + MessageSendInstructions(LDKMessageSendInstructions&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageSendInstructions)); } + operator LDKMessageSendInstructions() && { LDKMessageSendInstructions res = self; memset(&self, 0, sizeof(LDKMessageSendInstructions)); return res; } + ~MessageSendInstructions() { MessageSendInstructions_free(self); } + MessageSendInstructions& operator=(MessageSendInstructions&& o) { MessageSendInstructions_free(self); self = o.self; memset(&o, 0, sizeof(MessageSendInstructions)); return *this; } + LDKMessageSendInstructions* operator &() { return &self; } + LDKMessageSendInstructions* operator ->() { return &self; } + const LDKMessageSendInstructions* operator &() const { return &self; } + const LDKMessageSendInstructions* operator ->() const { return &self; } +}; class MessageRouter { private: LDKMessageRouter self; @@ -6051,10 +6789,26 @@ public: */ inline LDK::CResult_OnionMessagePathNoneZ find_path(struct LDKPublicKey sender, struct LDKCVec_PublicKeyZ peers, struct LDKDestination destination); /** - * Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - * direct peers with the `recipient`. + * Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + * be direct peers with the `recipient`. + */ + inline LDK::CResult_CVec_BlindedMessagePathZNoneZ create_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers); + /** + * Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + * assumed to be direct peers with the `recipient`. + * + * Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + * which is beneficial when a QR code is used to transport the data. The SCID is passed using + * a [`MessageForwardNode`] but may be `None` for graceful degradation. + * + * Implementations using additional intermediate nodes are responsible for using a + * [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + * should call [`BlindedMessagePath::use_compact_introduction_node`]. + * + * The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + * ignoring the short channel ids. */ - inline LDK::CResult_CVec_BlindedPathZNoneZ create_blinded_paths(struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers); + inline LDK::CResult_CVec_BlindedMessagePathZNoneZ create_compact_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers); }; class DefaultMessageRouter { private: @@ -6149,8 +6903,10 @@ public: * Called with the custom message that was received, returning a response to send, if any. * * The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. + * + * Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::COption_OnionMessageContentsZ handle_custom_message(struct LDKOnionMessageContents msg); + inline LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ handle_custom_message(struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder); /** * Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the * message type is unknown. @@ -6162,7 +6918,7 @@ public: * Typically, this is used for messages initiating a message flow rather than in response to * another message. The latter should use the return value of [`Self::handle_custom_message`]. */ - inline LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ release_pending_custom_messages(); + inline LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ release_pending_custom_messages(); }; class PeeledOnion { private: @@ -6194,37 +6950,227 @@ public: const LDKFilesystemStore* operator &() const { return &self; } const LDKFilesystemStore* operator ->() const { return &self; } }; -class BlindedPath { +class InitFeatures { private: - LDKBlindedPath self; + LDKInitFeatures self; public: - BlindedPath(const BlindedPath&) = delete; - BlindedPath(BlindedPath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedPath)); } - BlindedPath(LDKBlindedPath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedPath)); } - operator LDKBlindedPath() && { LDKBlindedPath res = self; memset(&self, 0, sizeof(LDKBlindedPath)); return res; } - ~BlindedPath() { BlindedPath_free(self); } - BlindedPath& operator=(BlindedPath&& o) { BlindedPath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedPath)); return *this; } - LDKBlindedPath* operator &() { return &self; } - LDKBlindedPath* operator ->() { return &self; } - const LDKBlindedPath* operator &() const { return &self; } - const LDKBlindedPath* operator ->() const { return &self; } + InitFeatures(const InitFeatures&) = delete; + InitFeatures(InitFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InitFeatures)); } + InitFeatures(LDKInitFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInitFeatures)); } + operator LDKInitFeatures() && { LDKInitFeatures res = self; memset(&self, 0, sizeof(LDKInitFeatures)); return res; } + ~InitFeatures() { InitFeatures_free(self); } + InitFeatures& operator=(InitFeatures&& o) { InitFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InitFeatures)); return *this; } + LDKInitFeatures* operator &() { return &self; } + LDKInitFeatures* operator ->() { return &self; } + const LDKInitFeatures* operator &() const { return &self; } + const LDKInitFeatures* operator ->() const { return &self; } }; -class BlindedHop { +class NodeFeatures { private: - LDKBlindedHop self; + LDKNodeFeatures self; public: - BlindedHop(const BlindedHop&) = delete; - BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } - BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } - operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } - ~BlindedHop() { BlindedHop_free(self); } - BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } - LDKBlindedHop* operator &() { return &self; } - LDKBlindedHop* operator ->() { return &self; } - const LDKBlindedHop* operator &() const { return &self; } - const LDKBlindedHop* operator ->() const { return &self; } + NodeFeatures(const NodeFeatures&) = delete; + NodeFeatures(NodeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(NodeFeatures)); } + NodeFeatures(LDKNodeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeFeatures)); } + operator LDKNodeFeatures() && { LDKNodeFeatures res = self; memset(&self, 0, sizeof(LDKNodeFeatures)); return res; } + ~NodeFeatures() { NodeFeatures_free(self); } + NodeFeatures& operator=(NodeFeatures&& o) { NodeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(NodeFeatures)); return *this; } + LDKNodeFeatures* operator &() { return &self; } + LDKNodeFeatures* operator ->() { return &self; } + const LDKNodeFeatures* operator &() const { return &self; } + const LDKNodeFeatures* operator ->() const { return &self; } }; -class InvoiceError { +class ChannelFeatures { +private: + LDKChannelFeatures self; +public: + ChannelFeatures(const ChannelFeatures&) = delete; + ChannelFeatures(ChannelFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelFeatures)); } + ChannelFeatures(LDKChannelFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelFeatures)); } + operator LDKChannelFeatures() && { LDKChannelFeatures res = self; memset(&self, 0, sizeof(LDKChannelFeatures)); return res; } + ~ChannelFeatures() { ChannelFeatures_free(self); } + ChannelFeatures& operator=(ChannelFeatures&& o) { ChannelFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelFeatures)); return *this; } + LDKChannelFeatures* operator &() { return &self; } + LDKChannelFeatures* operator ->() { return &self; } + const LDKChannelFeatures* operator &() const { return &self; } + const LDKChannelFeatures* operator ->() const { return &self; } +}; +class Bolt11InvoiceFeatures { +private: + LDKBolt11InvoiceFeatures self; +public: + Bolt11InvoiceFeatures(const Bolt11InvoiceFeatures&) = delete; + Bolt11InvoiceFeatures(Bolt11InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); } + Bolt11InvoiceFeatures(LDKBolt11InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt11InvoiceFeatures)); } + operator LDKBolt11InvoiceFeatures() && { LDKBolt11InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt11InvoiceFeatures)); return res; } + ~Bolt11InvoiceFeatures() { Bolt11InvoiceFeatures_free(self); } + Bolt11InvoiceFeatures& operator=(Bolt11InvoiceFeatures&& o) { Bolt11InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt11InvoiceFeatures)); return *this; } + LDKBolt11InvoiceFeatures* operator &() { return &self; } + LDKBolt11InvoiceFeatures* operator ->() { return &self; } + const LDKBolt11InvoiceFeatures* operator &() const { return &self; } + const LDKBolt11InvoiceFeatures* operator ->() const { return &self; } +}; +class OfferFeatures { +private: + LDKOfferFeatures self; +public: + OfferFeatures(const OfferFeatures&) = delete; + OfferFeatures(OfferFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(OfferFeatures)); } + OfferFeatures(LDKOfferFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOfferFeatures)); } + operator LDKOfferFeatures() && { LDKOfferFeatures res = self; memset(&self, 0, sizeof(LDKOfferFeatures)); return res; } + ~OfferFeatures() { OfferFeatures_free(self); } + OfferFeatures& operator=(OfferFeatures&& o) { OfferFeatures_free(self); self = o.self; memset(&o, 0, sizeof(OfferFeatures)); return *this; } + LDKOfferFeatures* operator &() { return &self; } + LDKOfferFeatures* operator ->() { return &self; } + const LDKOfferFeatures* operator &() const { return &self; } + const LDKOfferFeatures* operator ->() const { return &self; } +}; +class InvoiceRequestFeatures { +private: + LDKInvoiceRequestFeatures self; +public: + InvoiceRequestFeatures(const InvoiceRequestFeatures&) = delete; + InvoiceRequestFeatures(InvoiceRequestFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(InvoiceRequestFeatures)); } + InvoiceRequestFeatures(LDKInvoiceRequestFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKInvoiceRequestFeatures)); } + operator LDKInvoiceRequestFeatures() && { LDKInvoiceRequestFeatures res = self; memset(&self, 0, sizeof(LDKInvoiceRequestFeatures)); return res; } + ~InvoiceRequestFeatures() { InvoiceRequestFeatures_free(self); } + InvoiceRequestFeatures& operator=(InvoiceRequestFeatures&& o) { InvoiceRequestFeatures_free(self); self = o.self; memset(&o, 0, sizeof(InvoiceRequestFeatures)); return *this; } + LDKInvoiceRequestFeatures* operator &() { return &self; } + LDKInvoiceRequestFeatures* operator ->() { return &self; } + const LDKInvoiceRequestFeatures* operator &() const { return &self; } + const LDKInvoiceRequestFeatures* operator ->() const { return &self; } +}; +class Bolt12InvoiceFeatures { +private: + LDKBolt12InvoiceFeatures self; +public: + Bolt12InvoiceFeatures(const Bolt12InvoiceFeatures&) = delete; + Bolt12InvoiceFeatures(Bolt12InvoiceFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); } + Bolt12InvoiceFeatures(LDKBolt12InvoiceFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBolt12InvoiceFeatures)); } + operator LDKBolt12InvoiceFeatures() && { LDKBolt12InvoiceFeatures res = self; memset(&self, 0, sizeof(LDKBolt12InvoiceFeatures)); return res; } + ~Bolt12InvoiceFeatures() { Bolt12InvoiceFeatures_free(self); } + Bolt12InvoiceFeatures& operator=(Bolt12InvoiceFeatures&& o) { Bolt12InvoiceFeatures_free(self); self = o.self; memset(&o, 0, sizeof(Bolt12InvoiceFeatures)); return *this; } + LDKBolt12InvoiceFeatures* operator &() { return &self; } + LDKBolt12InvoiceFeatures* operator ->() { return &self; } + const LDKBolt12InvoiceFeatures* operator &() const { return &self; } + const LDKBolt12InvoiceFeatures* operator ->() const { return &self; } +}; +class BlindedHopFeatures { +private: + LDKBlindedHopFeatures self; +public: + BlindedHopFeatures(const BlindedHopFeatures&) = delete; + BlindedHopFeatures(BlindedHopFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHopFeatures)); } + BlindedHopFeatures(LDKBlindedHopFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHopFeatures)); } + operator LDKBlindedHopFeatures() && { LDKBlindedHopFeatures res = self; memset(&self, 0, sizeof(LDKBlindedHopFeatures)); return res; } + ~BlindedHopFeatures() { BlindedHopFeatures_free(self); } + BlindedHopFeatures& operator=(BlindedHopFeatures&& o) { BlindedHopFeatures_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHopFeatures)); return *this; } + LDKBlindedHopFeatures* operator &() { return &self; } + LDKBlindedHopFeatures* operator ->() { return &self; } + const LDKBlindedHopFeatures* operator &() const { return &self; } + const LDKBlindedHopFeatures* operator ->() const { return &self; } +}; +class ChannelTypeFeatures { +private: + LDKChannelTypeFeatures self; +public: + ChannelTypeFeatures(const ChannelTypeFeatures&) = delete; + ChannelTypeFeatures(ChannelTypeFeatures&& o) : self(o.self) { memset(&o, 0, sizeof(ChannelTypeFeatures)); } + ChannelTypeFeatures(LDKChannelTypeFeatures&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKChannelTypeFeatures)); } + operator LDKChannelTypeFeatures() && { LDKChannelTypeFeatures res = self; memset(&self, 0, sizeof(LDKChannelTypeFeatures)); return res; } + ~ChannelTypeFeatures() { ChannelTypeFeatures_free(self); } + ChannelTypeFeatures& operator=(ChannelTypeFeatures&& o) { ChannelTypeFeatures_free(self); self = o.self; memset(&o, 0, sizeof(ChannelTypeFeatures)); return *this; } + LDKChannelTypeFeatures* operator &() { return &self; } + LDKChannelTypeFeatures* operator ->() { return &self; } + const LDKChannelTypeFeatures* operator &() const { return &self; } + const LDKChannelTypeFeatures* operator ->() const { return &self; } +}; +class IntroductionNode { +private: + LDKIntroductionNode self; +public: + IntroductionNode(const IntroductionNode&) = delete; + IntroductionNode(IntroductionNode&& o) : self(o.self) { memset(&o, 0, sizeof(IntroductionNode)); } + IntroductionNode(LDKIntroductionNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKIntroductionNode)); } + operator LDKIntroductionNode() && { LDKIntroductionNode res = self; memset(&self, 0, sizeof(LDKIntroductionNode)); return res; } + ~IntroductionNode() { IntroductionNode_free(self); } + IntroductionNode& operator=(IntroductionNode&& o) { IntroductionNode_free(self); self = o.self; memset(&o, 0, sizeof(IntroductionNode)); return *this; } + LDKIntroductionNode* operator &() { return &self; } + LDKIntroductionNode* operator ->() { return &self; } + const LDKIntroductionNode* operator &() const { return &self; } + const LDKIntroductionNode* operator ->() const { return &self; } +}; +class Direction { +private: + LDKDirection self; +public: + Direction(const Direction&) = delete; + Direction(Direction&& o) : self(o.self) { memset(&o, 0, sizeof(Direction)); } + Direction(LDKDirection&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKDirection)); } + operator LDKDirection() && { LDKDirection res = self; memset(&self, 0, sizeof(LDKDirection)); return res; } + Direction& operator=(Direction&& o) { self = o.self; memset(&o, 0, sizeof(Direction)); return *this; } + LDKDirection* operator &() { return &self; } + LDKDirection* operator ->() { return &self; } + const LDKDirection* operator &() const { return &self; } + const LDKDirection* operator ->() const { return &self; } +}; +class NodeIdLookUp { +private: + LDKNodeIdLookUp self; +public: + NodeIdLookUp(const NodeIdLookUp&) = delete; + NodeIdLookUp(NodeIdLookUp&& o) : self(o.self) { memset(&o, 0, sizeof(NodeIdLookUp)); } + NodeIdLookUp(LDKNodeIdLookUp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNodeIdLookUp)); } + operator LDKNodeIdLookUp() && { LDKNodeIdLookUp res = self; memset(&self, 0, sizeof(LDKNodeIdLookUp)); return res; } + ~NodeIdLookUp() { NodeIdLookUp_free(self); } + NodeIdLookUp& operator=(NodeIdLookUp&& o) { NodeIdLookUp_free(self); self = o.self; memset(&o, 0, sizeof(NodeIdLookUp)); return *this; } + LDKNodeIdLookUp* operator &() { return &self; } + LDKNodeIdLookUp* operator ->() { return &self; } + const LDKNodeIdLookUp* operator &() const { return &self; } + const LDKNodeIdLookUp* operator ->() const { return &self; } + /** + * Returns the node id of the forwarding node's channel counterparty with `short_channel_id`. + * + * Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized + * by the [`NodeIdLookUp`] and the counterparty to one of that node's peers. + * + * [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + * + * Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + inline LDKPublicKey next_node_id(uint64_t short_channel_id); +}; +class EmptyNodeIdLookUp { +private: + LDKEmptyNodeIdLookUp self; +public: + EmptyNodeIdLookUp(const EmptyNodeIdLookUp&) = delete; + EmptyNodeIdLookUp(EmptyNodeIdLookUp&& o) : self(o.self) { memset(&o, 0, sizeof(EmptyNodeIdLookUp)); } + EmptyNodeIdLookUp(LDKEmptyNodeIdLookUp&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKEmptyNodeIdLookUp)); } + operator LDKEmptyNodeIdLookUp() && { LDKEmptyNodeIdLookUp res = self; memset(&self, 0, sizeof(LDKEmptyNodeIdLookUp)); return res; } + ~EmptyNodeIdLookUp() { EmptyNodeIdLookUp_free(self); } + EmptyNodeIdLookUp& operator=(EmptyNodeIdLookUp&& o) { EmptyNodeIdLookUp_free(self); self = o.self; memset(&o, 0, sizeof(EmptyNodeIdLookUp)); return *this; } + LDKEmptyNodeIdLookUp* operator &() { return &self; } + LDKEmptyNodeIdLookUp* operator ->() { return &self; } + const LDKEmptyNodeIdLookUp* operator &() const { return &self; } + const LDKEmptyNodeIdLookUp* operator ->() const { return &self; } +}; +class BlindedHop { +private: + LDKBlindedHop self; +public: + BlindedHop(const BlindedHop&) = delete; + BlindedHop(BlindedHop&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedHop)); } + BlindedHop(LDKBlindedHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedHop)); } + operator LDKBlindedHop() && { LDKBlindedHop res = self; memset(&self, 0, sizeof(LDKBlindedHop)); return res; } + ~BlindedHop() { BlindedHop_free(self); } + BlindedHop& operator=(BlindedHop&& o) { BlindedHop_free(self); self = o.self; memset(&o, 0, sizeof(BlindedHop)); return *this; } + LDKBlindedHop* operator &() { return &self; } + LDKBlindedHop* operator ->() { return &self; } + const LDKBlindedHop* operator &() const { return &self; } + const LDKBlindedHop* operator ->() const { return &self; } +}; +class InvoiceError { private: LDKInvoiceError self; public: @@ -6254,6 +7200,66 @@ public: const LDKErroneousField* operator &() const { return &self; } const LDKErroneousField* operator ->() const { return &self; } }; +class TrackedSpendableOutput { +private: + LDKTrackedSpendableOutput self; +public: + TrackedSpendableOutput(const TrackedSpendableOutput&) = delete; + TrackedSpendableOutput(TrackedSpendableOutput&& o) : self(o.self) { memset(&o, 0, sizeof(TrackedSpendableOutput)); } + TrackedSpendableOutput(LDKTrackedSpendableOutput&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKTrackedSpendableOutput)); } + operator LDKTrackedSpendableOutput() && { LDKTrackedSpendableOutput res = self; memset(&self, 0, sizeof(LDKTrackedSpendableOutput)); return res; } + ~TrackedSpendableOutput() { TrackedSpendableOutput_free(self); } + TrackedSpendableOutput& operator=(TrackedSpendableOutput&& o) { TrackedSpendableOutput_free(self); self = o.self; memset(&o, 0, sizeof(TrackedSpendableOutput)); return *this; } + LDKTrackedSpendableOutput* operator &() { return &self; } + LDKTrackedSpendableOutput* operator ->() { return &self; } + const LDKTrackedSpendableOutput* operator &() const { return &self; } + const LDKTrackedSpendableOutput* operator ->() const { return &self; } +}; +class OutputSpendStatus { +private: + LDKOutputSpendStatus self; +public: + OutputSpendStatus(const OutputSpendStatus&) = delete; + OutputSpendStatus(OutputSpendStatus&& o) : self(o.self) { memset(&o, 0, sizeof(OutputSpendStatus)); } + OutputSpendStatus(LDKOutputSpendStatus&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutputSpendStatus)); } + operator LDKOutputSpendStatus() && { LDKOutputSpendStatus res = self; memset(&self, 0, sizeof(LDKOutputSpendStatus)); return res; } + ~OutputSpendStatus() { OutputSpendStatus_free(self); } + OutputSpendStatus& operator=(OutputSpendStatus&& o) { OutputSpendStatus_free(self); self = o.self; memset(&o, 0, sizeof(OutputSpendStatus)); return *this; } + LDKOutputSpendStatus* operator &() { return &self; } + LDKOutputSpendStatus* operator ->() { return &self; } + const LDKOutputSpendStatus* operator &() const { return &self; } + const LDKOutputSpendStatus* operator ->() const { return &self; } +}; +class OutputSweeper { +private: + LDKOutputSweeper self; +public: + OutputSweeper(const OutputSweeper&) = delete; + OutputSweeper(OutputSweeper&& o) : self(o.self) { memset(&o, 0, sizeof(OutputSweeper)); } + OutputSweeper(LDKOutputSweeper&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOutputSweeper)); } + operator LDKOutputSweeper() && { LDKOutputSweeper res = self; memset(&self, 0, sizeof(LDKOutputSweeper)); return res; } + ~OutputSweeper() { OutputSweeper_free(self); } + OutputSweeper& operator=(OutputSweeper&& o) { OutputSweeper_free(self); self = o.self; memset(&o, 0, sizeof(OutputSweeper)); return *this; } + LDKOutputSweeper* operator &() { return &self; } + LDKOutputSweeper* operator ->() { return &self; } + const LDKOutputSweeper* operator &() const { return &self; } + const LDKOutputSweeper* operator ->() const { return &self; } +}; +class SpendingDelay { +private: + LDKSpendingDelay self; +public: + SpendingDelay(const SpendingDelay&) = delete; + SpendingDelay(SpendingDelay&& o) : self(o.self) { memset(&o, 0, sizeof(SpendingDelay)); } + SpendingDelay(LDKSpendingDelay&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKSpendingDelay)); } + operator LDKSpendingDelay() && { LDKSpendingDelay res = self; memset(&self, 0, sizeof(LDKSpendingDelay)); return res; } + ~SpendingDelay() { SpendingDelay_free(self); } + SpendingDelay& operator=(SpendingDelay&& o) { SpendingDelay_free(self); self = o.self; memset(&o, 0, sizeof(SpendingDelay)); return *this; } + LDKSpendingDelay* operator &() { return &self; } + LDKSpendingDelay* operator ->() { return &self; } + const LDKSpendingDelay* operator &() const { return &self; } + const LDKSpendingDelay* operator ->() const { return &self; } +}; class DelayedPaymentBasepoint { private: LDKDelayedPaymentBasepoint self; @@ -6344,21 +7350,6 @@ public: const LDKRevocationKey* operator &() const { return &self; } const LDKRevocationKey* operator ->() const { return &self; } }; -class MonitorUpdateId { -private: - LDKMonitorUpdateId self; -public: - MonitorUpdateId(const MonitorUpdateId&) = delete; - MonitorUpdateId(MonitorUpdateId&& o) : self(o.self) { memset(&o, 0, sizeof(MonitorUpdateId)); } - MonitorUpdateId(LDKMonitorUpdateId&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMonitorUpdateId)); } - operator LDKMonitorUpdateId() && { LDKMonitorUpdateId res = self; memset(&self, 0, sizeof(LDKMonitorUpdateId)); return res; } - ~MonitorUpdateId() { MonitorUpdateId_free(self); } - MonitorUpdateId& operator=(MonitorUpdateId&& o) { MonitorUpdateId_free(self); self = o.self; memset(&o, 0, sizeof(MonitorUpdateId)); return *this; } - LDKMonitorUpdateId* operator &() { return &self; } - LDKMonitorUpdateId* operator ->() { return &self; } - const LDKMonitorUpdateId* operator &() const { return &self; } - const LDKMonitorUpdateId* operator ->() const { return &self; } -}; class Persist { private: LDKPersist self; @@ -6381,8 +7372,9 @@ public: * channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint * and the stored channel data). Note that you **must** persist every new monitor to disk. * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` * and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. @@ -6390,7 +7382,7 @@ public: * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager * [`Writeable::write`]: crate::util::ser::Writeable::write */ - inline LDK::ChannelMonitorUpdateStatus persist_new_channel(struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + inline LDK::ChannelMonitorUpdateStatus persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor); /** * Update one channel's data. The provided [`ChannelMonitor`] has already applied the given * update. @@ -6408,7 +7400,9 @@ public: * If an implementer chooses to persist the updates only, they need to make * sure that all the updates are applied to the `ChannelMonitors` *before* * the set of channel monitors is given to the `ChannelManager` - * deserialization routine. See [`ChannelMonitor::update_monitor`] for + * deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + * implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + * See [`ChannelMonitor::update_monitor`] for * applying a monitor update to a monitor. If full `ChannelMonitors` are * persisted, then there is no need to persist individual updates. * @@ -6417,8 +7411,10 @@ public: * them in batches. The size of each monitor grows `O(number of state updates)` * whereas updates are small and `O(1)`. * - * The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - * if you return [`ChannelMonitorUpdateStatus::InProgress`]. + * The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + * links this call to [`ChainMonitor::channel_monitor_updated`]. + * For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + * when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. * * See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, * [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -6426,9 +7422,16 @@ public: * * [`Writeable::write`]: crate::util::ser::Writeable::write * - * Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None + * Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None */ - inline LDK::ChannelMonitorUpdateStatus update_persisted_channel(struct LDKOutPoint channel_id, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id); + inline LDK::ChannelMonitorUpdateStatus update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor); + /** + * Prevents the channel monitor from being loaded on startup. + * + * Archiving the data in a backup location (rather than deleting it fully) is useful for + * hedging against data loss in case of unexpected failure. + */ + inline void archive_persisted_channel(struct LDKOutPoint channel_funding_outpoint); }; class LockedChannelMonitor { private: @@ -6460,6 +7463,81 @@ public: const LDKChainMonitor* operator &() const { return &self; } const LDKChainMonitor* operator ->() const { return &self; } }; +class BlindedMessagePath { +private: + LDKBlindedMessagePath self; +public: + BlindedMessagePath(const BlindedMessagePath&) = delete; + BlindedMessagePath(BlindedMessagePath&& o) : self(o.self) { memset(&o, 0, sizeof(BlindedMessagePath)); } + BlindedMessagePath(LDKBlindedMessagePath&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKBlindedMessagePath)); } + operator LDKBlindedMessagePath() && { LDKBlindedMessagePath res = self; memset(&self, 0, sizeof(LDKBlindedMessagePath)); return res; } + ~BlindedMessagePath() { BlindedMessagePath_free(self); } + BlindedMessagePath& operator=(BlindedMessagePath&& o) { BlindedMessagePath_free(self); self = o.self; memset(&o, 0, sizeof(BlindedMessagePath)); return *this; } + LDKBlindedMessagePath* operator &() { return &self; } + LDKBlindedMessagePath* operator ->() { return &self; } + const LDKBlindedMessagePath* operator &() const { return &self; } + const LDKBlindedMessagePath* operator ->() const { return &self; } +}; +class NextMessageHop { +private: + LDKNextMessageHop self; +public: + NextMessageHop(const NextMessageHop&) = delete; + NextMessageHop(NextMessageHop&& o) : self(o.self) { memset(&o, 0, sizeof(NextMessageHop)); } + NextMessageHop(LDKNextMessageHop&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKNextMessageHop)); } + operator LDKNextMessageHop() && { LDKNextMessageHop res = self; memset(&self, 0, sizeof(LDKNextMessageHop)); return res; } + ~NextMessageHop() { NextMessageHop_free(self); } + NextMessageHop& operator=(NextMessageHop&& o) { NextMessageHop_free(self); self = o.self; memset(&o, 0, sizeof(NextMessageHop)); return *this; } + LDKNextMessageHop* operator &() { return &self; } + LDKNextMessageHop* operator ->() { return &self; } + const LDKNextMessageHop* operator &() const { return &self; } + const LDKNextMessageHop* operator ->() const { return &self; } +}; +class MessageForwardNode { +private: + LDKMessageForwardNode self; +public: + MessageForwardNode(const MessageForwardNode&) = delete; + MessageForwardNode(MessageForwardNode&& o) : self(o.self) { memset(&o, 0, sizeof(MessageForwardNode)); } + MessageForwardNode(LDKMessageForwardNode&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageForwardNode)); } + operator LDKMessageForwardNode() && { LDKMessageForwardNode res = self; memset(&self, 0, sizeof(LDKMessageForwardNode)); return res; } + ~MessageForwardNode() { MessageForwardNode_free(self); } + MessageForwardNode& operator=(MessageForwardNode&& o) { MessageForwardNode_free(self); self = o.self; memset(&o, 0, sizeof(MessageForwardNode)); return *this; } + LDKMessageForwardNode* operator &() { return &self; } + LDKMessageForwardNode* operator ->() { return &self; } + const LDKMessageForwardNode* operator &() const { return &self; } + const LDKMessageForwardNode* operator ->() const { return &self; } +}; +class MessageContext { +private: + LDKMessageContext self; +public: + MessageContext(const MessageContext&) = delete; + MessageContext(MessageContext&& o) : self(o.self) { memset(&o, 0, sizeof(MessageContext)); } + MessageContext(LDKMessageContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKMessageContext)); } + operator LDKMessageContext() && { LDKMessageContext res = self; memset(&self, 0, sizeof(LDKMessageContext)); return res; } + ~MessageContext() { MessageContext_free(self); } + MessageContext& operator=(MessageContext&& o) { MessageContext_free(self); self = o.self; memset(&o, 0, sizeof(MessageContext)); return *this; } + LDKMessageContext* operator &() { return &self; } + LDKMessageContext* operator ->() { return &self; } + const LDKMessageContext* operator &() const { return &self; } + const LDKMessageContext* operator ->() const { return &self; } +}; +class OffersContext { +private: + LDKOffersContext self; +public: + OffersContext(const OffersContext&) = delete; + OffersContext(OffersContext&& o) : self(o.self) { memset(&o, 0, sizeof(OffersContext)); } + OffersContext(LDKOffersContext&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKOffersContext)); } + operator LDKOffersContext() && { LDKOffersContext res = self; memset(&self, 0, sizeof(LDKOffersContext)); return res; } + ~OffersContext() { OffersContext_free(self); } + OffersContext& operator=(OffersContext&& o) { OffersContext_free(self); self = o.self; memset(&o, 0, sizeof(OffersContext)); return *this; } + LDKOffersContext* operator &() { return &self; } + LDKOffersContext* operator ->() { return &self; } + const LDKOffersContext* operator &() const { return &self; } + const LDKOffersContext* operator ->() const { return &self; } +}; class CResult_HtlcKeyDecodeErrorZ { private: LDKCResult_HtlcKeyDecodeErrorZ self; @@ -6490,6 +7568,21 @@ public: const LDKCResult_TransactionU16LenLimitedNoneZ* operator &() const { return &self; } const LDKCResult_TransactionU16LenLimitedNoneZ* operator ->() const { return &self; } }; +class CVec_TrackedSpendableOutputZ { +private: + LDKCVec_TrackedSpendableOutputZ self; +public: + CVec_TrackedSpendableOutputZ(const CVec_TrackedSpendableOutputZ&) = delete; + CVec_TrackedSpendableOutputZ(CVec_TrackedSpendableOutputZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TrackedSpendableOutputZ)); } + CVec_TrackedSpendableOutputZ(LDKCVec_TrackedSpendableOutputZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TrackedSpendableOutputZ)); } + operator LDKCVec_TrackedSpendableOutputZ() && { LDKCVec_TrackedSpendableOutputZ res = self; memset(&self, 0, sizeof(LDKCVec_TrackedSpendableOutputZ)); return res; } + ~CVec_TrackedSpendableOutputZ() { CVec_TrackedSpendableOutputZ_free(self); } + CVec_TrackedSpendableOutputZ& operator=(CVec_TrackedSpendableOutputZ&& o) { CVec_TrackedSpendableOutputZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TrackedSpendableOutputZ)); return *this; } + LDKCVec_TrackedSpendableOutputZ* operator &() { return &self; } + LDKCVec_TrackedSpendableOutputZ* operator ->() { return &self; } + const LDKCVec_TrackedSpendableOutputZ* operator &() const { return &self; } + const LDKCVec_TrackedSpendableOutputZ* operator ->() const { return &self; } +}; class CResult_LockedChannelMonitorNoneZ { private: LDKCResult_LockedChannelMonitorNoneZ self; @@ -6505,21 +7598,6 @@ public: const LDKCResult_LockedChannelMonitorNoneZ* operator &() const { return &self; } const LDKCResult_LockedChannelMonitorNoneZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { -private: - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ self; -public: - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(const CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&) = delete; - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); } - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); } - operator LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ() && { LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); return res; } - ~CVec_C2Tuple_BlindedPayInfoBlindedPathZZ() { CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(self); } - CVec_C2Tuple_BlindedPayInfoBlindedPathZZ& operator=(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ&& o) { CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_BlindedPayInfoBlindedPathZZ)); return *this; } - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator &() { return &self; } - LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ* operator ->() const { return &self; } -}; class CResult_PhantomRouteHintsDecodeErrorZ { private: LDKCResult_PhantomRouteHintsDecodeErrorZ self; @@ -6610,6 +7688,21 @@ public: const LDKCResult_ChannelInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelInfoDecodeErrorZ* operator ->() const { return &self; } }; +class COption_PaymentContextZ { +private: + LDKCOption_PaymentContextZ self; +public: + COption_PaymentContextZ(const COption_PaymentContextZ&) = delete; + COption_PaymentContextZ(COption_PaymentContextZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_PaymentContextZ)); } + COption_PaymentContextZ(LDKCOption_PaymentContextZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_PaymentContextZ)); } + operator LDKCOption_PaymentContextZ() && { LDKCOption_PaymentContextZ res = self; memset(&self, 0, sizeof(LDKCOption_PaymentContextZ)); return res; } + ~COption_PaymentContextZ() { COption_PaymentContextZ_free(self); } + COption_PaymentContextZ& operator=(COption_PaymentContextZ&& o) { COption_PaymentContextZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_PaymentContextZ)); return *this; } + LDKCOption_PaymentContextZ* operator &() { return &self; } + LDKCOption_PaymentContextZ* operator ->() { return &self; } + const LDKCOption_PaymentContextZ* operator &() const { return &self; } + const LDKCOption_PaymentContextZ* operator ->() const { return &self; } +}; class COption_MaxDustHTLCExposureZ { private: LDKCOption_MaxDustHTLCExposureZ self; @@ -6625,20 +7718,20 @@ public: const LDKCOption_MaxDustHTLCExposureZ* operator &() const { return &self; } const LDKCOption_MaxDustHTLCExposureZ* operator ->() const { return &self; } }; -class COption_OffersMessageZ { +class CResult_NoneSendErrorZ { private: - LDKCOption_OffersMessageZ self; + LDKCResult_NoneSendErrorZ self; public: - COption_OffersMessageZ(const COption_OffersMessageZ&) = delete; - COption_OffersMessageZ(COption_OffersMessageZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_OffersMessageZ)); } - COption_OffersMessageZ(LDKCOption_OffersMessageZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_OffersMessageZ)); } - operator LDKCOption_OffersMessageZ() && { LDKCOption_OffersMessageZ res = self; memset(&self, 0, sizeof(LDKCOption_OffersMessageZ)); return res; } - ~COption_OffersMessageZ() { COption_OffersMessageZ_free(self); } - COption_OffersMessageZ& operator=(COption_OffersMessageZ&& o) { COption_OffersMessageZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_OffersMessageZ)); return *this; } - LDKCOption_OffersMessageZ* operator &() { return &self; } - LDKCOption_OffersMessageZ* operator ->() { return &self; } - const LDKCOption_OffersMessageZ* operator &() const { return &self; } - const LDKCOption_OffersMessageZ* operator ->() const { return &self; } + CResult_NoneSendErrorZ(const CResult_NoneSendErrorZ&) = delete; + CResult_NoneSendErrorZ(CResult_NoneSendErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); } + CResult_NoneSendErrorZ(LDKCResult_NoneSendErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneSendErrorZ)); } + operator LDKCResult_NoneSendErrorZ() && { LDKCResult_NoneSendErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneSendErrorZ)); return res; } + ~CResult_NoneSendErrorZ() { CResult_NoneSendErrorZ_free(self); } + CResult_NoneSendErrorZ& operator=(CResult_NoneSendErrorZ&& o) { CResult_NoneSendErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneSendErrorZ)); return *this; } + LDKCResult_NoneSendErrorZ* operator &() { return &self; } + LDKCResult_NoneSendErrorZ* operator ->() { return &self; } + const LDKCResult_NoneSendErrorZ* operator &() const { return &self; } + const LDKCResult_NoneSendErrorZ* operator ->() const { return &self; } }; class CResult_CVec_u8ZPeerHandleErrorZ { private: @@ -6655,6 +7748,21 @@ public: const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZPeerHandleErrorZ* operator ->() const { return &self; } }; +class CResult_OnionPacketDecodeErrorZ { +private: + LDKCResult_OnionPacketDecodeErrorZ self; +public: + CResult_OnionPacketDecodeErrorZ(const CResult_OnionPacketDecodeErrorZ&) = delete; + CResult_OnionPacketDecodeErrorZ(CResult_OnionPacketDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); } + CResult_OnionPacketDecodeErrorZ(LDKCResult_OnionPacketDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); } + operator LDKCResult_OnionPacketDecodeErrorZ() && { LDKCResult_OnionPacketDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); return res; } + ~CResult_OnionPacketDecodeErrorZ() { CResult_OnionPacketDecodeErrorZ_free(self); } + CResult_OnionPacketDecodeErrorZ& operator=(CResult_OnionPacketDecodeErrorZ&& o) { CResult_OnionPacketDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); return *this; } + LDKCResult_OnionPacketDecodeErrorZ* operator &() { return &self; } + LDKCResult_OnionPacketDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OnionPacketDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OnionPacketDecodeErrorZ* operator ->() const { return &self; } +}; class COption_NetworkUpdateZ { private: LDKCOption_NetworkUpdateZ self; @@ -6685,21 +7793,6 @@ public: const LDKCOption_u64Z* operator &() const { return &self; } const LDKCOption_u64Z* operator ->() const { return &self; } }; -class CResult_OnionPacketDecodeErrorZ { -private: - LDKCResult_OnionPacketDecodeErrorZ self; -public: - CResult_OnionPacketDecodeErrorZ(const CResult_OnionPacketDecodeErrorZ&) = delete; - CResult_OnionPacketDecodeErrorZ(CResult_OnionPacketDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); } - CResult_OnionPacketDecodeErrorZ(LDKCResult_OnionPacketDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); } - operator LDKCResult_OnionPacketDecodeErrorZ() && { LDKCResult_OnionPacketDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OnionPacketDecodeErrorZ)); return res; } - ~CResult_OnionPacketDecodeErrorZ() { CResult_OnionPacketDecodeErrorZ_free(self); } - CResult_OnionPacketDecodeErrorZ& operator=(CResult_OnionPacketDecodeErrorZ&& o) { CResult_OnionPacketDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OnionPacketDecodeErrorZ)); return *this; } - LDKCResult_OnionPacketDecodeErrorZ* operator &() { return &self; } - LDKCResult_OnionPacketDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_OnionPacketDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_OnionPacketDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_GossipTimestampFilterDecodeErrorZ { private: LDKCResult_GossipTimestampFilterDecodeErrorZ self; @@ -6715,6 +7808,21 @@ public: const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator &() const { return &self; } const LDKCResult_GossipTimestampFilterDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_OnionMessageContentsResponseInstructionZ { +private: + LDKC2Tuple_OnionMessageContentsResponseInstructionZ self; +public: + C2Tuple_OnionMessageContentsResponseInstructionZ(const C2Tuple_OnionMessageContentsResponseInstructionZ&) = delete; + C2Tuple_OnionMessageContentsResponseInstructionZ(C2Tuple_OnionMessageContentsResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsResponseInstructionZ)); } + C2Tuple_OnionMessageContentsResponseInstructionZ(LDKC2Tuple_OnionMessageContentsResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OnionMessageContentsResponseInstructionZ)); } + operator LDKC2Tuple_OnionMessageContentsResponseInstructionZ() && { LDKC2Tuple_OnionMessageContentsResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OnionMessageContentsResponseInstructionZ)); return res; } + ~C2Tuple_OnionMessageContentsResponseInstructionZ() { C2Tuple_OnionMessageContentsResponseInstructionZ_free(self); } + C2Tuple_OnionMessageContentsResponseInstructionZ& operator=(C2Tuple_OnionMessageContentsResponseInstructionZ&& o) { C2Tuple_OnionMessageContentsResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsResponseInstructionZ)); return *this; } + LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_OnionMessageContentsResponseInstructionZ* operator ->() const { return &self; } +}; class CResult_RouteHintDecodeErrorZ { private: LDKCResult_RouteHintDecodeErrorZ self; @@ -6880,6 +7988,51 @@ public: const LDKC2Tuple__u1632_u1632Z* operator &() const { return &self; } const LDKC2Tuple__u1632_u1632Z* operator ->() const { return &self; } }; +class CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { +private: + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ self; +public: + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(const CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); } + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ() { CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ& operator=(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ&& o) { CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OffersMessageMessageSendInstructionsZZ* operator ->() const { return &self; } +}; +class C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { +private: + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ self; +public: + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(const C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&) = delete; + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); } + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); } + operator LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ() && { LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); return res; } + ~C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ() { C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(self); } + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ& operator=(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ&& o) { C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ* operator ->() const { return &self; } +}; +class CResult_TransactionNoneZ { +private: + LDKCResult_TransactionNoneZ self; +public: + CResult_TransactionNoneZ(const CResult_TransactionNoneZ&) = delete; + CResult_TransactionNoneZ(CResult_TransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionNoneZ)); } + CResult_TransactionNoneZ(LDKCResult_TransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionNoneZ)); } + operator LDKCResult_TransactionNoneZ() && { LDKCResult_TransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionNoneZ)); return res; } + ~CResult_TransactionNoneZ() { CResult_TransactionNoneZ_free(self); } + CResult_TransactionNoneZ& operator=(CResult_TransactionNoneZ&& o) { CResult_TransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionNoneZ)); return *this; } + LDKCResult_TransactionNoneZ* operator &() { return &self; } + LDKCResult_TransactionNoneZ* operator ->() { return &self; } + const LDKCResult_TransactionNoneZ* operator &() const { return &self; } + const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } +}; class CResult_CVec_StrZIOErrorZ { private: LDKCResult_CVec_StrZIOErrorZ self; @@ -6895,6 +8048,36 @@ public: const LDKCResult_CVec_StrZIOErrorZ* operator &() const { return &self; } const LDKCResult_CVec_StrZIOErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { +private: + LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ self; +public: + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ(const CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ&) = delete; + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ(CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ)); } + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ() { CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); } + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } +}; +class COption_ECDSASignatureZ { +private: + LDKCOption_ECDSASignatureZ self; +public: + COption_ECDSASignatureZ(const COption_ECDSASignatureZ&) = delete; + COption_ECDSASignatureZ(COption_ECDSASignatureZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_ECDSASignatureZ)); } + COption_ECDSASignatureZ(LDKCOption_ECDSASignatureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_ECDSASignatureZ)); } + operator LDKCOption_ECDSASignatureZ() && { LDKCOption_ECDSASignatureZ res = self; memset(&self, 0, sizeof(LDKCOption_ECDSASignatureZ)); return res; } + ~COption_ECDSASignatureZ() { COption_ECDSASignatureZ_free(self); } + COption_ECDSASignatureZ& operator=(COption_ECDSASignatureZ&& o) { COption_ECDSASignatureZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_ECDSASignatureZ)); return *this; } + LDKCOption_ECDSASignatureZ* operator &() { return &self; } + LDKCOption_ECDSASignatureZ* operator ->() { return &self; } + const LDKCOption_ECDSASignatureZ* operator &() const { return &self; } + const LDKCOption_ECDSASignatureZ* operator ->() const { return &self; } +}; class CResult_ClosingSignedFeeRangeDecodeErrorZ { private: LDKCResult_ClosingSignedFeeRangeDecodeErrorZ self; @@ -6910,21 +8093,6 @@ public: const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_TransactionNoneZ { -private: - LDKCResult_TransactionNoneZ self; -public: - CResult_TransactionNoneZ(const CResult_TransactionNoneZ&) = delete; - CResult_TransactionNoneZ(CResult_TransactionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TransactionNoneZ)); } - CResult_TransactionNoneZ(LDKCResult_TransactionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TransactionNoneZ)); } - operator LDKCResult_TransactionNoneZ() && { LDKCResult_TransactionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_TransactionNoneZ)); return res; } - ~CResult_TransactionNoneZ() { CResult_TransactionNoneZ_free(self); } - CResult_TransactionNoneZ& operator=(CResult_TransactionNoneZ&& o) { CResult_TransactionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TransactionNoneZ)); return *this; } - LDKCResult_TransactionNoneZ* operator &() { return &self; } - LDKCResult_TransactionNoneZ* operator ->() { return &self; } - const LDKCResult_TransactionNoneZ* operator &() const { return &self; } - const LDKCResult_TransactionNoneZ* operator ->() const { return &self; } -}; class CResult_CommitmentSignedDecodeErrorZ { private: LDKCResult_CommitmentSignedDecodeErrorZ self; @@ -6955,6 +8123,21 @@ public: const LDKCResult_CommitmentTransactionDecodeErrorZ* operator &() const { return &self; } const LDKCResult_CommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { +private: + LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ self; +public: + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ(const CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ&) = delete; + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ(CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ)); } + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ(LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ)); } + operator LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ() && { LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ)); return res; } + ~CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ() { CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(self); } + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ& operator=(CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ&& o) { CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ)); return *this; } + LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ* operator &() { return &self; } + LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_StfuDecodeErrorZ { private: LDKCResult_StfuDecodeErrorZ self; @@ -7015,6 +8198,36 @@ public: const LDKCOption_APIErrorZ* operator &() const { return &self; } const LDKCOption_APIErrorZ* operator ->() const { return &self; } }; +class CVec_PeerDetailsZ { +private: + LDKCVec_PeerDetailsZ self; +public: + CVec_PeerDetailsZ(const CVec_PeerDetailsZ&) = delete; + CVec_PeerDetailsZ(CVec_PeerDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PeerDetailsZ)); } + CVec_PeerDetailsZ(LDKCVec_PeerDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PeerDetailsZ)); } + operator LDKCVec_PeerDetailsZ() && { LDKCVec_PeerDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_PeerDetailsZ)); return res; } + ~CVec_PeerDetailsZ() { CVec_PeerDetailsZ_free(self); } + CVec_PeerDetailsZ& operator=(CVec_PeerDetailsZ&& o) { CVec_PeerDetailsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PeerDetailsZ)); return *this; } + LDKCVec_PeerDetailsZ* operator &() { return &self; } + LDKCVec_PeerDetailsZ* operator ->() { return &self; } + const LDKCVec_PeerDetailsZ* operator &() const { return &self; } + const LDKCVec_PeerDetailsZ* operator ->() const { return &self; } +}; +class CResult_u64ShortChannelIdErrorZ { +private: + LDKCResult_u64ShortChannelIdErrorZ self; +public: + CResult_u64ShortChannelIdErrorZ(const CResult_u64ShortChannelIdErrorZ&) = delete; + CResult_u64ShortChannelIdErrorZ(CResult_u64ShortChannelIdErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_u64ShortChannelIdErrorZ)); } + CResult_u64ShortChannelIdErrorZ(LDKCResult_u64ShortChannelIdErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_u64ShortChannelIdErrorZ)); } + operator LDKCResult_u64ShortChannelIdErrorZ() && { LDKCResult_u64ShortChannelIdErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_u64ShortChannelIdErrorZ)); return res; } + ~CResult_u64ShortChannelIdErrorZ() { CResult_u64ShortChannelIdErrorZ_free(self); } + CResult_u64ShortChannelIdErrorZ& operator=(CResult_u64ShortChannelIdErrorZ&& o) { CResult_u64ShortChannelIdErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_u64ShortChannelIdErrorZ)); return *this; } + LDKCResult_u64ShortChannelIdErrorZ* operator &() { return &self; } + LDKCResult_u64ShortChannelIdErrorZ* operator ->() { return &self; } + const LDKCResult_u64ShortChannelIdErrorZ* operator &() const { return &self; } + const LDKCResult_u64ShortChannelIdErrorZ* operator ->() const { return &self; } +}; class CResult_QueryChannelRangeDecodeErrorZ { private: LDKCResult_QueryChannelRangeDecodeErrorZ self; @@ -7030,21 +8243,6 @@ public: const LDKCResult_QueryChannelRangeDecodeErrorZ* operator &() const { return &self; } const LDKCResult_QueryChannelRangeDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_TransactionZ { -private: - LDKCVec_TransactionZ self; -public: - CVec_TransactionZ(const CVec_TransactionZ&) = delete; - CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); } - CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); } - operator LDKCVec_TransactionZ() && { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; } - ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } - CVec_TransactionZ& operator=(CVec_TransactionZ&& o) { CVec_TransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TransactionZ)); return *this; } - LDKCVec_TransactionZ* operator &() { return &self; } - LDKCVec_TransactionZ* operator ->() { return &self; } - const LDKCVec_TransactionZ* operator &() const { return &self; } - const LDKCVec_TransactionZ* operator ->() const { return &self; } -}; class CVec_InputZ { private: LDKCVec_InputZ self; @@ -7090,20 +8288,20 @@ public: const LDKCResult_ChannelReadyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelReadyDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_RevocationBasepointDecodeErrorZ { +class CVec_TransactionZ { private: - LDKCResult_RevocationBasepointDecodeErrorZ self; + LDKCVec_TransactionZ self; public: - CResult_RevocationBasepointDecodeErrorZ(const CResult_RevocationBasepointDecodeErrorZ&) = delete; - CResult_RevocationBasepointDecodeErrorZ(CResult_RevocationBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RevocationBasepointDecodeErrorZ)); } - CResult_RevocationBasepointDecodeErrorZ(LDKCResult_RevocationBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RevocationBasepointDecodeErrorZ)); } - operator LDKCResult_RevocationBasepointDecodeErrorZ() && { LDKCResult_RevocationBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RevocationBasepointDecodeErrorZ)); return res; } - ~CResult_RevocationBasepointDecodeErrorZ() { CResult_RevocationBasepointDecodeErrorZ_free(self); } - CResult_RevocationBasepointDecodeErrorZ& operator=(CResult_RevocationBasepointDecodeErrorZ&& o) { CResult_RevocationBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RevocationBasepointDecodeErrorZ)); return *this; } - LDKCResult_RevocationBasepointDecodeErrorZ* operator &() { return &self; } - LDKCResult_RevocationBasepointDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_RevocationBasepointDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_RevocationBasepointDecodeErrorZ* operator ->() const { return &self; } + CVec_TransactionZ(const CVec_TransactionZ&) = delete; + CVec_TransactionZ(CVec_TransactionZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_TransactionZ)); } + CVec_TransactionZ(LDKCVec_TransactionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_TransactionZ)); } + operator LDKCVec_TransactionZ() && { LDKCVec_TransactionZ res = self; memset(&self, 0, sizeof(LDKCVec_TransactionZ)); return res; } + ~CVec_TransactionZ() { CVec_TransactionZ_free(self); } + CVec_TransactionZ& operator=(CVec_TransactionZ&& o) { CVec_TransactionZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_TransactionZ)); return *this; } + LDKCVec_TransactionZ* operator &() { return &self; } + LDKCVec_TransactionZ* operator ->() { return &self; } + const LDKCVec_TransactionZ* operator &() const { return &self; } + const LDKCVec_TransactionZ* operator ->() const { return &self; } }; class CResult_UpdateFeeDecodeErrorZ { private: @@ -7135,6 +8333,21 @@ public: const LDKCResult_NoneBolt11SemanticErrorZ* operator &() const { return &self; } const LDKCResult_NoneBolt11SemanticErrorZ* operator ->() const { return &self; } }; +class CResult_RevocationBasepointDecodeErrorZ { +private: + LDKCResult_RevocationBasepointDecodeErrorZ self; +public: + CResult_RevocationBasepointDecodeErrorZ(const CResult_RevocationBasepointDecodeErrorZ&) = delete; + CResult_RevocationBasepointDecodeErrorZ(CResult_RevocationBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RevocationBasepointDecodeErrorZ)); } + CResult_RevocationBasepointDecodeErrorZ(LDKCResult_RevocationBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RevocationBasepointDecodeErrorZ)); } + operator LDKCResult_RevocationBasepointDecodeErrorZ() && { LDKCResult_RevocationBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RevocationBasepointDecodeErrorZ)); return res; } + ~CResult_RevocationBasepointDecodeErrorZ() { CResult_RevocationBasepointDecodeErrorZ_free(self); } + CResult_RevocationBasepointDecodeErrorZ& operator=(CResult_RevocationBasepointDecodeErrorZ&& o) { CResult_RevocationBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RevocationBasepointDecodeErrorZ)); return *this; } + LDKCResult_RevocationBasepointDecodeErrorZ* operator &() { return &self; } + LDKCResult_RevocationBasepointDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RevocationBasepointDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RevocationBasepointDecodeErrorZ* operator ->() const { return &self; } +}; class COption_OnionMessageContentsZ { private: LDKCOption_OnionMessageContentsZ self; @@ -7165,20 +8378,20 @@ public: const LDKCResult_NoneRetryableSendFailureZ* operator &() const { return &self; } const LDKCResult_NoneRetryableSendFailureZ* operator ->() const { return &self; } }; -class CResult_boolLightningErrorZ { +class CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { private: - LDKCResult_boolLightningErrorZ self; + LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ self; public: - CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete; - CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); } - CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); } - operator LDKCResult_boolLightningErrorZ() && { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; } - ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); } - CResult_boolLightningErrorZ& operator=(CResult_boolLightningErrorZ&& o) { CResult_boolLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); return *this; } - LDKCResult_boolLightningErrorZ* operator &() { return &self; } - LDKCResult_boolLightningErrorZ* operator ->() { return &self; } - const LDKCResult_boolLightningErrorZ* operator &() const { return &self; } - const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; } + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ(const CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ&) = delete; + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ(CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ)); } + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ(LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ() && { LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ() { CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(self); } + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ& operator=(CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ&& o) { CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_NodeIdDecodeErrorZ { private: @@ -7195,6 +8408,21 @@ public: const LDKCResult_NodeIdDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeIdDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_boolLightningErrorZ { +private: + LDKCResult_boolLightningErrorZ self; +public: + CResult_boolLightningErrorZ(const CResult_boolLightningErrorZ&) = delete; + CResult_boolLightningErrorZ(CResult_boolLightningErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); } + CResult_boolLightningErrorZ(LDKCResult_boolLightningErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_boolLightningErrorZ)); } + operator LDKCResult_boolLightningErrorZ() && { LDKCResult_boolLightningErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_boolLightningErrorZ)); return res; } + ~CResult_boolLightningErrorZ() { CResult_boolLightningErrorZ_free(self); } + CResult_boolLightningErrorZ& operator=(CResult_boolLightningErrorZ&& o) { CResult_boolLightningErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_boolLightningErrorZ)); return *this; } + LDKCResult_boolLightningErrorZ* operator &() { return &self; } + LDKCResult_boolLightningErrorZ* operator ->() { return &self; } + const LDKCResult_boolLightningErrorZ* operator &() const { return &self; } + const LDKCResult_boolLightningErrorZ* operator ->() const { return &self; } +}; class CResult_ChannelShutdownStateDecodeErrorZ { private: LDKCResult_ChannelShutdownStateDecodeErrorZ self; @@ -7210,21 +8438,6 @@ public: const LDKCResult_ChannelShutdownStateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelShutdownStateDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_HTLCOutputInCommitmentDecodeErrorZ { -private: - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self; -public: - CResult_HTLCOutputInCommitmentDecodeErrorZ(const CResult_HTLCOutputInCommitmentDecodeErrorZ&) = delete; - CResult_HTLCOutputInCommitmentDecodeErrorZ(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); } - CResult_HTLCOutputInCommitmentDecodeErrorZ(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); } - operator LDKCResult_HTLCOutputInCommitmentDecodeErrorZ() && { LDKCResult_HTLCOutputInCommitmentDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); return res; } - ~CResult_HTLCOutputInCommitmentDecodeErrorZ() { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); } - CResult_HTLCOutputInCommitmentDecodeErrorZ& operator=(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); return *this; } - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() { return &self; } - LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_NodeAnnouncementInfoDecodeErrorZ { private: LDKCResult_NodeAnnouncementInfoDecodeErrorZ self; @@ -7240,20 +8453,20 @@ public: const LDKCResult_NodeAnnouncementInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAnnouncementInfoDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_ShutdownScriptInvalidShutdownScriptZ { +class CResult_InvoiceRequestBolt12SemanticErrorZ { private: - LDKCResult_ShutdownScriptInvalidShutdownScriptZ self; + LDKCResult_InvoiceRequestBolt12SemanticErrorZ self; public: - CResult_ShutdownScriptInvalidShutdownScriptZ(const CResult_ShutdownScriptInvalidShutdownScriptZ&) = delete; - CResult_ShutdownScriptInvalidShutdownScriptZ(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); } - CResult_ShutdownScriptInvalidShutdownScriptZ(LDKCResult_ShutdownScriptInvalidShutdownScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); } - operator LDKCResult_ShutdownScriptInvalidShutdownScriptZ() && { LDKCResult_ShutdownScriptInvalidShutdownScriptZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); return res; } - ~CResult_ShutdownScriptInvalidShutdownScriptZ() { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); } - CResult_ShutdownScriptInvalidShutdownScriptZ& operator=(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); return *this; } - LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() { return &self; } - LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() { return &self; } - const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() const { return &self; } - const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() const { return &self; } + CResult_InvoiceRequestBolt12SemanticErrorZ(const CResult_InvoiceRequestBolt12SemanticErrorZ&) = delete; + CResult_InvoiceRequestBolt12SemanticErrorZ(CResult_InvoiceRequestBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceRequestBolt12SemanticErrorZ)); } + CResult_InvoiceRequestBolt12SemanticErrorZ(LDKCResult_InvoiceRequestBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceRequestBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceRequestBolt12SemanticErrorZ() && { LDKCResult_InvoiceRequestBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceRequestBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceRequestBolt12SemanticErrorZ() { CResult_InvoiceRequestBolt12SemanticErrorZ_free(self); } + CResult_InvoiceRequestBolt12SemanticErrorZ& operator=(CResult_InvoiceRequestBolt12SemanticErrorZ&& o) { CResult_InvoiceRequestBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceRequestBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceRequestBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceRequestBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceRequestBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceRequestBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_COption_NetworkUpdateZDecodeErrorZ { private: @@ -7315,6 +8528,21 @@ public: const LDKCResult_PendingHTLCInfoInboundHTLCErrZ* operator &() const { return &self; } const LDKCResult_PendingHTLCInfoInboundHTLCErrZ* operator ->() const { return &self; } }; +class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +private: + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ self; +public: + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(const CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&) = delete; + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } + operator LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() && { LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return res; } + ~CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); } + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ& operator=(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return *this; } + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() { return &self; } + LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() { return &self; } + const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() const { return &self; } + const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() const { return &self; } +}; class CResult_PendingHTLCInfoDecodeErrorZ { private: LDKCResult_PendingHTLCInfoDecodeErrorZ self; @@ -7330,50 +8558,35 @@ public: const LDKCResult_PendingHTLCInfoDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PendingHTLCInfoDecodeErrorZ* operator ->() const { return &self; } }; -class COption_HTLCDestinationZ { -private: - LDKCOption_HTLCDestinationZ self; -public: - COption_HTLCDestinationZ(const COption_HTLCDestinationZ&) = delete; - COption_HTLCDestinationZ(COption_HTLCDestinationZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_HTLCDestinationZ)); } - COption_HTLCDestinationZ(LDKCOption_HTLCDestinationZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_HTLCDestinationZ)); } - operator LDKCOption_HTLCDestinationZ() && { LDKCOption_HTLCDestinationZ res = self; memset(&self, 0, sizeof(LDKCOption_HTLCDestinationZ)); return res; } - ~COption_HTLCDestinationZ() { COption_HTLCDestinationZ_free(self); } - COption_HTLCDestinationZ& operator=(COption_HTLCDestinationZ&& o) { COption_HTLCDestinationZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_HTLCDestinationZ)); return *this; } - LDKCOption_HTLCDestinationZ* operator &() { return &self; } - LDKCOption_HTLCDestinationZ* operator ->() { return &self; } - const LDKCOption_HTLCDestinationZ* operator &() const { return &self; } - const LDKCOption_HTLCDestinationZ* operator ->() const { return &self; } -}; -class CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +class CResult_SpliceInitDecodeErrorZ { private: - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ self; + LDKCResult_SpliceInitDecodeErrorZ self; public: - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(const CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&) = delete; - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); } - operator LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() && { LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return res; } - ~CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ() { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); } - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ& operator=(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ&& o) { CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ)); return *this; } - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() { return &self; } - LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() { return &self; } - const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator &() const { return &self; } - const LDKCResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ* operator ->() const { return &self; } + CResult_SpliceInitDecodeErrorZ(const CResult_SpliceInitDecodeErrorZ&) = delete; + CResult_SpliceInitDecodeErrorZ(CResult_SpliceInitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceInitDecodeErrorZ)); } + CResult_SpliceInitDecodeErrorZ(LDKCResult_SpliceInitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceInitDecodeErrorZ)); } + operator LDKCResult_SpliceInitDecodeErrorZ() && { LDKCResult_SpliceInitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceInitDecodeErrorZ)); return res; } + ~CResult_SpliceInitDecodeErrorZ() { CResult_SpliceInitDecodeErrorZ_free(self); } + CResult_SpliceInitDecodeErrorZ& operator=(CResult_SpliceInitDecodeErrorZ&& o) { CResult_SpliceInitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceInitDecodeErrorZ)); return *this; } + LDKCResult_SpliceInitDecodeErrorZ* operator &() { return &self; } + LDKCResult_SpliceInitDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_SpliceInitDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_SpliceInitDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +class CResult_HTLCOutputInCommitmentDecodeErrorZ { private: - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ self; + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ self; public: - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(const CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&) = delete; - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); } - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); } - operator LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ() && { LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); return res; } - ~CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ() { CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(self); } - CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ& operator=(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ&& o) { CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ)); return *this; } - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ* operator ->() const { return &self; } + CResult_HTLCOutputInCommitmentDecodeErrorZ(const CResult_HTLCOutputInCommitmentDecodeErrorZ&) = delete; + CResult_HTLCOutputInCommitmentDecodeErrorZ(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); } + CResult_HTLCOutputInCommitmentDecodeErrorZ(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); } + operator LDKCResult_HTLCOutputInCommitmentDecodeErrorZ() && { LDKCResult_HTLCOutputInCommitmentDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ)); return res; } + ~CResult_HTLCOutputInCommitmentDecodeErrorZ() { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); } + CResult_HTLCOutputInCommitmentDecodeErrorZ& operator=(CResult_HTLCOutputInCommitmentDecodeErrorZ&& o) { CResult_HTLCOutputInCommitmentDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HTLCOutputInCommitmentDecodeErrorZ)); return *this; } + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() { return &self; } + LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* operator ->() const { return &self; } }; class CVec_RouteHopZ { private: @@ -7390,20 +8603,20 @@ public: const LDKCVec_RouteHopZ* operator &() const { return &self; } const LDKCVec_RouteHopZ* operator ->() const { return &self; } }; -class C2Tuple_PublicKeyCVec_SocketAddressZZ { +class CResult_ShutdownScriptInvalidShutdownScriptZ { private: - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ self; + LDKCResult_ShutdownScriptInvalidShutdownScriptZ self; public: - C2Tuple_PublicKeyCVec_SocketAddressZZ(const C2Tuple_PublicKeyCVec_SocketAddressZZ&) = delete; - C2Tuple_PublicKeyCVec_SocketAddressZZ(C2Tuple_PublicKeyCVec_SocketAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCVec_SocketAddressZZ)); } - C2Tuple_PublicKeyCVec_SocketAddressZZ(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ)); } - operator LDKC2Tuple_PublicKeyCVec_SocketAddressZZ() && { LDKC2Tuple_PublicKeyCVec_SocketAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCVec_SocketAddressZZ)); return res; } - ~C2Tuple_PublicKeyCVec_SocketAddressZZ() { C2Tuple_PublicKeyCVec_SocketAddressZZ_free(self); } - C2Tuple_PublicKeyCVec_SocketAddressZZ& operator=(C2Tuple_PublicKeyCVec_SocketAddressZZ&& o) { C2Tuple_PublicKeyCVec_SocketAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCVec_SocketAddressZZ)); return *this; } - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator &() { return &self; } - LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator ->() { return &self; } - const LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator &() const { return &self; } - const LDKC2Tuple_PublicKeyCVec_SocketAddressZZ* operator ->() const { return &self; } + CResult_ShutdownScriptInvalidShutdownScriptZ(const CResult_ShutdownScriptInvalidShutdownScriptZ&) = delete; + CResult_ShutdownScriptInvalidShutdownScriptZ(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); } + CResult_ShutdownScriptInvalidShutdownScriptZ(LDKCResult_ShutdownScriptInvalidShutdownScriptZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); } + operator LDKCResult_ShutdownScriptInvalidShutdownScriptZ() && { LDKCResult_ShutdownScriptInvalidShutdownScriptZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ)); return res; } + ~CResult_ShutdownScriptInvalidShutdownScriptZ() { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); } + CResult_ShutdownScriptInvalidShutdownScriptZ& operator=(CResult_ShutdownScriptInvalidShutdownScriptZ&& o) { CResult_ShutdownScriptInvalidShutdownScriptZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptInvalidShutdownScriptZ)); return *this; } + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() { return &self; } + LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptInvalidShutdownScriptZ* operator ->() const { return &self; } }; class CResult_CVec_UtxoZNoneZ { private: @@ -7420,21 +8633,6 @@ public: const LDKCResult_CVec_UtxoZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_UtxoZNoneZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { -private: - LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ self; -public: - CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ(const CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ&) = delete; - CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ(CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ)); } - CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ(LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ)); } - operator LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ() && { LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ)); return res; } - ~CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ() { CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(self); } - CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ& operator=(CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ&& o) { CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ)); return *this; } - LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ* operator ->() const { return &self; } -}; class CResult_CVec_u8ZIOErrorZ { private: LDKCResult_CVec_u8ZIOErrorZ self; @@ -7450,20 +8648,35 @@ public: const LDKCResult_CVec_u8ZIOErrorZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZIOErrorZ* operator ->() const { return &self; } }; -class C3Tuple_OffersMessageDestinationBlindedPathZ { +class COption_HTLCDestinationZ { +private: + LDKCOption_HTLCDestinationZ self; +public: + COption_HTLCDestinationZ(const COption_HTLCDestinationZ&) = delete; + COption_HTLCDestinationZ(COption_HTLCDestinationZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_HTLCDestinationZ)); } + COption_HTLCDestinationZ(LDKCOption_HTLCDestinationZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_HTLCDestinationZ)); } + operator LDKCOption_HTLCDestinationZ() && { LDKCOption_HTLCDestinationZ res = self; memset(&self, 0, sizeof(LDKCOption_HTLCDestinationZ)); return res; } + ~COption_HTLCDestinationZ() { COption_HTLCDestinationZ_free(self); } + COption_HTLCDestinationZ& operator=(COption_HTLCDestinationZ&& o) { COption_HTLCDestinationZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_HTLCDestinationZ)); return *this; } + LDKCOption_HTLCDestinationZ* operator &() { return &self; } + LDKCOption_HTLCDestinationZ* operator ->() { return &self; } + const LDKCOption_HTLCDestinationZ* operator &() const { return &self; } + const LDKCOption_HTLCDestinationZ* operator ->() const { return &self; } +}; +class CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { private: - LDKC3Tuple_OffersMessageDestinationBlindedPathZ self; + LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ self; public: - C3Tuple_OffersMessageDestinationBlindedPathZ(const C3Tuple_OffersMessageDestinationBlindedPathZ&) = delete; - C3Tuple_OffersMessageDestinationBlindedPathZ(C3Tuple_OffersMessageDestinationBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_OffersMessageDestinationBlindedPathZ)); } - C3Tuple_OffersMessageDestinationBlindedPathZ(LDKC3Tuple_OffersMessageDestinationBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ)); } - operator LDKC3Tuple_OffersMessageDestinationBlindedPathZ() && { LDKC3Tuple_OffersMessageDestinationBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ)); return res; } - ~C3Tuple_OffersMessageDestinationBlindedPathZ() { C3Tuple_OffersMessageDestinationBlindedPathZ_free(self); } - C3Tuple_OffersMessageDestinationBlindedPathZ& operator=(C3Tuple_OffersMessageDestinationBlindedPathZ&& o) { C3Tuple_OffersMessageDestinationBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_OffersMessageDestinationBlindedPathZ)); return *this; } - LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator &() { return &self; } - LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator ->() { return &self; } - const LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator &() const { return &self; } - const LDKC3Tuple_OffersMessageDestinationBlindedPathZ* operator ->() const { return &self; } + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ(const CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ&) = delete; + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ(CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ)); } + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ(LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ)); } + operator LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ() && { LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ)); return res; } + ~CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ() { CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(self); } + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ& operator=(CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ&& o) { CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ)); return *this; } + LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CVec_ThirtyTwoBytesZ { private: @@ -7540,6 +8753,21 @@ public: const LDKCResult_SchnorrSignatureNoneZ* operator &() const { return &self; } const LDKCResult_SchnorrSignatureNoneZ* operator ->() const { return &self; } }; +class C2Tuple_ReleaseHeldHtlcResponseInstructionZ { +private: + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ self; +public: + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(const C2Tuple_ReleaseHeldHtlcResponseInstructionZ&) = delete; + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(C2Tuple_ReleaseHeldHtlcResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_ReleaseHeldHtlcResponseInstructionZ)); } + C2Tuple_ReleaseHeldHtlcResponseInstructionZ(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ)); } + operator LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ() && { LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ)); return res; } + ~C2Tuple_ReleaseHeldHtlcResponseInstructionZ() { C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(self); } + C2Tuple_ReleaseHeldHtlcResponseInstructionZ& operator=(C2Tuple_ReleaseHeldHtlcResponseInstructionZ&& o) { C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_ReleaseHeldHtlcResponseInstructionZ)); return *this; } + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_ReleaseHeldHtlcResponseInstructionZ* operator ->() const { return &self; } +}; class CResult_CounterpartyCommitmentSecretsDecodeErrorZ { private: LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ self; @@ -7600,21 +8828,6 @@ public: const LDKCVec_RouteHintHopZ* operator &() const { return &self; } const LDKCVec_RouteHintHopZ* operator ->() const { return &self; } }; -class CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { -private: - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ self; -public: - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(const CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&) = delete; - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); } - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); } - operator LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ() && { LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); return res; } - ~CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ() { CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(self); } - CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ& operator=(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ&& o) { CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ)); return *this; } - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator &() { return &self; } - LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ* operator ->() const { return &self; } -}; class CResult_UntrustedStringDecodeErrorZ { private: LDKCResult_UntrustedStringDecodeErrorZ self; @@ -7645,21 +8858,6 @@ public: const LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ* operator &() const { return &self; } const LDKCVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ* operator ->() const { return &self; } }; -class CVec_U5Z { -private: - LDKCVec_U5Z self; -public: - CVec_U5Z(const CVec_U5Z&) = delete; - CVec_U5Z(CVec_U5Z&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_U5Z)); } - CVec_U5Z(LDKCVec_U5Z&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_U5Z)); } - operator LDKCVec_U5Z() && { LDKCVec_U5Z res = self; memset(&self, 0, sizeof(LDKCVec_U5Z)); return res; } - ~CVec_U5Z() { CVec_U5Z_free(self); } - CVec_U5Z& operator=(CVec_U5Z&& o) { CVec_U5Z_free(self); self = o.self; memset(&o, 0, sizeof(CVec_U5Z)); return *this; } - LDKCVec_U5Z* operator &() { return &self; } - LDKCVec_U5Z* operator ->() { return &self; } - const LDKCVec_U5Z* operator &() const { return &self; } - const LDKCVec_U5Z* operator ->() const { return &self; } -}; class CResult_PaymentParametersDecodeErrorZ { private: LDKCResult_PaymentParametersDecodeErrorZ self; @@ -7675,6 +8873,21 @@ public: const LDKCResult_PaymentParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_PaymentParametersDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_DelayedPaymentBasepointDecodeErrorZ { +private: + LDKCResult_DelayedPaymentBasepointDecodeErrorZ self; +public: + CResult_DelayedPaymentBasepointDecodeErrorZ(const CResult_DelayedPaymentBasepointDecodeErrorZ&) = delete; + CResult_DelayedPaymentBasepointDecodeErrorZ(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); } + CResult_DelayedPaymentBasepointDecodeErrorZ(LDKCResult_DelayedPaymentBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); } + operator LDKCResult_DelayedPaymentBasepointDecodeErrorZ() && { LDKCResult_DelayedPaymentBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); return res; } + ~CResult_DelayedPaymentBasepointDecodeErrorZ() { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); } + CResult_DelayedPaymentBasepointDecodeErrorZ& operator=(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); return *this; } + LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() { return &self; } + LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_ThirtyTwoBytesChannelMonitorZ { private: LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ self; @@ -7705,21 +8918,6 @@ public: const LDKCOption_U128Z* operator &() const { return &self; } const LDKCOption_U128Z* operator ->() const { return &self; } }; -class CResult_DelayedPaymentBasepointDecodeErrorZ { -private: - LDKCResult_DelayedPaymentBasepointDecodeErrorZ self; -public: - CResult_DelayedPaymentBasepointDecodeErrorZ(const CResult_DelayedPaymentBasepointDecodeErrorZ&) = delete; - CResult_DelayedPaymentBasepointDecodeErrorZ(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); } - CResult_DelayedPaymentBasepointDecodeErrorZ(LDKCResult_DelayedPaymentBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); } - operator LDKCResult_DelayedPaymentBasepointDecodeErrorZ() && { LDKCResult_DelayedPaymentBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DelayedPaymentBasepointDecodeErrorZ)); return res; } - ~CResult_DelayedPaymentBasepointDecodeErrorZ() { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); } - CResult_DelayedPaymentBasepointDecodeErrorZ& operator=(CResult_DelayedPaymentBasepointDecodeErrorZ&& o) { CResult_DelayedPaymentBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DelayedPaymentBasepointDecodeErrorZ)); return *this; } - LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() { return &self; } - LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_DelayedPaymentBasepointDecodeErrorZ* operator ->() const { return &self; } -}; class C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { private: LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ self; @@ -7735,6 +8933,21 @@ public: const LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* operator &() const { return &self; } const LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* operator ->() const { return &self; } }; +class CVec_MessageForwardNodeZ { +private: + LDKCVec_MessageForwardNodeZ self; +public: + CVec_MessageForwardNodeZ(const CVec_MessageForwardNodeZ&) = delete; + CVec_MessageForwardNodeZ(CVec_MessageForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MessageForwardNodeZ)); } + CVec_MessageForwardNodeZ(LDKCVec_MessageForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MessageForwardNodeZ)); } + operator LDKCVec_MessageForwardNodeZ() && { LDKCVec_MessageForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_MessageForwardNodeZ)); return res; } + ~CVec_MessageForwardNodeZ() { CVec_MessageForwardNodeZ_free(self); } + CVec_MessageForwardNodeZ& operator=(CVec_MessageForwardNodeZ&& o) { CVec_MessageForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MessageForwardNodeZ)); return *this; } + LDKCVec_MessageForwardNodeZ* operator &() { return &self; } + LDKCVec_MessageForwardNodeZ* operator ->() { return &self; } + const LDKCVec_MessageForwardNodeZ* operator &() const { return &self; } + const LDKCVec_MessageForwardNodeZ* operator ->() const { return &self; } +}; class CResult_TxAckRbfDecodeErrorZ { private: LDKCResult_TxAckRbfDecodeErrorZ self; @@ -7780,6 +8993,21 @@ public: const LDKCOption_UtxoLookupZ* operator &() const { return &self; } const LDKCOption_UtxoLookupZ* operator ->() const { return &self; } }; +class CResult__u832NoneZ { +private: + LDKCResult__u832NoneZ self; +public: + CResult__u832NoneZ(const CResult__u832NoneZ&) = delete; + CResult__u832NoneZ(CResult__u832NoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult__u832NoneZ)); } + CResult__u832NoneZ(LDKCResult__u832NoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult__u832NoneZ)); } + operator LDKCResult__u832NoneZ() && { LDKCResult__u832NoneZ res = self; memset(&self, 0, sizeof(LDKCResult__u832NoneZ)); return res; } + ~CResult__u832NoneZ() { CResult__u832NoneZ_free(self); } + CResult__u832NoneZ& operator=(CResult__u832NoneZ&& o) { CResult__u832NoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult__u832NoneZ)); return *this; } + LDKCResult__u832NoneZ* operator &() { return &self; } + LDKCResult__u832NoneZ* operator ->() { return &self; } + const LDKCResult__u832NoneZ* operator &() const { return &self; } + const LDKCResult__u832NoneZ* operator ->() const { return &self; } +}; class CResult_PongDecodeErrorZ { private: LDKCResult_PongDecodeErrorZ self; @@ -7810,20 +9038,20 @@ public: const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_OutPointCVec_MonitorUpdateIdZZ { +class CResult_ChannelIdAPIErrorZ { private: - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ self; + LDKCResult_ChannelIdAPIErrorZ self; public: - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(const C2Tuple_OutPointCVec_MonitorUpdateIdZZ&) = delete; - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(C2Tuple_OutPointCVec_MonitorUpdateIdZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_MonitorUpdateIdZZ)); } - C2Tuple_OutPointCVec_MonitorUpdateIdZZ(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ)); } - operator LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ() && { LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ)); return res; } - ~C2Tuple_OutPointCVec_MonitorUpdateIdZZ() { C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(self); } - C2Tuple_OutPointCVec_MonitorUpdateIdZZ& operator=(C2Tuple_OutPointCVec_MonitorUpdateIdZZ&& o) { C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_MonitorUpdateIdZZ)); return *this; } - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator &() { return &self; } - LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator ->() { return &self; } - const LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator &() const { return &self; } - const LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* operator ->() const { return &self; } + CResult_ChannelIdAPIErrorZ(const CResult_ChannelIdAPIErrorZ&) = delete; + CResult_ChannelIdAPIErrorZ(CResult_ChannelIdAPIErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelIdAPIErrorZ)); } + CResult_ChannelIdAPIErrorZ(LDKCResult_ChannelIdAPIErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelIdAPIErrorZ)); } + operator LDKCResult_ChannelIdAPIErrorZ() && { LDKCResult_ChannelIdAPIErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelIdAPIErrorZ)); return res; } + ~CResult_ChannelIdAPIErrorZ() { CResult_ChannelIdAPIErrorZ_free(self); } + CResult_ChannelIdAPIErrorZ& operator=(CResult_ChannelIdAPIErrorZ&& o) { CResult_ChannelIdAPIErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelIdAPIErrorZ)); return *this; } + LDKCResult_ChannelIdAPIErrorZ* operator &() { return &self; } + LDKCResult_ChannelIdAPIErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelIdAPIErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelIdAPIErrorZ* operator ->() const { return &self; } }; class CResult_CVec_u8ZNoneZ { private: @@ -7840,6 +9068,21 @@ public: const LDKCResult_CVec_u8ZNoneZ* operator &() const { return &self; } const LDKCResult_CVec_u8ZNoneZ* operator ->() const { return &self; } }; +class CVec_C2Tuple_ChannelIdPublicKeyZZ { +private: + LDKCVec_C2Tuple_ChannelIdPublicKeyZZ self; +public: + CVec_C2Tuple_ChannelIdPublicKeyZZ(const CVec_C2Tuple_ChannelIdPublicKeyZZ&) = delete; + CVec_C2Tuple_ChannelIdPublicKeyZZ(CVec_C2Tuple_ChannelIdPublicKeyZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_ChannelIdPublicKeyZZ)); } + CVec_C2Tuple_ChannelIdPublicKeyZZ(LDKCVec_C2Tuple_ChannelIdPublicKeyZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_ChannelIdPublicKeyZZ)); } + operator LDKCVec_C2Tuple_ChannelIdPublicKeyZZ() && { LDKCVec_C2Tuple_ChannelIdPublicKeyZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_ChannelIdPublicKeyZZ)); return res; } + ~CVec_C2Tuple_ChannelIdPublicKeyZZ() { CVec_C2Tuple_ChannelIdPublicKeyZZ_free(self); } + CVec_C2Tuple_ChannelIdPublicKeyZZ& operator=(CVec_C2Tuple_ChannelIdPublicKeyZZ&& o) { CVec_C2Tuple_ChannelIdPublicKeyZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_ChannelIdPublicKeyZZ)); return *this; } + LDKCVec_C2Tuple_ChannelIdPublicKeyZZ* operator &() { return &self; } + LDKCVec_C2Tuple_ChannelIdPublicKeyZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_ChannelIdPublicKeyZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_ChannelIdPublicKeyZZ* operator ->() const { return &self; } +}; class C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { private: LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ self; @@ -7870,20 +9113,20 @@ public: const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_WriteableEcdsaChannelSignerDecodeErrorZ { +class CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { private: - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ self; + LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ self; public: - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(const CResult_WriteableEcdsaChannelSignerDecodeErrorZ&) = delete; - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(CResult_WriteableEcdsaChannelSignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_WriteableEcdsaChannelSignerDecodeErrorZ)); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZ(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ)); } - operator LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ() && { LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ)); return res; } - ~CResult_WriteableEcdsaChannelSignerDecodeErrorZ() { CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(self); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZ& operator=(CResult_WriteableEcdsaChannelSignerDecodeErrorZ&& o) { CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_WriteableEcdsaChannelSignerDecodeErrorZ)); return *this; } - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator &() { return &self; } - LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* operator ->() const { return &self; } + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ(const CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ&) = delete; + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ(CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ)); } + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ() { CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_free(self); } + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { private: @@ -7915,6 +9158,21 @@ public: const LDKCResult_InFlightHtlcsDecodeErrorZ* operator &() const { return &self; } const LDKCResult_InFlightHtlcsDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_CommitmentSignedBatchDecodeErrorZ { +private: + LDKCResult_CommitmentSignedBatchDecodeErrorZ self; +public: + CResult_CommitmentSignedBatchDecodeErrorZ(const CResult_CommitmentSignedBatchDecodeErrorZ&) = delete; + CResult_CommitmentSignedBatchDecodeErrorZ(CResult_CommitmentSignedBatchDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CommitmentSignedBatchDecodeErrorZ)); } + CResult_CommitmentSignedBatchDecodeErrorZ(LDKCResult_CommitmentSignedBatchDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CommitmentSignedBatchDecodeErrorZ)); } + operator LDKCResult_CommitmentSignedBatchDecodeErrorZ() && { LDKCResult_CommitmentSignedBatchDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CommitmentSignedBatchDecodeErrorZ)); return res; } + ~CResult_CommitmentSignedBatchDecodeErrorZ() { CResult_CommitmentSignedBatchDecodeErrorZ_free(self); } + CResult_CommitmentSignedBatchDecodeErrorZ& operator=(CResult_CommitmentSignedBatchDecodeErrorZ&& o) { CResult_CommitmentSignedBatchDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CommitmentSignedBatchDecodeErrorZ)); return *this; } + LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator &() { return &self; } + LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CommitmentSignedBatchDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_COption_HTLCDestinationZDecodeErrorZ { private: LDKCResult_COption_HTLCDestinationZDecodeErrorZ self; @@ -7930,6 +9188,21 @@ public: const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_HTLCDestinationZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_Bolt12OfferContextDecodeErrorZ { +private: + LDKCResult_Bolt12OfferContextDecodeErrorZ self; +public: + CResult_Bolt12OfferContextDecodeErrorZ(const CResult_Bolt12OfferContextDecodeErrorZ&) = delete; + CResult_Bolt12OfferContextDecodeErrorZ(CResult_Bolt12OfferContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12OfferContextDecodeErrorZ)); } + CResult_Bolt12OfferContextDecodeErrorZ(LDKCResult_Bolt12OfferContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12OfferContextDecodeErrorZ)); } + operator LDKCResult_Bolt12OfferContextDecodeErrorZ() && { LDKCResult_Bolt12OfferContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12OfferContextDecodeErrorZ)); return res; } + ~CResult_Bolt12OfferContextDecodeErrorZ() { CResult_Bolt12OfferContextDecodeErrorZ_free(self); } + CResult_Bolt12OfferContextDecodeErrorZ& operator=(CResult_Bolt12OfferContextDecodeErrorZ&& o) { CResult_Bolt12OfferContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12OfferContextDecodeErrorZ)); return *this; } + LDKCResult_Bolt12OfferContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt12OfferContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12OfferContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12OfferContextDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ThirtyTwoBytesNoneZ { private: LDKCResult_ThirtyTwoBytesNoneZ self; @@ -7945,21 +9218,6 @@ public: const LDKCResult_ThirtyTwoBytesNoneZ* operator &() const { return &self; } const LDKCResult_ThirtyTwoBytesNoneZ* operator ->() const { return &self; } }; -class C3Tuple_OnionMessageContentsDestinationBlindedPathZ { -private: - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ self; -public: - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(const C3Tuple_OnionMessageContentsDestinationBlindedPathZ&) = delete; - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(C3Tuple_OnionMessageContentsDestinationBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_OnionMessageContentsDestinationBlindedPathZ)); } - C3Tuple_OnionMessageContentsDestinationBlindedPathZ(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ)); } - operator LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ() && { LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ)); return res; } - ~C3Tuple_OnionMessageContentsDestinationBlindedPathZ() { C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(self); } - C3Tuple_OnionMessageContentsDestinationBlindedPathZ& operator=(C3Tuple_OnionMessageContentsDestinationBlindedPathZ&& o) { C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_OnionMessageContentsDestinationBlindedPathZ)); return *this; } - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator &() { return &self; } - LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator ->() { return &self; } - const LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator &() const { return &self; } - const LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* operator ->() const { return &self; } -}; class C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { private: LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ self; @@ -7990,20 +9248,20 @@ public: const LDKCResult_SendSuccessSendErrorZ* operator &() const { return &self; } const LDKCResult_SendSuccessSendErrorZ* operator ->() const { return &self; } }; -class CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +class CResult_NoneReplayEventZ { private: - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ self; + LDKCResult_NoneReplayEventZ self; public: - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(const CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&) = delete; - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); } - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); } - operator LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ() && { LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); return res; } - ~CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ() { CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(self); } - CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ& operator=(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ&& o) { CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ)); return *this; } - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator &() { return &self; } - LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ* operator ->() const { return &self; } + CResult_NoneReplayEventZ(const CResult_NoneReplayEventZ&) = delete; + CResult_NoneReplayEventZ(CResult_NoneReplayEventZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NoneReplayEventZ)); } + CResult_NoneReplayEventZ(LDKCResult_NoneReplayEventZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NoneReplayEventZ)); } + operator LDKCResult_NoneReplayEventZ() && { LDKCResult_NoneReplayEventZ res = self; memset(&self, 0, sizeof(LDKCResult_NoneReplayEventZ)); return res; } + ~CResult_NoneReplayEventZ() { CResult_NoneReplayEventZ_free(self); } + CResult_NoneReplayEventZ& operator=(CResult_NoneReplayEventZ&& o) { CResult_NoneReplayEventZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NoneReplayEventZ)); return *this; } + LDKCResult_NoneReplayEventZ* operator &() { return &self; } + LDKCResult_NoneReplayEventZ* operator ->() { return &self; } + const LDKCResult_NoneReplayEventZ* operator &() const { return &self; } + const LDKCResult_NoneReplayEventZ* operator ->() const { return &self; } }; class C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { private: @@ -8065,21 +9323,6 @@ public: const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator &() const { return &self; } const LDKCResult_FixedPenaltyScorerDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_BlindedPathZ { -private: - LDKCVec_BlindedPathZ self; -public: - CVec_BlindedPathZ(const CVec_BlindedPathZ&) = delete; - CVec_BlindedPathZ(CVec_BlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedPathZ)); } - CVec_BlindedPathZ(LDKCVec_BlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedPathZ)); } - operator LDKCVec_BlindedPathZ() && { LDKCVec_BlindedPathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedPathZ)); return res; } - ~CVec_BlindedPathZ() { CVec_BlindedPathZ_free(self); } - CVec_BlindedPathZ& operator=(CVec_BlindedPathZ&& o) { CVec_BlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedPathZ)); return *this; } - LDKCVec_BlindedPathZ* operator &() { return &self; } - LDKCVec_BlindedPathZ* operator ->() { return &self; } - const LDKCVec_BlindedPathZ* operator &() const { return &self; } - const LDKCVec_BlindedPathZ* operator ->() const { return &self; } -}; class CResult_NonePeerHandleErrorZ { private: LDKCResult_NonePeerHandleErrorZ self; @@ -8095,21 +9338,6 @@ public: const LDKCResult_NonePeerHandleErrorZ* operator &() const { return &self; } const LDKCResult_NonePeerHandleErrorZ* operator ->() const { return &self; } }; -class CResult_FinalOnionHopDataDecodeErrorZ { -private: - LDKCResult_FinalOnionHopDataDecodeErrorZ self; -public: - CResult_FinalOnionHopDataDecodeErrorZ(const CResult_FinalOnionHopDataDecodeErrorZ&) = delete; - CResult_FinalOnionHopDataDecodeErrorZ(CResult_FinalOnionHopDataDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); } - CResult_FinalOnionHopDataDecodeErrorZ(LDKCResult_FinalOnionHopDataDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); } - operator LDKCResult_FinalOnionHopDataDecodeErrorZ() && { LDKCResult_FinalOnionHopDataDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); return res; } - ~CResult_FinalOnionHopDataDecodeErrorZ() { CResult_FinalOnionHopDataDecodeErrorZ_free(self); } - CResult_FinalOnionHopDataDecodeErrorZ& operator=(CResult_FinalOnionHopDataDecodeErrorZ&& o) { CResult_FinalOnionHopDataDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); return *this; } - LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() { return &self; } - LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_TrustedCommitmentTransactionNoneZ { private: LDKCResult_TrustedCommitmentTransactionNoneZ self; @@ -8125,9 +9353,24 @@ public: const LDKCResult_TrustedCommitmentTransactionNoneZ* operator &() const { return &self; } const LDKCResult_TrustedCommitmentTransactionNoneZ* operator ->() const { return &self; } }; -class CResult_COption_EventZDecodeErrorZ { +class CResult_FinalOnionHopDataDecodeErrorZ { private: - LDKCResult_COption_EventZDecodeErrorZ self; + LDKCResult_FinalOnionHopDataDecodeErrorZ self; +public: + CResult_FinalOnionHopDataDecodeErrorZ(const CResult_FinalOnionHopDataDecodeErrorZ&) = delete; + CResult_FinalOnionHopDataDecodeErrorZ(CResult_FinalOnionHopDataDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); } + CResult_FinalOnionHopDataDecodeErrorZ(LDKCResult_FinalOnionHopDataDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); } + operator LDKCResult_FinalOnionHopDataDecodeErrorZ() && { LDKCResult_FinalOnionHopDataDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FinalOnionHopDataDecodeErrorZ)); return res; } + ~CResult_FinalOnionHopDataDecodeErrorZ() { CResult_FinalOnionHopDataDecodeErrorZ_free(self); } + CResult_FinalOnionHopDataDecodeErrorZ& operator=(CResult_FinalOnionHopDataDecodeErrorZ&& o) { CResult_FinalOnionHopDataDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FinalOnionHopDataDecodeErrorZ)); return *this; } + LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() { return &self; } + LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FinalOnionHopDataDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_COption_EventZDecodeErrorZ { +private: + LDKCResult_COption_EventZDecodeErrorZ self; public: CResult_COption_EventZDecodeErrorZ(const CResult_COption_EventZDecodeErrorZ&) = delete; CResult_COption_EventZDecodeErrorZ(CResult_COption_EventZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_EventZDecodeErrorZ)); } @@ -8140,36 +9383,6 @@ public: const LDKCResult_COption_EventZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_EventZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { -private: - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ self; -public: - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(const CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&) = delete; - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); } - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); } - operator LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ() && { LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); return res; } - ~CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ() { CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(self); } - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ& operator=(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ&& o) { CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ)); return *this; } - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator &() { return &self; } - LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator ->() { return &self; } - const LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator &() const { return &self; } - const LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* operator ->() const { return &self; } -}; -class CResult_PaymentFailureReasonDecodeErrorZ { -private: - LDKCResult_PaymentFailureReasonDecodeErrorZ self; -public: - CResult_PaymentFailureReasonDecodeErrorZ(const CResult_PaymentFailureReasonDecodeErrorZ&) = delete; - CResult_PaymentFailureReasonDecodeErrorZ(CResult_PaymentFailureReasonDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentFailureReasonDecodeErrorZ)); } - CResult_PaymentFailureReasonDecodeErrorZ(LDKCResult_PaymentFailureReasonDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ)); } - operator LDKCResult_PaymentFailureReasonDecodeErrorZ() && { LDKCResult_PaymentFailureReasonDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ)); return res; } - ~CResult_PaymentFailureReasonDecodeErrorZ() { CResult_PaymentFailureReasonDecodeErrorZ_free(self); } - CResult_PaymentFailureReasonDecodeErrorZ& operator=(CResult_PaymentFailureReasonDecodeErrorZ&& o) { CResult_PaymentFailureReasonDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentFailureReasonDecodeErrorZ)); return *this; } - LDKCResult_PaymentFailureReasonDecodeErrorZ* operator &() { return &self; } - LDKCResult_PaymentFailureReasonDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentFailureReasonDecodeErrorZ* operator ->() const { return &self; } -}; class COption_SocketAddressZ { private: LDKCOption_SocketAddressZ self; @@ -8215,20 +9428,20 @@ public: const LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ* operator &() const { return &self; } const LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ* operator ->() const { return &self; } }; -class CResult_DescriptionCreationErrorZ { +class CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { private: - LDKCResult_DescriptionCreationErrorZ self; + LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ self; public: - CResult_DescriptionCreationErrorZ(const CResult_DescriptionCreationErrorZ&) = delete; - CResult_DescriptionCreationErrorZ(CResult_DescriptionCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); } - CResult_DescriptionCreationErrorZ(LDKCResult_DescriptionCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); } - operator LDKCResult_DescriptionCreationErrorZ() && { LDKCResult_DescriptionCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); return res; } - ~CResult_DescriptionCreationErrorZ() { CResult_DescriptionCreationErrorZ_free(self); } - CResult_DescriptionCreationErrorZ& operator=(CResult_DescriptionCreationErrorZ&& o) { CResult_DescriptionCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); return *this; } - LDKCResult_DescriptionCreationErrorZ* operator &() { return &self; } - LDKCResult_DescriptionCreationErrorZ* operator ->() { return &self; } - const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; } - const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; } + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ(const CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ&) = delete; + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ(CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ)); } + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ(LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ)); } + operator LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ() && { LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ)); return res; } + ~CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ() { CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_free(self); } + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ& operator=(CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ&& o) { CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ)); return *this; } + LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ* operator ->() const { return &self; } }; class CResult_RoutingFeesDecodeErrorZ { private: @@ -8260,6 +9473,21 @@ public: const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ* operator ->() const { return &self; } }; +class CResult_DescriptionCreationErrorZ { +private: + LDKCResult_DescriptionCreationErrorZ self; +public: + CResult_DescriptionCreationErrorZ(const CResult_DescriptionCreationErrorZ&) = delete; + CResult_DescriptionCreationErrorZ(CResult_DescriptionCreationErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); } + CResult_DescriptionCreationErrorZ(LDKCResult_DescriptionCreationErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); } + operator LDKCResult_DescriptionCreationErrorZ() && { LDKCResult_DescriptionCreationErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_DescriptionCreationErrorZ)); return res; } + ~CResult_DescriptionCreationErrorZ() { CResult_DescriptionCreationErrorZ_free(self); } + CResult_DescriptionCreationErrorZ& operator=(CResult_DescriptionCreationErrorZ&& o) { CResult_DescriptionCreationErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_DescriptionCreationErrorZ)); return *this; } + LDKCResult_DescriptionCreationErrorZ* operator &() { return &self; } + LDKCResult_DescriptionCreationErrorZ* operator ->() { return &self; } + const LDKCResult_DescriptionCreationErrorZ* operator &() const { return &self; } + const LDKCResult_DescriptionCreationErrorZ* operator ->() const { return &self; } +}; class CResult_PaymentRelayDecodeErrorZ { private: LDKCResult_PaymentRelayDecodeErrorZ self; @@ -8320,6 +9548,21 @@ public: const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateAddHTLCDecodeErrorZ* operator ->() const { return &self; } }; +class COption_OutboundHTLCStateDetailsZ { +private: + LDKCOption_OutboundHTLCStateDetailsZ self; +public: + COption_OutboundHTLCStateDetailsZ(const COption_OutboundHTLCStateDetailsZ&) = delete; + COption_OutboundHTLCStateDetailsZ(COption_OutboundHTLCStateDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_OutboundHTLCStateDetailsZ)); } + COption_OutboundHTLCStateDetailsZ(LDKCOption_OutboundHTLCStateDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_OutboundHTLCStateDetailsZ)); } + operator LDKCOption_OutboundHTLCStateDetailsZ() && { LDKCOption_OutboundHTLCStateDetailsZ res = self; memset(&self, 0, sizeof(LDKCOption_OutboundHTLCStateDetailsZ)); return res; } + ~COption_OutboundHTLCStateDetailsZ() { COption_OutboundHTLCStateDetailsZ_free(self); } + COption_OutboundHTLCStateDetailsZ& operator=(COption_OutboundHTLCStateDetailsZ&& o) { COption_OutboundHTLCStateDetailsZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_OutboundHTLCStateDetailsZ)); return *this; } + LDKCOption_OutboundHTLCStateDetailsZ* operator &() { return &self; } + LDKCOption_OutboundHTLCStateDetailsZ* operator ->() { return &self; } + const LDKCOption_OutboundHTLCStateDetailsZ* operator &() const { return &self; } + const LDKCOption_OutboundHTLCStateDetailsZ* operator ->() const { return &self; } +}; class COption_MonitorEventZ { private: LDKCOption_MonitorEventZ self; @@ -8365,6 +9608,21 @@ public: const LDKCResult_COption_TypeZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_TypeZDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_OfferDecodeErrorZ { +private: + LDKCResult_OfferDecodeErrorZ self; +public: + CResult_OfferDecodeErrorZ(const CResult_OfferDecodeErrorZ&) = delete; + CResult_OfferDecodeErrorZ(CResult_OfferDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferDecodeErrorZ)); } + CResult_OfferDecodeErrorZ(LDKCResult_OfferDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferDecodeErrorZ)); } + operator LDKCResult_OfferDecodeErrorZ() && { LDKCResult_OfferDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferDecodeErrorZ)); return res; } + ~CResult_OfferDecodeErrorZ() { CResult_OfferDecodeErrorZ_free(self); } + CResult_OfferDecodeErrorZ& operator=(CResult_OfferDecodeErrorZ&& o) { CResult_OfferDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferDecodeErrorZ)); return *this; } + LDKCResult_OfferDecodeErrorZ* operator &() { return &self; } + LDKCResult_OfferDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OfferDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OfferDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_COption_PathFailureZDecodeErrorZ { private: LDKCResult_COption_PathFailureZDecodeErrorZ self; @@ -8395,6 +9653,21 @@ public: const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator &() const { return &self; } const LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* operator ->() const { return &self; } }; +class CResult_BlindedMessagePathNoneZ { +private: + LDKCResult_BlindedMessagePathNoneZ self; +public: + CResult_BlindedMessagePathNoneZ(const CResult_BlindedMessagePathNoneZ&) = delete; + CResult_BlindedMessagePathNoneZ(CResult_BlindedMessagePathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedMessagePathNoneZ)); } + CResult_BlindedMessagePathNoneZ(LDKCResult_BlindedMessagePathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedMessagePathNoneZ)); } + operator LDKCResult_BlindedMessagePathNoneZ() && { LDKCResult_BlindedMessagePathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedMessagePathNoneZ)); return res; } + ~CResult_BlindedMessagePathNoneZ() { CResult_BlindedMessagePathNoneZ_free(self); } + CResult_BlindedMessagePathNoneZ& operator=(CResult_BlindedMessagePathNoneZ&& o) { CResult_BlindedMessagePathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedMessagePathNoneZ)); return *this; } + LDKCResult_BlindedMessagePathNoneZ* operator &() { return &self; } + LDKCResult_BlindedMessagePathNoneZ* operator ->() { return &self; } + const LDKCResult_BlindedMessagePathNoneZ* operator &() const { return &self; } + const LDKCResult_BlindedMessagePathNoneZ* operator ->() const { return &self; } +}; class CResult_UpdateFailHTLCDecodeErrorZ { private: LDKCResult_UpdateFailHTLCDecodeErrorZ self; @@ -8410,20 +9683,35 @@ public: const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_UpdateFailHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_BlindedPathZNoneZ { +class CResult_BlindedPaymentPathNoneZ { +private: + LDKCResult_BlindedPaymentPathNoneZ self; +public: + CResult_BlindedPaymentPathNoneZ(const CResult_BlindedPaymentPathNoneZ&) = delete; + CResult_BlindedPaymentPathNoneZ(CResult_BlindedPaymentPathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPaymentPathNoneZ)); } + CResult_BlindedPaymentPathNoneZ(LDKCResult_BlindedPaymentPathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPaymentPathNoneZ)); } + operator LDKCResult_BlindedPaymentPathNoneZ() && { LDKCResult_BlindedPaymentPathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPaymentPathNoneZ)); return res; } + ~CResult_BlindedPaymentPathNoneZ() { CResult_BlindedPaymentPathNoneZ_free(self); } + CResult_BlindedPaymentPathNoneZ& operator=(CResult_BlindedPaymentPathNoneZ&& o) { CResult_BlindedPaymentPathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPaymentPathNoneZ)); return *this; } + LDKCResult_BlindedPaymentPathNoneZ* operator &() { return &self; } + LDKCResult_BlindedPaymentPathNoneZ* operator ->() { return &self; } + const LDKCResult_BlindedPaymentPathNoneZ* operator &() const { return &self; } + const LDKCResult_BlindedPaymentPathNoneZ* operator ->() const { return &self; } +}; +class CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { private: - LDKCResult_CVec_BlindedPathZNoneZ self; + LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ self; public: - CResult_CVec_BlindedPathZNoneZ(const CResult_CVec_BlindedPathZNoneZ&) = delete; - CResult_CVec_BlindedPathZNoneZ(CResult_CVec_BlindedPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedPathZNoneZ)); } - CResult_CVec_BlindedPathZNoneZ(LDKCResult_CVec_BlindedPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedPathZNoneZ)); } - operator LDKCResult_CVec_BlindedPathZNoneZ() && { LDKCResult_CVec_BlindedPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedPathZNoneZ)); return res; } - ~CResult_CVec_BlindedPathZNoneZ() { CResult_CVec_BlindedPathZNoneZ_free(self); } - CResult_CVec_BlindedPathZNoneZ& operator=(CResult_CVec_BlindedPathZNoneZ&& o) { CResult_CVec_BlindedPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedPathZNoneZ)); return *this; } - LDKCResult_CVec_BlindedPathZNoneZ* operator &() { return &self; } - LDKCResult_CVec_BlindedPathZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_BlindedPathZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_BlindedPathZNoneZ* operator ->() const { return &self; } + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ(const CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ&) = delete; + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ(CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ)); } + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ(LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ() && { LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ() { CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(self); } + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ& operator=(CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ&& o) { CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { private: @@ -8440,21 +9728,6 @@ public: const LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ* operator ->() const { return &self; } }; -class CResult_RevokeAndACKDecodeErrorZ { -private: - LDKCResult_RevokeAndACKDecodeErrorZ self; -public: - CResult_RevokeAndACKDecodeErrorZ(const CResult_RevokeAndACKDecodeErrorZ&) = delete; - CResult_RevokeAndACKDecodeErrorZ(CResult_RevokeAndACKDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RevokeAndACKDecodeErrorZ)); } - CResult_RevokeAndACKDecodeErrorZ(LDKCResult_RevokeAndACKDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RevokeAndACKDecodeErrorZ)); } - operator LDKCResult_RevokeAndACKDecodeErrorZ() && { LDKCResult_RevokeAndACKDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RevokeAndACKDecodeErrorZ)); return res; } - ~CResult_RevokeAndACKDecodeErrorZ() { CResult_RevokeAndACKDecodeErrorZ_free(self); } - CResult_RevokeAndACKDecodeErrorZ& operator=(CResult_RevokeAndACKDecodeErrorZ&& o) { CResult_RevokeAndACKDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RevokeAndACKDecodeErrorZ)); return *this; } - LDKCResult_RevokeAndACKDecodeErrorZ* operator &() { return &self; } - LDKCResult_RevokeAndACKDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_RevokeAndACKDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_RevokeAndACKDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_SpendableOutputDescriptorDecodeErrorZ { private: LDKCResult_SpendableOutputDescriptorDecodeErrorZ self; @@ -8470,20 +9743,20 @@ public: const LDKCResult_SpendableOutputDescriptorDecodeErrorZ* operator &() const { return &self; } const LDKCResult_SpendableOutputDescriptorDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_PublicKeyCOption_SocketAddressZZ { +class CResult_RevokeAndACKDecodeErrorZ { private: - LDKC2Tuple_PublicKeyCOption_SocketAddressZZ self; + LDKCResult_RevokeAndACKDecodeErrorZ self; public: - C2Tuple_PublicKeyCOption_SocketAddressZZ(const C2Tuple_PublicKeyCOption_SocketAddressZZ&) = delete; - C2Tuple_PublicKeyCOption_SocketAddressZZ(C2Tuple_PublicKeyCOption_SocketAddressZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_SocketAddressZZ)); } - C2Tuple_PublicKeyCOption_SocketAddressZZ(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ)); } - operator LDKC2Tuple_PublicKeyCOption_SocketAddressZZ() && { LDKC2Tuple_PublicKeyCOption_SocketAddressZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ)); return res; } - ~C2Tuple_PublicKeyCOption_SocketAddressZZ() { C2Tuple_PublicKeyCOption_SocketAddressZZ_free(self); } - C2Tuple_PublicKeyCOption_SocketAddressZZ& operator=(C2Tuple_PublicKeyCOption_SocketAddressZZ&& o) { C2Tuple_PublicKeyCOption_SocketAddressZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_PublicKeyCOption_SocketAddressZZ)); return *this; } - LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* operator &() { return &self; } - LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* operator ->() { return &self; } - const LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* operator &() const { return &self; } - const LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* operator ->() const { return &self; } + CResult_RevokeAndACKDecodeErrorZ(const CResult_RevokeAndACKDecodeErrorZ&) = delete; + CResult_RevokeAndACKDecodeErrorZ(CResult_RevokeAndACKDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RevokeAndACKDecodeErrorZ)); } + CResult_RevokeAndACKDecodeErrorZ(LDKCResult_RevokeAndACKDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RevokeAndACKDecodeErrorZ)); } + operator LDKCResult_RevokeAndACKDecodeErrorZ() && { LDKCResult_RevokeAndACKDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RevokeAndACKDecodeErrorZ)); return res; } + ~CResult_RevokeAndACKDecodeErrorZ() { CResult_RevokeAndACKDecodeErrorZ_free(self); } + CResult_RevokeAndACKDecodeErrorZ& operator=(CResult_RevokeAndACKDecodeErrorZ&& o) { CResult_RevokeAndACKDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RevokeAndACKDecodeErrorZ)); return *this; } + LDKCResult_RevokeAndACKDecodeErrorZ* operator &() { return &self; } + LDKCResult_RevokeAndACKDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RevokeAndACKDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RevokeAndACKDecodeErrorZ* operator ->() const { return &self; } }; class CResult_UnsignedChannelUpdateDecodeErrorZ { private: @@ -8530,6 +9803,36 @@ public: const LDKC2Tuple__u832u16Z* operator &() const { return &self; } const LDKC2Tuple__u832u16Z* operator ->() const { return &self; } }; +class CResult_BlindedMessagePathDecodeErrorZ { +private: + LDKCResult_BlindedMessagePathDecodeErrorZ self; +public: + CResult_BlindedMessagePathDecodeErrorZ(const CResult_BlindedMessagePathDecodeErrorZ&) = delete; + CResult_BlindedMessagePathDecodeErrorZ(CResult_BlindedMessagePathDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedMessagePathDecodeErrorZ)); } + CResult_BlindedMessagePathDecodeErrorZ(LDKCResult_BlindedMessagePathDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedMessagePathDecodeErrorZ)); } + operator LDKCResult_BlindedMessagePathDecodeErrorZ() && { LDKCResult_BlindedMessagePathDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedMessagePathDecodeErrorZ)); return res; } + ~CResult_BlindedMessagePathDecodeErrorZ() { CResult_BlindedMessagePathDecodeErrorZ_free(self); } + CResult_BlindedMessagePathDecodeErrorZ& operator=(CResult_BlindedMessagePathDecodeErrorZ&& o) { CResult_BlindedMessagePathDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedMessagePathDecodeErrorZ)); return *this; } + LDKCResult_BlindedMessagePathDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedMessagePathDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedMessagePathDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedMessagePathDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_CVec_BlindedMessagePathZNoneZ { +private: + LDKCResult_CVec_BlindedMessagePathZNoneZ self; +public: + CResult_CVec_BlindedMessagePathZNoneZ(const CResult_CVec_BlindedMessagePathZNoneZ&) = delete; + CResult_CVec_BlindedMessagePathZNoneZ(CResult_CVec_BlindedMessagePathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedMessagePathZNoneZ)); } + CResult_CVec_BlindedMessagePathZNoneZ(LDKCResult_CVec_BlindedMessagePathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedMessagePathZNoneZ)); } + operator LDKCResult_CVec_BlindedMessagePathZNoneZ() && { LDKCResult_CVec_BlindedMessagePathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedMessagePathZNoneZ)); return res; } + ~CResult_CVec_BlindedMessagePathZNoneZ() { CResult_CVec_BlindedMessagePathZNoneZ_free(self); } + CResult_CVec_BlindedMessagePathZNoneZ& operator=(CResult_CVec_BlindedMessagePathZNoneZ&& o) { CResult_CVec_BlindedMessagePathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedMessagePathZNoneZ)); return *this; } + LDKCResult_CVec_BlindedMessagePathZNoneZ* operator &() { return &self; } + LDKCResult_CVec_BlindedMessagePathZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_BlindedMessagePathZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_BlindedMessagePathZNoneZ* operator ->() const { return &self; } +}; class COption_BigEndianScalarZ { private: LDKCOption_BigEndianScalarZ self; @@ -8545,6 +9848,21 @@ public: const LDKCOption_BigEndianScalarZ* operator &() const { return &self; } const LDKCOption_BigEndianScalarZ* operator ->() const { return &self; } }; +class CVec_ChannelIdZ { +private: + LDKCVec_ChannelIdZ self; +public: + CVec_ChannelIdZ(const CVec_ChannelIdZ&) = delete; + CVec_ChannelIdZ(CVec_ChannelIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelIdZ)); } + CVec_ChannelIdZ(LDKCVec_ChannelIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ChannelIdZ)); } + operator LDKCVec_ChannelIdZ() && { LDKCVec_ChannelIdZ res = self; memset(&self, 0, sizeof(LDKCVec_ChannelIdZ)); return res; } + ~CVec_ChannelIdZ() { CVec_ChannelIdZ_free(self); } + CVec_ChannelIdZ& operator=(CVec_ChannelIdZ&& o) { CVec_ChannelIdZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ChannelIdZ)); return *this; } + LDKCVec_ChannelIdZ* operator &() { return &self; } + LDKCVec_ChannelIdZ* operator ->() { return &self; } + const LDKCVec_ChannelIdZ* operator &() const { return &self; } + const LDKCVec_ChannelIdZ* operator ->() const { return &self; } +}; class CResult_PublicKeySecp256k1ErrorZ { private: LDKCResult_PublicKeySecp256k1ErrorZ self; @@ -8560,20 +9878,20 @@ public: const LDKCResult_PublicKeySecp256k1ErrorZ* operator &() const { return &self; } const LDKCResult_PublicKeySecp256k1ErrorZ* operator ->() const { return &self; } }; -class CResult_CVec_ECDSASignatureZNoneZ { +class C2Tuple_OnionMessageContentsMessageSendInstructionsZ { private: - LDKCResult_CVec_ECDSASignatureZNoneZ self; + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ self; public: - CResult_CVec_ECDSASignatureZNoneZ(const CResult_CVec_ECDSASignatureZNoneZ&) = delete; - CResult_CVec_ECDSASignatureZNoneZ(CResult_CVec_ECDSASignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); } - CResult_CVec_ECDSASignatureZNoneZ(LDKCResult_CVec_ECDSASignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); } - operator LDKCResult_CVec_ECDSASignatureZNoneZ() && { LDKCResult_CVec_ECDSASignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); return res; } - ~CResult_CVec_ECDSASignatureZNoneZ() { CResult_CVec_ECDSASignatureZNoneZ_free(self); } - CResult_CVec_ECDSASignatureZNoneZ& operator=(CResult_CVec_ECDSASignatureZNoneZ&& o) { CResult_CVec_ECDSASignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); return *this; } - LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() { return &self; } - LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() const { return &self; } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(const C2Tuple_OnionMessageContentsMessageSendInstructionsZ&) = delete; + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(C2Tuple_OnionMessageContentsMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsMessageSendInstructionsZ)); } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ)); } + operator LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ() && { LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ)); return res; } + ~C2Tuple_OnionMessageContentsMessageSendInstructionsZ() { C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(self); } + C2Tuple_OnionMessageContentsMessageSendInstructionsZ& operator=(C2Tuple_OnionMessageContentsMessageSendInstructionsZ&& o) { C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OnionMessageContentsMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_OnionMessageContentsMessageSendInstructionsZ* operator ->() const { return &self; } }; class CVec_BlindedHopZ { private: @@ -8590,6 +9908,36 @@ public: const LDKCVec_BlindedHopZ* operator &() const { return &self; } const LDKCVec_BlindedHopZ* operator ->() const { return &self; } }; +class CResult_ReleaseHeldHtlcDecodeErrorZ { +private: + LDKCResult_ReleaseHeldHtlcDecodeErrorZ self; +public: + CResult_ReleaseHeldHtlcDecodeErrorZ(const CResult_ReleaseHeldHtlcDecodeErrorZ&) = delete; + CResult_ReleaseHeldHtlcDecodeErrorZ(CResult_ReleaseHeldHtlcDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ReleaseHeldHtlcDecodeErrorZ)); } + CResult_ReleaseHeldHtlcDecodeErrorZ(LDKCResult_ReleaseHeldHtlcDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ReleaseHeldHtlcDecodeErrorZ)); } + operator LDKCResult_ReleaseHeldHtlcDecodeErrorZ() && { LDKCResult_ReleaseHeldHtlcDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ReleaseHeldHtlcDecodeErrorZ)); return res; } + ~CResult_ReleaseHeldHtlcDecodeErrorZ() { CResult_ReleaseHeldHtlcDecodeErrorZ_free(self); } + CResult_ReleaseHeldHtlcDecodeErrorZ& operator=(CResult_ReleaseHeldHtlcDecodeErrorZ&& o) { CResult_ReleaseHeldHtlcDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ReleaseHeldHtlcDecodeErrorZ)); return *this; } + LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator &() { return &self; } + LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ReleaseHeldHtlcDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_CVec_ECDSASignatureZNoneZ { +private: + LDKCResult_CVec_ECDSASignatureZNoneZ self; +public: + CResult_CVec_ECDSASignatureZNoneZ(const CResult_CVec_ECDSASignatureZNoneZ&) = delete; + CResult_CVec_ECDSASignatureZNoneZ(CResult_CVec_ECDSASignatureZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); } + CResult_CVec_ECDSASignatureZNoneZ(LDKCResult_CVec_ECDSASignatureZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); } + operator LDKCResult_CVec_ECDSASignatureZNoneZ() && { LDKCResult_CVec_ECDSASignatureZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ)); return res; } + ~CResult_CVec_ECDSASignatureZNoneZ() { CResult_CVec_ECDSASignatureZNoneZ_free(self); } + CResult_CVec_ECDSASignatureZNoneZ& operator=(CResult_CVec_ECDSASignatureZNoneZ&& o) { CResult_CVec_ECDSASignatureZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_ECDSASignatureZNoneZ)); return *this; } + LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() { return &self; } + LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_ECDSASignatureZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_ECDSASignatureZNoneZ* operator ->() const { return &self; } +}; class CResult_COption_ClosureReasonZDecodeErrorZ { private: LDKCResult_COption_ClosureReasonZDecodeErrorZ self; @@ -8605,21 +9953,6 @@ public: const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_COption_ClosureReasonZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InvoiceErrorDecodeErrorZ { -private: - LDKCResult_InvoiceErrorDecodeErrorZ self; -public: - CResult_InvoiceErrorDecodeErrorZ(const CResult_InvoiceErrorDecodeErrorZ&) = delete; - CResult_InvoiceErrorDecodeErrorZ(CResult_InvoiceErrorDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); } - CResult_InvoiceErrorDecodeErrorZ(LDKCResult_InvoiceErrorDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); } - operator LDKCResult_InvoiceErrorDecodeErrorZ() && { LDKCResult_InvoiceErrorDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); return res; } - ~CResult_InvoiceErrorDecodeErrorZ() { CResult_InvoiceErrorDecodeErrorZ_free(self); } - CResult_InvoiceErrorDecodeErrorZ& operator=(CResult_InvoiceErrorDecodeErrorZ&& o) { CResult_InvoiceErrorDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); return *this; } - LDKCResult_InvoiceErrorDecodeErrorZ* operator &() { return &self; } - LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InvoiceErrorDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() const { return &self; } -}; class C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { private: LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ self; @@ -8635,6 +9968,21 @@ public: const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator &() const { return &self; } const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* operator ->() const { return &self; } }; +class CResult_NonceDecodeErrorZ { +private: + LDKCResult_NonceDecodeErrorZ self; +public: + CResult_NonceDecodeErrorZ(const CResult_NonceDecodeErrorZ&) = delete; + CResult_NonceDecodeErrorZ(CResult_NonceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_NonceDecodeErrorZ)); } + CResult_NonceDecodeErrorZ(LDKCResult_NonceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_NonceDecodeErrorZ)); } + operator LDKCResult_NonceDecodeErrorZ() && { LDKCResult_NonceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_NonceDecodeErrorZ)); return res; } + ~CResult_NonceDecodeErrorZ() { CResult_NonceDecodeErrorZ_free(self); } + CResult_NonceDecodeErrorZ& operator=(CResult_NonceDecodeErrorZ&& o) { CResult_NonceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_NonceDecodeErrorZ)); return *this; } + LDKCResult_NonceDecodeErrorZ* operator &() { return &self; } + LDKCResult_NonceDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_NonceDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_NonceDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RouteParametersDecodeErrorZ { private: LDKCResult_RouteParametersDecodeErrorZ self; @@ -8665,6 +10013,21 @@ public: const LDKCResult_PrivateRouteCreationErrorZ* operator &() const { return &self; } const LDKCResult_PrivateRouteCreationErrorZ* operator ->() const { return &self; } }; +class CResult_InvoiceErrorDecodeErrorZ { +private: + LDKCResult_InvoiceErrorDecodeErrorZ self; +public: + CResult_InvoiceErrorDecodeErrorZ(const CResult_InvoiceErrorDecodeErrorZ&) = delete; + CResult_InvoiceErrorDecodeErrorZ(CResult_InvoiceErrorDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); } + CResult_InvoiceErrorDecodeErrorZ(LDKCResult_InvoiceErrorDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); } + operator LDKCResult_InvoiceErrorDecodeErrorZ() && { LDKCResult_InvoiceErrorDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceErrorDecodeErrorZ)); return res; } + ~CResult_InvoiceErrorDecodeErrorZ() { CResult_InvoiceErrorDecodeErrorZ_free(self); } + CResult_InvoiceErrorDecodeErrorZ& operator=(CResult_InvoiceErrorDecodeErrorZ&& o) { CResult_InvoiceErrorDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceErrorDecodeErrorZ)); return *this; } + LDKCResult_InvoiceErrorDecodeErrorZ* operator &() { return &self; } + LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceErrorDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceErrorDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_NodeAliasDecodeErrorZ { private: LDKCResult_NodeAliasDecodeErrorZ self; @@ -8680,6 +10043,36 @@ public: const LDKCResult_NodeAliasDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAliasDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_BestBlockOutputSweeperZ { +private: + LDKC2Tuple_BestBlockOutputSweeperZ self; +public: + C2Tuple_BestBlockOutputSweeperZ(const C2Tuple_BestBlockOutputSweeperZ&) = delete; + C2Tuple_BestBlockOutputSweeperZ(C2Tuple_BestBlockOutputSweeperZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); } + C2Tuple_BestBlockOutputSweeperZ(LDKC2Tuple_BestBlockOutputSweeperZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); } + operator LDKC2Tuple_BestBlockOutputSweeperZ() && { LDKC2Tuple_BestBlockOutputSweeperZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BestBlockOutputSweeperZ)); return res; } + ~C2Tuple_BestBlockOutputSweeperZ() { C2Tuple_BestBlockOutputSweeperZ_free(self); } + C2Tuple_BestBlockOutputSweeperZ& operator=(C2Tuple_BestBlockOutputSweeperZ&& o) { C2Tuple_BestBlockOutputSweeperZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BestBlockOutputSweeperZ)); return *this; } + LDKC2Tuple_BestBlockOutputSweeperZ* operator &() { return &self; } + LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() { return &self; } + const LDKC2Tuple_BestBlockOutputSweeperZ* operator &() const { return &self; } + const LDKC2Tuple_BestBlockOutputSweeperZ* operator ->() const { return &self; } +}; +class C2Tuple_OutPointCVec_u64ZZ { +private: + LDKC2Tuple_OutPointCVec_u64ZZ self; +public: + C2Tuple_OutPointCVec_u64ZZ(const C2Tuple_OutPointCVec_u64ZZ&) = delete; + C2Tuple_OutPointCVec_u64ZZ(C2Tuple_OutPointCVec_u64ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); } + C2Tuple_OutPointCVec_u64ZZ(LDKC2Tuple_OutPointCVec_u64ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); } + operator LDKC2Tuple_OutPointCVec_u64ZZ() && { LDKC2Tuple_OutPointCVec_u64ZZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointCVec_u64ZZ)); return res; } + ~C2Tuple_OutPointCVec_u64ZZ() { C2Tuple_OutPointCVec_u64ZZ_free(self); } + C2Tuple_OutPointCVec_u64ZZ& operator=(C2Tuple_OutPointCVec_u64ZZ&& o) { C2Tuple_OutPointCVec_u64ZZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointCVec_u64ZZ)); return *this; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator &() { return &self; } + LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator &() const { return &self; } + const LDKC2Tuple_OutPointCVec_u64ZZ* operator ->() const { return &self; } +}; class CVec_UpdateFulfillHTLCZ { private: LDKCVec_UpdateFulfillHTLCZ self; @@ -8860,20 +10253,20 @@ public: const LDKCOption_PathFailureZ* operator &() const { return &self; } const LDKCOption_PathFailureZ* operator ->() const { return &self; } }; -class CResult_StrSecp256k1ErrorZ { +class COption_MessageContextZ { private: - LDKCResult_StrSecp256k1ErrorZ self; + LDKCOption_MessageContextZ self; public: - CResult_StrSecp256k1ErrorZ(const CResult_StrSecp256k1ErrorZ&) = delete; - CResult_StrSecp256k1ErrorZ(CResult_StrSecp256k1ErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_StrSecp256k1ErrorZ)); } - CResult_StrSecp256k1ErrorZ(LDKCResult_StrSecp256k1ErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_StrSecp256k1ErrorZ)); } - operator LDKCResult_StrSecp256k1ErrorZ() && { LDKCResult_StrSecp256k1ErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_StrSecp256k1ErrorZ)); return res; } - ~CResult_StrSecp256k1ErrorZ() { CResult_StrSecp256k1ErrorZ_free(self); } - CResult_StrSecp256k1ErrorZ& operator=(CResult_StrSecp256k1ErrorZ&& o) { CResult_StrSecp256k1ErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_StrSecp256k1ErrorZ)); return *this; } - LDKCResult_StrSecp256k1ErrorZ* operator &() { return &self; } - LDKCResult_StrSecp256k1ErrorZ* operator ->() { return &self; } - const LDKCResult_StrSecp256k1ErrorZ* operator &() const { return &self; } - const LDKCResult_StrSecp256k1ErrorZ* operator ->() const { return &self; } + COption_MessageContextZ(const COption_MessageContextZ&) = delete; + COption_MessageContextZ(COption_MessageContextZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_MessageContextZ)); } + COption_MessageContextZ(LDKCOption_MessageContextZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_MessageContextZ)); } + operator LDKCOption_MessageContextZ() && { LDKCOption_MessageContextZ res = self; memset(&self, 0, sizeof(LDKCOption_MessageContextZ)); return res; } + ~COption_MessageContextZ() { COption_MessageContextZ_free(self); } + COption_MessageContextZ& operator=(COption_MessageContextZ&& o) { COption_MessageContextZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_MessageContextZ)); return *this; } + LDKCOption_MessageContextZ* operator &() { return &self; } + LDKCOption_MessageContextZ* operator ->() { return &self; } + const LDKCOption_MessageContextZ* operator &() const { return &self; } + const LDKCOption_MessageContextZ* operator ->() const { return &self; } }; class CVec_ECDSASignatureZ { private: @@ -8935,6 +10328,36 @@ public: const LDKCVec_TxOutZ* operator &() const { return &self; } const LDKCVec_TxOutZ* operator ->() const { return &self; } }; +class CVec_InboundHTLCDetailsZ { +private: + LDKCVec_InboundHTLCDetailsZ self; +public: + CVec_InboundHTLCDetailsZ(const CVec_InboundHTLCDetailsZ&) = delete; + CVec_InboundHTLCDetailsZ(CVec_InboundHTLCDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_InboundHTLCDetailsZ)); } + CVec_InboundHTLCDetailsZ(LDKCVec_InboundHTLCDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_InboundHTLCDetailsZ)); } + operator LDKCVec_InboundHTLCDetailsZ() && { LDKCVec_InboundHTLCDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_InboundHTLCDetailsZ)); return res; } + ~CVec_InboundHTLCDetailsZ() { CVec_InboundHTLCDetailsZ_free(self); } + CVec_InboundHTLCDetailsZ& operator=(CVec_InboundHTLCDetailsZ&& o) { CVec_InboundHTLCDetailsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_InboundHTLCDetailsZ)); return *this; } + LDKCVec_InboundHTLCDetailsZ* operator &() { return &self; } + LDKCVec_InboundHTLCDetailsZ* operator ->() { return &self; } + const LDKCVec_InboundHTLCDetailsZ* operator &() const { return &self; } + const LDKCVec_InboundHTLCDetailsZ* operator ->() const { return &self; } +}; +class CVec_OutboundHTLCDetailsZ { +private: + LDKCVec_OutboundHTLCDetailsZ self; +public: + CVec_OutboundHTLCDetailsZ(const CVec_OutboundHTLCDetailsZ&) = delete; + CVec_OutboundHTLCDetailsZ(CVec_OutboundHTLCDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_OutboundHTLCDetailsZ)); } + CVec_OutboundHTLCDetailsZ(LDKCVec_OutboundHTLCDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_OutboundHTLCDetailsZ)); } + operator LDKCVec_OutboundHTLCDetailsZ() && { LDKCVec_OutboundHTLCDetailsZ res = self; memset(&self, 0, sizeof(LDKCVec_OutboundHTLCDetailsZ)); return res; } + ~CVec_OutboundHTLCDetailsZ() { CVec_OutboundHTLCDetailsZ_free(self); } + CVec_OutboundHTLCDetailsZ& operator=(CVec_OutboundHTLCDetailsZ&& o) { CVec_OutboundHTLCDetailsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_OutboundHTLCDetailsZ)); return *this; } + LDKCVec_OutboundHTLCDetailsZ* operator &() { return &self; } + LDKCVec_OutboundHTLCDetailsZ* operator ->() { return &self; } + const LDKCVec_OutboundHTLCDetailsZ* operator &() const { return &self; } + const LDKCVec_OutboundHTLCDetailsZ* operator ->() const { return &self; } +}; class CResult_BuiltCommitmentTransactionDecodeErrorZ { private: LDKCResult_BuiltCommitmentTransactionDecodeErrorZ self; @@ -8950,6 +10373,36 @@ public: const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_PaymentForwardNodeZ { +private: + LDKCVec_PaymentForwardNodeZ self; +public: + CVec_PaymentForwardNodeZ(const CVec_PaymentForwardNodeZ&) = delete; + CVec_PaymentForwardNodeZ(CVec_PaymentForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PaymentForwardNodeZ)); } + CVec_PaymentForwardNodeZ(LDKCVec_PaymentForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PaymentForwardNodeZ)); } + operator LDKCVec_PaymentForwardNodeZ() && { LDKCVec_PaymentForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_PaymentForwardNodeZ)); return res; } + ~CVec_PaymentForwardNodeZ() { CVec_PaymentForwardNodeZ_free(self); } + CVec_PaymentForwardNodeZ& operator=(CVec_PaymentForwardNodeZ&& o) { CVec_PaymentForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PaymentForwardNodeZ)); return *this; } + LDKCVec_PaymentForwardNodeZ* operator &() { return &self; } + LDKCVec_PaymentForwardNodeZ* operator ->() { return &self; } + const LDKCVec_PaymentForwardNodeZ* operator &() const { return &self; } + const LDKCVec_PaymentForwardNodeZ* operator ->() const { return &self; } +}; +class CResult_TrackedSpendableOutputDecodeErrorZ { +private: + LDKCResult_TrackedSpendableOutputDecodeErrorZ self; +public: + CResult_TrackedSpendableOutputDecodeErrorZ(const CResult_TrackedSpendableOutputDecodeErrorZ&) = delete; + CResult_TrackedSpendableOutputDecodeErrorZ(CResult_TrackedSpendableOutputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TrackedSpendableOutputDecodeErrorZ)); } + CResult_TrackedSpendableOutputDecodeErrorZ(LDKCResult_TrackedSpendableOutputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TrackedSpendableOutputDecodeErrorZ)); } + operator LDKCResult_TrackedSpendableOutputDecodeErrorZ() && { LDKCResult_TrackedSpendableOutputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TrackedSpendableOutputDecodeErrorZ)); return res; } + ~CResult_TrackedSpendableOutputDecodeErrorZ() { CResult_TrackedSpendableOutputDecodeErrorZ_free(self); } + CResult_TrackedSpendableOutputDecodeErrorZ& operator=(CResult_TrackedSpendableOutputDecodeErrorZ&& o) { CResult_TrackedSpendableOutputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TrackedSpendableOutputDecodeErrorZ)); return *this; } + LDKCResult_TrackedSpendableOutputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TrackedSpendableOutputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TrackedSpendableOutputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TrackedSpendableOutputDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_SpendableOutputDescriptorZ { private: LDKCVec_SpendableOutputDescriptorZ self; @@ -8965,6 +10418,21 @@ public: const LDKCVec_SpendableOutputDescriptorZ* operator &() const { return &self; } const LDKCVec_SpendableOutputDescriptorZ* operator ->() const { return &self; } }; +class CResult_ResponderDecodeErrorZ { +private: + LDKCResult_ResponderDecodeErrorZ self; +public: + CResult_ResponderDecodeErrorZ(const CResult_ResponderDecodeErrorZ&) = delete; + CResult_ResponderDecodeErrorZ(CResult_ResponderDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ResponderDecodeErrorZ)); } + CResult_ResponderDecodeErrorZ(LDKCResult_ResponderDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ResponderDecodeErrorZ)); } + operator LDKCResult_ResponderDecodeErrorZ() && { LDKCResult_ResponderDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ResponderDecodeErrorZ)); return res; } + ~CResult_ResponderDecodeErrorZ() { CResult_ResponderDecodeErrorZ_free(self); } + CResult_ResponderDecodeErrorZ& operator=(CResult_ResponderDecodeErrorZ&& o) { CResult_ResponderDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ResponderDecodeErrorZ)); return *this; } + LDKCResult_ResponderDecodeErrorZ* operator &() { return &self; } + LDKCResult_ResponderDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ResponderDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ResponderDecodeErrorZ* operator ->() const { return &self; } +}; class C2Tuple_OutPointCVec_u8ZZ { private: LDKC2Tuple_OutPointCVec_u8ZZ self; @@ -9055,20 +10523,20 @@ public: const LDKCResult_TxAddInputDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TxAddInputDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PeeledOnionNoneZ { +class CResult_HeldHtlcAvailableDecodeErrorZ { private: - LDKCResult_PeeledOnionNoneZ self; + LDKCResult_HeldHtlcAvailableDecodeErrorZ self; public: - CResult_PeeledOnionNoneZ(const CResult_PeeledOnionNoneZ&) = delete; - CResult_PeeledOnionNoneZ(CResult_PeeledOnionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); } - CResult_PeeledOnionNoneZ(LDKCResult_PeeledOnionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); } - operator LDKCResult_PeeledOnionNoneZ() && { LDKCResult_PeeledOnionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); return res; } - ~CResult_PeeledOnionNoneZ() { CResult_PeeledOnionNoneZ_free(self); } - CResult_PeeledOnionNoneZ& operator=(CResult_PeeledOnionNoneZ&& o) { CResult_PeeledOnionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); return *this; } - LDKCResult_PeeledOnionNoneZ* operator &() { return &self; } - LDKCResult_PeeledOnionNoneZ* operator ->() { return &self; } - const LDKCResult_PeeledOnionNoneZ* operator &() const { return &self; } - const LDKCResult_PeeledOnionNoneZ* operator ->() const { return &self; } + CResult_HeldHtlcAvailableDecodeErrorZ(const CResult_HeldHtlcAvailableDecodeErrorZ&) = delete; + CResult_HeldHtlcAvailableDecodeErrorZ(CResult_HeldHtlcAvailableDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HeldHtlcAvailableDecodeErrorZ)); } + CResult_HeldHtlcAvailableDecodeErrorZ(LDKCResult_HeldHtlcAvailableDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HeldHtlcAvailableDecodeErrorZ)); } + operator LDKCResult_HeldHtlcAvailableDecodeErrorZ() && { LDKCResult_HeldHtlcAvailableDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HeldHtlcAvailableDecodeErrorZ)); return res; } + ~CResult_HeldHtlcAvailableDecodeErrorZ() { CResult_HeldHtlcAvailableDecodeErrorZ_free(self); } + CResult_HeldHtlcAvailableDecodeErrorZ& operator=(CResult_HeldHtlcAvailableDecodeErrorZ&& o) { CResult_HeldHtlcAvailableDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HeldHtlcAvailableDecodeErrorZ)); return *this; } + LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator &() { return &self; } + LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HeldHtlcAvailableDecodeErrorZ* operator ->() const { return &self; } }; class CResult_TxInitRbfDecodeErrorZ { private: @@ -9115,20 +10583,20 @@ public: const LDKCVec_StrZ* operator &() const { return &self; } const LDKCVec_StrZ* operator ->() const { return &self; } }; -class CVec_OutPointZ { +class CResult_AsyncPaymentsMessageDecodeErrorZ { private: - LDKCVec_OutPointZ self; + LDKCResult_AsyncPaymentsMessageDecodeErrorZ self; public: - CVec_OutPointZ(const CVec_OutPointZ&) = delete; - CVec_OutPointZ(CVec_OutPointZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_OutPointZ)); } - CVec_OutPointZ(LDKCVec_OutPointZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_OutPointZ)); } - operator LDKCVec_OutPointZ() && { LDKCVec_OutPointZ res = self; memset(&self, 0, sizeof(LDKCVec_OutPointZ)); return res; } - ~CVec_OutPointZ() { CVec_OutPointZ_free(self); } - CVec_OutPointZ& operator=(CVec_OutPointZ&& o) { CVec_OutPointZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_OutPointZ)); return *this; } - LDKCVec_OutPointZ* operator &() { return &self; } - LDKCVec_OutPointZ* operator ->() { return &self; } - const LDKCVec_OutPointZ* operator &() const { return &self; } - const LDKCVec_OutPointZ* operator ->() const { return &self; } + CResult_AsyncPaymentsMessageDecodeErrorZ(const CResult_AsyncPaymentsMessageDecodeErrorZ&) = delete; + CResult_AsyncPaymentsMessageDecodeErrorZ(CResult_AsyncPaymentsMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_AsyncPaymentsMessageDecodeErrorZ)); } + CResult_AsyncPaymentsMessageDecodeErrorZ(LDKCResult_AsyncPaymentsMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_AsyncPaymentsMessageDecodeErrorZ)); } + operator LDKCResult_AsyncPaymentsMessageDecodeErrorZ() && { LDKCResult_AsyncPaymentsMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_AsyncPaymentsMessageDecodeErrorZ)); return res; } + ~CResult_AsyncPaymentsMessageDecodeErrorZ() { CResult_AsyncPaymentsMessageDecodeErrorZ_free(self); } + CResult_AsyncPaymentsMessageDecodeErrorZ& operator=(CResult_AsyncPaymentsMessageDecodeErrorZ&& o) { CResult_AsyncPaymentsMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_AsyncPaymentsMessageDecodeErrorZ)); return *this; } + LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_AsyncPaymentsMessageDecodeErrorZ* operator ->() const { return &self; } }; class CResult_SpliceAckDecodeErrorZ { private: @@ -9160,6 +10628,36 @@ public: const LDKCResult_PositiveTimestampCreationErrorZ* operator &() const { return &self; } const LDKCResult_PositiveTimestampCreationErrorZ* operator ->() const { return &self; } }; +class CResult_PeeledOnionNoneZ { +private: + LDKCResult_PeeledOnionNoneZ self; +public: + CResult_PeeledOnionNoneZ(const CResult_PeeledOnionNoneZ&) = delete; + CResult_PeeledOnionNoneZ(CResult_PeeledOnionNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); } + CResult_PeeledOnionNoneZ(LDKCResult_PeeledOnionNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); } + operator LDKCResult_PeeledOnionNoneZ() && { LDKCResult_PeeledOnionNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_PeeledOnionNoneZ)); return res; } + ~CResult_PeeledOnionNoneZ() { CResult_PeeledOnionNoneZ_free(self); } + CResult_PeeledOnionNoneZ& operator=(CResult_PeeledOnionNoneZ&& o) { CResult_PeeledOnionNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PeeledOnionNoneZ)); return *this; } + LDKCResult_PeeledOnionNoneZ* operator &() { return &self; } + LDKCResult_PeeledOnionNoneZ* operator ->() { return &self; } + const LDKCResult_PeeledOnionNoneZ* operator &() const { return &self; } + const LDKCResult_PeeledOnionNoneZ* operator ->() const { return &self; } +}; +class CVec_C2Tuple_OutPointChannelIdZZ { +private: + LDKCVec_C2Tuple_OutPointChannelIdZZ self; +public: + CVec_C2Tuple_OutPointChannelIdZZ(const CVec_C2Tuple_OutPointChannelIdZZ&) = delete; + CVec_C2Tuple_OutPointChannelIdZZ(CVec_C2Tuple_OutPointChannelIdZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OutPointChannelIdZZ)); } + CVec_C2Tuple_OutPointChannelIdZZ(LDKCVec_C2Tuple_OutPointChannelIdZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OutPointChannelIdZZ)); } + operator LDKCVec_C2Tuple_OutPointChannelIdZZ() && { LDKCVec_C2Tuple_OutPointChannelIdZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OutPointChannelIdZZ)); return res; } + ~CVec_C2Tuple_OutPointChannelIdZZ() { CVec_C2Tuple_OutPointChannelIdZZ_free(self); } + CVec_C2Tuple_OutPointChannelIdZZ& operator=(CVec_C2Tuple_OutPointChannelIdZZ&& o) { CVec_C2Tuple_OutPointChannelIdZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OutPointChannelIdZZ)); return *this; } + LDKCVec_C2Tuple_OutPointChannelIdZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OutPointChannelIdZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OutPointChannelIdZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OutPointChannelIdZZ* operator ->() const { return &self; } +}; class CResult_ChannelMonitorUpdateDecodeErrorZ { private: LDKCResult_ChannelMonitorUpdateDecodeErrorZ self; @@ -9175,21 +10673,6 @@ public: const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelMonitorUpdateDecodeErrorZ* operator ->() const { return &self; } }; -class C2Tuple_BlindedPayInfoBlindedPathZ { -private: - LDKC2Tuple_BlindedPayInfoBlindedPathZ self; -public: - C2Tuple_BlindedPayInfoBlindedPathZ(const C2Tuple_BlindedPayInfoBlindedPathZ&) = delete; - C2Tuple_BlindedPayInfoBlindedPathZ(C2Tuple_BlindedPayInfoBlindedPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_BlindedPayInfoBlindedPathZ)); } - C2Tuple_BlindedPayInfoBlindedPathZ(LDKC2Tuple_BlindedPayInfoBlindedPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ)); } - operator LDKC2Tuple_BlindedPayInfoBlindedPathZ() && { LDKC2Tuple_BlindedPayInfoBlindedPathZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ)); return res; } - ~C2Tuple_BlindedPayInfoBlindedPathZ() { C2Tuple_BlindedPayInfoBlindedPathZ_free(self); } - C2Tuple_BlindedPayInfoBlindedPathZ& operator=(C2Tuple_BlindedPayInfoBlindedPathZ&& o) { C2Tuple_BlindedPayInfoBlindedPathZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_BlindedPayInfoBlindedPathZ)); return *this; } - LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator &() { return &self; } - LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator ->() { return &self; } - const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator &() const { return &self; } - const LDKC2Tuple_BlindedPayInfoBlindedPathZ* operator ->() const { return &self; } -}; class CResult_ReplyChannelRangeDecodeErrorZ { private: LDKCResult_ReplyChannelRangeDecodeErrorZ self; @@ -9325,6 +10808,21 @@ public: const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator &() const { return &self; } const LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* operator ->() const { return &self; } }; +class CResult_MessageContextDecodeErrorZ { +private: + LDKCResult_MessageContextDecodeErrorZ self; +public: + CResult_MessageContextDecodeErrorZ(const CResult_MessageContextDecodeErrorZ&) = delete; + CResult_MessageContextDecodeErrorZ(CResult_MessageContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_MessageContextDecodeErrorZ)); } + CResult_MessageContextDecodeErrorZ(LDKCResult_MessageContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_MessageContextDecodeErrorZ)); } + operator LDKCResult_MessageContextDecodeErrorZ() && { LDKCResult_MessageContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_MessageContextDecodeErrorZ)); return res; } + ~CResult_MessageContextDecodeErrorZ() { CResult_MessageContextDecodeErrorZ_free(self); } + CResult_MessageContextDecodeErrorZ& operator=(CResult_MessageContextDecodeErrorZ&& o) { CResult_MessageContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_MessageContextDecodeErrorZ)); return *this; } + LDKCResult_MessageContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_MessageContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_MessageContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_MessageContextDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_InitFeaturesDecodeErrorZ { private: LDKCResult_InitFeaturesDecodeErrorZ self; @@ -9385,6 +10883,21 @@ public: const LDKCResult_RevocationKeyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RevocationKeyDecodeErrorZ* operator ->() const { return &self; } }; +class C2Tuple_OffersMessageMessageSendInstructionsZ { +private: + LDKC2Tuple_OffersMessageMessageSendInstructionsZ self; +public: + C2Tuple_OffersMessageMessageSendInstructionsZ(const C2Tuple_OffersMessageMessageSendInstructionsZ&) = delete; + C2Tuple_OffersMessageMessageSendInstructionsZ(C2Tuple_OffersMessageMessageSendInstructionsZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OffersMessageMessageSendInstructionsZ)); } + C2Tuple_OffersMessageMessageSendInstructionsZ(LDKC2Tuple_OffersMessageMessageSendInstructionsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OffersMessageMessageSendInstructionsZ)); } + operator LDKC2Tuple_OffersMessageMessageSendInstructionsZ() && { LDKC2Tuple_OffersMessageMessageSendInstructionsZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OffersMessageMessageSendInstructionsZ)); return res; } + ~C2Tuple_OffersMessageMessageSendInstructionsZ() { C2Tuple_OffersMessageMessageSendInstructionsZ_free(self); } + C2Tuple_OffersMessageMessageSendInstructionsZ& operator=(C2Tuple_OffersMessageMessageSendInstructionsZ&& o) { C2Tuple_OffersMessageMessageSendInstructionsZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OffersMessageMessageSendInstructionsZ)); return *this; } + LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator &() { return &self; } + LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator ->() { return &self; } + const LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator &() const { return &self; } + const LDKC2Tuple_OffersMessageMessageSendInstructionsZ* operator ->() const { return &self; } +}; class CResult_BlindedHopFeaturesDecodeErrorZ { private: LDKCResult_BlindedHopFeaturesDecodeErrorZ self; @@ -9400,6 +10913,21 @@ public: const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator &() const { return &self; } const LDKCResult_BlindedHopFeaturesDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_ChannelIdDecodeErrorZ { +private: + LDKCResult_ChannelIdDecodeErrorZ self; +public: + CResult_ChannelIdDecodeErrorZ(const CResult_ChannelIdDecodeErrorZ&) = delete; + CResult_ChannelIdDecodeErrorZ(CResult_ChannelIdDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); } + CResult_ChannelIdDecodeErrorZ(LDKCResult_ChannelIdDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); } + operator LDKCResult_ChannelIdDecodeErrorZ() && { LDKCResult_ChannelIdDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelIdDecodeErrorZ)); return res; } + ~CResult_ChannelIdDecodeErrorZ() { CResult_ChannelIdDecodeErrorZ_free(self); } + CResult_ChannelIdDecodeErrorZ& operator=(CResult_ChannelIdDecodeErrorZ&& o) { CResult_ChannelIdDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelIdDecodeErrorZ)); return *this; } + LDKCResult_ChannelIdDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelIdDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelIdDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelIdDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_TransactionOutputsZ { private: LDKCVec_TransactionOutputsZ self; @@ -9445,20 +10973,20 @@ public: const LDKCOption_boolZ* operator &() const { return &self; } const LDKCOption_boolZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { +class CVec_BlindedPaymentPathZ { private: - LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ self; + LDKCVec_BlindedPaymentPathZ self; public: - CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ(const CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ&) = delete; - CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ(CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ)); } - CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ(LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ)); } - operator LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ() && { LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ)); return res; } - ~CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ() { CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(self); } - CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ& operator=(CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ&& o) { CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ)); return *this; } - LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ* operator &() { return &self; } - LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ* operator ->() const { return &self; } + CVec_BlindedPaymentPathZ(const CVec_BlindedPaymentPathZ&) = delete; + CVec_BlindedPaymentPathZ(CVec_BlindedPaymentPathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedPaymentPathZ)); } + CVec_BlindedPaymentPathZ(LDKCVec_BlindedPaymentPathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedPaymentPathZ)); } + operator LDKCVec_BlindedPaymentPathZ() && { LDKCVec_BlindedPaymentPathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedPaymentPathZ)); return res; } + ~CVec_BlindedPaymentPathZ() { CVec_BlindedPaymentPathZ_free(self); } + CVec_BlindedPaymentPathZ& operator=(CVec_BlindedPaymentPathZ&& o) { CVec_BlindedPaymentPathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedPaymentPathZ)); return *this; } + LDKCVec_BlindedPaymentPathZ* operator &() { return &self; } + LDKCVec_BlindedPaymentPathZ* operator ->() { return &self; } + const LDKCVec_BlindedPaymentPathZ* operator &() const { return &self; } + const LDKCVec_BlindedPaymentPathZ* operator ->() const { return &self; } }; class CResult_ProbabilisticScorerDecodeErrorZ { private: @@ -9490,35 +11018,35 @@ public: const LDKCOption_StrZ* operator &() const { return &self; } const LDKCOption_StrZ* operator ->() const { return &self; } }; -class CResult_ShutdownScriptDecodeErrorZ { +class CResult_CVec_BlindedPaymentPathZNoneZ { private: - LDKCResult_ShutdownScriptDecodeErrorZ self; + LDKCResult_CVec_BlindedPaymentPathZNoneZ self; public: - CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; - CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } - CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } - operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } - ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } - CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } - LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } + CResult_CVec_BlindedPaymentPathZNoneZ(const CResult_CVec_BlindedPaymentPathZNoneZ&) = delete; + CResult_CVec_BlindedPaymentPathZNoneZ(CResult_CVec_BlindedPaymentPathZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_BlindedPaymentPathZNoneZ)); } + CResult_CVec_BlindedPaymentPathZNoneZ(LDKCResult_CVec_BlindedPaymentPathZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_BlindedPaymentPathZNoneZ)); } + operator LDKCResult_CVec_BlindedPaymentPathZNoneZ() && { LDKCResult_CVec_BlindedPaymentPathZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_BlindedPaymentPathZNoneZ)); return res; } + ~CResult_CVec_BlindedPaymentPathZNoneZ() { CResult_CVec_BlindedPaymentPathZNoneZ_free(self); } + CResult_CVec_BlindedPaymentPathZNoneZ& operator=(CResult_CVec_BlindedPaymentPathZNoneZ&& o) { CResult_CVec_BlindedPaymentPathZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_BlindedPaymentPathZNoneZ)); return *this; } + LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator &() { return &self; } + LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator ->() { return &self; } + const LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator &() const { return &self; } + const LDKCResult_CVec_BlindedPaymentPathZNoneZ* operator ->() const { return &self; } }; -class CResult_SiPrefixBolt11ParseErrorZ { +class COption_C2Tuple_OffersMessageResponseInstructionZZ { private: - LDKCResult_SiPrefixBolt11ParseErrorZ self; + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ self; public: - CResult_SiPrefixBolt11ParseErrorZ(const CResult_SiPrefixBolt11ParseErrorZ&) = delete; - CResult_SiPrefixBolt11ParseErrorZ(CResult_SiPrefixBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); } - CResult_SiPrefixBolt11ParseErrorZ(LDKCResult_SiPrefixBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); } - operator LDKCResult_SiPrefixBolt11ParseErrorZ() && { LDKCResult_SiPrefixBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); return res; } - ~CResult_SiPrefixBolt11ParseErrorZ() { CResult_SiPrefixBolt11ParseErrorZ_free(self); } - CResult_SiPrefixBolt11ParseErrorZ& operator=(CResult_SiPrefixBolt11ParseErrorZ&& o) { CResult_SiPrefixBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); return *this; } - LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() { return &self; } - LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() { return &self; } - const LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() const { return &self; } - const LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() const { return &self; } + COption_C2Tuple_OffersMessageResponseInstructionZZ(const COption_C2Tuple_OffersMessageResponseInstructionZZ&) = delete; + COption_C2Tuple_OffersMessageResponseInstructionZZ(COption_C2Tuple_OffersMessageResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_OffersMessageResponseInstructionZZ)); } + COption_C2Tuple_OffersMessageResponseInstructionZZ(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ() && { LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ)); return res; } + ~COption_C2Tuple_OffersMessageResponseInstructionZZ() { COption_C2Tuple_OffersMessageResponseInstructionZZ_free(self); } + COption_C2Tuple_OffersMessageResponseInstructionZZ& operator=(COption_C2Tuple_OffersMessageResponseInstructionZZ&& o) { COption_C2Tuple_OffersMessageResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_OffersMessageResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_OffersMessageResponseInstructionZZ* operator ->() const { return &self; } }; class C2Tuple_usizeTransactionZ { private: @@ -9535,6 +11063,21 @@ public: const LDKC2Tuple_usizeTransactionZ* operator &() const { return &self; } const LDKC2Tuple_usizeTransactionZ* operator ->() const { return &self; } }; +class COption_OffersContextZ { +private: + LDKCOption_OffersContextZ self; +public: + COption_OffersContextZ(const COption_OffersContextZ&) = delete; + COption_OffersContextZ(COption_OffersContextZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_OffersContextZ)); } + COption_OffersContextZ(LDKCOption_OffersContextZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_OffersContextZ)); } + operator LDKCOption_OffersContextZ() && { LDKCOption_OffersContextZ res = self; memset(&self, 0, sizeof(LDKCOption_OffersContextZ)); return res; } + ~COption_OffersContextZ() { COption_OffersContextZ_free(self); } + COption_OffersContextZ& operator=(COption_OffersContextZ&& o) { COption_OffersContextZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_OffersContextZ)); return *this; } + LDKCOption_OffersContextZ* operator &() { return &self; } + LDKCOption_OffersContextZ* operator ->() { return &self; } + const LDKCOption_OffersContextZ* operator &() const { return &self; } + const LDKCOption_OffersContextZ* operator ->() const { return &self; } +}; class CResult_NodeAnnouncementDecodeErrorZ { private: LDKCResult_NodeAnnouncementDecodeErrorZ self; @@ -9550,24 +11093,9 @@ public: const LDKCResult_NodeAnnouncementDecodeErrorZ* operator &() const { return &self; } const LDKCResult_NodeAnnouncementDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_FutureZ { +class CVec_ChannelMonitorZ { private: - LDKCVec_FutureZ self; -public: - CVec_FutureZ(const CVec_FutureZ&) = delete; - CVec_FutureZ(CVec_FutureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_FutureZ)); } - CVec_FutureZ(LDKCVec_FutureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_FutureZ)); } - operator LDKCVec_FutureZ() && { LDKCVec_FutureZ res = self; memset(&self, 0, sizeof(LDKCVec_FutureZ)); return res; } - ~CVec_FutureZ() { CVec_FutureZ_free(self); } - CVec_FutureZ& operator=(CVec_FutureZ&& o) { CVec_FutureZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_FutureZ)); return *this; } - LDKCVec_FutureZ* operator &() { return &self; } - LDKCVec_FutureZ* operator ->() { return &self; } - const LDKCVec_FutureZ* operator &() const { return &self; } - const LDKCVec_FutureZ* operator ->() const { return &self; } -}; -class CVec_ChannelMonitorZ { -private: - LDKCVec_ChannelMonitorZ self; + LDKCVec_ChannelMonitorZ self; public: CVec_ChannelMonitorZ(const CVec_ChannelMonitorZ&) = delete; CVec_ChannelMonitorZ(CVec_ChannelMonitorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ChannelMonitorZ)); } @@ -9580,21 +11108,6 @@ public: const LDKCVec_ChannelMonitorZ* operator &() const { return &self; } const LDKCVec_ChannelMonitorZ* operator ->() const { return &self; } }; -class CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { -private: - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ self; -public: - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(const CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&) = delete; - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); } - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); } - operator LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ() && { LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); return res; } - ~CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ() { CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(self); } - CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ& operator=(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ&& o) { CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ)); return *this; } - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator &() { return &self; } - LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator ->() { return &self; } - const LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator &() const { return &self; } - const LDKCVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ* operator ->() const { return &self; } -}; class CResult_AcceptChannelV2DecodeErrorZ { private: LDKCResult_AcceptChannelV2DecodeErrorZ self; @@ -9610,6 +11123,21 @@ public: const LDKCResult_AcceptChannelV2DecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelV2DecodeErrorZ* operator ->() const { return &self; } }; +class CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { +private: + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ self; +public: + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(const CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&) = delete; + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); } + operator LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() && { LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return res; } + ~CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ() { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ& operator=(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ&& o) { CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ)); return *this; } + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_InboundHTLCStateDetailsZDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RouteHopDecodeErrorZ { private: LDKCResult_RouteHopDecodeErrorZ self; @@ -9625,6 +11153,21 @@ public: const LDKCResult_RouteHopDecodeErrorZ* operator &() const { return &self; } const LDKCResult_RouteHopDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_OfferIdDecodeErrorZ { +private: + LDKCResult_OfferIdDecodeErrorZ self; +public: + CResult_OfferIdDecodeErrorZ(const CResult_OfferIdDecodeErrorZ&) = delete; + CResult_OfferIdDecodeErrorZ(CResult_OfferIdDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferIdDecodeErrorZ)); } + CResult_OfferIdDecodeErrorZ(LDKCResult_OfferIdDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferIdDecodeErrorZ)); } + operator LDKCResult_OfferIdDecodeErrorZ() && { LDKCResult_OfferIdDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferIdDecodeErrorZ)); return res; } + ~CResult_OfferIdDecodeErrorZ() { CResult_OfferIdDecodeErrorZ_free(self); } + CResult_OfferIdDecodeErrorZ& operator=(CResult_OfferIdDecodeErrorZ&& o) { CResult_OfferIdDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferIdDecodeErrorZ)); return *this; } + LDKCResult_OfferIdDecodeErrorZ* operator &() { return &self; } + LDKCResult_OfferIdDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OfferIdDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OfferIdDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_HTLCOutputInCommitmentZ { private: LDKCVec_HTLCOutputInCommitmentZ self; @@ -9655,20 +11198,20 @@ public: const LDKCResult_CoinSelectionNoneZ* operator &() const { return &self; } const LDKCResult_CoinSelectionNoneZ* operator ->() const { return &self; } }; -class C2Tuple_ThirtyTwoBytesPublicKeyZ { +class CVec_FutureZ { private: - LDKC2Tuple_ThirtyTwoBytesPublicKeyZ self; + LDKCVec_FutureZ self; public: - C2Tuple_ThirtyTwoBytesPublicKeyZ(const C2Tuple_ThirtyTwoBytesPublicKeyZ&) = delete; - C2Tuple_ThirtyTwoBytesPublicKeyZ(C2Tuple_ThirtyTwoBytesPublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_ThirtyTwoBytesPublicKeyZ)); } - C2Tuple_ThirtyTwoBytesPublicKeyZ(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ)); } - operator LDKC2Tuple_ThirtyTwoBytesPublicKeyZ() && { LDKC2Tuple_ThirtyTwoBytesPublicKeyZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ)); return res; } - ~C2Tuple_ThirtyTwoBytesPublicKeyZ() { C2Tuple_ThirtyTwoBytesPublicKeyZ_free(self); } - C2Tuple_ThirtyTwoBytesPublicKeyZ& operator=(C2Tuple_ThirtyTwoBytesPublicKeyZ&& o) { C2Tuple_ThirtyTwoBytesPublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_ThirtyTwoBytesPublicKeyZ)); return *this; } - LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* operator &() { return &self; } - LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* operator ->() { return &self; } - const LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* operator &() const { return &self; } - const LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* operator ->() const { return &self; } + CVec_FutureZ(const CVec_FutureZ&) = delete; + CVec_FutureZ(CVec_FutureZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_FutureZ)); } + CVec_FutureZ(LDKCVec_FutureZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_FutureZ)); } + operator LDKCVec_FutureZ() && { LDKCVec_FutureZ res = self; memset(&self, 0, sizeof(LDKCVec_FutureZ)); return res; } + ~CVec_FutureZ() { CVec_FutureZ_free(self); } + CVec_FutureZ& operator=(CVec_FutureZ&& o) { CVec_FutureZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_FutureZ)); return *this; } + LDKCVec_FutureZ* operator &() { return &self; } + LDKCVec_FutureZ* operator ->() { return &self; } + const LDKCVec_FutureZ* operator &() const { return &self; } + const LDKCVec_FutureZ* operator ->() const { return &self; } }; class CResult_TxCreationKeysDecodeErrorZ { private: @@ -9685,35 +11228,20 @@ public: const LDKCResult_TxCreationKeysDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TxCreationKeysDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_BlindedPathDecodeErrorZ { +class CResult_RefundBolt12SemanticErrorZ { private: - LDKCResult_BlindedPathDecodeErrorZ self; + LDKCResult_RefundBolt12SemanticErrorZ self; public: - CResult_BlindedPathDecodeErrorZ(const CResult_BlindedPathDecodeErrorZ&) = delete; - CResult_BlindedPathDecodeErrorZ(CResult_BlindedPathDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); } - CResult_BlindedPathDecodeErrorZ(LDKCResult_BlindedPathDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); } - operator LDKCResult_BlindedPathDecodeErrorZ() && { LDKCResult_BlindedPathDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPathDecodeErrorZ)); return res; } - ~CResult_BlindedPathDecodeErrorZ() { CResult_BlindedPathDecodeErrorZ_free(self); } - CResult_BlindedPathDecodeErrorZ& operator=(CResult_BlindedPathDecodeErrorZ&& o) { CResult_BlindedPathDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPathDecodeErrorZ)); return *this; } - LDKCResult_BlindedPathDecodeErrorZ* operator &() { return &self; } - LDKCResult_BlindedPathDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_BlindedPathDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_BlindedPathDecodeErrorZ* operator ->() const { return &self; } -}; -class CVec_BalanceZ { -private: - LDKCVec_BalanceZ self; -public: - CVec_BalanceZ(const CVec_BalanceZ&) = delete; - CVec_BalanceZ(CVec_BalanceZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BalanceZ)); } - CVec_BalanceZ(LDKCVec_BalanceZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BalanceZ)); } - operator LDKCVec_BalanceZ() && { LDKCVec_BalanceZ res = self; memset(&self, 0, sizeof(LDKCVec_BalanceZ)); return res; } - ~CVec_BalanceZ() { CVec_BalanceZ_free(self); } - CVec_BalanceZ& operator=(CVec_BalanceZ&& o) { CVec_BalanceZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BalanceZ)); return *this; } - LDKCVec_BalanceZ* operator &() { return &self; } - LDKCVec_BalanceZ* operator ->() { return &self; } - const LDKCVec_BalanceZ* operator &() const { return &self; } - const LDKCVec_BalanceZ* operator ->() const { return &self; } + CResult_RefundBolt12SemanticErrorZ(const CResult_RefundBolt12SemanticErrorZ&) = delete; + CResult_RefundBolt12SemanticErrorZ(CResult_RefundBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RefundBolt12SemanticErrorZ)); } + CResult_RefundBolt12SemanticErrorZ(LDKCResult_RefundBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RefundBolt12SemanticErrorZ)); } + operator LDKCResult_RefundBolt12SemanticErrorZ() && { LDKCResult_RefundBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RefundBolt12SemanticErrorZ)); return res; } + ~CResult_RefundBolt12SemanticErrorZ() { CResult_RefundBolt12SemanticErrorZ_free(self); } + CResult_RefundBolt12SemanticErrorZ& operator=(CResult_RefundBolt12SemanticErrorZ&& o) { CResult_RefundBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RefundBolt12SemanticErrorZ)); return *this; } + LDKCResult_RefundBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_RefundBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_RefundBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_RefundBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_NoneIOErrorZ { private: @@ -9745,6 +11273,21 @@ public: const LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator &() const { return &self; } const LDKCResult_MaxDustHTLCExposureDecodeErrorZ* operator ->() const { return &self; } }; +class CVec_BalanceZ { +private: + LDKCVec_BalanceZ self; +public: + CVec_BalanceZ(const CVec_BalanceZ&) = delete; + CVec_BalanceZ(CVec_BalanceZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BalanceZ)); } + CVec_BalanceZ(LDKCVec_BalanceZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BalanceZ)); } + operator LDKCVec_BalanceZ() && { LDKCVec_BalanceZ res = self; memset(&self, 0, sizeof(LDKCVec_BalanceZ)); return res; } + ~CVec_BalanceZ() { CVec_BalanceZ_free(self); } + CVec_BalanceZ& operator=(CVec_BalanceZ&& o) { CVec_BalanceZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BalanceZ)); return *this; } + LDKCVec_BalanceZ* operator &() { return &self; } + LDKCVec_BalanceZ* operator ->() { return &self; } + const LDKCVec_BalanceZ* operator &() const { return &self; } + const LDKCVec_BalanceZ* operator ->() const { return &self; } +}; class CVec_CommitmentTransactionZ { private: LDKCVec_CommitmentTransactionZ self; @@ -9820,6 +11363,51 @@ public: const LDKC2Tuple_Z* operator &() const { return &self; } const LDKC2Tuple_Z* operator ->() const { return &self; } }; +class CResult_ShutdownScriptDecodeErrorZ { +private: + LDKCResult_ShutdownScriptDecodeErrorZ self; +public: + CResult_ShutdownScriptDecodeErrorZ(const CResult_ShutdownScriptDecodeErrorZ&) = delete; + CResult_ShutdownScriptDecodeErrorZ(CResult_ShutdownScriptDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); } + CResult_ShutdownScriptDecodeErrorZ(LDKCResult_ShutdownScriptDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); } + operator LDKCResult_ShutdownScriptDecodeErrorZ() && { LDKCResult_ShutdownScriptDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ShutdownScriptDecodeErrorZ)); return res; } + ~CResult_ShutdownScriptDecodeErrorZ() { CResult_ShutdownScriptDecodeErrorZ_free(self); } + CResult_ShutdownScriptDecodeErrorZ& operator=(CResult_ShutdownScriptDecodeErrorZ&& o) { CResult_ShutdownScriptDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ShutdownScriptDecodeErrorZ)); return *this; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator &() { return &self; } + LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ShutdownScriptDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_InboundHTLCDetailsDecodeErrorZ { +private: + LDKCResult_InboundHTLCDetailsDecodeErrorZ self; +public: + CResult_InboundHTLCDetailsDecodeErrorZ(const CResult_InboundHTLCDetailsDecodeErrorZ&) = delete; + CResult_InboundHTLCDetailsDecodeErrorZ(CResult_InboundHTLCDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InboundHTLCDetailsDecodeErrorZ)); } + CResult_InboundHTLCDetailsDecodeErrorZ(LDKCResult_InboundHTLCDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InboundHTLCDetailsDecodeErrorZ)); } + operator LDKCResult_InboundHTLCDetailsDecodeErrorZ() && { LDKCResult_InboundHTLCDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InboundHTLCDetailsDecodeErrorZ)); return res; } + ~CResult_InboundHTLCDetailsDecodeErrorZ() { CResult_InboundHTLCDetailsDecodeErrorZ_free(self); } + CResult_InboundHTLCDetailsDecodeErrorZ& operator=(CResult_InboundHTLCDetailsDecodeErrorZ&& o) { CResult_InboundHTLCDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InboundHTLCDetailsDecodeErrorZ)); return *this; } + LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator &() { return &self; } + LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InboundHTLCDetailsDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_SiPrefixBolt11ParseErrorZ { +private: + LDKCResult_SiPrefixBolt11ParseErrorZ self; +public: + CResult_SiPrefixBolt11ParseErrorZ(const CResult_SiPrefixBolt11ParseErrorZ&) = delete; + CResult_SiPrefixBolt11ParseErrorZ(CResult_SiPrefixBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); } + CResult_SiPrefixBolt11ParseErrorZ(LDKCResult_SiPrefixBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); } + operator LDKCResult_SiPrefixBolt11ParseErrorZ() && { LDKCResult_SiPrefixBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ)); return res; } + ~CResult_SiPrefixBolt11ParseErrorZ() { CResult_SiPrefixBolt11ParseErrorZ_free(self); } + CResult_SiPrefixBolt11ParseErrorZ& operator=(CResult_SiPrefixBolt11ParseErrorZ&& o) { CResult_SiPrefixBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SiPrefixBolt11ParseErrorZ)); return *this; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() { return &self; } + LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator &() const { return &self; } + const LDKCResult_SiPrefixBolt11ParseErrorZ* operator ->() const { return &self; } +}; class C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { private: LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ self; @@ -10015,6 +11603,21 @@ public: const LDKCVec_SocketAddressZ* operator &() const { return &self; } const LDKCVec_SocketAddressZ* operator ->() const { return &self; } }; +class CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { +private: + LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ self; +public: + CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ(const CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ&) = delete; + CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ(CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ)); } + CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ(LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ)); } + operator LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ() && { LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ res = self; memset(&self, 0, sizeof(LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ)); return res; } + ~CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ() { CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ_free(self); } + CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ& operator=(CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ&& o) { CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ)); return *this; } + LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ* operator &() { return &self; } + LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ* operator ->() { return &self; } + const LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ* operator &() const { return &self; } + const LDKCVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ* operator ->() const { return &self; } +}; class CResult_ThirtyTwoBytesPaymentSendFailureZ { private: LDKCResult_ThirtyTwoBytesPaymentSendFailureZ self; @@ -10030,21 +11633,6 @@ public: const LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* operator &() const { return &self; } const LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* operator ->() const { return &self; } }; -class CResult_HolderCommitmentTransactionDecodeErrorZ { -private: - LDKCResult_HolderCommitmentTransactionDecodeErrorZ self; -public: - CResult_HolderCommitmentTransactionDecodeErrorZ(const CResult_HolderCommitmentTransactionDecodeErrorZ&) = delete; - CResult_HolderCommitmentTransactionDecodeErrorZ(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); } - CResult_HolderCommitmentTransactionDecodeErrorZ(LDKCResult_HolderCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); } - operator LDKCResult_HolderCommitmentTransactionDecodeErrorZ() && { LDKCResult_HolderCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); return res; } - ~CResult_HolderCommitmentTransactionDecodeErrorZ() { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); } - CResult_HolderCommitmentTransactionDecodeErrorZ& operator=(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); return *this; } - LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() { return &self; } - LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_WarningMessageDecodeErrorZ { private: LDKCResult_WarningMessageDecodeErrorZ self; @@ -10075,20 +11663,20 @@ public: const LDKCResult_ChannelCounterpartyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelCounterpartyDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_ForwardNodeZ { +class CResult_HolderCommitmentTransactionDecodeErrorZ { private: - LDKCVec_ForwardNodeZ self; + LDKCResult_HolderCommitmentTransactionDecodeErrorZ self; public: - CVec_ForwardNodeZ(const CVec_ForwardNodeZ&) = delete; - CVec_ForwardNodeZ(CVec_ForwardNodeZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_ForwardNodeZ)); } - CVec_ForwardNodeZ(LDKCVec_ForwardNodeZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_ForwardNodeZ)); } - operator LDKCVec_ForwardNodeZ() && { LDKCVec_ForwardNodeZ res = self; memset(&self, 0, sizeof(LDKCVec_ForwardNodeZ)); return res; } - ~CVec_ForwardNodeZ() { CVec_ForwardNodeZ_free(self); } - CVec_ForwardNodeZ& operator=(CVec_ForwardNodeZ&& o) { CVec_ForwardNodeZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_ForwardNodeZ)); return *this; } - LDKCVec_ForwardNodeZ* operator &() { return &self; } - LDKCVec_ForwardNodeZ* operator ->() { return &self; } - const LDKCVec_ForwardNodeZ* operator &() const { return &self; } - const LDKCVec_ForwardNodeZ* operator ->() const { return &self; } + CResult_HolderCommitmentTransactionDecodeErrorZ(const CResult_HolderCommitmentTransactionDecodeErrorZ&) = delete; + CResult_HolderCommitmentTransactionDecodeErrorZ(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); } + CResult_HolderCommitmentTransactionDecodeErrorZ(LDKCResult_HolderCommitmentTransactionDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); } + operator LDKCResult_HolderCommitmentTransactionDecodeErrorZ() && { LDKCResult_HolderCommitmentTransactionDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ)); return res; } + ~CResult_HolderCommitmentTransactionDecodeErrorZ() { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); } + CResult_HolderCommitmentTransactionDecodeErrorZ& operator=(CResult_HolderCommitmentTransactionDecodeErrorZ&& o) { CResult_HolderCommitmentTransactionDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HolderCommitmentTransactionDecodeErrorZ)); return *this; } + LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() { return &self; } + LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HolderCommitmentTransactionDecodeErrorZ* operator ->() const { return &self; } }; class CResult_DelayedPaymentKeyDecodeErrorZ { private: @@ -10105,20 +11693,35 @@ public: const LDKCResult_DelayedPaymentKeyDecodeErrorZ* operator &() const { return &self; } const LDKCResult_DelayedPaymentKeyDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_InitDecodeErrorZ { +class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { private: - LDKCResult_InitDecodeErrorZ self; + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ self; public: - CResult_InitDecodeErrorZ(const CResult_InitDecodeErrorZ&) = delete; - CResult_InitDecodeErrorZ(CResult_InitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); } - CResult_InitDecodeErrorZ(LDKCResult_InitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); } - operator LDKCResult_InitDecodeErrorZ() && { LDKCResult_InitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); return res; } - ~CResult_InitDecodeErrorZ() { CResult_InitDecodeErrorZ_free(self); } - CResult_InitDecodeErrorZ& operator=(CResult_InitDecodeErrorZ&& o) { CResult_InitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); return *this; } - LDKCResult_InitDecodeErrorZ* operator &() { return &self; } - LDKCResult_InitDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_InitDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_InitDecodeErrorZ* operator ->() const { return &self; } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(const C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&) = delete; + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } + operator LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() && { LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return res; } + ~C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); } + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ& operator=(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return *this; } + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() { return &self; } + LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() { return &self; } + const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() const { return &self; } + const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() const { return &self; } +}; +class CResult_OfferBolt12SemanticErrorZ { +private: + LDKCResult_OfferBolt12SemanticErrorZ self; +public: + CResult_OfferBolt12SemanticErrorZ(const CResult_OfferBolt12SemanticErrorZ&) = delete; + CResult_OfferBolt12SemanticErrorZ(CResult_OfferBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OfferBolt12SemanticErrorZ)); } + CResult_OfferBolt12SemanticErrorZ(LDKCResult_OfferBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OfferBolt12SemanticErrorZ)); } + operator LDKCResult_OfferBolt12SemanticErrorZ() && { LDKCResult_OfferBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OfferBolt12SemanticErrorZ)); return res; } + ~CResult_OfferBolt12SemanticErrorZ() { CResult_OfferBolt12SemanticErrorZ_free(self); } + CResult_OfferBolt12SemanticErrorZ& operator=(CResult_OfferBolt12SemanticErrorZ&& o) { CResult_OfferBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OfferBolt12SemanticErrorZ)); return *this; } + LDKCResult_OfferBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_OfferBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_OfferBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_OfferBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { private: @@ -10135,20 +11738,20 @@ public: const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_SpliceDecodeErrorZ { +class CResult_InitDecodeErrorZ { private: - LDKCResult_SpliceDecodeErrorZ self; + LDKCResult_InitDecodeErrorZ self; public: - CResult_SpliceDecodeErrorZ(const CResult_SpliceDecodeErrorZ&) = delete; - CResult_SpliceDecodeErrorZ(CResult_SpliceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceDecodeErrorZ)); } - CResult_SpliceDecodeErrorZ(LDKCResult_SpliceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceDecodeErrorZ)); } - operator LDKCResult_SpliceDecodeErrorZ() && { LDKCResult_SpliceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceDecodeErrorZ)); return res; } - ~CResult_SpliceDecodeErrorZ() { CResult_SpliceDecodeErrorZ_free(self); } - CResult_SpliceDecodeErrorZ& operator=(CResult_SpliceDecodeErrorZ&& o) { CResult_SpliceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceDecodeErrorZ)); return *this; } - LDKCResult_SpliceDecodeErrorZ* operator &() { return &self; } - LDKCResult_SpliceDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_SpliceDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_SpliceDecodeErrorZ* operator ->() const { return &self; } + CResult_InitDecodeErrorZ(const CResult_InitDecodeErrorZ&) = delete; + CResult_InitDecodeErrorZ(CResult_InitDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); } + CResult_InitDecodeErrorZ(LDKCResult_InitDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); } + operator LDKCResult_InitDecodeErrorZ() && { LDKCResult_InitDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InitDecodeErrorZ)); return res; } + ~CResult_InitDecodeErrorZ() { CResult_InitDecodeErrorZ_free(self); } + CResult_InitDecodeErrorZ& operator=(CResult_InitDecodeErrorZ&& o) { CResult_InitDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InitDecodeErrorZ)); return *this; } + LDKCResult_InitDecodeErrorZ* operator &() { return &self; } + LDKCResult_InitDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InitDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InitDecodeErrorZ* operator ->() const { return &self; } }; class CResult_PaymentPurposeDecodeErrorZ { private: @@ -10180,21 +11783,6 @@ public: const LDKCResult_ClaimedHTLCDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ClaimedHTLCDecodeErrorZ* operator ->() const { return &self; } }; -class C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { -private: - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ self; -public: - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(const C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&) = delete; - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); } - operator LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() && { LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return res; } - ~C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ() { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); } - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ& operator=(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ&& o) { C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ)); return *this; } - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() { return &self; } - LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() { return &self; } - const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator &() const { return &self; } - const LDKC3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ* operator ->() const { return &self; } -}; class CResult_OutPointDecodeErrorZ { private: LDKCResult_OutPointDecodeErrorZ self; @@ -10225,21 +11813,6 @@ public: const LDKCVec_ChannelDetailsZ* operator &() const { return &self; } const LDKCVec_ChannelDetailsZ* operator ->() const { return &self; } }; -class CVec_MonitorUpdateIdZ { -private: - LDKCVec_MonitorUpdateIdZ self; -public: - CVec_MonitorUpdateIdZ(const CVec_MonitorUpdateIdZ&) = delete; - CVec_MonitorUpdateIdZ(CVec_MonitorUpdateIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_MonitorUpdateIdZ)); } - CVec_MonitorUpdateIdZ(LDKCVec_MonitorUpdateIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_MonitorUpdateIdZ)); } - operator LDKCVec_MonitorUpdateIdZ() && { LDKCVec_MonitorUpdateIdZ res = self; memset(&self, 0, sizeof(LDKCVec_MonitorUpdateIdZ)); return res; } - ~CVec_MonitorUpdateIdZ() { CVec_MonitorUpdateIdZ_free(self); } - CVec_MonitorUpdateIdZ& operator=(CVec_MonitorUpdateIdZ&& o) { CVec_MonitorUpdateIdZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_MonitorUpdateIdZ)); return *this; } - LDKCVec_MonitorUpdateIdZ* operator &() { return &self; } - LDKCVec_MonitorUpdateIdZ* operator ->() { return &self; } - const LDKCVec_MonitorUpdateIdZ* operator &() const { return &self; } - const LDKCVec_MonitorUpdateIdZ* operator ->() const { return &self; } -}; class CResult_Bolt11InvoiceFeaturesDecodeErrorZ { private: LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ self; @@ -10270,6 +11843,21 @@ public: const LDKCVec_MessageSendEventZ* operator &() const { return &self; } const LDKCVec_MessageSendEventZ* operator ->() const { return &self; } }; +class CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { +private: + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ self; +public: + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(const CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); } + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ() { CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ& operator=(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ&& o) { CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ* operator ->() const { return &self; } +}; class CResult_RouteHintHopDecodeErrorZ { private: LDKCResult_RouteHintHopDecodeErrorZ self; @@ -10360,6 +11948,36 @@ public: const LDKCOption_ChannelShutdownStateZ* operator &() const { return &self; } const LDKCOption_ChannelShutdownStateZ* operator ->() const { return &self; } }; +class CResult_Bolt12InvoiceBolt12SemanticErrorZ { +private: + LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ self; +public: + CResult_Bolt12InvoiceBolt12SemanticErrorZ(const CResult_Bolt12InvoiceBolt12SemanticErrorZ&) = delete; + CResult_Bolt12InvoiceBolt12SemanticErrorZ(CResult_Bolt12InvoiceBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12InvoiceBolt12SemanticErrorZ)); } + CResult_Bolt12InvoiceBolt12SemanticErrorZ(LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ)); } + operator LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ() && { LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ)); return res; } + ~CResult_Bolt12InvoiceBolt12SemanticErrorZ() { CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(self); } + CResult_Bolt12InvoiceBolt12SemanticErrorZ& operator=(CResult_Bolt12InvoiceBolt12SemanticErrorZ&& o) { CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12InvoiceBolt12SemanticErrorZ)); return *this; } + LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12InvoiceBolt12SemanticErrorZ* operator ->() const { return &self; } +}; +class CResult_InvoiceRequestFieldsDecodeErrorZ { +private: + LDKCResult_InvoiceRequestFieldsDecodeErrorZ self; +public: + CResult_InvoiceRequestFieldsDecodeErrorZ(const CResult_InvoiceRequestFieldsDecodeErrorZ&) = delete; + CResult_InvoiceRequestFieldsDecodeErrorZ(CResult_InvoiceRequestFieldsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceRequestFieldsDecodeErrorZ)); } + CResult_InvoiceRequestFieldsDecodeErrorZ(LDKCResult_InvoiceRequestFieldsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceRequestFieldsDecodeErrorZ)); } + operator LDKCResult_InvoiceRequestFieldsDecodeErrorZ() && { LDKCResult_InvoiceRequestFieldsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceRequestFieldsDecodeErrorZ)); return res; } + ~CResult_InvoiceRequestFieldsDecodeErrorZ() { CResult_InvoiceRequestFieldsDecodeErrorZ_free(self); } + CResult_InvoiceRequestFieldsDecodeErrorZ& operator=(CResult_InvoiceRequestFieldsDecodeErrorZ&& o) { CResult_InvoiceRequestFieldsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceRequestFieldsDecodeErrorZ)); return *this; } + LDKCResult_InvoiceRequestFieldsDecodeErrorZ* operator &() { return &self; } + LDKCResult_InvoiceRequestFieldsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceRequestFieldsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceRequestFieldsDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_AcceptChannelDecodeErrorZ { private: LDKCResult_AcceptChannelDecodeErrorZ self; @@ -10375,6 +11993,21 @@ public: const LDKCResult_AcceptChannelDecodeErrorZ* operator &() const { return &self; } const LDKCResult_AcceptChannelDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_RefundDecodeErrorZ { +private: + LDKCResult_RefundDecodeErrorZ self; +public: + CResult_RefundDecodeErrorZ(const CResult_RefundDecodeErrorZ&) = delete; + CResult_RefundDecodeErrorZ(CResult_RefundDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_RefundDecodeErrorZ)); } + CResult_RefundDecodeErrorZ(LDKCResult_RefundDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_RefundDecodeErrorZ)); } + operator LDKCResult_RefundDecodeErrorZ() && { LDKCResult_RefundDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_RefundDecodeErrorZ)); return res; } + ~CResult_RefundDecodeErrorZ() { CResult_RefundDecodeErrorZ_free(self); } + CResult_RefundDecodeErrorZ& operator=(CResult_RefundDecodeErrorZ&& o) { CResult_RefundDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_RefundDecodeErrorZ)); return *this; } + LDKCResult_RefundDecodeErrorZ* operator &() { return &self; } + LDKCResult_RefundDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_RefundDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_RefundDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_HostnameDecodeErrorZ { private: LDKCResult_HostnameDecodeErrorZ self; @@ -10450,20 +12083,50 @@ public: const LDKCResult_NoneBolt12SemanticErrorZ* operator &() const { return &self; } const LDKCResult_NoneBolt12SemanticErrorZ* operator ->() const { return &self; } }; -class COption_SecretKeyZ { -private: - LDKCOption_SecretKeyZ self; -public: - COption_SecretKeyZ(const COption_SecretKeyZ&) = delete; - COption_SecretKeyZ(COption_SecretKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_SecretKeyZ)); } - COption_SecretKeyZ(LDKCOption_SecretKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_SecretKeyZ)); } - operator LDKCOption_SecretKeyZ() && { LDKCOption_SecretKeyZ res = self; memset(&self, 0, sizeof(LDKCOption_SecretKeyZ)); return res; } - ~COption_SecretKeyZ() { COption_SecretKeyZ_free(self); } - COption_SecretKeyZ& operator=(COption_SecretKeyZ&& o) { COption_SecretKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_SecretKeyZ)); return *this; } - LDKCOption_SecretKeyZ* operator &() { return &self; } - LDKCOption_SecretKeyZ* operator ->() { return &self; } - const LDKCOption_SecretKeyZ* operator &() const { return &self; } - const LDKCOption_SecretKeyZ* operator ->() const { return &self; } +class CResult_UnknownPaymentContextDecodeErrorZ { +private: + LDKCResult_UnknownPaymentContextDecodeErrorZ self; +public: + CResult_UnknownPaymentContextDecodeErrorZ(const CResult_UnknownPaymentContextDecodeErrorZ&) = delete; + CResult_UnknownPaymentContextDecodeErrorZ(CResult_UnknownPaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); } + CResult_UnknownPaymentContextDecodeErrorZ(LDKCResult_UnknownPaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); } + operator LDKCResult_UnknownPaymentContextDecodeErrorZ() && { LDKCResult_UnknownPaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnknownPaymentContextDecodeErrorZ)); return res; } + ~CResult_UnknownPaymentContextDecodeErrorZ() { CResult_UnknownPaymentContextDecodeErrorZ_free(self); } + CResult_UnknownPaymentContextDecodeErrorZ& operator=(CResult_UnknownPaymentContextDecodeErrorZ&& o) { CResult_UnknownPaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnknownPaymentContextDecodeErrorZ)); return *this; } + LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_UnknownPaymentContextDecodeErrorZ* operator ->() const { return &self; } +}; +class COption_InboundHTLCStateDetailsZ { +private: + LDKCOption_InboundHTLCStateDetailsZ self; +public: + COption_InboundHTLCStateDetailsZ(const COption_InboundHTLCStateDetailsZ&) = delete; + COption_InboundHTLCStateDetailsZ(COption_InboundHTLCStateDetailsZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_InboundHTLCStateDetailsZ)); } + COption_InboundHTLCStateDetailsZ(LDKCOption_InboundHTLCStateDetailsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_InboundHTLCStateDetailsZ)); } + operator LDKCOption_InboundHTLCStateDetailsZ() && { LDKCOption_InboundHTLCStateDetailsZ res = self; memset(&self, 0, sizeof(LDKCOption_InboundHTLCStateDetailsZ)); return res; } + ~COption_InboundHTLCStateDetailsZ() { COption_InboundHTLCStateDetailsZ_free(self); } + COption_InboundHTLCStateDetailsZ& operator=(COption_InboundHTLCStateDetailsZ&& o) { COption_InboundHTLCStateDetailsZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_InboundHTLCStateDetailsZ)); return *this; } + LDKCOption_InboundHTLCStateDetailsZ* operator &() { return &self; } + LDKCOption_InboundHTLCStateDetailsZ* operator ->() { return &self; } + const LDKCOption_InboundHTLCStateDetailsZ* operator &() const { return &self; } + const LDKCOption_InboundHTLCStateDetailsZ* operator ->() const { return &self; } +}; +class CResult_OutputSweeperDecodeErrorZ { +private: + LDKCResult_OutputSweeperDecodeErrorZ self; +public: + CResult_OutputSweeperDecodeErrorZ(const CResult_OutputSweeperDecodeErrorZ&) = delete; + CResult_OutputSweeperDecodeErrorZ(CResult_OutputSweeperDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); } + CResult_OutputSweeperDecodeErrorZ(LDKCResult_OutputSweeperDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); } + operator LDKCResult_OutputSweeperDecodeErrorZ() && { LDKCResult_OutputSweeperDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutputSweeperDecodeErrorZ)); return res; } + ~CResult_OutputSweeperDecodeErrorZ() { CResult_OutputSweeperDecodeErrorZ_free(self); } + CResult_OutputSweeperDecodeErrorZ& operator=(CResult_OutputSweeperDecodeErrorZ&& o) { CResult_OutputSweeperDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutputSweeperDecodeErrorZ)); return *this; } + LDKCResult_OutputSweeperDecodeErrorZ* operator &() { return &self; } + LDKCResult_OutputSweeperDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OutputSweeperDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OutputSweeperDecodeErrorZ* operator ->() const { return &self; } }; class CResult_C2Tuple_CVec_u8Zu64ZNoneZ { private: @@ -10570,6 +12233,21 @@ public: const LDKCOption_PaymentFailureReasonZ* operator &() const { return &self; } const LDKCOption_PaymentFailureReasonZ* operator ->() const { return &self; } }; +class CResult_Bolt12RefundContextDecodeErrorZ { +private: + LDKCResult_Bolt12RefundContextDecodeErrorZ self; +public: + CResult_Bolt12RefundContextDecodeErrorZ(const CResult_Bolt12RefundContextDecodeErrorZ&) = delete; + CResult_Bolt12RefundContextDecodeErrorZ(CResult_Bolt12RefundContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12RefundContextDecodeErrorZ)); } + CResult_Bolt12RefundContextDecodeErrorZ(LDKCResult_Bolt12RefundContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12RefundContextDecodeErrorZ)); } + operator LDKCResult_Bolt12RefundContextDecodeErrorZ() && { LDKCResult_Bolt12RefundContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12RefundContextDecodeErrorZ)); return res; } + ~CResult_Bolt12RefundContextDecodeErrorZ() { CResult_Bolt12RefundContextDecodeErrorZ_free(self); } + CResult_Bolt12RefundContextDecodeErrorZ& operator=(CResult_Bolt12RefundContextDecodeErrorZ&& o) { CResult_Bolt12RefundContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12RefundContextDecodeErrorZ)); return *this; } + LDKCResult_Bolt12RefundContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt12RefundContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12RefundContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12RefundContextDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ECDSASignatureNoneZ { private: LDKCResult_ECDSASignatureNoneZ self; @@ -10585,20 +12263,65 @@ public: const LDKCResult_ECDSASignatureNoneZ* operator &() const { return &self; } const LDKCResult_ECDSASignatureNoneZ* operator ->() const { return &self; } }; -class CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +class C2Tuple_ChannelIdPublicKeyZ { +private: + LDKC2Tuple_ChannelIdPublicKeyZ self; +public: + C2Tuple_ChannelIdPublicKeyZ(const C2Tuple_ChannelIdPublicKeyZ&) = delete; + C2Tuple_ChannelIdPublicKeyZ(C2Tuple_ChannelIdPublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_ChannelIdPublicKeyZ)); } + C2Tuple_ChannelIdPublicKeyZ(LDKC2Tuple_ChannelIdPublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_ChannelIdPublicKeyZ)); } + operator LDKC2Tuple_ChannelIdPublicKeyZ() && { LDKC2Tuple_ChannelIdPublicKeyZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_ChannelIdPublicKeyZ)); return res; } + ~C2Tuple_ChannelIdPublicKeyZ() { C2Tuple_ChannelIdPublicKeyZ_free(self); } + C2Tuple_ChannelIdPublicKeyZ& operator=(C2Tuple_ChannelIdPublicKeyZ&& o) { C2Tuple_ChannelIdPublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_ChannelIdPublicKeyZ)); return *this; } + LDKC2Tuple_ChannelIdPublicKeyZ* operator &() { return &self; } + LDKC2Tuple_ChannelIdPublicKeyZ* operator ->() { return &self; } + const LDKC2Tuple_ChannelIdPublicKeyZ* operator &() const { return &self; } + const LDKC2Tuple_ChannelIdPublicKeyZ* operator ->() const { return &self; } +}; +class C2Tuple_OffersMessageResponseInstructionZ { +private: + LDKC2Tuple_OffersMessageResponseInstructionZ self; +public: + C2Tuple_OffersMessageResponseInstructionZ(const C2Tuple_OffersMessageResponseInstructionZ&) = delete; + C2Tuple_OffersMessageResponseInstructionZ(C2Tuple_OffersMessageResponseInstructionZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OffersMessageResponseInstructionZ)); } + C2Tuple_OffersMessageResponseInstructionZ(LDKC2Tuple_OffersMessageResponseInstructionZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OffersMessageResponseInstructionZ)); } + operator LDKC2Tuple_OffersMessageResponseInstructionZ() && { LDKC2Tuple_OffersMessageResponseInstructionZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OffersMessageResponseInstructionZ)); return res; } + ~C2Tuple_OffersMessageResponseInstructionZ() { C2Tuple_OffersMessageResponseInstructionZ_free(self); } + C2Tuple_OffersMessageResponseInstructionZ& operator=(C2Tuple_OffersMessageResponseInstructionZ&& o) { C2Tuple_OffersMessageResponseInstructionZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OffersMessageResponseInstructionZ)); return *this; } + LDKC2Tuple_OffersMessageResponseInstructionZ* operator &() { return &self; } + LDKC2Tuple_OffersMessageResponseInstructionZ* operator ->() { return &self; } + const LDKC2Tuple_OffersMessageResponseInstructionZ* operator &() const { return &self; } + const LDKC2Tuple_OffersMessageResponseInstructionZ* operator ->() const { return &self; } +}; +class CResult_EcdsaChannelSignerDecodeErrorZ { +private: + LDKCResult_EcdsaChannelSignerDecodeErrorZ self; +public: + CResult_EcdsaChannelSignerDecodeErrorZ(const CResult_EcdsaChannelSignerDecodeErrorZ&) = delete; + CResult_EcdsaChannelSignerDecodeErrorZ(CResult_EcdsaChannelSignerDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_EcdsaChannelSignerDecodeErrorZ)); } + CResult_EcdsaChannelSignerDecodeErrorZ(LDKCResult_EcdsaChannelSignerDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_EcdsaChannelSignerDecodeErrorZ)); } + operator LDKCResult_EcdsaChannelSignerDecodeErrorZ() && { LDKCResult_EcdsaChannelSignerDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_EcdsaChannelSignerDecodeErrorZ)); return res; } + ~CResult_EcdsaChannelSignerDecodeErrorZ() { CResult_EcdsaChannelSignerDecodeErrorZ_free(self); } + CResult_EcdsaChannelSignerDecodeErrorZ& operator=(CResult_EcdsaChannelSignerDecodeErrorZ&& o) { CResult_EcdsaChannelSignerDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_EcdsaChannelSignerDecodeErrorZ)); return *this; } + LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator &() { return &self; } + LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_EcdsaChannelSignerDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_BlindedTailDecodeErrorZ { private: - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ self; + LDKCResult_BlindedTailDecodeErrorZ self; public: - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(const CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&) = delete; - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); } - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); } - operator LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ() && { LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); return res; } - ~CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ() { CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(self); } - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ& operator=(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ&& o) { CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ)); return *this; } - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator &() { return &self; } - LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator ->() { return &self; } - const LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator &() const { return &self; } - const LDKCResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ* operator ->() const { return &self; } + CResult_BlindedTailDecodeErrorZ(const CResult_BlindedTailDecodeErrorZ&) = delete; + CResult_BlindedTailDecodeErrorZ(CResult_BlindedTailDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); } + CResult_BlindedTailDecodeErrorZ(LDKCResult_BlindedTailDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); } + operator LDKCResult_BlindedTailDecodeErrorZ() && { LDKCResult_BlindedTailDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); return res; } + ~CResult_BlindedTailDecodeErrorZ() { CResult_BlindedTailDecodeErrorZ_free(self); } + CResult_BlindedTailDecodeErrorZ& operator=(CResult_BlindedTailDecodeErrorZ&& o) { CResult_BlindedTailDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); return *this; } + LDKCResult_BlindedTailDecodeErrorZ* operator &() { return &self; } + LDKCResult_BlindedTailDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BlindedTailDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BlindedTailDecodeErrorZ* operator ->() const { return &self; } }; class CVec_WitnessZ { private: @@ -10615,20 +12338,20 @@ public: const LDKCVec_WitnessZ* operator &() const { return &self; } const LDKCVec_WitnessZ* operator ->() const { return &self; } }; -class CResult_BlindedTailDecodeErrorZ { +class COption_C2Tuple_u64u16ZZ { private: - LDKCResult_BlindedTailDecodeErrorZ self; + LDKCOption_C2Tuple_u64u16ZZ self; public: - CResult_BlindedTailDecodeErrorZ(const CResult_BlindedTailDecodeErrorZ&) = delete; - CResult_BlindedTailDecodeErrorZ(CResult_BlindedTailDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); } - CResult_BlindedTailDecodeErrorZ(LDKCResult_BlindedTailDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); } - operator LDKCResult_BlindedTailDecodeErrorZ() && { LDKCResult_BlindedTailDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedTailDecodeErrorZ)); return res; } - ~CResult_BlindedTailDecodeErrorZ() { CResult_BlindedTailDecodeErrorZ_free(self); } - CResult_BlindedTailDecodeErrorZ& operator=(CResult_BlindedTailDecodeErrorZ&& o) { CResult_BlindedTailDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedTailDecodeErrorZ)); return *this; } - LDKCResult_BlindedTailDecodeErrorZ* operator &() { return &self; } - LDKCResult_BlindedTailDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_BlindedTailDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_BlindedTailDecodeErrorZ* operator ->() const { return &self; } + COption_C2Tuple_u64u16ZZ(const COption_C2Tuple_u64u16ZZ&) = delete; + COption_C2Tuple_u64u16ZZ(COption_C2Tuple_u64u16ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_u64u16ZZ)); } + COption_C2Tuple_u64u16ZZ(LDKCOption_C2Tuple_u64u16ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_u64u16ZZ)); } + operator LDKCOption_C2Tuple_u64u16ZZ() && { LDKCOption_C2Tuple_u64u16ZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_u64u16ZZ)); return res; } + ~COption_C2Tuple_u64u16ZZ() { COption_C2Tuple_u64u16ZZ_free(self); } + COption_C2Tuple_u64u16ZZ& operator=(COption_C2Tuple_u64u16ZZ&& o) { COption_C2Tuple_u64u16ZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_u64u16ZZ)); return *this; } + LDKCOption_C2Tuple_u64u16ZZ* operator &() { return &self; } + LDKCOption_C2Tuple_u64u16ZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_u64u16ZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_u64u16ZZ* operator ->() const { return &self; } }; class CResult_SocketAddressSocketAddressParseErrorZ { private: @@ -10645,35 +12368,20 @@ public: const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator &() const { return &self; } const LDKCResult_SocketAddressSocketAddressParseErrorZ* operator ->() const { return &self; } }; -class COption_C2Tuple_u64u16ZZ { +class CResult_COption_PaymentFailureReasonZDecodeErrorZ { private: - LDKCOption_C2Tuple_u64u16ZZ self; + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ self; public: - COption_C2Tuple_u64u16ZZ(const COption_C2Tuple_u64u16ZZ&) = delete; - COption_C2Tuple_u64u16ZZ(COption_C2Tuple_u64u16ZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_u64u16ZZ)); } - COption_C2Tuple_u64u16ZZ(LDKCOption_C2Tuple_u64u16ZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_u64u16ZZ)); } - operator LDKCOption_C2Tuple_u64u16ZZ() && { LDKCOption_C2Tuple_u64u16ZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_u64u16ZZ)); return res; } - ~COption_C2Tuple_u64u16ZZ() { COption_C2Tuple_u64u16ZZ_free(self); } - COption_C2Tuple_u64u16ZZ& operator=(COption_C2Tuple_u64u16ZZ&& o) { COption_C2Tuple_u64u16ZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_u64u16ZZ)); return *this; } - LDKCOption_C2Tuple_u64u16ZZ* operator &() { return &self; } - LDKCOption_C2Tuple_u64u16ZZ* operator ->() { return &self; } - const LDKCOption_C2Tuple_u64u16ZZ* operator &() const { return &self; } - const LDKCOption_C2Tuple_u64u16ZZ* operator ->() const { return &self; } -}; -class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { -private: - LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ self; -public: - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(const CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&) = delete; - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } - operator LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() && { LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return res; } - ~CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); } - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ& operator=(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return *this; } - LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() { return &self; } - LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() { return &self; } - const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() const { return &self; } - const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() const { return &self; } + CResult_COption_PaymentFailureReasonZDecodeErrorZ(const CResult_COption_PaymentFailureReasonZDecodeErrorZ&) = delete; + CResult_COption_PaymentFailureReasonZDecodeErrorZ(CResult_COption_PaymentFailureReasonZDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_COption_PaymentFailureReasonZDecodeErrorZ)); } + CResult_COption_PaymentFailureReasonZDecodeErrorZ(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ)); } + operator LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ() && { LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ)); return res; } + ~CResult_COption_PaymentFailureReasonZDecodeErrorZ() { CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(self); } + CResult_COption_PaymentFailureReasonZDecodeErrorZ& operator=(CResult_COption_PaymentFailureReasonZDecodeErrorZ&& o) { CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_COption_PaymentFailureReasonZDecodeErrorZ)); return *this; } + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator &() { return &self; } + LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_COption_PaymentFailureReasonZDecodeErrorZ* operator ->() const { return &self; } }; class CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { private: @@ -10705,20 +12413,35 @@ public: const LDKCResult_ChannelDerivationParametersDecodeErrorZ* operator &() const { return &self; } const LDKCResult_ChannelDerivationParametersDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_PaymentConstraintsDecodeErrorZ { +class CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { private: - LDKCResult_PaymentConstraintsDecodeErrorZ self; + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ self; public: - CResult_PaymentConstraintsDecodeErrorZ(const CResult_PaymentConstraintsDecodeErrorZ&) = delete; - CResult_PaymentConstraintsDecodeErrorZ(CResult_PaymentConstraintsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); } - CResult_PaymentConstraintsDecodeErrorZ(LDKCResult_PaymentConstraintsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); } - operator LDKCResult_PaymentConstraintsDecodeErrorZ() && { LDKCResult_PaymentConstraintsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); return res; } - ~CResult_PaymentConstraintsDecodeErrorZ() { CResult_PaymentConstraintsDecodeErrorZ_free(self); } - CResult_PaymentConstraintsDecodeErrorZ& operator=(CResult_PaymentConstraintsDecodeErrorZ&& o) { CResult_PaymentConstraintsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); return *this; } - LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() { return &self; } - LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() const { return &self; } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(const CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&) = delete; + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); } + operator LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() && { LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return res; } + ~CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ() { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ& operator=(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ&& o) { CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ)); return *this; } + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() { return &self; } + LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() { return &self; } + const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator &() const { return &self; } + const LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* operator ->() const { return &self; } +}; +class CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { +private: + LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ self; +public: + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ(const CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ&) = delete; + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ(CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ)); } + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ(LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ)); } + operator LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ() && { LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ)); return res; } + ~CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ() { CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_free(self); } + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ& operator=(CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ&& o) { CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ)); return *this; } + LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_UnsignedInvoiceRequestBolt12SemanticErrorZ* operator ->() const { return &self; } }; class CResult_OnionMessagePathNoneZ { private: @@ -10765,6 +12488,21 @@ public: const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_PublicKeyTypeZZ* operator ->() const { return &self; } }; +class CResult_OutboundHTLCDetailsDecodeErrorZ { +private: + LDKCResult_OutboundHTLCDetailsDecodeErrorZ self; +public: + CResult_OutboundHTLCDetailsDecodeErrorZ(const CResult_OutboundHTLCDetailsDecodeErrorZ&) = delete; + CResult_OutboundHTLCDetailsDecodeErrorZ(CResult_OutboundHTLCDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutboundHTLCDetailsDecodeErrorZ)); } + CResult_OutboundHTLCDetailsDecodeErrorZ(LDKCResult_OutboundHTLCDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutboundHTLCDetailsDecodeErrorZ)); } + operator LDKCResult_OutboundHTLCDetailsDecodeErrorZ() && { LDKCResult_OutboundHTLCDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutboundHTLCDetailsDecodeErrorZ)); return res; } + ~CResult_OutboundHTLCDetailsDecodeErrorZ() { CResult_OutboundHTLCDetailsDecodeErrorZ_free(self); } + CResult_OutboundHTLCDetailsDecodeErrorZ& operator=(CResult_OutboundHTLCDetailsDecodeErrorZ&& o) { CResult_OutboundHTLCDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutboundHTLCDetailsDecodeErrorZ)); return *this; } + LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator &() { return &self; } + LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OutboundHTLCDetailsDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_RefundBolt12ParseErrorZ { private: LDKCResult_RefundBolt12ParseErrorZ self; @@ -10780,20 +12518,20 @@ public: const LDKCResult_RefundBolt12ParseErrorZ* operator &() const { return &self; } const LDKCResult_RefundBolt12ParseErrorZ* operator ->() const { return &self; } }; -class C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { +class CResult_u32GraphSyncErrorZ { private: - LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ self; + LDKCResult_u32GraphSyncErrorZ self; public: - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ(const C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ&) = delete; - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ(C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)); } - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)); } - operator LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ() && { LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ res = self; memset(&self, 0, sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)); return res; } - ~C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ() { C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(self); } - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ& operator=(C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ&& o) { C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ)); return *this; } - LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* operator &() { return &self; } - LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* operator ->() { return &self; } - const LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* operator &() const { return &self; } - const LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* operator ->() const { return &self; } + CResult_u32GraphSyncErrorZ(const CResult_u32GraphSyncErrorZ&) = delete; + CResult_u32GraphSyncErrorZ(CResult_u32GraphSyncErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_u32GraphSyncErrorZ)); } + CResult_u32GraphSyncErrorZ(LDKCResult_u32GraphSyncErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_u32GraphSyncErrorZ)); } + operator LDKCResult_u32GraphSyncErrorZ() && { LDKCResult_u32GraphSyncErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_u32GraphSyncErrorZ)); return res; } + ~CResult_u32GraphSyncErrorZ() { CResult_u32GraphSyncErrorZ_free(self); } + CResult_u32GraphSyncErrorZ& operator=(CResult_u32GraphSyncErrorZ&& o) { CResult_u32GraphSyncErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_u32GraphSyncErrorZ)); return *this; } + LDKCResult_u32GraphSyncErrorZ* operator &() { return &self; } + LDKCResult_u32GraphSyncErrorZ* operator ->() { return &self; } + const LDKCResult_u32GraphSyncErrorZ* operator &() const { return &self; } + const LDKCResult_u32GraphSyncErrorZ* operator ->() const { return &self; } }; class CVec_C2Tuple_u64CVec_u8ZZZ { private: @@ -10810,35 +12548,35 @@ public: const LDKCVec_C2Tuple_u64CVec_u8ZZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_u64CVec_u8ZZZ* operator ->() const { return &self; } }; -class CResult_u32GraphSyncErrorZ { +class CResult_OffersMessageDecodeErrorZ { private: - LDKCResult_u32GraphSyncErrorZ self; + LDKCResult_OffersMessageDecodeErrorZ self; public: - CResult_u32GraphSyncErrorZ(const CResult_u32GraphSyncErrorZ&) = delete; - CResult_u32GraphSyncErrorZ(CResult_u32GraphSyncErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_u32GraphSyncErrorZ)); } - CResult_u32GraphSyncErrorZ(LDKCResult_u32GraphSyncErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_u32GraphSyncErrorZ)); } - operator LDKCResult_u32GraphSyncErrorZ() && { LDKCResult_u32GraphSyncErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_u32GraphSyncErrorZ)); return res; } - ~CResult_u32GraphSyncErrorZ() { CResult_u32GraphSyncErrorZ_free(self); } - CResult_u32GraphSyncErrorZ& operator=(CResult_u32GraphSyncErrorZ&& o) { CResult_u32GraphSyncErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_u32GraphSyncErrorZ)); return *this; } - LDKCResult_u32GraphSyncErrorZ* operator &() { return &self; } - LDKCResult_u32GraphSyncErrorZ* operator ->() { return &self; } - const LDKCResult_u32GraphSyncErrorZ* operator &() const { return &self; } - const LDKCResult_u32GraphSyncErrorZ* operator ->() const { return &self; } + CResult_OffersMessageDecodeErrorZ(const CResult_OffersMessageDecodeErrorZ&) = delete; + CResult_OffersMessageDecodeErrorZ(CResult_OffersMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); } + CResult_OffersMessageDecodeErrorZ(LDKCResult_OffersMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); } + operator LDKCResult_OffersMessageDecodeErrorZ() && { LDKCResult_OffersMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); return res; } + ~CResult_OffersMessageDecodeErrorZ() { CResult_OffersMessageDecodeErrorZ_free(self); } + CResult_OffersMessageDecodeErrorZ& operator=(CResult_OffersMessageDecodeErrorZ&& o) { CResult_OffersMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); return *this; } + LDKCResult_OffersMessageDecodeErrorZ* operator &() { return &self; } + LDKCResult_OffersMessageDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OffersMessageDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OffersMessageDecodeErrorZ* operator ->() const { return &self; } }; -class CVec_PhantomRouteHintsZ { +class CResult_PaymentConstraintsDecodeErrorZ { private: - LDKCVec_PhantomRouteHintsZ self; + LDKCResult_PaymentConstraintsDecodeErrorZ self; public: - CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; - CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } - CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } - operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } - ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } - CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } - LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } - LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } - const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } + CResult_PaymentConstraintsDecodeErrorZ(const CResult_PaymentConstraintsDecodeErrorZ&) = delete; + CResult_PaymentConstraintsDecodeErrorZ(CResult_PaymentConstraintsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); } + CResult_PaymentConstraintsDecodeErrorZ(LDKCResult_PaymentConstraintsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); } + operator LDKCResult_PaymentConstraintsDecodeErrorZ() && { LDKCResult_PaymentConstraintsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ)); return res; } + ~CResult_PaymentConstraintsDecodeErrorZ() { CResult_PaymentConstraintsDecodeErrorZ_free(self); } + CResult_PaymentConstraintsDecodeErrorZ& operator=(CResult_PaymentConstraintsDecodeErrorZ&& o) { CResult_PaymentConstraintsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentConstraintsDecodeErrorZ)); return *this; } + LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() { return &self; } + LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentConstraintsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentConstraintsDecodeErrorZ* operator ->() const { return &self; } }; class CResult_NoneAPIErrorZ { private: @@ -10885,20 +12623,20 @@ public: const LDKCOption_f64Z* operator &() const { return &self; } const LDKCOption_f64Z* operator ->() const { return &self; } }; -class CResult_ChannelDetailsDecodeErrorZ { +class CResult_TxRemoveInputDecodeErrorZ { private: - LDKCResult_ChannelDetailsDecodeErrorZ self; + LDKCResult_TxRemoveInputDecodeErrorZ self; public: - CResult_ChannelDetailsDecodeErrorZ(const CResult_ChannelDetailsDecodeErrorZ&) = delete; - CResult_ChannelDetailsDecodeErrorZ(CResult_ChannelDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); } - CResult_ChannelDetailsDecodeErrorZ(LDKCResult_ChannelDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); } - operator LDKCResult_ChannelDetailsDecodeErrorZ() && { LDKCResult_ChannelDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); return res; } - ~CResult_ChannelDetailsDecodeErrorZ() { CResult_ChannelDetailsDecodeErrorZ_free(self); } - CResult_ChannelDetailsDecodeErrorZ& operator=(CResult_ChannelDetailsDecodeErrorZ&& o) { CResult_ChannelDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); return *this; } - LDKCResult_ChannelDetailsDecodeErrorZ* operator &() { return &self; } - LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } + CResult_TxRemoveInputDecodeErrorZ(const CResult_TxRemoveInputDecodeErrorZ&) = delete; + CResult_TxRemoveInputDecodeErrorZ(CResult_TxRemoveInputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); } + CResult_TxRemoveInputDecodeErrorZ(LDKCResult_TxRemoveInputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); } + operator LDKCResult_TxRemoveInputDecodeErrorZ() && { LDKCResult_TxRemoveInputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); return res; } + ~CResult_TxRemoveInputDecodeErrorZ() { CResult_TxRemoveInputDecodeErrorZ_free(self); } + CResult_TxRemoveInputDecodeErrorZ& operator=(CResult_TxRemoveInputDecodeErrorZ&& o) { CResult_TxRemoveInputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); return *this; } + LDKCResult_TxRemoveInputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxRemoveInputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() const { return &self; } }; class CVec_PublicKeyZ { private: @@ -10960,20 +12698,20 @@ public: const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ* operator &() const { return &self; } const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ* operator ->() const { return &self; } }; -class CResult_PendingHTLCRoutingDecodeErrorZ { +class CResult_Bolt12InvoiceDecodeErrorZ { private: - LDKCResult_PendingHTLCRoutingDecodeErrorZ self; + LDKCResult_Bolt12InvoiceDecodeErrorZ self; public: - CResult_PendingHTLCRoutingDecodeErrorZ(const CResult_PendingHTLCRoutingDecodeErrorZ&) = delete; - CResult_PendingHTLCRoutingDecodeErrorZ(CResult_PendingHTLCRoutingDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); } - CResult_PendingHTLCRoutingDecodeErrorZ(LDKCResult_PendingHTLCRoutingDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); } - operator LDKCResult_PendingHTLCRoutingDecodeErrorZ() && { LDKCResult_PendingHTLCRoutingDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); return res; } - ~CResult_PendingHTLCRoutingDecodeErrorZ() { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); } - CResult_PendingHTLCRoutingDecodeErrorZ& operator=(CResult_PendingHTLCRoutingDecodeErrorZ&& o) { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); return *this; } - LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() { return &self; } - LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() const { return &self; } + CResult_Bolt12InvoiceDecodeErrorZ(const CResult_Bolt12InvoiceDecodeErrorZ&) = delete; + CResult_Bolt12InvoiceDecodeErrorZ(CResult_Bolt12InvoiceDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_Bolt12InvoiceDecodeErrorZ)); } + CResult_Bolt12InvoiceDecodeErrorZ(LDKCResult_Bolt12InvoiceDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_Bolt12InvoiceDecodeErrorZ)); } + operator LDKCResult_Bolt12InvoiceDecodeErrorZ() && { LDKCResult_Bolt12InvoiceDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_Bolt12InvoiceDecodeErrorZ)); return res; } + ~CResult_Bolt12InvoiceDecodeErrorZ() { CResult_Bolt12InvoiceDecodeErrorZ_free(self); } + CResult_Bolt12InvoiceDecodeErrorZ& operator=(CResult_Bolt12InvoiceDecodeErrorZ&& o) { CResult_Bolt12InvoiceDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_Bolt12InvoiceDecodeErrorZ)); return *this; } + LDKCResult_Bolt12InvoiceDecodeErrorZ* operator &() { return &self; } + LDKCResult_Bolt12InvoiceDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_Bolt12InvoiceDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_Bolt12InvoiceDecodeErrorZ* operator ->() const { return &self; } }; class C2Tuple_u64u64Z { private: @@ -10987,53 +12725,53 @@ public: C2Tuple_u64u64Z& operator=(C2Tuple_u64u64Z&& o) { C2Tuple_u64u64Z_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_u64u64Z)); return *this; } LDKC2Tuple_u64u64Z* operator &() { return &self; } LDKC2Tuple_u64u64Z* operator ->() { return &self; } - const LDKC2Tuple_u64u64Z* operator &() const { return &self; } - const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } -}; -class CResult_TxRemoveInputDecodeErrorZ { -private: - LDKCResult_TxRemoveInputDecodeErrorZ self; -public: - CResult_TxRemoveInputDecodeErrorZ(const CResult_TxRemoveInputDecodeErrorZ&) = delete; - CResult_TxRemoveInputDecodeErrorZ(CResult_TxRemoveInputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); } - CResult_TxRemoveInputDecodeErrorZ(LDKCResult_TxRemoveInputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); } - operator LDKCResult_TxRemoveInputDecodeErrorZ() && { LDKCResult_TxRemoveInputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxRemoveInputDecodeErrorZ)); return res; } - ~CResult_TxRemoveInputDecodeErrorZ() { CResult_TxRemoveInputDecodeErrorZ_free(self); } - CResult_TxRemoveInputDecodeErrorZ& operator=(CResult_TxRemoveInputDecodeErrorZ&& o) { CResult_TxRemoveInputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxRemoveInputDecodeErrorZ)); return *this; } - LDKCResult_TxRemoveInputDecodeErrorZ* operator &() { return &self; } - LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TxRemoveInputDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TxRemoveInputDecodeErrorZ* operator ->() const { return &self; } + const LDKC2Tuple_u64u64Z* operator &() const { return &self; } + const LDKC2Tuple_u64u64Z* operator ->() const { return &self; } }; -class CResult_OffersMessageDecodeErrorZ { +class COption_NodeAnnouncementInfoZ { private: - LDKCResult_OffersMessageDecodeErrorZ self; + LDKCOption_NodeAnnouncementInfoZ self; public: - CResult_OffersMessageDecodeErrorZ(const CResult_OffersMessageDecodeErrorZ&) = delete; - CResult_OffersMessageDecodeErrorZ(CResult_OffersMessageDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); } - CResult_OffersMessageDecodeErrorZ(LDKCResult_OffersMessageDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); } - operator LDKCResult_OffersMessageDecodeErrorZ() && { LDKCResult_OffersMessageDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OffersMessageDecodeErrorZ)); return res; } - ~CResult_OffersMessageDecodeErrorZ() { CResult_OffersMessageDecodeErrorZ_free(self); } - CResult_OffersMessageDecodeErrorZ& operator=(CResult_OffersMessageDecodeErrorZ&& o) { CResult_OffersMessageDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OffersMessageDecodeErrorZ)); return *this; } - LDKCResult_OffersMessageDecodeErrorZ* operator &() { return &self; } - LDKCResult_OffersMessageDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_OffersMessageDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_OffersMessageDecodeErrorZ* operator ->() const { return &self; } + COption_NodeAnnouncementInfoZ(const COption_NodeAnnouncementInfoZ&) = delete; + COption_NodeAnnouncementInfoZ(COption_NodeAnnouncementInfoZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_NodeAnnouncementInfoZ)); } + COption_NodeAnnouncementInfoZ(LDKCOption_NodeAnnouncementInfoZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_NodeAnnouncementInfoZ)); } + operator LDKCOption_NodeAnnouncementInfoZ() && { LDKCOption_NodeAnnouncementInfoZ res = self; memset(&self, 0, sizeof(LDKCOption_NodeAnnouncementInfoZ)); return res; } + ~COption_NodeAnnouncementInfoZ() { COption_NodeAnnouncementInfoZ_free(self); } + COption_NodeAnnouncementInfoZ& operator=(COption_NodeAnnouncementInfoZ&& o) { COption_NodeAnnouncementInfoZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_NodeAnnouncementInfoZ)); return *this; } + LDKCOption_NodeAnnouncementInfoZ* operator &() { return &self; } + LDKCOption_NodeAnnouncementInfoZ* operator ->() { return &self; } + const LDKCOption_NodeAnnouncementInfoZ* operator &() const { return &self; } + const LDKCOption_NodeAnnouncementInfoZ* operator ->() const { return &self; } }; -class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +class CResult_PendingHTLCRoutingDecodeErrorZ { private: - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; + LDKCResult_PendingHTLCRoutingDecodeErrorZ self; public: - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(const CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&) = delete; - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } - operator LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ() && { LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return res; } - ~CResult_CounterpartyChannelTransactionParametersDecodeErrorZ() { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ& operator=(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return *this; } - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() { return &self; } - LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } + CResult_PendingHTLCRoutingDecodeErrorZ(const CResult_PendingHTLCRoutingDecodeErrorZ&) = delete; + CResult_PendingHTLCRoutingDecodeErrorZ(CResult_PendingHTLCRoutingDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); } + CResult_PendingHTLCRoutingDecodeErrorZ(LDKCResult_PendingHTLCRoutingDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); } + operator LDKCResult_PendingHTLCRoutingDecodeErrorZ() && { LDKCResult_PendingHTLCRoutingDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PendingHTLCRoutingDecodeErrorZ)); return res; } + ~CResult_PendingHTLCRoutingDecodeErrorZ() { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); } + CResult_PendingHTLCRoutingDecodeErrorZ& operator=(CResult_PendingHTLCRoutingDecodeErrorZ&& o) { CResult_PendingHTLCRoutingDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PendingHTLCRoutingDecodeErrorZ)); return *this; } + LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() { return &self; } + LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PendingHTLCRoutingDecodeErrorZ* operator ->() const { return &self; } +}; +class COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { +private: + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ self; +public: + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(const COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&) = delete; + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); } + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ() && { LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); return res; } + ~COption_C2Tuple_OnionMessageContentsResponseInstructionZZ() { COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(self); } + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ& operator=(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ&& o) { COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_OnionMessageContentsResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_OnionMessageContentsResponseInstructionZZ* operator ->() const { return &self; } }; class CResult_RecipientOnionFieldsDecodeErrorZ { private: @@ -11065,6 +12803,51 @@ public: const LDKC2Tuple_u32TxOutZ* operator &() const { return &self; } const LDKC2Tuple_u32TxOutZ* operator ->() const { return &self; } }; +class CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { +private: + LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ self; +public: + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ(const CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ&) = delete; + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ(CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ)); } + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ() { CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_free(self); } + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } +}; +class CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { +private: + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ self; +public: + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(const CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&) = delete; + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); } + operator LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() && { LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return res; } + ~CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ() { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ& operator=(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ&& o) { CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ)); return *this; } + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() { return &self; } + LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() { return &self; } + const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator &() const { return &self; } + const LDKCResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ* operator ->() const { return &self; } +}; +class CResult_ChannelDetailsDecodeErrorZ { +private: + LDKCResult_ChannelDetailsDecodeErrorZ self; +public: + CResult_ChannelDetailsDecodeErrorZ(const CResult_ChannelDetailsDecodeErrorZ&) = delete; + CResult_ChannelDetailsDecodeErrorZ(CResult_ChannelDetailsDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); } + CResult_ChannelDetailsDecodeErrorZ(LDKCResult_ChannelDetailsDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); } + operator LDKCResult_ChannelDetailsDecodeErrorZ() && { LDKCResult_ChannelDetailsDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_ChannelDetailsDecodeErrorZ)); return res; } + ~CResult_ChannelDetailsDecodeErrorZ() { CResult_ChannelDetailsDecodeErrorZ_free(self); } + CResult_ChannelDetailsDecodeErrorZ& operator=(CResult_ChannelDetailsDecodeErrorZ&& o) { CResult_ChannelDetailsDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_ChannelDetailsDecodeErrorZ)); return *this; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator &() { return &self; } + LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_ChannelDetailsDecodeErrorZ* operator ->() const { return &self; } +}; class CVec_UtxoZ { private: LDKCVec_UtxoZ self; @@ -11080,6 +12863,21 @@ public: const LDKCVec_UtxoZ* operator &() const { return &self; } const LDKCVec_UtxoZ* operator ->() const { return &self; } }; +class CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +private: + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ self; +public: + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(const CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&) = delete; + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); } + operator LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ() && { LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return res; } + ~CResult_CounterpartyChannelTransactionParametersDecodeErrorZ() { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ& operator=(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ&& o) { CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyChannelTransactionParametersDecodeErrorZ)); return *this; } + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() { return &self; } + LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_ChannelConfigDecodeErrorZ { private: LDKCResult_ChannelConfigDecodeErrorZ self; @@ -11125,6 +12923,51 @@ public: const LDKCOption_i64Z* operator &() const { return &self; } const LDKCOption_i64Z* operator ->() const { return &self; } }; +class CResult_PaymentContextDecodeErrorZ { +private: + LDKCResult_PaymentContextDecodeErrorZ self; +public: + CResult_PaymentContextDecodeErrorZ(const CResult_PaymentContextDecodeErrorZ&) = delete; + CResult_PaymentContextDecodeErrorZ(CResult_PaymentContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); } + CResult_PaymentContextDecodeErrorZ(LDKCResult_PaymentContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); } + operator LDKCResult_PaymentContextDecodeErrorZ() && { LDKCResult_PaymentContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_PaymentContextDecodeErrorZ)); return res; } + ~CResult_PaymentContextDecodeErrorZ() { CResult_PaymentContextDecodeErrorZ_free(self); } + CResult_PaymentContextDecodeErrorZ& operator=(CResult_PaymentContextDecodeErrorZ&& o) { CResult_PaymentContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_PaymentContextDecodeErrorZ)); return *this; } + LDKCResult_PaymentContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_PaymentContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_PaymentContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_PaymentContextDecodeErrorZ* operator ->() const { return &self; } +}; +class CVec_PhantomRouteHintsZ { +private: + LDKCVec_PhantomRouteHintsZ self; +public: + CVec_PhantomRouteHintsZ(const CVec_PhantomRouteHintsZ&) = delete; + CVec_PhantomRouteHintsZ(CVec_PhantomRouteHintsZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); } + CVec_PhantomRouteHintsZ(LDKCVec_PhantomRouteHintsZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); } + operator LDKCVec_PhantomRouteHintsZ() && { LDKCVec_PhantomRouteHintsZ res = self; memset(&self, 0, sizeof(LDKCVec_PhantomRouteHintsZ)); return res; } + ~CVec_PhantomRouteHintsZ() { CVec_PhantomRouteHintsZ_free(self); } + CVec_PhantomRouteHintsZ& operator=(CVec_PhantomRouteHintsZ&& o) { CVec_PhantomRouteHintsZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_PhantomRouteHintsZ)); return *this; } + LDKCVec_PhantomRouteHintsZ* operator &() { return &self; } + LDKCVec_PhantomRouteHintsZ* operator ->() { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator &() const { return &self; } + const LDKCVec_PhantomRouteHintsZ* operator ->() const { return &self; } +}; +class CVec_C2Tuple_OutPointCVec_u64ZZZ { +private: + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ self; +public: + CVec_C2Tuple_OutPointCVec_u64ZZZ(const CVec_C2Tuple_OutPointCVec_u64ZZZ&) = delete; + CVec_C2Tuple_OutPointCVec_u64ZZZ(CVec_C2Tuple_OutPointCVec_u64ZZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_u64ZZZ)); } + CVec_C2Tuple_OutPointCVec_u64ZZZ(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ)); } + operator LDKCVec_C2Tuple_OutPointCVec_u64ZZZ() && { LDKCVec_C2Tuple_OutPointCVec_u64ZZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_OutPointCVec_u64ZZZ)); return res; } + ~CVec_C2Tuple_OutPointCVec_u64ZZZ() { CVec_C2Tuple_OutPointCVec_u64ZZZ_free(self); } + CVec_C2Tuple_OutPointCVec_u64ZZZ& operator=(CVec_C2Tuple_OutPointCVec_u64ZZZ&& o) { CVec_C2Tuple_OutPointCVec_u64ZZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_OutPointCVec_u64ZZZ)); return *this; } + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator &() { return &self; } + LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_OutPointCVec_u64ZZZ* operator ->() const { return &self; } +}; class C2Tuple_ThirtyTwoBytesChannelManagerZ { private: LDKC2Tuple_ThirtyTwoBytesChannelManagerZ self; @@ -11260,21 +13103,6 @@ public: const LDKCResult_TxOutUtxoLookupErrorZ* operator &() const { return &self; } const LDKCResult_TxOutUtxoLookupErrorZ* operator ->() const { return &self; } }; -class CResult_BlindedPathNoneZ { -private: - LDKCResult_BlindedPathNoneZ self; -public: - CResult_BlindedPathNoneZ(const CResult_BlindedPathNoneZ&) = delete; - CResult_BlindedPathNoneZ(CResult_BlindedPathNoneZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BlindedPathNoneZ)); } - CResult_BlindedPathNoneZ(LDKCResult_BlindedPathNoneZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BlindedPathNoneZ)); } - operator LDKCResult_BlindedPathNoneZ() && { LDKCResult_BlindedPathNoneZ res = self; memset(&self, 0, sizeof(LDKCResult_BlindedPathNoneZ)); return res; } - ~CResult_BlindedPathNoneZ() { CResult_BlindedPathNoneZ_free(self); } - CResult_BlindedPathNoneZ& operator=(CResult_BlindedPathNoneZ&& o) { CResult_BlindedPathNoneZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BlindedPathNoneZ)); return *this; } - LDKCResult_BlindedPathNoneZ* operator &() { return &self; } - LDKCResult_BlindedPathNoneZ* operator ->() { return &self; } - const LDKCResult_BlindedPathNoneZ* operator &() const { return &self; } - const LDKCResult_BlindedPathNoneZ* operator ->() const { return &self; } -}; class COption_usizeZ { private: LDKCOption_usizeZ self; @@ -11290,20 +13118,35 @@ public: const LDKCOption_usizeZ* operator &() const { return &self; } const LDKCOption_usizeZ* operator ->() const { return &self; } }; -class CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +class CVec_BlindedMessagePathZ { +private: + LDKCVec_BlindedMessagePathZ self; +public: + CVec_BlindedMessagePathZ(const CVec_BlindedMessagePathZ&) = delete; + CVec_BlindedMessagePathZ(CVec_BlindedMessagePathZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_BlindedMessagePathZ)); } + CVec_BlindedMessagePathZ(LDKCVec_BlindedMessagePathZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_BlindedMessagePathZ)); } + operator LDKCVec_BlindedMessagePathZ() && { LDKCVec_BlindedMessagePathZ res = self; memset(&self, 0, sizeof(LDKCVec_BlindedMessagePathZ)); return res; } + ~CVec_BlindedMessagePathZ() { CVec_BlindedMessagePathZ_free(self); } + CVec_BlindedMessagePathZ& operator=(CVec_BlindedMessagePathZ&& o) { CVec_BlindedMessagePathZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_BlindedMessagePathZ)); return *this; } + LDKCVec_BlindedMessagePathZ* operator &() { return &self; } + LDKCVec_BlindedMessagePathZ* operator ->() { return &self; } + const LDKCVec_BlindedMessagePathZ* operator &() const { return &self; } + const LDKCVec_BlindedMessagePathZ* operator ->() const { return &self; } +}; +class CResult_OffersContextDecodeErrorZ { private: - LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ self; + LDKCResult_OffersContextDecodeErrorZ self; public: - CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ(const CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ&) = delete; - CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ(CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ)); } - CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ(LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ)); } - operator LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ() && { LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ res = self; memset(&self, 0, sizeof(LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ)); return res; } - ~CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ() { CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(self); } - CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ& operator=(CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ&& o) { CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ)); return *this; } - LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ* operator &() { return &self; } - LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ* operator ->() { return &self; } - const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ* operator &() const { return &self; } - const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ* operator ->() const { return &self; } + CResult_OffersContextDecodeErrorZ(const CResult_OffersContextDecodeErrorZ&) = delete; + CResult_OffersContextDecodeErrorZ(CResult_OffersContextDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OffersContextDecodeErrorZ)); } + CResult_OffersContextDecodeErrorZ(LDKCResult_OffersContextDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OffersContextDecodeErrorZ)); } + operator LDKCResult_OffersContextDecodeErrorZ() && { LDKCResult_OffersContextDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OffersContextDecodeErrorZ)); return res; } + ~CResult_OffersContextDecodeErrorZ() { CResult_OffersContextDecodeErrorZ_free(self); } + CResult_OffersContextDecodeErrorZ& operator=(CResult_OffersContextDecodeErrorZ&& o) { CResult_OffersContextDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OffersContextDecodeErrorZ)); return *this; } + LDKCResult_OffersContextDecodeErrorZ* operator &() { return &self; } + LDKCResult_OffersContextDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OffersContextDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OffersContextDecodeErrorZ* operator ->() const { return &self; } }; class CResult_NoneNoneZ { private: @@ -11395,6 +13238,21 @@ public: const LDKCOption_ClosureReasonZ* operator &() const { return &self; } const LDKCOption_ClosureReasonZ* operator ->() const { return &self; } }; +class CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { +private: + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ self; +public: + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(const CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&) = delete; + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& o) : self(o.self) { memset(&o, 0, sizeof(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); } + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); } + operator LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ() && { LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ res = self; memset(&self, 0, sizeof(LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); return res; } + ~CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ() { CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(self); } + CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ& operator=(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ&& o) { CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(self); self = o.self; memset(&o, 0, sizeof(CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ)); return *this; } + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator &() { return &self; } + LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator ->() { return &self; } + const LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator &() const { return &self; } + const LDKCVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { private: LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ self; @@ -11425,6 +13283,51 @@ public: const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator &() const { return &self; } const LDKCResult_TransactionU16LenLimitedDecodeErrorZ* operator ->() const { return &self; } }; +class CResult_FundingInfoDecodeErrorZ { +private: + LDKCResult_FundingInfoDecodeErrorZ self; +public: + CResult_FundingInfoDecodeErrorZ(const CResult_FundingInfoDecodeErrorZ&) = delete; + CResult_FundingInfoDecodeErrorZ(CResult_FundingInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_FundingInfoDecodeErrorZ)); } + CResult_FundingInfoDecodeErrorZ(LDKCResult_FundingInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_FundingInfoDecodeErrorZ)); } + operator LDKCResult_FundingInfoDecodeErrorZ() && { LDKCResult_FundingInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_FundingInfoDecodeErrorZ)); return res; } + ~CResult_FundingInfoDecodeErrorZ() { CResult_FundingInfoDecodeErrorZ_free(self); } + CResult_FundingInfoDecodeErrorZ& operator=(CResult_FundingInfoDecodeErrorZ&& o) { CResult_FundingInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_FundingInfoDecodeErrorZ)); return *this; } + LDKCResult_FundingInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_FundingInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_FundingInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_FundingInfoDecodeErrorZ* operator ->() const { return &self; } +}; +class COption_AmountZ { +private: + LDKCOption_AmountZ self; +public: + COption_AmountZ(const COption_AmountZ&) = delete; + COption_AmountZ(COption_AmountZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_AmountZ)); } + COption_AmountZ(LDKCOption_AmountZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_AmountZ)); } + operator LDKCOption_AmountZ() && { LDKCOption_AmountZ res = self; memset(&self, 0, sizeof(LDKCOption_AmountZ)); return res; } + ~COption_AmountZ() { COption_AmountZ_free(self); } + COption_AmountZ& operator=(COption_AmountZ&& o) { COption_AmountZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_AmountZ)); return *this; } + LDKCOption_AmountZ* operator &() { return &self; } + LDKCOption_AmountZ* operator ->() { return &self; } + const LDKCOption_AmountZ* operator &() const { return &self; } + const LDKCOption_AmountZ* operator ->() const { return &self; } +}; +class COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { +private: + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ self; +public: + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(const COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&) = delete; + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); } + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); } + operator LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ() && { LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ res = self; memset(&self, 0, sizeof(LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); return res; } + ~COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ() { COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(self); } + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ& operator=(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ&& o) { COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ)); return *this; } + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator &() { return &self; } + LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator ->() { return &self; } + const LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator &() const { return &self; } + const LDKCOption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { private: LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ self; @@ -11440,21 +13343,6 @@ public: const LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* operator ->() const { return &self; } }; -class CResult_CounterpartyForwardingInfoDecodeErrorZ { -private: - LDKCResult_CounterpartyForwardingInfoDecodeErrorZ self; -public: - CResult_CounterpartyForwardingInfoDecodeErrorZ(const CResult_CounterpartyForwardingInfoDecodeErrorZ&) = delete; - CResult_CounterpartyForwardingInfoDecodeErrorZ(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); } - CResult_CounterpartyForwardingInfoDecodeErrorZ(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); } - operator LDKCResult_CounterpartyForwardingInfoDecodeErrorZ() && { LDKCResult_CounterpartyForwardingInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); return res; } - ~CResult_CounterpartyForwardingInfoDecodeErrorZ() { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); } - CResult_CounterpartyForwardingInfoDecodeErrorZ& operator=(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); return *this; } - LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() { return &self; } - LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() const { return &self; } -}; class CResult_OpenChannelV2DecodeErrorZ { private: LDKCResult_OpenChannelV2DecodeErrorZ self; @@ -11470,6 +13358,21 @@ public: const LDKCResult_OpenChannelV2DecodeErrorZ* operator &() const { return &self; } const LDKCResult_OpenChannelV2DecodeErrorZ* operator ->() const { return &self; } }; +class CResult_BestBlockDecodeErrorZ { +private: + LDKCResult_BestBlockDecodeErrorZ self; +public: + CResult_BestBlockDecodeErrorZ(const CResult_BestBlockDecodeErrorZ&) = delete; + CResult_BestBlockDecodeErrorZ(CResult_BestBlockDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_BestBlockDecodeErrorZ)); } + CResult_BestBlockDecodeErrorZ(LDKCResult_BestBlockDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_BestBlockDecodeErrorZ)); } + operator LDKCResult_BestBlockDecodeErrorZ() && { LDKCResult_BestBlockDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_BestBlockDecodeErrorZ)); return res; } + ~CResult_BestBlockDecodeErrorZ() { CResult_BestBlockDecodeErrorZ_free(self); } + CResult_BestBlockDecodeErrorZ& operator=(CResult_BestBlockDecodeErrorZ&& o) { CResult_BestBlockDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_BestBlockDecodeErrorZ)); return *this; } + LDKCResult_BestBlockDecodeErrorZ* operator &() { return &self; } + LDKCResult_BestBlockDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_BestBlockDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_BestBlockDecodeErrorZ* operator ->() const { return &self; } +}; class CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { private: LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ self; @@ -11485,35 +13388,50 @@ public: const LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* operator &() const { return &self; } const LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* operator ->() const { return &self; } }; -class CResult_HtlcBasepointDecodeErrorZ { +class CResult_CounterpartyForwardingInfoDecodeErrorZ { private: - LDKCResult_HtlcBasepointDecodeErrorZ self; + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ self; public: - CResult_HtlcBasepointDecodeErrorZ(const CResult_HtlcBasepointDecodeErrorZ&) = delete; - CResult_HtlcBasepointDecodeErrorZ(CResult_HtlcBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HtlcBasepointDecodeErrorZ)); } - CResult_HtlcBasepointDecodeErrorZ(LDKCResult_HtlcBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HtlcBasepointDecodeErrorZ)); } - operator LDKCResult_HtlcBasepointDecodeErrorZ() && { LDKCResult_HtlcBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HtlcBasepointDecodeErrorZ)); return res; } - ~CResult_HtlcBasepointDecodeErrorZ() { CResult_HtlcBasepointDecodeErrorZ_free(self); } - CResult_HtlcBasepointDecodeErrorZ& operator=(CResult_HtlcBasepointDecodeErrorZ&& o) { CResult_HtlcBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HtlcBasepointDecodeErrorZ)); return *this; } - LDKCResult_HtlcBasepointDecodeErrorZ* operator &() { return &self; } - LDKCResult_HtlcBasepointDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_HtlcBasepointDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_HtlcBasepointDecodeErrorZ* operator ->() const { return &self; } + CResult_CounterpartyForwardingInfoDecodeErrorZ(const CResult_CounterpartyForwardingInfoDecodeErrorZ&) = delete; + CResult_CounterpartyForwardingInfoDecodeErrorZ(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); } + CResult_CounterpartyForwardingInfoDecodeErrorZ(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); } + operator LDKCResult_CounterpartyForwardingInfoDecodeErrorZ() && { LDKCResult_CounterpartyForwardingInfoDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ)); return res; } + ~CResult_CounterpartyForwardingInfoDecodeErrorZ() { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); } + CResult_CounterpartyForwardingInfoDecodeErrorZ& operator=(CResult_CounterpartyForwardingInfoDecodeErrorZ&& o) { CResult_CounterpartyForwardingInfoDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_CounterpartyForwardingInfoDecodeErrorZ)); return *this; } + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() { return &self; } + LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* operator ->() const { return &self; } }; -class CResult_SpliceLockedDecodeErrorZ { +class CResult_OutputSpendStatusDecodeErrorZ { private: - LDKCResult_SpliceLockedDecodeErrorZ self; + LDKCResult_OutputSpendStatusDecodeErrorZ self; public: - CResult_SpliceLockedDecodeErrorZ(const CResult_SpliceLockedDecodeErrorZ&) = delete; - CResult_SpliceLockedDecodeErrorZ(CResult_SpliceLockedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceLockedDecodeErrorZ)); } - CResult_SpliceLockedDecodeErrorZ(LDKCResult_SpliceLockedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceLockedDecodeErrorZ)); } - operator LDKCResult_SpliceLockedDecodeErrorZ() && { LDKCResult_SpliceLockedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceLockedDecodeErrorZ)); return res; } - ~CResult_SpliceLockedDecodeErrorZ() { CResult_SpliceLockedDecodeErrorZ_free(self); } - CResult_SpliceLockedDecodeErrorZ& operator=(CResult_SpliceLockedDecodeErrorZ&& o) { CResult_SpliceLockedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceLockedDecodeErrorZ)); return *this; } - LDKCResult_SpliceLockedDecodeErrorZ* operator &() { return &self; } - LDKCResult_SpliceLockedDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_SpliceLockedDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_SpliceLockedDecodeErrorZ* operator ->() const { return &self; } + CResult_OutputSpendStatusDecodeErrorZ(const CResult_OutputSpendStatusDecodeErrorZ&) = delete; + CResult_OutputSpendStatusDecodeErrorZ(CResult_OutputSpendStatusDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_OutputSpendStatusDecodeErrorZ)); } + CResult_OutputSpendStatusDecodeErrorZ(LDKCResult_OutputSpendStatusDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_OutputSpendStatusDecodeErrorZ)); } + operator LDKCResult_OutputSpendStatusDecodeErrorZ() && { LDKCResult_OutputSpendStatusDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_OutputSpendStatusDecodeErrorZ)); return res; } + ~CResult_OutputSpendStatusDecodeErrorZ() { CResult_OutputSpendStatusDecodeErrorZ_free(self); } + CResult_OutputSpendStatusDecodeErrorZ& operator=(CResult_OutputSpendStatusDecodeErrorZ&& o) { CResult_OutputSpendStatusDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_OutputSpendStatusDecodeErrorZ)); return *this; } + LDKCResult_OutputSpendStatusDecodeErrorZ* operator &() { return &self; } + LDKCResult_OutputSpendStatusDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_OutputSpendStatusDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_OutputSpendStatusDecodeErrorZ* operator ->() const { return &self; } +}; +class C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { +private: + LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ self; +public: + C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ(const C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ&) = delete; + C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ(C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ&& o) : self(o.self) { memset(&o, 0, sizeof(C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ)); } + C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ(LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ)); } + operator LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ() && { LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ res = self; memset(&self, 0, sizeof(LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ)); return res; } + ~C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ() { C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_free(self); } + C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ& operator=(C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ&& o) { C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_free(self); self = o.self; memset(&o, 0, sizeof(C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ)); return *this; } + LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ* operator &() { return &self; } + LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ* operator ->() { return &self; } + const LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ* operator &() const { return &self; } + const LDKC4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ* operator ->() const { return &self; } }; class CResult_RouteDecodeErrorZ { private: @@ -11575,20 +13493,20 @@ public: const LDKCOption_NoneZ* operator &() const { return &self; } const LDKCOption_NoneZ* operator ->() const { return &self; } }; -class CResult_TxAddOutputDecodeErrorZ { +class CResult_SpliceLockedDecodeErrorZ { private: - LDKCResult_TxAddOutputDecodeErrorZ self; + LDKCResult_SpliceLockedDecodeErrorZ self; public: - CResult_TxAddOutputDecodeErrorZ(const CResult_TxAddOutputDecodeErrorZ&) = delete; - CResult_TxAddOutputDecodeErrorZ(CResult_TxAddOutputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); } - CResult_TxAddOutputDecodeErrorZ(LDKCResult_TxAddOutputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); } - operator LDKCResult_TxAddOutputDecodeErrorZ() && { LDKCResult_TxAddOutputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); return res; } - ~CResult_TxAddOutputDecodeErrorZ() { CResult_TxAddOutputDecodeErrorZ_free(self); } - CResult_TxAddOutputDecodeErrorZ& operator=(CResult_TxAddOutputDecodeErrorZ&& o) { CResult_TxAddOutputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); return *this; } - LDKCResult_TxAddOutputDecodeErrorZ* operator &() { return &self; } - LDKCResult_TxAddOutputDecodeErrorZ* operator ->() { return &self; } - const LDKCResult_TxAddOutputDecodeErrorZ* operator &() const { return &self; } - const LDKCResult_TxAddOutputDecodeErrorZ* operator ->() const { return &self; } + CResult_SpliceLockedDecodeErrorZ(const CResult_SpliceLockedDecodeErrorZ&) = delete; + CResult_SpliceLockedDecodeErrorZ(CResult_SpliceLockedDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_SpliceLockedDecodeErrorZ)); } + CResult_SpliceLockedDecodeErrorZ(LDKCResult_SpliceLockedDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_SpliceLockedDecodeErrorZ)); } + operator LDKCResult_SpliceLockedDecodeErrorZ() && { LDKCResult_SpliceLockedDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_SpliceLockedDecodeErrorZ)); return res; } + ~CResult_SpliceLockedDecodeErrorZ() { CResult_SpliceLockedDecodeErrorZ_free(self); } + CResult_SpliceLockedDecodeErrorZ& operator=(CResult_SpliceLockedDecodeErrorZ&& o) { CResult_SpliceLockedDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_SpliceLockedDecodeErrorZ)); return *this; } + LDKCResult_SpliceLockedDecodeErrorZ* operator &() { return &self; } + LDKCResult_SpliceLockedDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_SpliceLockedDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_SpliceLockedDecodeErrorZ* operator ->() const { return &self; } }; class COption_CVec_u8ZZ { private: @@ -11605,13 +13523,77 @@ public: const LDKCOption_CVec_u8ZZ* operator &() const { return &self; } const LDKCOption_CVec_u8ZZ* operator ->() const { return &self; } }; +class COption_QuantityZ { +private: + LDKCOption_QuantityZ self; +public: + COption_QuantityZ(const COption_QuantityZ&) = delete; + COption_QuantityZ(COption_QuantityZ&& o) : self(o.self) { memset(&o, 0, sizeof(COption_QuantityZ)); } + COption_QuantityZ(LDKCOption_QuantityZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCOption_QuantityZ)); } + operator LDKCOption_QuantityZ() && { LDKCOption_QuantityZ res = self; memset(&self, 0, sizeof(LDKCOption_QuantityZ)); return res; } + ~COption_QuantityZ() { COption_QuantityZ_free(self); } + COption_QuantityZ& operator=(COption_QuantityZ&& o) { COption_QuantityZ_free(self); self = o.self; memset(&o, 0, sizeof(COption_QuantityZ)); return *this; } + LDKCOption_QuantityZ* operator &() { return &self; } + LDKCOption_QuantityZ* operator ->() { return &self; } + const LDKCOption_QuantityZ* operator &() const { return &self; } + const LDKCOption_QuantityZ* operator ->() const { return &self; } +}; +class CResult_TxAddOutputDecodeErrorZ { +private: + LDKCResult_TxAddOutputDecodeErrorZ self; +public: + CResult_TxAddOutputDecodeErrorZ(const CResult_TxAddOutputDecodeErrorZ&) = delete; + CResult_TxAddOutputDecodeErrorZ(CResult_TxAddOutputDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); } + CResult_TxAddOutputDecodeErrorZ(LDKCResult_TxAddOutputDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); } + operator LDKCResult_TxAddOutputDecodeErrorZ() && { LDKCResult_TxAddOutputDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_TxAddOutputDecodeErrorZ)); return res; } + ~CResult_TxAddOutputDecodeErrorZ() { CResult_TxAddOutputDecodeErrorZ_free(self); } + CResult_TxAddOutputDecodeErrorZ& operator=(CResult_TxAddOutputDecodeErrorZ&& o) { CResult_TxAddOutputDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_TxAddOutputDecodeErrorZ)); return *this; } + LDKCResult_TxAddOutputDecodeErrorZ* operator &() { return &self; } + LDKCResult_TxAddOutputDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_TxAddOutputDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_TxAddOutputDecodeErrorZ* operator ->() const { return &self; } +}; +class CResult_HtlcBasepointDecodeErrorZ { +private: + LDKCResult_HtlcBasepointDecodeErrorZ self; +public: + CResult_HtlcBasepointDecodeErrorZ(const CResult_HtlcBasepointDecodeErrorZ&) = delete; + CResult_HtlcBasepointDecodeErrorZ(CResult_HtlcBasepointDecodeErrorZ&& o) : self(o.self) { memset(&o, 0, sizeof(CResult_HtlcBasepointDecodeErrorZ)); } + CResult_HtlcBasepointDecodeErrorZ(LDKCResult_HtlcBasepointDecodeErrorZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKCResult_HtlcBasepointDecodeErrorZ)); } + operator LDKCResult_HtlcBasepointDecodeErrorZ() && { LDKCResult_HtlcBasepointDecodeErrorZ res = self; memset(&self, 0, sizeof(LDKCResult_HtlcBasepointDecodeErrorZ)); return res; } + ~CResult_HtlcBasepointDecodeErrorZ() { CResult_HtlcBasepointDecodeErrorZ_free(self); } + CResult_HtlcBasepointDecodeErrorZ& operator=(CResult_HtlcBasepointDecodeErrorZ&& o) { CResult_HtlcBasepointDecodeErrorZ_free(self); self = o.self; memset(&o, 0, sizeof(CResult_HtlcBasepointDecodeErrorZ)); return *this; } + LDKCResult_HtlcBasepointDecodeErrorZ* operator &() { return &self; } + LDKCResult_HtlcBasepointDecodeErrorZ* operator ->() { return &self; } + const LDKCResult_HtlcBasepointDecodeErrorZ* operator &() const { return &self; } + const LDKCResult_HtlcBasepointDecodeErrorZ* operator ->() const { return &self; } +}; +class C2Tuple_OutPointChannelIdZ { +private: + LDKC2Tuple_OutPointChannelIdZ self; +public: + C2Tuple_OutPointChannelIdZ(const C2Tuple_OutPointChannelIdZ&) = delete; + C2Tuple_OutPointChannelIdZ(C2Tuple_OutPointChannelIdZ&& o) : self(o.self) { memset(&o, 0, sizeof(C2Tuple_OutPointChannelIdZ)); } + C2Tuple_OutPointChannelIdZ(LDKC2Tuple_OutPointChannelIdZ&& m_self) : self(m_self) { memset(&m_self, 0, sizeof(LDKC2Tuple_OutPointChannelIdZ)); } + operator LDKC2Tuple_OutPointChannelIdZ() && { LDKC2Tuple_OutPointChannelIdZ res = self; memset(&self, 0, sizeof(LDKC2Tuple_OutPointChannelIdZ)); return res; } + ~C2Tuple_OutPointChannelIdZ() { C2Tuple_OutPointChannelIdZ_free(self); } + C2Tuple_OutPointChannelIdZ& operator=(C2Tuple_OutPointChannelIdZ&& o) { C2Tuple_OutPointChannelIdZ_free(self); self = o.self; memset(&o, 0, sizeof(C2Tuple_OutPointChannelIdZ)); return *this; } + LDKC2Tuple_OutPointChannelIdZ* operator &() { return &self; } + LDKC2Tuple_OutPointChannelIdZ* operator ->() { return &self; } + const LDKC2Tuple_OutPointChannelIdZ* operator &() const { return &self; } + const LDKC2Tuple_OutPointChannelIdZ* operator ->() const { return &self; } +}; -inline LDKPublicKey ChannelSigner::get_per_commitment_point(uint64_t idx) { - LDKPublicKey ret = (self.get_per_commitment_point)(self.this_arg, idx); +inline LDK::CResult_SchnorrSignatureNoneZ SignBolt12InvoiceFn::sign_invoice(const struct LDKUnsignedBolt12Invoice *NONNULL_PTR message) { + LDK::CResult_SchnorrSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, message); + return ret; +} +inline LDK::CResult_PublicKeyNoneZ ChannelSigner::get_per_commitment_point(uint64_t idx) { + LDK::CResult_PublicKeyNoneZ ret = (self.get_per_commitment_point)(self.this_arg, idx); return ret; } -inline LDKThirtyTwoBytes ChannelSigner::release_commitment_secret(uint64_t idx) { - LDKThirtyTwoBytes ret = (self.release_commitment_secret)(self.this_arg, idx); +inline LDK::CResult__u832NoneZ ChannelSigner::release_commitment_secret(uint64_t idx) { + LDK::CResult__u832NoneZ ret = (self.release_commitment_secret)(self.this_arg, idx); return ret; } inline LDK::CResult_NoneNoneZ ChannelSigner::validate_holder_commitment(const struct LDKHolderCommitmentTransaction *NONNULL_PTR holder_tx, struct LDKCVec_ThirtyTwoBytesZ outbound_htlc_preimages) { @@ -11645,8 +13627,8 @@ inline LDK::CResult_ThirtyTwoBytesNoneZ NodeSigner::ecdh(enum LDKRecipient recip LDK::CResult_ThirtyTwoBytesNoneZ ret = (self.ecdh)(self.this_arg, recipient, other_key, tweak); return ret; } -inline LDK::CResult_RecoverableSignatureNoneZ NodeSigner::sign_invoice(struct LDKu8slice hrp_bytes, struct LDKCVec_U5Z invoice_data, enum LDKRecipient recipient) { - LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, hrp_bytes, invoice_data, recipient); +inline LDK::CResult_RecoverableSignatureNoneZ NodeSigner::sign_invoice(const struct LDKRawBolt11Invoice *NONNULL_PTR invoice, enum LDKRecipient recipient) { + LDK::CResult_RecoverableSignatureNoneZ ret = (self.sign_invoice)(self.this_arg, invoice, recipient); return ret; } inline LDK::CResult_SchnorrSignatureNoneZ NodeSigner::sign_bolt12_invoice_request(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR invoice_request) { @@ -11661,16 +13643,20 @@ inline LDK::CResult_ECDSASignatureNoneZ NodeSigner::sign_gossip_message(struct L LDK::CResult_ECDSASignatureNoneZ ret = (self.sign_gossip_message)(self.this_arg, msg); return ret; } +inline LDK::CResult_TransactionNoneZ OutputSpender::spend_spendable_outputs(struct LDKCVec_SpendableOutputDescriptorZ descriptors, struct LDKCVec_TxOutZ outputs, struct LDKCVec_u8Z change_destination_script, uint32_t feerate_sat_per_1000_weight, struct LDKCOption_u32Z locktime) { + LDK::CResult_TransactionNoneZ ret = (self.spend_spendable_outputs)(self.this_arg, descriptors, outputs, change_destination_script, feerate_sat_per_1000_weight, locktime); + return ret; +} inline LDKThirtyTwoBytes SignerProvider::generate_channel_keys_id(bool inbound, uint64_t channel_value_satoshis, struct LDKU128 user_channel_id) { LDKThirtyTwoBytes ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id); return ret; } -inline LDK::WriteableEcdsaChannelSigner SignerProvider::derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id) { - LDK::WriteableEcdsaChannelSigner ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, channel_keys_id); +inline LDK::EcdsaChannelSigner SignerProvider::derive_channel_signer(uint64_t channel_value_satoshis, struct LDKThirtyTwoBytes channel_keys_id) { + LDK::EcdsaChannelSigner ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, channel_keys_id); return ret; } -inline LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ SignerProvider::read_chan_signer(struct LDKu8slice reader) { - LDK::CResult_WriteableEcdsaChannelSignerDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); +inline LDK::CResult_EcdsaChannelSignerDecodeErrorZ SignerProvider::read_chan_signer(struct LDKu8slice reader) { + LDK::CResult_EcdsaChannelSignerDecodeErrorZ ret = (self.read_chan_signer)(self.this_arg, reader); return ret; } inline LDK::CResult_CVec_u8ZNoneZ SignerProvider::get_destination_script(struct LDKThirtyTwoBytes channel_keys_id) { @@ -11681,6 +13667,10 @@ inline LDK::CResult_ShutdownScriptNoneZ SignerProvider::get_shutdown_scriptpubke LDK::CResult_ShutdownScriptNoneZ ret = (self.get_shutdown_scriptpubkey)(self.this_arg); return ret; } +inline LDK::CResult_CVec_u8ZNoneZ ChangeDestinationSource::get_change_destination_script() { + LDK::CResult_CVec_u8ZNoneZ ret = (self.get_change_destination_script)(self.this_arg); + return ret; +} inline LDK::CResult_RouteLightningErrorZ Router::find_route(struct LDKPublicKey payer, const struct LDKRouteParameters *NONNULL_PTR route_params, struct LDKCVec_ChannelDetailsZ *first_hops, struct LDKInFlightHtlcs inflight_htlcs) { LDK::CResult_RouteLightningErrorZ ret = (self.find_route)(self.this_arg, payer, route_params, first_hops, inflight_htlcs); return ret; @@ -11689,8 +13679,8 @@ inline LDK::CResult_RouteLightningErrorZ Router::find_route_with_id(struct LDKPu LDK::CResult_RouteLightningErrorZ ret = (self.find_route_with_id)(self.this_arg, payer, route_params, first_hops, inflight_htlcs, _payment_hash, _payment_id); return ret; } -inline LDK::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ Router::create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats) { - LDK::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ ret = (self.create_blinded_payment_paths)(self.this_arg, recipient, first_hops, tlvs, amount_msats); +inline LDK::CResult_CVec_BlindedPaymentPathZNoneZ Router::create_blinded_payment_paths(struct LDKPublicKey recipient, struct LDKCVec_ChannelDetailsZ first_hops, struct LDKReceiveTlvs tlvs, uint64_t amount_msats) { + LDK::CResult_CVec_BlindedPaymentPathZNoneZ ret = (self.create_blinded_payment_paths)(self.this_arg, recipient, first_hops, tlvs, amount_msats); return ret; } inline uint64_t ScoreLookUp::channel_penalty_msat(const struct LDKCandidateRouteHop *NONNULL_PTR candidate, struct LDKChannelUsage usage, const struct LDKProbabilisticScoringFeeParameters *NONNULL_PTR score_params) { @@ -11750,8 +13740,8 @@ inline LDK::ChannelMonitorUpdateStatus Watch::update_channel(struct LDKOutPoint LDK::ChannelMonitorUpdateStatus ret = (self.update_channel)(self.this_arg, funding_txo, update); return ret; } -inline LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Watch::release_pending_monitor_events() { - LDK::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = (self.release_pending_monitor_events)(self.this_arg); +inline LDK::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ Watch::release_pending_monitor_events() { + LDK::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ ret = (self.release_pending_monitor_events)(self.this_arg); return ret; } inline void Filter::register_tx(const uint8_t (*txid)[32], struct LDKu8slice script_pubkey) { @@ -11824,6 +13814,13 @@ inline LDK::CVec_C2Tuple_PublicKeyTypeZZ CustomMessageHandler::get_and_clear_pen LDK::CVec_C2Tuple_PublicKeyTypeZZ ret = (self.get_and_clear_pending_msg)(self.this_arg); return ret; } +inline void CustomMessageHandler::peer_disconnected(struct LDKPublicKey their_node_id) { + (self.peer_disconnected)(self.this_arg, their_node_id); +} +inline LDK::CResult_NoneNoneZ CustomMessageHandler::peer_connected(struct LDKPublicKey their_node_id, const struct LDKInit *NONNULL_PTR msg, bool inbound) { + LDK::CResult_NoneNoneZ ret = (self.peer_connected)(self.this_arg, their_node_id, msg, inbound); + return ret; +} inline LDK::NodeFeatures CustomMessageHandler::provided_node_features() { LDK::NodeFeatures ret = (self.provided_node_features)(self.this_arg); return ret; @@ -11875,6 +13872,10 @@ inline LDK::CResult_NoneIOErrorZ Persister::persist_scorer(const struct LDKWrite LDK::CResult_NoneIOErrorZ ret = (self.persist_scorer)(self.this_arg, scorer); return ret; } +inline LDK::CResult_SchnorrSignatureNoneZ SignInvoiceRequestFn::sign_invoice_request(const struct LDKUnsignedInvoiceRequest *NONNULL_PTR message) { + LDK::CResult_SchnorrSignatureNoneZ ret = (self.sign_invoice_request)(self.this_arg, message); + return ret; +} inline void ChannelMessageHandler::handle_open_channel(struct LDKPublicKey their_node_id, const struct LDKOpenChannel *NONNULL_PTR msg) { (self.handle_open_channel)(self.this_arg, their_node_id, msg); } @@ -11905,15 +13906,6 @@ inline void ChannelMessageHandler::handle_closing_signed(struct LDKPublicKey the inline void ChannelMessageHandler::handle_stfu(struct LDKPublicKey their_node_id, const struct LDKStfu *NONNULL_PTR msg) { (self.handle_stfu)(self.this_arg, their_node_id, msg); } -inline void ChannelMessageHandler::handle_splice(struct LDKPublicKey their_node_id, const struct LDKSplice *NONNULL_PTR msg) { - (self.handle_splice)(self.this_arg, their_node_id, msg); -} -inline void ChannelMessageHandler::handle_splice_ack(struct LDKPublicKey their_node_id, const struct LDKSpliceAck *NONNULL_PTR msg) { - (self.handle_splice_ack)(self.this_arg, their_node_id, msg); -} -inline void ChannelMessageHandler::handle_splice_locked(struct LDKPublicKey their_node_id, const struct LDKSpliceLocked *NONNULL_PTR msg) { - (self.handle_splice_locked)(self.this_arg, their_node_id, msg); -} inline void ChannelMessageHandler::handle_tx_add_input(struct LDKPublicKey their_node_id, const struct LDKTxAddInput *NONNULL_PTR msg) { (self.handle_tx_add_input)(self.this_arg, their_node_id, msg); } @@ -12045,10 +14037,6 @@ inline LDK::InitFeatures RoutingMessageHandler::provided_init_features(struct LD LDK::InitFeatures ret = (self.provided_init_features)(self.this_arg, their_node_id); return ret; } -inline LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ OnionMessageHandler::get_and_clear_connections_needed() { - LDK::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ ret = (self.get_and_clear_connections_needed)(self.this_arg); - return ret; -} inline void OnionMessageHandler::handle_onion_message(struct LDKPublicKey peer_node_id, const struct LDKOnionMessage *NONNULL_PTR msg) { (self.handle_onion_message)(self.this_arg, peer_node_id, msg); } @@ -12080,12 +14068,23 @@ inline void Logger::log(struct LDKRecord record) { inline void FutureCallback::call() { (self.call)(self.this_arg); } -inline LDK::COption_OffersMessageZ OffersMessageHandler::handle_message(struct LDKOffersMessage message) { - LDK::COption_OffersMessageZ ret = (self.handle_message)(self.this_arg, message); +inline LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ AsyncPaymentsMessageHandler::held_htlc_available(struct LDKHeldHtlcAvailable message, struct LDKResponder responder) { + LDK::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ ret = (self.held_htlc_available)(self.this_arg, message, responder); + return ret; +} +inline void AsyncPaymentsMessageHandler::release_held_htlc(struct LDKReleaseHeldHtlc message) { + (self.release_held_htlc)(self.this_arg, message); +} +inline LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ AsyncPaymentsMessageHandler::release_pending_messages() { + LDK::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ ret = (self.release_pending_messages)(self.this_arg); + return ret; +} +inline LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ OffersMessageHandler::handle_message(struct LDKOffersMessage message, struct LDKCOption_OffersContextZ context, struct LDKResponder responder) { + LDK::COption_C2Tuple_OffersMessageResponseInstructionZZ ret = (self.handle_message)(self.this_arg, message, context, responder); return ret; } -inline LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ OffersMessageHandler::release_pending_messages() { - LDK::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret = (self.release_pending_messages)(self.this_arg); +inline LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ OffersMessageHandler::release_pending_messages() { + LDK::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ ret = (self.release_pending_messages)(self.this_arg); return ret; } inline void BroadcasterInterface::broadcast_transactions(struct LDKCVec_TransactionZ txs) { @@ -12099,6 +14098,10 @@ inline uint64_t OnionMessageContents::tlv_type() { uint64_t ret = (self.tlv_type)(self.this_arg); return ret; } +inline LDK::Str OnionMessageContents::msg_type() { + LDK::Str ret = (self.msg_type)(self.this_arg); + return ret; +} inline LDK::Str OnionMessageContents::debug_str() { LDK::Str ret = (self.debug_str)(self.this_arg); return ret; @@ -12110,8 +14113,9 @@ inline LDK::CVec_MessageSendEventZ MessageSendEventsProvider::get_and_clear_pend inline void EventsProvider::process_pending_events(struct LDKEventHandler handler) { (self.process_pending_events)(self.this_arg, handler); } -inline void EventHandler::handle_event(struct LDKEvent event) { - (self.handle_event)(self.this_arg, event); +inline LDK::CResult_NoneReplayEventZ EventHandler::handle_event(struct LDKEvent event) { + LDK::CResult_NoneReplayEventZ ret = (self.handle_event)(self.this_arg, event); + return ret; } inline LDK::CResult_COption_TypeZDecodeErrorZ CustomMessageReader::read(uint16_t message_type, struct LDKu8slice buffer) { LDK::CResult_COption_TypeZDecodeErrorZ ret = (self.read)(self.this_arg, message_type, buffer); @@ -12133,28 +14137,39 @@ inline LDK::CResult_OnionMessagePathNoneZ MessageRouter::find_path(struct LDKPub LDK::CResult_OnionMessagePathNoneZ ret = (self.find_path)(self.this_arg, sender, peers, destination); return ret; } -inline LDK::CResult_CVec_BlindedPathZNoneZ MessageRouter::create_blinded_paths(struct LDKPublicKey recipient, struct LDKCVec_PublicKeyZ peers) { - LDK::CResult_CVec_BlindedPathZNoneZ ret = (self.create_blinded_paths)(self.this_arg, recipient, peers); +inline LDK::CResult_CVec_BlindedMessagePathZNoneZ MessageRouter::create_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_PublicKeyZ peers) { + LDK::CResult_CVec_BlindedMessagePathZNoneZ ret = (self.create_blinded_paths)(self.this_arg, recipient, context, peers); + return ret; +} +inline LDK::CResult_CVec_BlindedMessagePathZNoneZ MessageRouter::create_compact_blinded_paths(struct LDKPublicKey recipient, struct LDKMessageContext context, struct LDKCVec_MessageForwardNodeZ peers) { + LDK::CResult_CVec_BlindedMessagePathZNoneZ ret = (self.create_compact_blinded_paths)(self.this_arg, recipient, context, peers); return ret; } -inline LDK::COption_OnionMessageContentsZ CustomOnionMessageHandler::handle_custom_message(struct LDKOnionMessageContents msg) { - LDK::COption_OnionMessageContentsZ ret = (self.handle_custom_message)(self.this_arg, msg); +inline LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ CustomOnionMessageHandler::handle_custom_message(struct LDKOnionMessageContents message, struct LDKCOption_CVec_u8ZZ context, struct LDKResponder responder) { + LDK::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ ret = (self.handle_custom_message)(self.this_arg, message, context, responder); return ret; } inline LDK::CResult_COption_OnionMessageContentsZDecodeErrorZ CustomOnionMessageHandler::read_custom_message(uint64_t message_type, struct LDKu8slice buffer) { LDK::CResult_COption_OnionMessageContentsZDecodeErrorZ ret = (self.read_custom_message)(self.this_arg, message_type, buffer); return ret; } -inline LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ CustomOnionMessageHandler::release_pending_custom_messages() { - LDK::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret = (self.release_pending_custom_messages)(self.this_arg); +inline LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ CustomOnionMessageHandler::release_pending_custom_messages() { + LDK::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ ret = (self.release_pending_custom_messages)(self.this_arg); + return ret; +} +inline LDKPublicKey NodeIdLookUp::next_node_id(uint64_t short_channel_id) { + LDKPublicKey ret = (self.next_node_id)(self.this_arg, short_channel_id); return ret; } -inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_id, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) { - LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_id, data, update_id); +inline LDK::ChannelMonitorUpdateStatus Persist::persist_new_channel(struct LDKOutPoint channel_funding_outpoint, const struct LDKChannelMonitor *NONNULL_PTR monitor) { + LDK::ChannelMonitorUpdateStatus ret = (self.persist_new_channel)(self.this_arg, channel_funding_outpoint, monitor); return ret; } -inline LDK::ChannelMonitorUpdateStatus Persist::update_persisted_channel(struct LDKOutPoint channel_id, struct LDKChannelMonitorUpdate update, const struct LDKChannelMonitor *NONNULL_PTR data, struct LDKMonitorUpdateId update_id) { - LDK::ChannelMonitorUpdateStatus ret = (self.update_persisted_channel)(self.this_arg, channel_id, update, data, update_id); +inline LDK::ChannelMonitorUpdateStatus Persist::update_persisted_channel(struct LDKOutPoint channel_funding_outpoint, struct LDKChannelMonitorUpdate monitor_update, const struct LDKChannelMonitor *NONNULL_PTR monitor) { + LDK::ChannelMonitorUpdateStatus ret = (self.update_persisted_channel)(self.this_arg, channel_funding_outpoint, monitor_update, monitor); return ret; } +inline void Persist::archive_persisted_channel(struct LDKOutPoint channel_funding_outpoint) { + (self.archive_persisted_channel)(self.this_arg, channel_funding_outpoint); +} } diff --git a/lightning-c-bindings/src/bitcoin/network.rs b/lightning-c-bindings/src/bitcoin/network.rs index 78565a1..08131cf 100644 --- a/lightning-c-bindings/src/bitcoin/network.rs +++ b/lightning-c-bindings/src/bitcoin/network.rs @@ -1,6 +1,6 @@ //! A C-mapped version fo bitcoin::network::constants::Network -use bitcoin::network::constants::Network as BitcoinNetwork; +use bitcoin::Network as BitcoinNetwork; #[repr(C)] /// An enum representing the possible Bitcoin or test networks which we can run on diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index 220fa3c..1dc119a 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -8,6 +8,244 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +#[repr(C)] +/// A dynamically-allocated array of u8s of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_u8Z { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut u8, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_u8Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_u8Z { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } +impl Drop for CVec_u8Z { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_u8Z { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ +pub union CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder) -> CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + contents: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + contents: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(_res: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(orig: &CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ) -> CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_RefundBolt12SemanticErrorZ +pub union CResult_RefundBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::refund::Refund, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_RefundBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RefundBolt12SemanticErrorZ { + /// The contents of this CResult_RefundBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundBolt12SemanticErrorZPtr, + /// Whether this CResult_RefundBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_RefundBolt12SemanticErrorZ_ok(o: crate::lightning::offers::refund::Refund) -> CResult_RefundBolt12SemanticErrorZ { + CResult_RefundBolt12SemanticErrorZ { + contents: CResult_RefundBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_RefundBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_RefundBolt12SemanticErrorZ { + CResult_RefundBolt12SemanticErrorZ { + contents: CResult_RefundBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RefundBolt12SemanticErrorZ_is_ok(o: &CResult_RefundBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundBolt12SemanticErrorZ. +pub extern "C" fn CResult_RefundBolt12SemanticErrorZ_free(_res: CResult_RefundBolt12SemanticErrorZ) { } +impl Drop for CResult_RefundBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RefundBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RefundBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundBolt12SemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundBolt12SemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundBolt12SemanticErrorZ_clone(orig: &CResult_RefundBolt12SemanticErrorZ) -> CResult_RefundBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] /// An enum which can either contain a u64 or not @@ -46,29 +284,29 @@ pub extern "C" fn COption_u64Z_free(_res: COption_u64Z) { } /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_u64Z_clone(orig: &COption_u64Z) -> COption_u64Z { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedPaths of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::message::BlindedMessagePaths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BlindedPathZ { +pub struct CVec_BlindedMessagePathZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::blinded_path::BlindedPath, + pub data: *mut crate::lightning::blinded_path::message::BlindedMessagePath, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BlindedPathZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_BlindedMessagePathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedPath] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::message::BlindedMessagePath] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BlindedPathZ { - fn from(v: Vec) -> Self { +impl From> for CVec_BlindedMessagePathZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -76,14 +314,14 @@ impl From> for CVec_BlindedPath } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BlindedPathZ_free(_res: CVec_BlindedPathZ) { } -impl Drop for CVec_BlindedPathZ { +pub extern "C" fn CVec_BlindedMessagePathZ_free(_res: CVec_BlindedMessagePathZ) { } +impl Drop for CVec_BlindedMessagePathZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_BlindedPathZ { +impl Clone for CVec_BlindedMessagePathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -92,6 +330,102 @@ impl Clone for CVec_BlindedPathZ { } } #[repr(C)] +/// The contents of CResult_RefundDecodeErrorZ +pub union CResult_RefundDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::refund::Refund, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_RefundDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::refund::Refund on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RefundDecodeErrorZ { + /// The contents of this CResult_RefundDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RefundDecodeErrorZPtr, + /// Whether this CResult_RefundDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ in the success state. +pub extern "C" fn CResult_RefundDecodeErrorZ_ok(o: crate::lightning::offers::refund::Refund) -> CResult_RefundDecodeErrorZ { + CResult_RefundDecodeErrorZ { + contents: CResult_RefundDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ in the error state. +pub extern "C" fn CResult_RefundDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RefundDecodeErrorZ { + CResult_RefundDecodeErrorZ { + contents: CResult_RefundDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_RefundDecodeErrorZ_is_ok(o: &CResult_RefundDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_RefundDecodeErrorZ. +pub extern "C" fn CResult_RefundDecodeErrorZ_free(_res: CResult_RefundDecodeErrorZ) { } +impl Drop for CResult_RefundDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_RefundDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RefundDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RefundDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_RefundDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RefundDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RefundDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_RefundDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RefundDecodeErrorZ_clone(orig: &CResult_RefundDecodeErrorZ) -> CResult_RefundDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] /// The contents of CResult_RefundBolt12ParseErrorZ pub union CResult_RefundBolt12ParseErrorZPtr { /// A pointer to the contents in the success state. @@ -505,52 +839,6 @@ pub extern "C" fn COption_ThirtyTwoBytesZ_free(_res: COption_ThirtyTwoBytesZ) { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn COption_ThirtyTwoBytesZ_clone(orig: &COption_ThirtyTwoBytesZ) -> COption_ThirtyTwoBytesZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of u8s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_u8Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u8, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_u8Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_u8Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u8Z_free(_res: CVec_u8Z) { } -impl Drop for CVec_u8Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_u8Z { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] #[derive(Clone)] /// An enum which can either contain a crate::c_types::derived::CVec_u8Z or not pub enum COption_CVec_u8ZZ { @@ -864,156 +1152,77 @@ impl Clone for CResult_RecipientOnionFieldsNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_RecipientOnionFieldsNoneZ_clone(orig: &CResult_RecipientOnionFieldsNoneZ) -> CResult_RecipientOnionFieldsNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ThirtyTwoBytesZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ThirtyTwoBytes, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ThirtyTwoBytesZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ThirtyTwoBytesZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } -impl Drop for CVec_ThirtyTwoBytesZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ThirtyTwoBytesZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::CVec_ThirtyTwoBytesZ or not -pub enum COption_CVec_ThirtyTwoBytesZZ { - /// When we're in this state, this COption_CVec_ThirtyTwoBytesZZ contains a crate::c_types::derived::CVec_ThirtyTwoBytesZ - Some(crate::c_types::derived::CVec_ThirtyTwoBytesZ), - /// When we're in this state, this COption_CVec_ThirtyTwoBytesZZ contains nothing - None -} -impl COption_CVec_ThirtyTwoBytesZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_CVec_ThirtyTwoBytesZZ containing a crate::c_types::derived::CVec_ThirtyTwoBytesZ -pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_some(o: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> COption_CVec_ThirtyTwoBytesZZ { - COption_CVec_ThirtyTwoBytesZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_CVec_ThirtyTwoBytesZZ containing nothing -pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_none() -> COption_CVec_ThirtyTwoBytesZZ { - COption_CVec_ThirtyTwoBytesZZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::CVec_ThirtyTwoBytesZ, if we are in the Some state -pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_free(_res: COption_CVec_ThirtyTwoBytesZZ) { } -#[no_mangle] -/// Creates a new COption_CVec_ThirtyTwoBytesZZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_clone(orig: &COption_CVec_ThirtyTwoBytesZZ) -> COption_CVec_ThirtyTwoBytesZZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ThirtyTwoBytesNoneZ -pub union CResult_ThirtyTwoBytesNoneZPtr { +/// The contents of CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ +pub union CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::offers::invoice::UnsignedBolt12Invoice, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_ThirtyTwoBytesNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. +/// A CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::UnsignedBolt12Invoice on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ThirtyTwoBytesNoneZ { - /// The contents of this CResult_ThirtyTwoBytesNoneZ, accessible via either +pub struct CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + /// The contents of this CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ThirtyTwoBytesNoneZPtr, - /// Whether this CResult_ThirtyTwoBytesNoneZ represents a success state. + pub contents: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr, + /// Whether this CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesNoneZ in the success state. -pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesNoneZ { - CResult_ThirtyTwoBytesNoneZ { - contents: CResult_ThirtyTwoBytesNoneZPtr { +/// Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + contents: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesNoneZ in the error state. -pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_err() -> CResult_ThirtyTwoBytesNoneZ { - CResult_ThirtyTwoBytesNoneZ { - contents: CResult_ThirtyTwoBytesNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + contents: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_is_ok(o: &CResult_ThirtyTwoBytesNoneZ) -> bool { +pub extern "C" fn CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_is_ok(o: &CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ThirtyTwoBytesNoneZ. -pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_free(_res: CResult_ThirtyTwoBytesNoneZ) { } -impl Drop for CResult_ThirtyTwoBytesNoneZ { +/// Frees any resources used by the CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ. +pub extern "C" fn CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_free(_res: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ) { } +impl Drop for CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_ThirtyTwoBytesNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ThirtyTwoBytesNoneZPtr { result } + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_ThirtyTwoBytesNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -1021,59 +1230,59 @@ impl From> for } } } -impl Clone for CResult_ThirtyTwoBytesNoneZ { +impl Clone for CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ThirtyTwoBytesNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ThirtyTwoBytesNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesNoneZ which has the same data as `orig` +/// Creates a new CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_clone(orig: &CResult_ThirtyTwoBytesNoneZ) -> CResult_ThirtyTwoBytesNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ_clone(orig: &CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ) -> CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPayInfoDecodeErrorZ -pub union CResult_BlindedPayInfoDecodeErrorZPtr { +/// The contents of CResult_Bolt12InvoiceBolt12SemanticErrorZ +pub union CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::invoice::BlindedPayInfo, + pub result: *mut crate::lightning::offers::invoice::Bolt12Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::invoice::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt12InvoiceBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::Bolt12Invoice on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPayInfoDecodeErrorZ { - /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either +pub struct CResult_Bolt12InvoiceBolt12SemanticErrorZ { + /// The contents of this CResult_Bolt12InvoiceBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, - /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. + pub contents: CResult_Bolt12InvoiceBolt12SemanticErrorZPtr, + /// Whether this CResult_Bolt12InvoiceBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::offers::invoice::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { +/// Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice::Bolt12Invoice) -> CResult_Bolt12InvoiceBolt12SemanticErrorZ { + CResult_Bolt12InvoiceBolt12SemanticErrorZ { + contents: CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { - CResult_BlindedPayInfoDecodeErrorZ { - contents: CResult_BlindedPayInfoDecodeErrorZPtr { +/// Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_Bolt12InvoiceBolt12SemanticErrorZ { + CResult_Bolt12InvoiceBolt12SemanticErrorZ { + contents: CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -1081,13 +1290,13 @@ pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12InvoiceBolt12SemanticErrorZ_is_ok(o: &CResult_Bolt12InvoiceBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } -impl Drop for CResult_BlindedPayInfoDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt12InvoiceBolt12SemanticErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceBolt12SemanticErrorZ_free(_res: CResult_Bolt12InvoiceBolt12SemanticErrorZ) { } +impl Drop for CResult_Bolt12InvoiceBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1100,16 +1309,16 @@ impl Drop for CResult_BlindedPayInfoDecodeErrorZ { } } } -impl From> for CResult_BlindedPayInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12InvoiceBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPayInfoDecodeErrorZPtr { result } + CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPayInfoDecodeErrorZPtr { err } + CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -1117,287 +1326,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt12InvoiceBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceBolt12SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12InvoiceBolt12SemanticErrorZ_clone(orig: &CResult_Bolt12InvoiceBolt12SemanticErrorZ) -> CResult_Bolt12InvoiceBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ -pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { +/// The contents of CResult_SchnorrSignatureNoneZ +pub union CResult_SchnorrSignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::DelayedPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::SchnorrSignature, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SchnorrSignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::SchnorrSignature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either +pub struct CResult_SchnorrSignatureNoneZ { + /// The contents of this CResult_SchnorrSignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_SchnorrSignatureNoneZPtr, + /// Whether this CResult_SchnorrSignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { +/// Creates a new CResult_SchnorrSignatureNoneZ in the success state. +pub extern "C" fn CResult_SchnorrSignatureNoneZ_ok(o: crate::c_types::SchnorrSignature) -> CResult_SchnorrSignatureNoneZ { + CResult_SchnorrSignatureNoneZ { + contents: CResult_SchnorrSignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_SchnorrSignatureNoneZ in the error state. +pub extern "C" fn CResult_SchnorrSignatureNoneZ_err() -> CResult_SchnorrSignatureNoneZ { + CResult_SchnorrSignatureNoneZ { + contents: CResult_SchnorrSignatureNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SchnorrSignatureNoneZ_is_ok(o: &CResult_SchnorrSignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_SchnorrSignatureNoneZ. +pub extern "C" fn CResult_SchnorrSignatureNoneZ_free(_res: CResult_SchnorrSignatureNoneZ) { } +impl Drop for CResult_SchnorrSignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SchnorrSignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } + CResult_SchnorrSignatureNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ -pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::StaticPaymentOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ -pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::SpendableOutputDescriptor, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { - /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, - /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { - CResult_SpendableOutputDescriptorDecodeErrorZ { - contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } -impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_SchnorrSignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1405,47 +1418,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SchnorrSignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SchnorrSignatureNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SchnorrSignatureNoneZ_clone(orig: &CResult_SchnorrSignatureNoneZ) -> CResult_SchnorrSignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::sign::SpendableOutputDescriptors of arbitrary size. +/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_SpendableOutputDescriptorZ { +pub struct CVec_StrZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::sign::SpendableOutputDescriptor, + pub data: *mut crate::c_types::Str, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_SpendableOutputDescriptorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_StrZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::SpendableOutputDescriptor] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_SpendableOutputDescriptorZ { - fn from(v: Vec) -> Self { +impl From> for CVec_StrZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -1453,14 +1466,14 @@ impl From> for CVec_Spend } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } -impl Drop for CVec_SpendableOutputDescriptorZ { +pub extern "C" fn CVec_StrZ_free(_res: CVec_StrZ) { } +impl Drop for CVec_StrZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_SpendableOutputDescriptorZ { +impl Clone for CVec_StrZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -1469,29 +1482,29 @@ impl Clone for CVec_SpendableOutputDescriptorZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. +/// A dynamically-allocated array of crate::c_types::ThirtyTwoBytess of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TxOutZ { +pub struct CVec_ThirtyTwoBytesZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::TxOut, + pub data: *mut crate::c_types::ThirtyTwoBytes, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TxOutZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ThirtyTwoBytesZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_TxOutZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ThirtyTwoBytesZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -1499,14 +1512,14 @@ impl From> for CVec_TxOutZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } -impl Drop for CVec_TxOutZ { +pub extern "C" fn CVec_ThirtyTwoBytesZ_free(_res: CVec_ThirtyTwoBytesZ) { } +impl Drop for CVec_ThirtyTwoBytesZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_TxOutZ { +impl Clone for CVec_ThirtyTwoBytesZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -1516,118 +1529,150 @@ impl Clone for CVec_TxOutZ { } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a u32 or not -pub enum COption_u32Z { - /// When we're in this state, this COption_u32Z contains a u32 - Some(u32), - /// When we're in this state, this COption_u32Z contains nothing +/// An enum which can either contain a crate::c_types::derived::CVec_ThirtyTwoBytesZ or not +pub enum COption_CVec_ThirtyTwoBytesZZ { + /// When we're in this state, this COption_CVec_ThirtyTwoBytesZZ contains a crate::c_types::derived::CVec_ThirtyTwoBytesZ + Some(crate::c_types::derived::CVec_ThirtyTwoBytesZ), + /// When we're in this state, this COption_CVec_ThirtyTwoBytesZZ contains nothing None } -impl COption_u32Z { +impl COption_CVec_ThirtyTwoBytesZZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> u32 { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_ThirtyTwoBytesZ { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_u32Z containing a u32 -pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { - COption_u32Z::Some(o) +/// Constructs a new COption_CVec_ThirtyTwoBytesZZ containing a crate::c_types::derived::CVec_ThirtyTwoBytesZ +pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_some(o: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> COption_CVec_ThirtyTwoBytesZZ { + COption_CVec_ThirtyTwoBytesZZ::Some(o) } #[no_mangle] -/// Constructs a new COption_u32Z containing nothing -pub extern "C" fn COption_u32Z_none() -> COption_u32Z { - COption_u32Z::None +/// Constructs a new COption_CVec_ThirtyTwoBytesZZ containing nothing +pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_none() -> COption_CVec_ThirtyTwoBytesZZ { + COption_CVec_ThirtyTwoBytesZZ::None } #[no_mangle] -/// Frees any resources associated with the u32, if we are in the Some state -pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +/// Frees any resources associated with the crate::c_types::derived::CVec_ThirtyTwoBytesZ, if we are in the Some state +pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_free(_res: COption_CVec_ThirtyTwoBytesZZ) { } #[no_mangle] -/// Creates a new COption_u32Z which has the same data as `orig` +/// Creates a new COption_CVec_ThirtyTwoBytesZZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } +pub extern "C" fn COption_CVec_ThirtyTwoBytesZZ_clone(orig: &COption_CVec_ThirtyTwoBytesZZ) -> COption_CVec_ThirtyTwoBytesZZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_CVec_u8Zu64Z { - /// The element at position 0 - pub a: crate::c_types::derived::CVec_u8Z, - /// The element at position 1 - pub b: u64, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::offers::offer::Amount or not +pub enum COption_AmountZ { + /// When we're in this state, this COption_AmountZ contains a crate::lightning::offers::offer::Amount + Some(crate::lightning::offers::offer::Amount), + /// When we're in this state, this COption_AmountZ contains nothing + None } -impl From<(crate::c_types::derived::CVec_u8Z, u64)> for C2Tuple_CVec_u8Zu64Z { - fn from (tup: (crate::c_types::derived::CVec_u8Z, u64)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl COption_AmountZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -impl C2Tuple_CVec_u8Zu64Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::derived::CVec_u8Z, u64) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl Clone for C2Tuple_CVec_u8Zu64Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::offers::offer::Amount { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Constructs a new COption_AmountZ containing a crate::lightning::offers::offer::Amount +pub extern "C" fn COption_AmountZ_some(o: crate::lightning::offers::offer::Amount) -> COption_AmountZ { + COption_AmountZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_AmountZ containing nothing +pub extern "C" fn COption_AmountZ_none() -> COption_AmountZ { + COption_AmountZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::offers::offer::Amount, if we are in the Some state +pub extern "C" fn COption_AmountZ_free(_res: COption_AmountZ) { } +#[no_mangle] +/// Creates a new COption_AmountZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_CVec_u8Zu64Z_clone(orig: &C2Tuple_CVec_u8Zu64Z) -> C2Tuple_CVec_u8Zu64Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_CVec_u8Zu64Z from the contained elements. +pub extern "C" fn COption_AmountZ_clone(orig: &COption_AmountZ) -> COption_AmountZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::offers::offer::Quantity or not +pub enum COption_QuantityZ { + /// When we're in this state, this COption_QuantityZ contains a crate::lightning::offers::offer::Quantity + Some(crate::lightning::offers::offer::Quantity), + /// When we're in this state, this COption_QuantityZ contains nothing + None +} +impl COption_QuantityZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::offers::offer::Quantity { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} #[no_mangle] -pub extern "C" fn C2Tuple_CVec_u8Zu64Z_new(a: crate::c_types::derived::CVec_u8Z, b: u64) -> C2Tuple_CVec_u8Zu64Z { - C2Tuple_CVec_u8Zu64Z { a, b, } +/// Constructs a new COption_QuantityZ containing a crate::lightning::offers::offer::Quantity +pub extern "C" fn COption_QuantityZ_some(o: crate::lightning::offers::offer::Quantity) -> COption_QuantityZ { + COption_QuantityZ::Some(o) } - #[no_mangle] -/// Frees any resources used by the C2Tuple_CVec_u8Zu64Z. -pub extern "C" fn C2Tuple_CVec_u8Zu64Z_free(_res: C2Tuple_CVec_u8Zu64Z) { } +/// Constructs a new COption_QuantityZ containing nothing +pub extern "C" fn COption_QuantityZ_none() -> COption_QuantityZ { + COption_QuantityZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::offers::offer::Quantity, if we are in the Some state +pub extern "C" fn COption_QuantityZ_free(_res: COption_QuantityZ) { } +#[no_mangle] +/// Creates a new COption_QuantityZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_QuantityZ_clone(orig: &COption_QuantityZ) -> COption_QuantityZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_CVec_u8Zu64ZNoneZ -pub union CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { +/// The contents of CResult_ThirtyTwoBytesNoneZ +pub union CResult_ThirtyTwoBytesNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_CVec_u8Zu64Z, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_C2Tuple_CVec_u8Zu64ZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_CVec_u8Zu64Z on success and a () on failure. +/// A CResult_ThirtyTwoBytesNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - /// The contents of this CResult_C2Tuple_CVec_u8Zu64ZNoneZ, accessible via either +pub struct CResult_ThirtyTwoBytesNoneZ { + /// The contents of this CResult_ThirtyTwoBytesNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr, - /// Whether this CResult_C2Tuple_CVec_u8Zu64ZNoneZ represents a success state. + pub contents: CResult_ThirtyTwoBytesNoneZPtr, + /// Whether this CResult_ThirtyTwoBytesNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_ok(o: crate::c_types::derived::C2Tuple_CVec_u8Zu64Z) -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { +/// Creates a new CResult_ThirtyTwoBytesNoneZ in the success state. +pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesNoneZ { + CResult_ThirtyTwoBytesNoneZ { + contents: CResult_ThirtyTwoBytesNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_err() -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { +/// Creates a new CResult_ThirtyTwoBytesNoneZ in the error state. +pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_err() -> CResult_ThirtyTwoBytesNoneZ { + CResult_ThirtyTwoBytesNoneZ { + contents: CResult_ThirtyTwoBytesNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -1635,13 +1680,13 @@ pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_err() -> CResult_C2Tuple_CVe } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_is_ok(o: &CResult_C2Tuple_CVec_u8Zu64ZNoneZ) -> bool { +pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_is_ok(o: &CResult_ThirtyTwoBytesNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_CVec_u8Zu64ZNoneZ. -pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_free(_res: CResult_C2Tuple_CVec_u8Zu64ZNoneZ) { } -impl Drop for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { +/// Frees any resources used by the CResult_ThirtyTwoBytesNoneZ. +pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_free(_res: CResult_ThirtyTwoBytesNoneZ) { } +impl Drop for CResult_ThirtyTwoBytesNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1651,16 +1696,16 @@ impl Drop for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { } } } -impl From> for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ThirtyTwoBytesNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { result } + CResult_ThirtyTwoBytesNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { err: core::ptr::null_mut() } + CResult_ThirtyTwoBytesNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -1668,59 +1713,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ThirtyTwoBytesNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { + Self { result_ok: false, contents: CResult_ThirtyTwoBytesNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ which has the same data as `orig` +/// Creates a new CResult_ThirtyTwoBytesNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_clone(orig: &CResult_C2Tuple_CVec_u8Zu64ZNoneZ) -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ThirtyTwoBytesNoneZ_clone(orig: &CResult_ThirtyTwoBytesNoneZ) -> CResult_ThirtyTwoBytesNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelDerivationParametersDecodeErrorZ -pub union CResult_ChannelDerivationParametersDecodeErrorZPtr { +/// The contents of CResult_Bolt12InvoiceDecodeErrorZ +pub union CResult_Bolt12InvoiceDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::ChannelDerivationParameters, + pub result: *mut crate::lightning::offers::invoice::Bolt12Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelDerivationParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::ChannelDerivationParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt12InvoiceDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::Bolt12Invoice on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelDerivationParametersDecodeErrorZ { - /// The contents of this CResult_ChannelDerivationParametersDecodeErrorZ, accessible via either +pub struct CResult_Bolt12InvoiceDecodeErrorZ { + /// The contents of this CResult_Bolt12InvoiceDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelDerivationParametersDecodeErrorZPtr, - /// Whether this CResult_ChannelDerivationParametersDecodeErrorZ represents a success state. + pub contents: CResult_Bolt12InvoiceDecodeErrorZPtr, + /// Whether this CResult_Bolt12InvoiceDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_ok(o: crate::lightning::sign::ChannelDerivationParameters) -> CResult_ChannelDerivationParametersDecodeErrorZ { - CResult_ChannelDerivationParametersDecodeErrorZ { - contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_ok(o: crate::lightning::offers::invoice::Bolt12Invoice) -> CResult_Bolt12InvoiceDecodeErrorZ { + CResult_Bolt12InvoiceDecodeErrorZ { + contents: CResult_Bolt12InvoiceDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDerivationParametersDecodeErrorZ { - CResult_ChannelDerivationParametersDecodeErrorZ { - contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceDecodeErrorZ { + CResult_Bolt12InvoiceDecodeErrorZ { + contents: CResult_Bolt12InvoiceDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -1728,13 +1773,13 @@ pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(o: &CResult_ChannelDerivationParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelDerivationParametersDecodeErrorZ. -pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_free(_res: CResult_ChannelDerivationParametersDecodeErrorZ) { } -impl Drop for CResult_ChannelDerivationParametersDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt12InvoiceDecodeErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_free(_res: CResult_Bolt12InvoiceDecodeErrorZ) { } +impl Drop for CResult_Bolt12InvoiceDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1747,16 +1792,16 @@ impl Drop for CResult_ChannelDerivationParametersDecodeErrorZ { } } } -impl From> for CResult_ChannelDerivationParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12InvoiceDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelDerivationParametersDecodeErrorZPtr { result } + CResult_Bolt12InvoiceDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelDerivationParametersDecodeErrorZPtr { err } + CResult_Bolt12InvoiceDecodeErrorZPtr { err } }; Self { contents, @@ -1764,59 +1809,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12InvoiceDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt12InvoiceDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_clone(orig: &CResult_ChannelDerivationParametersDecodeErrorZ) -> CResult_ChannelDerivationParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12InvoiceDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceDecodeErrorZ) -> CResult_Bolt12InvoiceDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HTLCDescriptorDecodeErrorZ -pub union CResult_HTLCDescriptorDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentOutputDescriptorDecodeErrorZ +pub union CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::HTLCDescriptor, + pub result: *mut crate::lightning::sign::DelayedPaymentOutputDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_HTLCDescriptorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::HTLCDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::DelayedPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCDescriptorDecodeErrorZ { - /// The contents of this CResult_HTLCDescriptorDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCDescriptorDecodeErrorZPtr, - /// Whether this CResult_HTLCDescriptorDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HTLCDescriptorDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::HTLCDescriptor) -> CResult_HTLCDescriptorDecodeErrorZ { - CResult_HTLCDescriptorDecodeErrorZ { - contents: CResult_HTLCDescriptorDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::DelayedPaymentOutputDescriptor) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HTLCDescriptorDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCDescriptorDecodeErrorZ { - CResult_HTLCDescriptorDecodeErrorZ { - contents: CResult_HTLCDescriptorDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -1824,13 +1869,13 @@ pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_is_ok(o: &CResult_HTLCDescriptorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HTLCDescriptorDecodeErrorZ. -pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_free(_res: CResult_HTLCDescriptorDecodeErrorZ) { } -impl Drop for CResult_HTLCDescriptorDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -1843,16 +1888,16 @@ impl Drop for CResult_HTLCDescriptorDecodeErrorZ { } } } -impl From> for CResult_HTLCDescriptorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCDescriptorDecodeErrorZPtr { result } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCDescriptorDecodeErrorZPtr { err } + CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -1860,87 +1905,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCDescriptorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCDescriptorDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HTLCDescriptorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_clone(orig: &CResult_HTLCDescriptorDecodeErrorZ) -> CResult_HTLCDescriptorDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_NoneNoneZ -pub union CResult_NoneNoneZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} +pub extern "C" fn CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_DelayedPaymentOutputDescriptorDecodeErrorZ) -> CResult_DelayedPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_NoneNoneZ represents the result of a fallible operation, -/// containing a () on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneNoneZ { - /// The contents of this CResult_NoneNoneZ, accessible via either +/// The contents of CResult_StaticPaymentOutputDescriptorDecodeErrorZ +pub union CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::sign::StaticPaymentOutputDescriptor, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::StaticPaymentOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_StaticPaymentOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneNoneZPtr, - /// Whether this CResult_NoneNoneZ represents a success state. + pub contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_StaticPaymentOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the success state. -pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::StaticPaymentOutputDescriptor) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ in the error state. -pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { - CResult_NoneNoneZ { - contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneNoneZ. -pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } -impl Drop for CResult_NoneNoneZ { +/// Frees any resources used by the CResult_StaticPaymentOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res: CResult_StaticPaymentOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_NoneNoneZ { - fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { +impl From> for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneNoneZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_NoneNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -1948,91 +2001,95 @@ impl From> for CResult_NoneNoneZ { } } } -impl Clone for CResult_NoneNoneZ { +impl Clone for CResult_StaticPaymentOutputDescriptorDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneNoneZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneNoneZ which has the same data as `orig` +/// Creates a new CResult_StaticPaymentOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig: &CResult_StaticPaymentOutputDescriptorDecodeErrorZ) -> CResult_StaticPaymentOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PublicKeyNoneZ -pub union CResult_PublicKeyNoneZPtr { +/// The contents of CResult_SpendableOutputDescriptorDecodeErrorZ +pub union CResult_SpendableOutputDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::PublicKey, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::sign::SpendableOutputDescriptor, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a () on failure. +/// A CResult_SpendableOutputDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::SpendableOutputDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PublicKeyNoneZ { - /// The contents of this CResult_PublicKeyNoneZ, accessible via either +pub struct CResult_SpendableOutputDescriptorDecodeErrorZ { + /// The contents of this CResult_SpendableOutputDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PublicKeyNoneZPtr, - /// Whether this CResult_PublicKeyNoneZ represents a success state. + pub contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr, + /// Whether this CResult_SpendableOutputDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the success state. -pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::SpendableOutputDescriptor) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ in the error state. -pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { - CResult_PublicKeyNoneZ { - contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpendableOutputDescriptorDecodeErrorZ { + CResult_SpendableOutputDescriptorDecodeErrorZ { + contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PublicKeyNoneZ. -pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } -impl Drop for CResult_PublicKeyNoneZ { +/// Frees any resources used by the CResult_SpendableOutputDescriptorDecodeErrorZ. +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res: CResult_SpendableOutputDescriptorDecodeErrorZ) { } +impl Drop for CResult_SpendableOutputDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_PublicKeyNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SpendableOutputDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PublicKeyNoneZPtr { result } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SpendableOutputDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -2040,84 +2097,93 @@ impl From> for CResu } } } -impl Clone for CResult_PublicKeyNoneZ { +impl Clone for CResult_SpendableOutputDescriptorDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_SpendableOutputDescriptorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` +/// Creates a new CResult_SpendableOutputDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig: &CResult_SpendableOutputDescriptorDecodeErrorZ) -> CResult_SpendableOutputDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::BigEndianScalar or not -pub enum COption_BigEndianScalarZ { - /// When we're in this state, this COption_BigEndianScalarZ contains a crate::c_types::BigEndianScalar - Some(crate::c_types::BigEndianScalar), - /// When we're in this state, this COption_BigEndianScalarZ contains nothing - None +/// A dynamically-allocated array of crate::lightning::sign::SpendableOutputDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_SpendableOutputDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::sign::SpendableOutputDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_BigEndianScalarZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_SpendableOutputDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::SpendableOutputDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl From> for CVec_SpendableOutputDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Constructs a new COption_BigEndianScalarZ containing a crate::c_types::BigEndianScalar -pub extern "C" fn COption_BigEndianScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_BigEndianScalarZ { - COption_BigEndianScalarZ::Some(o) +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_SpendableOutputDescriptorZ_free(_res: CVec_SpendableOutputDescriptorZ) { } +impl Drop for CVec_SpendableOutputDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } -#[no_mangle] -/// Constructs a new COption_BigEndianScalarZ containing nothing -pub extern "C" fn COption_BigEndianScalarZ_none() -> COption_BigEndianScalarZ { - COption_BigEndianScalarZ::None +impl Clone for CVec_SpendableOutputDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state -pub extern "C" fn COption_BigEndianScalarZ_free(_res: COption_BigEndianScalarZ) { } -#[no_mangle] -/// Creates a new COption_BigEndianScalarZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_BigEndianScalarZ_clone(orig: &COption_BigEndianScalarZ) -> COption_BigEndianScalarZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::U5s of arbitrary size. +/// A dynamically-allocated array of crate::c_types::TxOuts of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_U5Z { +pub struct CVec_TxOutZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::U5, + pub data: *mut crate::c_types::TxOut, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_U5Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_TxOutZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::U5] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_U5Z { - fn from(v: Vec) -> Self { +impl From> for CVec_TxOutZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -2125,14 +2191,14 @@ impl From> for CVec_U5Z { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_U5Z_free(_res: CVec_U5Z) { } -impl Drop for CVec_U5Z { +pub extern "C" fn CVec_TxOutZ_free(_res: CVec_TxOutZ) { } +impl Drop for CVec_TxOutZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_U5Z { +impl Clone for CVec_TxOutZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -2141,132 +2207,119 @@ impl Clone for CVec_U5Z { } } #[repr(C)] -/// The contents of CResult_RecoverableSignatureNoneZ -pub union CResult_RecoverableSignatureNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::RecoverableSignature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +#[derive(Clone)] +/// An enum which can either contain a u32 or not +pub enum COption_u32Z { + /// When we're in this state, this COption_u32Z contains a u32 + Some(u32), + /// When we're in this state, this COption_u32Z contains nothing + None } -#[repr(C)] -/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::RecoverableSignature on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RecoverableSignatureNoneZ { - /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RecoverableSignatureNoneZPtr, - /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_u32Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> u32 { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { - CResult_RecoverableSignatureNoneZ { - contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } +/// Constructs a new COption_u32Z containing a u32 +pub extern "C" fn COption_u32Z_some(o: u32) -> COption_u32Z { + COption_u32Z::Some(o) } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { - o.result_ok +/// Constructs a new COption_u32Z containing nothing +pub extern "C" fn COption_u32Z_none() -> COption_u32Z { + COption_u32Z::None } #[no_mangle] -/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } -impl Drop for CResult_RecoverableSignatureNoneZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - } - } +/// Frees any resources associated with the u32, if we are in the Some state +pub extern "C" fn COption_u32Z_free(_res: COption_u32Z) { } +#[no_mangle] +/// Creates a new COption_u32Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u32Z_clone(orig: &COption_u32Z) -> COption_u32Z { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_CVec_u8Zu64Z { + /// The element at position 0 + pub a: crate::c_types::derived::CVec_u8Z, + /// The element at position 1 + pub b: u64, } -impl From> for CResult_RecoverableSignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RecoverableSignatureNoneZPtr { result } - } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } - }; +impl From<(crate::c_types::derived::CVec_u8Z, u64)> for C2Tuple_CVec_u8Zu64Z { + fn from (tup: (crate::c_types::derived::CVec_u8Z, u64)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_RecoverableSignatureNoneZ { +impl C2Tuple_CVec_u8Zu64Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::derived::CVec_u8Z, u64) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_CVec_u8Zu64Z { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { - err: core::ptr::null_mut() - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_CVec_u8Zu64Z_clone(orig: &C2Tuple_CVec_u8Zu64Z) -> C2Tuple_CVec_u8Zu64Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_CVec_u8Zu64Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_CVec_u8Zu64Z_new(a: crate::c_types::derived::CVec_u8Z, b: u64) -> C2Tuple_CVec_u8Zu64Z { + C2Tuple_CVec_u8Zu64Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_CVec_u8Zu64Z. +pub extern "C" fn C2Tuple_CVec_u8Zu64Z_free(_res: C2Tuple_CVec_u8Zu64Z) { } #[repr(C)] -/// The contents of CResult_SchnorrSignatureNoneZ -pub union CResult_SchnorrSignatureNoneZPtr { +/// The contents of CResult_C2Tuple_CVec_u8Zu64ZNoneZ +pub union CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::SchnorrSignature, + pub result: *mut crate::c_types::derived::C2Tuple_CVec_u8Zu64Z, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_SchnorrSignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::SchnorrSignature on success and a () on failure. +/// A CResult_C2Tuple_CVec_u8Zu64ZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_CVec_u8Zu64Z on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SchnorrSignatureNoneZ { - /// The contents of this CResult_SchnorrSignatureNoneZ, accessible via either +pub struct CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + /// The contents of this CResult_C2Tuple_CVec_u8Zu64ZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SchnorrSignatureNoneZPtr, - /// Whether this CResult_SchnorrSignatureNoneZ represents a success state. + pub contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr, + /// Whether this CResult_C2Tuple_CVec_u8Zu64ZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SchnorrSignatureNoneZ in the success state. -pub extern "C" fn CResult_SchnorrSignatureNoneZ_ok(o: crate::c_types::SchnorrSignature) -> CResult_SchnorrSignatureNoneZ { - CResult_SchnorrSignatureNoneZ { - contents: CResult_SchnorrSignatureNoneZPtr { +/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_ok(o: crate::c_types::derived::C2Tuple_CVec_u8Zu64Z) -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SchnorrSignatureNoneZ in the error state. -pub extern "C" fn CResult_SchnorrSignatureNoneZ_err() -> CResult_SchnorrSignatureNoneZ { - CResult_SchnorrSignatureNoneZ { - contents: CResult_SchnorrSignatureNoneZPtr { +/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_err() -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2274,13 +2327,13 @@ pub extern "C" fn CResult_SchnorrSignatureNoneZ_err() -> CResult_SchnorrSignatur } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SchnorrSignatureNoneZ_is_ok(o: &CResult_SchnorrSignatureNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_is_ok(o: &CResult_C2Tuple_CVec_u8Zu64ZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SchnorrSignatureNoneZ. -pub extern "C" fn CResult_SchnorrSignatureNoneZ_free(_res: CResult_SchnorrSignatureNoneZ) { } -impl Drop for CResult_SchnorrSignatureNoneZ { +/// Frees any resources used by the CResult_C2Tuple_CVec_u8Zu64ZNoneZ. +pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_free(_res: CResult_C2Tuple_CVec_u8Zu64ZNoneZ) { } +impl Drop for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2290,16 +2343,16 @@ impl Drop for CResult_SchnorrSignatureNoneZ { } } } -impl From> for CResult_SchnorrSignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SchnorrSignatureNoneZPtr { result } + CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_SchnorrSignatureNoneZPtr { err: core::ptr::null_mut() } + CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2307,91 +2360,95 @@ impl From> fo } } } -impl Clone for CResult_SchnorrSignatureNoneZ { +impl Clone for CResult_C2Tuple_CVec_u8Zu64ZNoneZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SchnorrSignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SchnorrSignatureNoneZPtr { + Self { result_ok: false, contents: CResult_C2Tuple_CVec_u8Zu64ZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_SchnorrSignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_CVec_u8Zu64ZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SchnorrSignatureNoneZ_clone(orig: &CResult_SchnorrSignatureNoneZ) -> CResult_SchnorrSignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_CVec_u8Zu64ZNoneZ_clone(orig: &CResult_C2Tuple_CVec_u8Zu64ZNoneZ) -> CResult_C2Tuple_CVec_u8Zu64ZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ECDSASignatureNoneZ -pub union CResult_ECDSASignatureNoneZPtr { +/// The contents of CResult_ChannelDerivationParametersDecodeErrorZ +pub union CResult_ChannelDerivationParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ECDSASignature, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::sign::ChannelDerivationParameters, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ECDSASignatureNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::ECDSASignature on success and a () on failure. +/// A CResult_ChannelDerivationParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::ChannelDerivationParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ECDSASignatureNoneZ { - /// The contents of this CResult_ECDSASignatureNoneZ, accessible via either +pub struct CResult_ChannelDerivationParametersDecodeErrorZ { + /// The contents of this CResult_ChannelDerivationParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ECDSASignatureNoneZPtr, - /// Whether this CResult_ECDSASignatureNoneZ represents a success state. + pub contents: CResult_ChannelDerivationParametersDecodeErrorZPtr, + /// Whether this CResult_ChannelDerivationParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ECDSASignatureNoneZ in the success state. -pub extern "C" fn CResult_ECDSASignatureNoneZ_ok(o: crate::c_types::ECDSASignature) -> CResult_ECDSASignatureNoneZ { - CResult_ECDSASignatureNoneZ { - contents: CResult_ECDSASignatureNoneZPtr { +/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_ok(o: crate::lightning::sign::ChannelDerivationParameters) -> CResult_ChannelDerivationParametersDecodeErrorZ { + CResult_ChannelDerivationParametersDecodeErrorZ { + contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ECDSASignatureNoneZ in the error state. -pub extern "C" fn CResult_ECDSASignatureNoneZ_err() -> CResult_ECDSASignatureNoneZ { - CResult_ECDSASignatureNoneZ { - contents: CResult_ECDSASignatureNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDerivationParametersDecodeErrorZ { + CResult_ChannelDerivationParametersDecodeErrorZ { + contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ECDSASignatureNoneZ_is_ok(o: &CResult_ECDSASignatureNoneZ) -> bool { +pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(o: &CResult_ChannelDerivationParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ECDSASignatureNoneZ. -pub extern "C" fn CResult_ECDSASignatureNoneZ_free(_res: CResult_ECDSASignatureNoneZ) { } -impl Drop for CResult_ECDSASignatureNoneZ { +/// Frees any resources used by the CResult_ChannelDerivationParametersDecodeErrorZ. +pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_free(_res: CResult_ChannelDerivationParametersDecodeErrorZ) { } +impl Drop for CResult_ChannelDerivationParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_ECDSASignatureNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelDerivationParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ECDSASignatureNoneZPtr { result } + CResult_ChannelDerivationParametersDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_ECDSASignatureNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelDerivationParametersDecodeErrorZPtr { err } }; Self { contents, @@ -2399,59 +2456,59 @@ impl From> for } } } -impl Clone for CResult_ECDSASignatureNoneZ { +impl Clone for CResult_ChannelDerivationParametersDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ECDSASignatureNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ECDSASignatureNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_ChannelDerivationParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ECDSASignatureNoneZ which has the same data as `orig` +/// Creates a new CResult_ChannelDerivationParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ECDSASignatureNoneZ_clone(orig: &CResult_ECDSASignatureNoneZ) -> CResult_ECDSASignatureNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelDerivationParametersDecodeErrorZ_clone(orig: &CResult_ChannelDerivationParametersDecodeErrorZ) -> CResult_ChannelDerivationParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WriteableEcdsaChannelSignerDecodeErrorZ -pub union CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +/// The contents of CResult_HTLCDescriptorDecodeErrorZ +pub union CResult_HTLCDescriptorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner, + pub result: *mut crate::lightning::sign::HTLCDescriptor, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HTLCDescriptorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::HTLCDescriptor on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - /// The contents of this CResult_WriteableEcdsaChannelSignerDecodeErrorZ, accessible via either +pub struct CResult_HTLCDescriptorDecodeErrorZ { + /// The contents of this CResult_HTLCDescriptorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr, - /// Whether this CResult_WriteableEcdsaChannelSignerDecodeErrorZ represents a success state. + pub contents: CResult_HTLCDescriptorDecodeErrorZPtr, + /// Whether this CResult_HTLCDescriptorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +/// Creates a new CResult_HTLCDescriptorDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_ok(o: crate::lightning::sign::HTLCDescriptor) -> CResult_HTLCDescriptorDecodeErrorZ { + CResult_HTLCDescriptorDecodeErrorZ { + contents: CResult_HTLCDescriptorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { +/// Creates a new CResult_HTLCDescriptorDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCDescriptorDecodeErrorZ { + CResult_HTLCDescriptorDecodeErrorZ { + contents: CResult_HTLCDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -2459,13 +2516,13 @@ pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_is_ok(o: &CResult_HTLCDescriptorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_WriteableEcdsaChannelSignerDecodeErrorZ. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res: CResult_WriteableEcdsaChannelSignerDecodeErrorZ) { } -impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { +/// Frees any resources used by the CResult_HTLCDescriptorDecodeErrorZ. +pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_free(_res: CResult_HTLCDescriptorDecodeErrorZ) { } +impl Drop for CResult_HTLCDescriptorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2478,16 +2535,16 @@ impl Drop for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { } } } -impl From> for CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCDescriptorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { result } + CResult_HTLCDescriptorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { err } + CResult_HTLCDescriptorDecodeErrorZPtr { err } }; Self { contents, @@ -2495,58 +2552,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCDescriptorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_WriteableEcdsaChannelSignerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HTLCDescriptorDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_WriteableEcdsaChannelSignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCDescriptorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig: &CResult_WriteableEcdsaChannelSignerDecodeErrorZ) -> CResult_WriteableEcdsaChannelSignerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HTLCDescriptorDecodeErrorZ_clone(orig: &CResult_HTLCDescriptorDecodeErrorZ) -> CResult_HTLCDescriptorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_u8ZNoneZ -pub union CResult_CVec_u8ZNoneZPtr { +/// The contents of CResult_PublicKeyNoneZ +pub union CResult_PublicKeyNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, + pub result: *mut crate::c_types::PublicKey, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CVec_u8ZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. +/// A CResult_PublicKeyNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::PublicKey on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZNoneZ { - /// The contents of this CResult_CVec_u8ZNoneZ, accessible via either +pub struct CResult_PublicKeyNoneZ { + /// The contents of this CResult_PublicKeyNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZNoneZPtr, - /// Whether this CResult_CVec_u8ZNoneZ represents a success state. + pub contents: CResult_PublicKeyNoneZPtr, + /// Whether this CResult_PublicKeyNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_u8ZNoneZ in the success state. -pub extern "C" fn CResult_CVec_u8ZNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZNoneZ { - CResult_CVec_u8ZNoneZ { - contents: CResult_CVec_u8ZNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the success state. +pub extern "C" fn CResult_PublicKeyNoneZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZNoneZ in the error state. -pub extern "C" fn CResult_CVec_u8ZNoneZ_err() -> CResult_CVec_u8ZNoneZ { - CResult_CVec_u8ZNoneZ { - contents: CResult_CVec_u8ZNoneZPtr { +/// Creates a new CResult_PublicKeyNoneZ in the error state. +pub extern "C" fn CResult_PublicKeyNoneZ_err() -> CResult_PublicKeyNoneZ { + CResult_PublicKeyNoneZ { + contents: CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2554,13 +2611,13 @@ pub extern "C" fn CResult_CVec_u8ZNoneZ_err() -> CResult_CVec_u8ZNoneZ { } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_u8ZNoneZ_is_ok(o: &CResult_CVec_u8ZNoneZ) -> bool { +pub extern "C" fn CResult_PublicKeyNoneZ_is_ok(o: &CResult_PublicKeyNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZNoneZ. -pub extern "C" fn CResult_CVec_u8ZNoneZ_free(_res: CResult_CVec_u8ZNoneZ) { } -impl Drop for CResult_CVec_u8ZNoneZ { +/// Frees any resources used by the CResult_PublicKeyNoneZ. +pub extern "C" fn CResult_PublicKeyNoneZ_free(_res: CResult_PublicKeyNoneZ) { } +impl Drop for CResult_PublicKeyNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2570,16 +2627,16 @@ impl Drop for CResult_CVec_u8ZNoneZ { } } } -impl From> for CResult_CVec_u8ZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PublicKeyNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_u8ZNoneZPtr { result } + CResult_PublicKeyNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_u8ZNoneZPtr { err: core::ptr::null_mut() } + CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2587,58 +2644,58 @@ impl From> f } } } -impl Clone for CResult_CVec_u8ZNoneZ { +impl Clone for CResult_PublicKeyNoneZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PublicKeyNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_u8ZNoneZPtr { + Self { result_ok: false, contents: CResult_PublicKeyNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZNoneZ which has the same data as `orig` +/// Creates a new CResult_PublicKeyNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZNoneZ_clone(orig: &CResult_CVec_u8ZNoneZ) -> CResult_CVec_u8ZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PublicKeyNoneZ_clone(orig: &CResult_PublicKeyNoneZ) -> CResult_PublicKeyNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptNoneZ -pub union CResult_ShutdownScriptNoneZPtr { +/// The contents of CResult__u832NoneZ +pub union CResult__u832NoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::script::ShutdownScript, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ShutdownScriptNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a () on failure. +/// A CResult__u832NoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptNoneZ { - /// The contents of this CResult_ShutdownScriptNoneZ, accessible via either +pub struct CResult__u832NoneZ { + /// The contents of this CResult__u832NoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptNoneZPtr, - /// Whether this CResult_ShutdownScriptNoneZ represents a success state. + pub contents: CResult__u832NoneZPtr, + /// Whether this CResult__u832NoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptNoneZ in the success state. -pub extern "C" fn CResult_ShutdownScriptNoneZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptNoneZ { - CResult_ShutdownScriptNoneZ { - contents: CResult_ShutdownScriptNoneZPtr { +/// Creates a new CResult__u832NoneZ in the success state. +pub extern "C" fn CResult__u832NoneZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult__u832NoneZ { + CResult__u832NoneZ { + contents: CResult__u832NoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptNoneZ in the error state. -pub extern "C" fn CResult_ShutdownScriptNoneZ_err() -> CResult_ShutdownScriptNoneZ { - CResult_ShutdownScriptNoneZ { - contents: CResult_ShutdownScriptNoneZPtr { +/// Creates a new CResult__u832NoneZ in the error state. +pub extern "C" fn CResult__u832NoneZ_err() -> CResult__u832NoneZ { + CResult__u832NoneZ { + contents: CResult__u832NoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2646,13 +2703,13 @@ pub extern "C" fn CResult_ShutdownScriptNoneZ_err() -> CResult_ShutdownScriptNon } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptNoneZ_is_ok(o: &CResult_ShutdownScriptNoneZ) -> bool { +pub extern "C" fn CResult__u832NoneZ_is_ok(o: &CResult__u832NoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptNoneZ. -pub extern "C" fn CResult_ShutdownScriptNoneZ_free(_res: CResult_ShutdownScriptNoneZ) { } -impl Drop for CResult_ShutdownScriptNoneZ { +/// Frees any resources used by the CResult__u832NoneZ. +pub extern "C" fn CResult__u832NoneZ_free(_res: CResult__u832NoneZ) { } +impl Drop for CResult__u832NoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -2662,16 +2719,16 @@ impl Drop for CResult_ShutdownScriptNoneZ { } } } -impl From> for CResult_ShutdownScriptNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult__u832NoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptNoneZPtr { result } + CResult__u832NoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_ShutdownScriptNoneZPtr { err: core::ptr::null_mut() } + CResult__u832NoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2679,132 +2736,57 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult__u832NoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptNoneZPtr { + Self { result_ok: false, contents: CResult__u832NoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptNoneZ_clone(orig: &CResult_ShutdownScriptNoneZ) -> CResult_ShutdownScriptNoneZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a u16 or not -pub enum COption_u16Z { - /// When we're in this state, this COption_u16Z contains a u16 - Some(u16), - /// When we're in this state, this COption_u16Z contains nothing - None -} -impl COption_u16Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> u16 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_u16Z containing a u16 -pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { - COption_u16Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_u16Z containing nothing -pub extern "C" fn COption_u16Z_none() -> COption_u16Z { - COption_u16Z::None -} -#[no_mangle] -/// Frees any resources associated with the u16, if we are in the Some state -pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } -#[no_mangle] -/// Creates a new COption_u16Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a bool or not -pub enum COption_boolZ { - /// When we're in this state, this COption_boolZ contains a bool - Some(bool), - /// When we're in this state, this COption_boolZ contains nothing - None -} -impl COption_boolZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> bool { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_boolZ containing a bool -pub extern "C" fn COption_boolZ_some(o: bool) -> COption_boolZ { - COption_boolZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_boolZ containing nothing -pub extern "C" fn COption_boolZ_none() -> COption_boolZ { - COption_boolZ::None -} -#[no_mangle] -/// Frees any resources associated with the bool, if we are in the Some state -pub extern "C" fn COption_boolZ_free(_res: COption_boolZ) { } -#[no_mangle] -/// Creates a new COption_boolZ which has the same data as `orig` +/// Creates a new CResult__u832NoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_boolZ_clone(orig: &COption_boolZ) -> COption_boolZ { Clone::clone(&orig) } +pub extern "C" fn CResult__u832NoneZ_clone(orig: &CResult__u832NoneZ) -> CResult__u832NoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WitnessNoneZ -pub union CResult_WitnessNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Witness, +/// The contents of CResult_NoneNoneZ +pub union CResult_NoneNoneZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_WitnessNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::Witness on success and a () on failure. +/// A CResult_NoneNoneZ represents the result of a fallible operation, +/// containing a () on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WitnessNoneZ { - /// The contents of this CResult_WitnessNoneZ, accessible via either +pub struct CResult_NoneNoneZ { + /// The contents of this CResult_NoneNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WitnessNoneZPtr, - /// Whether this CResult_WitnessNoneZ represents a success state. + pub contents: CResult_NoneNoneZPtr, + /// Whether this CResult_NoneNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_WitnessNoneZ in the success state. -pub extern "C" fn CResult_WitnessNoneZ_ok(o: crate::c_types::Witness) -> CResult_WitnessNoneZ { - CResult_WitnessNoneZ { - contents: CResult_WitnessNoneZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneNoneZ in the success state. +pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_WitnessNoneZ in the error state. -pub extern "C" fn CResult_WitnessNoneZ_err() -> CResult_WitnessNoneZ { - CResult_WitnessNoneZ { - contents: CResult_WitnessNoneZPtr { +/// Creates a new CResult_NoneNoneZ in the error state. +pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ { + CResult_NoneNoneZ { + contents: CResult_NoneNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2812,32 +2794,29 @@ pub extern "C" fn CResult_WitnessNoneZ_err() -> CResult_WitnessNoneZ { } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_WitnessNoneZ_is_ok(o: &CResult_WitnessNoneZ) -> bool { +pub extern "C" fn CResult_NoneNoneZ_is_ok(o: &CResult_NoneNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_WitnessNoneZ. -pub extern "C" fn CResult_WitnessNoneZ_free(_res: CResult_WitnessNoneZ) { } -impl Drop for CResult_WitnessNoneZ { +/// Frees any resources used by the CResult_NoneNoneZ. +pub extern "C" fn CResult_NoneNoneZ_free(_res: CResult_NoneNoneZ) { } +impl Drop for CResult_NoneNoneZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { } } } -impl From> for CResult_WitnessNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneNoneZ { + fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WitnessNoneZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneNoneZPtr { result: core::ptr::null_mut() } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_WitnessNoneZPtr { err: core::ptr::null_mut() } + CResult_NoneNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -2845,146 +2824,95 @@ impl From> for CResult } } } -impl Clone for CResult_WitnessNoneZ { +impl Clone for CResult_NoneNoneZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WitnessNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneNoneZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_WitnessNoneZPtr { + Self { result_ok: false, contents: CResult_NoneNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_WitnessNoneZ which has the same data as `orig` +/// Creates a new CResult_NoneNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WitnessNoneZ_clone(orig: &CResult_WitnessNoneZ) -> CResult_WitnessNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneNoneZ_clone(orig: &CResult_NoneNoneZ) -> CResult_NoneNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::ECDSASignatures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ECDSASignatureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::ECDSASignature, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::BigEndianScalar or not +pub enum COption_BigEndianScalarZ { + /// When we're in this state, this COption_BigEndianScalarZ contains a crate::c_types::BigEndianScalar + Some(crate::c_types::BigEndianScalar), + /// When we're in this state, this COption_BigEndianScalarZ contains nothing + None } -impl CVec_ECDSASignatureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_BigEndianScalarZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ECDSASignature] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_ECDSASignatureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::BigEndianScalar { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ECDSASignatureZ_free(_res: CVec_ECDSASignatureZ) { } -impl Drop for CVec_ECDSASignatureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ECDSASignatureZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { - /// The element at position 0 - pub a: crate::c_types::ECDSASignature, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_ECDSASignatureZ, -} -impl From<(crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ)> for C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { - fn from (tup: (crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } +/// Constructs a new COption_BigEndianScalarZ containing a crate::c_types::BigEndianScalar +pub extern "C" fn COption_BigEndianScalarZ_some(o: crate::c_types::BigEndianScalar) -> COption_BigEndianScalarZ { + COption_BigEndianScalarZ::Some(o) } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(orig: &C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) -> C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(a: crate::c_types::ECDSASignature, b: crate::c_types::derived::CVec_ECDSASignatureZ) -> C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { - C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { a, b, } +/// Constructs a new COption_BigEndianScalarZ containing nothing +pub extern "C" fn COption_BigEndianScalarZ_none() -> COption_BigEndianScalarZ { + COption_BigEndianScalarZ::None } - #[no_mangle] -/// Frees any resources used by the C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ. -pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(_res: C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) { } +/// Frees any resources associated with the crate::c_types::BigEndianScalar, if we are in the Some state +pub extern "C" fn COption_BigEndianScalarZ_free(_res: COption_BigEndianScalarZ) { } +#[no_mangle] +/// Creates a new COption_BigEndianScalarZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_BigEndianScalarZ_clone(orig: &COption_BigEndianScalarZ) -> COption_BigEndianScalarZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ -pub union CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { +/// The contents of CResult_RecoverableSignatureNoneZ +pub union CResult_RecoverableSignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ, + pub result: *mut crate::c_types::RecoverableSignature, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ on success and a () on failure. +/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::RecoverableSignature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - /// The contents of this CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ, accessible via either +pub struct CResult_RecoverableSignatureNoneZ { + /// The contents of this CResult_RecoverableSignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr, - /// Whether this CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ represents a success state. + pub contents: CResult_RecoverableSignatureNoneZPtr, + /// Whether this CResult_RecoverableSignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the success state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_ok(o: crate::c_types::RecoverableSignature) -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err() -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { +/// Creates a new CResult_RecoverableSignatureNoneZ in the error state. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ { + CResult_RecoverableSignatureNoneZ { + contents: CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -2992,13 +2920,13 @@ pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err() } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) -> bool { +pub extern "C" fn CResult_RecoverableSignatureNoneZ_is_ok(o: &CResult_RecoverableSignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ. -pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(_res: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) { } -impl Drop for CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { +/// Frees any resources used by the CResult_RecoverableSignatureNoneZ. +pub extern "C" fn CResult_RecoverableSignatureNoneZ_free(_res: CResult_RecoverableSignatureNoneZ) { } +impl Drop for CResult_RecoverableSignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3008,16 +2936,16 @@ impl Drop for CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { } } } -impl From> for CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RecoverableSignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { result } + CResult_RecoverableSignatureNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { err: core::ptr::null_mut() } + CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3025,95 +2953,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RecoverableSignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { + Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ which has the same data as `orig` +/// Creates a new CResult_RecoverableSignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(orig: &CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RecoverableSignatureNoneZ_clone(orig: &CResult_RecoverableSignatureNoneZ) -> CResult_RecoverableSignatureNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InMemorySignerDecodeErrorZ -pub union CResult_InMemorySignerDecodeErrorZPtr { +/// The contents of CResult_ECDSASignatureNoneZ +pub union CResult_ECDSASignatureNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::sign::InMemorySigner, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::ECDSASignature, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::sign::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ECDSASignatureNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::ECDSASignature on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InMemorySignerDecodeErrorZ { - /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either +pub struct CResult_ECDSASignatureNoneZ { + /// The contents of this CResult_ECDSASignatureNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InMemorySignerDecodeErrorZPtr, - /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. + pub contents: CResult_ECDSASignatureNoneZPtr, + /// Whether this CResult_ECDSASignatureNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::sign::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { +/// Creates a new CResult_ECDSASignatureNoneZ in the success state. +pub extern "C" fn CResult_ECDSASignatureNoneZ_ok(o: crate::c_types::ECDSASignature) -> CResult_ECDSASignatureNoneZ { + CResult_ECDSASignatureNoneZ { + contents: CResult_ECDSASignatureNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { - CResult_InMemorySignerDecodeErrorZ { - contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ECDSASignatureNoneZ in the error state. +pub extern "C" fn CResult_ECDSASignatureNoneZ_err() -> CResult_ECDSASignatureNoneZ { + CResult_ECDSASignatureNoneZ { + contents: CResult_ECDSASignatureNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ECDSASignatureNoneZ_is_ok(o: &CResult_ECDSASignatureNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } -impl Drop for CResult_InMemorySignerDecodeErrorZ { +/// Frees any resources used by the CResult_ECDSASignatureNoneZ. +pub extern "C" fn CResult_ECDSASignatureNoneZ_free(_res: CResult_ECDSASignatureNoneZ) { } +impl Drop for CResult_ECDSASignatureNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_InMemorySignerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ECDSASignatureNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InMemorySignerDecodeErrorZPtr { result } + CResult_ECDSASignatureNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InMemorySignerDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ECDSASignatureNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3121,23 +3045,23 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ECDSASignatureNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { result_ok: false, contents: CResult_ECDSASignatureNoneZPtr { + err: core::ptr::null_mut() + } } } } } #[no_mangle] -/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ECDSASignatureNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ECDSASignatureNoneZ_clone(orig: &CResult_ECDSASignatureNoneZ) -> CResult_ECDSASignatureNoneZ { Clone::clone(&orig) } #[repr(C)] /// The contents of CResult_TransactionNoneZ pub union CResult_TransactionNoneZPtr { @@ -3231,72 +3155,41 @@ impl Clone for CResult_TransactionNoneZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_TransactionNoneZ_clone(orig: &CResult_TransactionNoneZ) -> CResult_TransactionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not -pub enum COption_WriteableScoreZ { - /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore - Some(crate::lightning::routing::scoring::WriteableScore), - /// When we're in this state, this COption_WriteableScoreZ contains nothing - None -} -impl COption_WriteableScoreZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore -pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { - COption_WriteableScoreZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_WriteableScoreZ containing nothing -pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { - COption_WriteableScoreZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state -pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } -#[repr(C)] -/// The contents of CResult_NoneIOErrorZ -pub union CResult_NoneIOErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_EcdsaChannelSignerDecodeErrorZ +pub union CResult_EcdsaChannelSignerDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::sign::ecdsa::EcdsaChannelSigner, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneIOErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::c_types::IOError on failure. +/// A CResult_EcdsaChannelSignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::ecdsa::EcdsaChannelSigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneIOErrorZ { - /// The contents of this CResult_NoneIOErrorZ, accessible via either +pub struct CResult_EcdsaChannelSignerDecodeErrorZ { + /// The contents of this CResult_EcdsaChannelSignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneIOErrorZPtr, - /// Whether this CResult_NoneIOErrorZ represents a success state. + pub contents: CResult_EcdsaChannelSignerDecodeErrorZPtr, + /// Whether this CResult_EcdsaChannelSignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneIOErrorZ in the success state. -pub extern "C" fn CResult_NoneIOErrorZ_ok() -> CResult_NoneIOErrorZ { - CResult_NoneIOErrorZ { - contents: CResult_NoneIOErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_ok(o: crate::lightning::sign::ecdsa::EcdsaChannelSigner) -> CResult_EcdsaChannelSignerDecodeErrorZ { + CResult_EcdsaChannelSignerDecodeErrorZ { + contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneIOErrorZ in the error state. -pub extern "C" fn CResult_NoneIOErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneIOErrorZ { - CResult_NoneIOErrorZ { - contents: CResult_NoneIOErrorZPtr { +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_EcdsaChannelSignerDecodeErrorZ { + CResult_EcdsaChannelSignerDecodeErrorZ { + contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3304,15 +3197,18 @@ pub extern "C" fn CResult_NoneIOErrorZ_err(e: crate::c_types::IOError) -> CResul } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneIOErrorZ_is_ok(o: &CResult_NoneIOErrorZ) -> bool { +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_is_ok(o: &CResult_EcdsaChannelSignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneIOErrorZ. -pub extern "C" fn CResult_NoneIOErrorZ_free(_res: CResult_NoneIOErrorZ) { } -impl Drop for CResult_NoneIOErrorZ { +/// Frees any resources used by the CResult_EcdsaChannelSignerDecodeErrorZ. +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_free(_res: CResult_EcdsaChannelSignerDecodeErrorZ) { } +impl Drop for CResult_EcdsaChannelSignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -3320,16 +3216,16 @@ impl Drop for CResult_NoneIOErrorZ { } } } -impl From> for CResult_NoneIOErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { +impl From> for CResult_EcdsaChannelSignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneIOErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_EcdsaChannelSignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneIOErrorZPtr { err } + CResult_EcdsaChannelSignerDecodeErrorZPtr { err } }; Self { contents, @@ -3337,141 +3233,91 @@ impl From> for CResult } } } -impl Clone for CResult_NoneIOErrorZ { +impl Clone for CResult_EcdsaChannelSignerDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneIOErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneIOErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_EcdsaChannelSignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneIOErrorZ which has the same data as `orig` +/// Creates a new CResult_EcdsaChannelSignerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneIOErrorZ_clone(orig: &CResult_NoneIOErrorZ) -> CResult_NoneIOErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::ChannelDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChannelDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ChannelDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ChannelDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } -impl Drop for CVec_ChannelDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChannelDetailsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_EcdsaChannelSignerDecodeErrorZ_clone(orig: &CResult_EcdsaChannelSignerDecodeErrorZ) -> CResult_EcdsaChannelSignerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteLightningErrorZ -pub union CResult_RouteLightningErrorZPtr { +/// The contents of CResult_CVec_u8ZNoneZ +pub union CResult_CVec_u8ZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. +/// A CResult_CVec_u8ZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteLightningErrorZ { - /// The contents of this CResult_RouteLightningErrorZ, accessible via either +pub struct CResult_CVec_u8ZNoneZ { + /// The contents of this CResult_CVec_u8ZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteLightningErrorZPtr, - /// Whether this CResult_RouteLightningErrorZ represents a success state. + pub contents: CResult_CVec_u8ZNoneZPtr, + /// Whether this CResult_CVec_u8ZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the success state. -pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { +/// Creates a new CResult_CVec_u8ZNoneZ in the success state. +pub extern "C" fn CResult_CVec_u8ZNoneZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZNoneZ { + CResult_CVec_u8ZNoneZ { + contents: CResult_CVec_u8ZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ in the error state. -pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { - CResult_RouteLightningErrorZ { - contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_u8ZNoneZ in the error state. +pub extern "C" fn CResult_CVec_u8ZNoneZ_err() -> CResult_CVec_u8ZNoneZ { + CResult_CVec_u8ZNoneZ { + contents: CResult_CVec_u8ZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { +pub extern "C" fn CResult_CVec_u8ZNoneZ_is_ok(o: &CResult_CVec_u8ZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteLightningErrorZ. -pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } -impl Drop for CResult_RouteLightningErrorZ { +/// Frees any resources used by the CResult_CVec_u8ZNoneZ. +pub extern "C" fn CResult_CVec_u8ZNoneZ_free(_res: CResult_CVec_u8ZNoneZ) { } +impl Drop for CResult_CVec_u8ZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_u8ZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteLightningErrorZPtr { result } + CResult_CVec_u8ZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteLightningErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_u8ZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3479,146 +3325,224 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_u8ZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_u8ZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_u8ZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_u8ZNoneZ_clone(orig: &CResult_CVec_u8ZNoneZ) -> CResult_CVec_u8ZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_BlindedPayInfoBlindedPathZ { - /// The element at position 0 - pub a: crate::lightning::offers::invoice::BlindedPayInfo, - /// The element at position 1 - pub b: crate::lightning::blinded_path::BlindedPath, +/// The contents of CResult_ShutdownScriptNoneZ +pub union CResult_ShutdownScriptNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::script::ShutdownScript, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } -impl From<(crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)> for C2Tuple_BlindedPayInfoBlindedPathZ { - fn from (tup: (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_ShutdownScriptNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ShutdownScriptNoneZ { + /// The contents of this CResult_ShutdownScriptNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ShutdownScriptNoneZPtr, + /// Whether this CResult_ShutdownScriptNoneZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_BlindedPayInfoBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::offers::invoice::BlindedPayInfo, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_ShutdownScriptNoneZ in the success state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_BlindedPayInfoBlindedPathZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_ShutdownScriptNoneZ in the error state. +pub extern "C" fn CResult_ShutdownScriptNoneZ_err() -> CResult_ShutdownScriptNoneZ { + CResult_ShutdownScriptNoneZ { + contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig: &C2Tuple_BlindedPayInfoBlindedPathZ) -> C2Tuple_BlindedPayInfoBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_BlindedPayInfoBlindedPathZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_new(a: crate::lightning::offers::invoice::BlindedPayInfo, b: crate::lightning::blinded_path::BlindedPath) -> C2Tuple_BlindedPayInfoBlindedPathZ { - C2Tuple_BlindedPayInfoBlindedPathZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_BlindedPayInfoBlindedPathZ. -pub extern "C" fn C2Tuple_BlindedPayInfoBlindedPathZ_free(_res: C2Tuple_BlindedPayInfoBlindedPathZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +pub extern "C" fn CResult_ShutdownScriptNoneZ_is_ok(o: &CResult_ShutdownScriptNoneZ) -> bool { + o.result_ok } -impl CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +#[no_mangle] +/// Frees any resources used by the CResult_ShutdownScriptNoneZ. +pub extern "C" fn CResult_ShutdownScriptNoneZ_free(_res: CResult_ShutdownScriptNoneZ) { } +impl Drop for CResult_ShutdownScriptNoneZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +} +impl From> for CResult_ShutdownScriptNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ShutdownScriptNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ShutdownScriptNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl From> for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl Clone for CResult_ShutdownScriptNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ShutdownScriptNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ShutdownScriptNoneZPtr { + err: core::ptr::null_mut() + } } + } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res: CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) { } -impl Drop for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Creates a new CResult_ShutdownScriptNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ShutdownScriptNoneZ_clone(orig: &CResult_ShutdownScriptNoneZ) -> CResult_ShutdownScriptNoneZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a u16 or not +pub enum COption_u16Z { + /// When we're in this state, this COption_u16Z contains a u16 + Some(u16), + /// When we're in this state, this COption_u16Z contains nothing + None +} +impl COption_u16Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> u16 { + if let Self::Some(v) = self { v } else { unreachable!() } } } -impl Clone for CVec_C2Tuple_BlindedPayInfoBlindedPathZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Constructs a new COption_u16Z containing a u16 +pub extern "C" fn COption_u16Z_some(o: u16) -> COption_u16Z { + COption_u16Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_u16Z containing nothing +pub extern "C" fn COption_u16Z_none() -> COption_u16Z { + COption_u16Z::None +} +#[no_mangle] +/// Frees any resources associated with the u16, if we are in the Some state +pub extern "C" fn COption_u16Z_free(_res: COption_u16Z) { } +#[no_mangle] +/// Creates a new COption_u16Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_u16Z_clone(orig: &COption_u16Z) -> COption_u16Z { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a bool or not +pub enum COption_boolZ { + /// When we're in this state, this COption_boolZ contains a bool + Some(bool), + /// When we're in this state, this COption_boolZ contains nothing + None +} +impl COption_boolZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> bool { + if let Self::Some(v) = self { v } else { unreachable!() } } } +#[no_mangle] +/// Constructs a new COption_boolZ containing a bool +pub extern "C" fn COption_boolZ_some(o: bool) -> COption_boolZ { + COption_boolZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_boolZ containing nothing +pub extern "C" fn COption_boolZ_none() -> COption_boolZ { + COption_boolZ::None +} +#[no_mangle] +/// Frees any resources associated with the bool, if we are in the Some state +pub extern "C" fn COption_boolZ_free(_res: COption_boolZ) { } +#[no_mangle] +/// Creates a new COption_boolZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_boolZ_clone(orig: &COption_boolZ) -> COption_boolZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ -pub union CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// The contents of CResult_WitnessNoneZ +pub union CResult_WitnessNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, + pub result: *mut crate::c_types::Witness, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ on success and a () on failure. +/// A CResult_WitnessNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::Witness on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - /// The contents of this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, accessible via either +pub struct CResult_WitnessNoneZ { + /// The contents of this CResult_WitnessNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr, - /// Whether this CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ represents a success state. + pub contents: CResult_WitnessNoneZPtr, + /// Whether this CResult_WitnessNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_ok(o: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// Creates a new CResult_WitnessNoneZ in the success state. +pub extern "C" fn CResult_WitnessNoneZ_ok(o: crate::c_types::Witness) -> CResult_WitnessNoneZ { + CResult_WitnessNoneZ { + contents: CResult_WitnessNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err() -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { +/// Creates a new CResult_WitnessNoneZ in the error state. +pub extern "C" fn CResult_WitnessNoneZ_err() -> CResult_WitnessNoneZ { + CResult_WitnessNoneZ { + contents: CResult_WitnessNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -3626,13 +3550,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_err() -> } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_is_ok(o: &CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) -> bool { +pub extern "C" fn CResult_WitnessNoneZ_is_ok(o: &CResult_WitnessNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_free(_res: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) { } -impl Drop for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +/// Frees any resources used by the CResult_WitnessNoneZ. +pub extern "C" fn CResult_WitnessNoneZ_free(_res: CResult_WitnessNoneZ) { } +impl Drop for CResult_WitnessNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3642,16 +3566,16 @@ impl Drop for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { } } } -impl From> for CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WitnessNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { result } + CResult_WitnessNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { err: core::ptr::null_mut() } + CResult_WitnessNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3659,47 +3583,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_WitnessNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZPtr { + Self { result_ok: false, contents: CResult_WitnessNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ which has the same data as `orig` +/// Creates a new CResult_WitnessNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ_clone(orig: &CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ) -> CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_WitnessNoneZ_clone(orig: &CResult_WitnessNoneZ) -> CResult_WitnessNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// A dynamically-allocated array of crate::c_types::ECDSASignatures of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PublicKeyZ { +pub struct CVec_ECDSASignatureZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::PublicKey, + pub data: *mut crate::c_types::ECDSASignature, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PublicKeyZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ECDSASignatureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ECDSASignature] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PublicKeyZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ECDSASignatureZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -3707,14 +3631,14 @@ impl From> for CVec_PublicKeyZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } -impl Drop for CVec_PublicKeyZ { +pub extern "C" fn CVec_ECDSASignatureZ_free(_res: CVec_ECDSASignatureZ) { } +impl Drop for CVec_ECDSASignatureZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PublicKeyZ { +impl Clone for CVec_ECDSASignatureZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -3723,40 +3647,82 @@ impl Clone for CVec_PublicKeyZ { } } #[repr(C)] -/// The contents of CResult_OnionMessagePathNoneZ -pub union CResult_OnionMessagePathNoneZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { + /// The element at position 0 + pub a: crate::c_types::ECDSASignature, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_ECDSASignatureZ, +} +impl From<(crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ)> for C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { + fn from (tup: (crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ECDSASignature, crate::c_types::derived::CVec_ECDSASignatureZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(orig: &C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) -> C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(a: crate::c_types::ECDSASignature, b: crate::c_types::derived::CVec_ECDSASignatureZ) -> C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { + C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ. +pub extern "C" fn C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(_res: C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ +pub union CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::messenger::OnionMessagePath, + pub result: *mut crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ, /// Note that this value is always NULL, as there are no contents in the Err variant pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_OnionMessagePathNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::messenger::OnionMessagePath on success and a () on failure. +/// A CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OnionMessagePathNoneZ { - /// The contents of this CResult_OnionMessagePathNoneZ, accessible via either +pub struct CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + /// The contents of this CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OnionMessagePathNoneZPtr, - /// Whether this CResult_OnionMessagePathNoneZ represents a success state. + pub contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr, + /// Whether this CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OnionMessagePathNoneZ in the success state. -pub extern "C" fn CResult_OnionMessagePathNoneZ_ok(o: crate::lightning::onion_message::messenger::OnionMessagePath) -> CResult_OnionMessagePathNoneZ { - CResult_OnionMessagePathNoneZ { - contents: CResult_OnionMessagePathNoneZPtr { +/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(o: crate::c_types::derived::C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ) -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OnionMessagePathNoneZ in the error state. -pub extern "C" fn CResult_OnionMessagePathNoneZ_err() -> CResult_OnionMessagePathNoneZ { - CResult_OnionMessagePathNoneZ { - contents: CResult_OnionMessagePathNoneZPtr { +/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err() -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { err: core::ptr::null_mut(), }, result_ok: false, @@ -3764,13 +3730,13 @@ pub extern "C" fn CResult_OnionMessagePathNoneZ_err() -> CResult_OnionMessagePat } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OnionMessagePathNoneZ_is_ok(o: &CResult_OnionMessagePathNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(o: &CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OnionMessagePathNoneZ. -pub extern "C" fn CResult_OnionMessagePathNoneZ_free(_res: CResult_OnionMessagePathNoneZ) { } -impl Drop for CResult_OnionMessagePathNoneZ { +/// Frees any resources used by the CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ. +pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(_res: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) { } +impl Drop for CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3780,16 +3746,16 @@ impl Drop for CResult_OnionMessagePathNoneZ { } } } -impl From> for CResult_OnionMessagePathNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OnionMessagePathNoneZPtr { result } + CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { result } } else { let _ = unsafe { Box::from_raw(o.contents.err) }; o.contents.err = core::ptr::null_mut(); - CResult_OnionMessagePathNoneZPtr { err: core::ptr::null_mut() } + CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -3797,91 +3763,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OnionMessagePathNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OnionMessagePathNoneZPtr { + Self { result_ok: false, contents: CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZPtr { err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_OnionMessagePathNoneZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OnionMessagePathNoneZ_clone(orig: &CResult_OnionMessagePathNoneZ) -> CResult_OnionMessagePathNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(orig: &CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ) -> CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_BlindedPathZNoneZ -pub union CResult_CVec_BlindedPathZNoneZPtr { +/// The contents of CResult_InMemorySignerDecodeErrorZ +pub union CResult_InMemorySignerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_BlindedPathZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::sign::InMemorySigner, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_BlindedPathZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_BlindedPathZ on success and a () on failure. +/// A CResult_InMemorySignerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::sign::InMemorySigner on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_BlindedPathZNoneZ { - /// The contents of this CResult_CVec_BlindedPathZNoneZ, accessible via either +pub struct CResult_InMemorySignerDecodeErrorZ { + /// The contents of this CResult_InMemorySignerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_BlindedPathZNoneZPtr, - /// Whether this CResult_CVec_BlindedPathZNoneZ represents a success state. + pub contents: CResult_InMemorySignerDecodeErrorZPtr, + /// Whether this CResult_InMemorySignerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ in the success state. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedPathZ) -> CResult_CVec_BlindedPathZNoneZ { - CResult_CVec_BlindedPathZNoneZ { - contents: CResult_CVec_BlindedPathZNoneZPtr { +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the success state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::lightning::sign::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ in the error state. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_err() -> CResult_CVec_BlindedPathZNoneZ { - CResult_CVec_BlindedPathZNoneZ { - contents: CResult_CVec_BlindedPathZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_InMemorySignerDecodeErrorZ in the error state. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_is_ok(o: &CResult_CVec_BlindedPathZNoneZ) -> bool { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_is_ok(o: &CResult_InMemorySignerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_BlindedPathZNoneZ. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_free(_res: CResult_CVec_BlindedPathZNoneZ) { } -impl Drop for CResult_CVec_BlindedPathZNoneZ { +/// Frees any resources used by the CResult_InMemorySignerDecodeErrorZ. +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_BlindedPathZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_BlindedPathZNoneZPtr { result } + CResult_InMemorySignerDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CVec_BlindedPathZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -3889,59 +3859,90 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_BlindedPathZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_BlindedPathZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_BlindedPathZNoneZ which has the same data as `orig` +/// Creates a new CResult_InMemorySignerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_BlindedPathZNoneZ_clone(orig: &CResult_CVec_BlindedPathZNoneZ) -> CResult_CVec_BlindedPathZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InFlightHtlcsDecodeErrorZ -pub union CResult_InFlightHtlcsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::InFlightHtlcs, +/// An enum which can either contain a crate::lightning::routing::scoring::WriteableScore or not +pub enum COption_WriteableScoreZ { + /// When we're in this state, this COption_WriteableScoreZ contains a crate::lightning::routing::scoring::WriteableScore + Some(crate::lightning::routing::scoring::WriteableScore), + /// When we're in this state, this COption_WriteableScoreZ contains nothing + None +} +impl COption_WriteableScoreZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::scoring::WriteableScore { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing a crate::lightning::routing::scoring::WriteableScore +pub extern "C" fn COption_WriteableScoreZ_some(o: crate::lightning::routing::scoring::WriteableScore) -> COption_WriteableScoreZ { + COption_WriteableScoreZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_WriteableScoreZ containing nothing +pub extern "C" fn COption_WriteableScoreZ_none() -> COption_WriteableScoreZ { + COption_WriteableScoreZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::scoring::WriteableScore, if we are in the Some state +pub extern "C" fn COption_WriteableScoreZ_free(_res: COption_WriteableScoreZ) { } +#[repr(C)] +/// The contents of CResult_NoneIOErrorZ +pub union CResult_NoneIOErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::IOError, } #[repr(C)] -/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneIOErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::c_types::IOError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InFlightHtlcsDecodeErrorZ { - /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either +pub struct CResult_NoneIOErrorZ { + /// The contents of this CResult_NoneIOErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, - /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. + pub contents: CResult_NoneIOErrorZPtr, + /// Whether this CResult_NoneIOErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneIOErrorZ in the success state. +pub extern "C" fn CResult_NoneIOErrorZ_ok() -> CResult_NoneIOErrorZ { + CResult_NoneIOErrorZ { + contents: CResult_NoneIOErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { - CResult_InFlightHtlcsDecodeErrorZ { - contents: CResult_InFlightHtlcsDecodeErrorZPtr { +/// Creates a new CResult_NoneIOErrorZ in the error state. +pub extern "C" fn CResult_NoneIOErrorZ_err(e: crate::c_types::IOError) -> CResult_NoneIOErrorZ { + CResult_NoneIOErrorZ { + contents: CResult_NoneIOErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -3949,18 +3950,15 @@ pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneIOErrorZ_is_ok(o: &CResult_NoneIOErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } -impl Drop for CResult_InFlightHtlcsDecodeErrorZ { +/// Frees any resources used by the CResult_NoneIOErrorZ. +pub extern "C" fn CResult_NoneIOErrorZ_free(_res: CResult_NoneIOErrorZ) { } +impl Drop for CResult_NoneIOErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -3968,16 +3966,16 @@ impl Drop for CResult_InFlightHtlcsDecodeErrorZ { } } } -impl From> for CResult_InFlightHtlcsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneIOErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InFlightHtlcsDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneIOErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InFlightHtlcsDecodeErrorZPtr { err } + CResult_NoneIOErrorZPtr { err } }; Self { contents, @@ -3985,95 +3983,137 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneIOErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneIOErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneIOErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_RouteHopDecodeErrorZ -pub union CResult_RouteHopDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHop, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NoneIOErrorZ_clone(orig: &CResult_NoneIOErrorZ) -> CResult_NoneIOErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHopDecodeErrorZ { - /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHopDecodeErrorZPtr, - /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::outbound_payment::RecipientOnionFields, + /// The element at position 2 + pub c: crate::lightning::routing::router::RouteParameters, } -#[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)> for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } } } -#[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { - CResult_RouteHopDecodeErrorZ { - contents: CResult_RouteHopDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, +impl C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters) { + (self.a, self.b, self.c) } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { - o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } -impl Drop for CResult_RouteHopDecodeErrorZ { +impl Clone for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(orig: &C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::outbound_payment::RecipientOnionFields, c: crate::lightning::routing::router::RouteParameters) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { + C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. +pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(_res: C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) { } +#[repr(C)] +/// The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ +pub union CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + /// The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr, + /// Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(o: crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err() -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(o: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(_res: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) { } +impl Drop for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHopDecodeErrorZPtr { result } + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHopDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4081,47 +4121,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(orig: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::channel_state::ChannelDetailss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_BlindedHopZ { +pub struct CVec_ChannelDetailsZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::blinded_path::BlindedHop, + pub data: *mut crate::lightning::ln::channel_state::ChannelDetails, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_BlindedHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_ChannelDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channel_state::ChannelDetails] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_BlindedHopZ { - fn from(v: Vec) -> Self { +impl From> for CVec_ChannelDetailsZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -4129,14 +4169,14 @@ impl From> for CVec_BlindedHopZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } -impl Drop for CVec_BlindedHopZ { +pub extern "C" fn CVec_ChannelDetailsZ_free(_res: CVec_ChannelDetailsZ) { } +impl Drop for CVec_ChannelDetailsZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_BlindedHopZ { +impl Clone for CVec_ChannelDetailsZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -4145,41 +4185,41 @@ impl Clone for CVec_BlindedHopZ { } } #[repr(C)] -/// The contents of CResult_BlindedTailDecodeErrorZ -pub union CResult_BlindedTailDecodeErrorZPtr { +/// The contents of CResult_RouteLightningErrorZ +pub union CResult_RouteLightningErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::BlindedTail, + pub result: *mut crate::lightning::routing::router::Route, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteLightningErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedTailDecodeErrorZ { - /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either +pub struct CResult_RouteLightningErrorZ { + /// The contents of this CResult_RouteLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedTailDecodeErrorZPtr, - /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. + pub contents: CResult_RouteLightningErrorZPtr, + /// Whether this CResult_RouteLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the success state. +pub extern "C" fn CResult_RouteLightningErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { - CResult_BlindedTailDecodeErrorZ { - contents: CResult_BlindedTailDecodeErrorZPtr { +/// Creates a new CResult_RouteLightningErrorZ in the error state. +pub extern "C" fn CResult_RouteLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_RouteLightningErrorZ { + CResult_RouteLightningErrorZ { + contents: CResult_RouteLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4187,13 +4227,13 @@ pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteLightningErrorZ_is_ok(o: &CResult_RouteLightningErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } -impl Drop for CResult_BlindedTailDecodeErrorZ { +/// Frees any resources used by the CResult_RouteLightningErrorZ. +pub extern "C" fn CResult_RouteLightningErrorZ_free(_res: CResult_RouteLightningErrorZ) { } +impl Drop for CResult_RouteLightningErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4206,16 +4246,16 @@ impl Drop for CResult_BlindedTailDecodeErrorZ { } } } -impl From> for CResult_BlindedTailDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedTailDecodeErrorZPtr { result } + CResult_RouteLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedTailDecodeErrorZPtr { err } + CResult_RouteLightningErrorZPtr { err } }; Self { contents, @@ -4223,93 +4263,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RouteLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } -impl Drop for CVec_RouteHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_RouteLightningErrorZ_clone(orig: &CResult_RouteLightningErrorZ) -> CResult_RouteLightningErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::payment::BlindedPaymentPaths of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PathZ { +pub struct CVec_BlindedPaymentPathZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::Path, + pub data: *mut crate::lightning::blinded_path::payment::BlindedPaymentPath, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PathZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_BlindedPaymentPathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::payment::BlindedPaymentPath] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PathZ { - fn from(v: Vec) -> Self { +impl From> for CVec_BlindedPaymentPathZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -4317,14 +4311,14 @@ impl From> for CVec_PathZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } -impl Drop for CVec_PathZ { +pub extern "C" fn CVec_BlindedPaymentPathZ_free(_res: CVec_BlindedPaymentPathZ) { } +impl Drop for CVec_BlindedPaymentPathZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PathZ { +impl Clone for CVec_BlindedPaymentPathZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -4333,77 +4327,73 @@ impl Clone for CVec_PathZ { } } #[repr(C)] -/// The contents of CResult_RouteDecodeErrorZ -pub union CResult_RouteDecodeErrorZPtr { +/// The contents of CResult_CVec_BlindedPaymentPathZNoneZ +pub union CResult_CVec_BlindedPaymentPathZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::Route, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_BlindedPaymentPathZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_BlindedPaymentPathZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_BlindedPaymentPathZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteDecodeErrorZ { - /// The contents of this CResult_RouteDecodeErrorZ, accessible via either +pub struct CResult_CVec_BlindedPaymentPathZNoneZ { + /// The contents of this CResult_CVec_BlindedPaymentPathZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteDecodeErrorZPtr, - /// Whether this CResult_RouteDecodeErrorZ represents a success state. + pub contents: CResult_CVec_BlindedPaymentPathZNoneZPtr, + /// Whether this CResult_CVec_BlindedPaymentPathZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the success state. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedPaymentPathZ) -> CResult_CVec_BlindedPaymentPathZNoneZ { + CResult_CVec_BlindedPaymentPathZNoneZ { + contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { - CResult_RouteDecodeErrorZ { - contents: CResult_RouteDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ in the error state. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_err() -> CResult_CVec_BlindedPaymentPathZNoneZ { + CResult_CVec_BlindedPaymentPathZNoneZ { + contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_is_ok(o: &CResult_CVec_BlindedPaymentPathZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteDecodeErrorZ. -pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } -impl Drop for CResult_RouteDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_BlindedPaymentPathZNoneZ. +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_free(_res: CResult_CVec_BlindedPaymentPathZNoneZ) { } +impl Drop for CResult_CVec_BlindedPaymentPathZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_BlindedPaymentPathZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteDecodeErrorZPtr { result } + CResult_CVec_BlindedPaymentPathZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_BlindedPaymentPathZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4411,95 +4401,137 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_BlindedPaymentPathZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_BlindedPaymentPathZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_BlindedPaymentPathZNoneZ_clone(orig: &CResult_CVec_BlindedPaymentPathZNoneZ) -> CResult_CVec_BlindedPaymentPathZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteParametersDecodeErrorZ -pub union CResult_RouteParametersDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PublicKeyZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::PublicKey, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PublicKeyZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PublicKeyZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PublicKeyZ_free(_res: CVec_PublicKeyZ) { } +impl Drop for CVec_PublicKeyZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PublicKeyZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_OnionMessagePathNoneZ +pub union CResult_OnionMessagePathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::onion_message::messenger::OnionMessagePath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OnionMessagePathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::OnionMessagePath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteParametersDecodeErrorZ { - /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either +pub struct CResult_OnionMessagePathNoneZ { + /// The contents of this CResult_OnionMessagePathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteParametersDecodeErrorZPtr, - /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. + pub contents: CResult_OnionMessagePathNoneZPtr, + /// Whether this CResult_OnionMessagePathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { +/// Creates a new CResult_OnionMessagePathNoneZ in the success state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_ok(o: crate::lightning::onion_message::messenger::OnionMessagePath) -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { - CResult_RouteParametersDecodeErrorZ { - contents: CResult_RouteParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_OnionMessagePathNoneZ in the error state. +pub extern "C" fn CResult_OnionMessagePathNoneZ_err() -> CResult_OnionMessagePathNoneZ { + CResult_OnionMessagePathNoneZ { + contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OnionMessagePathNoneZ_is_ok(o: &CResult_OnionMessagePathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } -impl Drop for CResult_RouteParametersDecodeErrorZ { +/// Frees any resources used by the CResult_OnionMessagePathNoneZ. +pub extern "C" fn CResult_OnionMessagePathNoneZ_free(_res: CResult_OnionMessagePathNoneZ) { } +impl Drop for CResult_OnionMessagePathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RouteParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OnionMessagePathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteParametersDecodeErrorZPtr { result } + CResult_OnionMessagePathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteParametersDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_OnionMessagePathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4507,141 +4539,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OnionMessagePathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OnionMessagePathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OnionMessagePathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of u64s of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_u64Z { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut u64, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_u64Z { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_u64Z { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } -impl Drop for CVec_u64Z { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_u64Z { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_OnionMessagePathNoneZ_clone(orig: &CResult_OnionMessagePathNoneZ) -> CResult_OnionMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentParametersDecodeErrorZ -pub union CResult_PaymentParametersDecodeErrorZPtr { +/// The contents of CResult_CVec_BlindedMessagePathZNoneZ +pub union CResult_CVec_BlindedMessagePathZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::PaymentParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_BlindedMessagePathZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_BlindedMessagePathZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_BlindedMessagePathZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentParametersDecodeErrorZ { - /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either +pub struct CResult_CVec_BlindedMessagePathZNoneZ { + /// The contents of this CResult_CVec_BlindedMessagePathZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentParametersDecodeErrorZPtr, - /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub contents: CResult_CVec_BlindedMessagePathZNoneZPtr, + /// Whether this CResult_CVec_BlindedMessagePathZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the success state. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_ok(o: crate::c_types::derived::CVec_BlindedMessagePathZ) -> CResult_CVec_BlindedMessagePathZNoneZ { + CResult_CVec_BlindedMessagePathZNoneZ { + contents: CResult_CVec_BlindedMessagePathZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { - CResult_PaymentParametersDecodeErrorZ { - contents: CResult_PaymentParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ in the error state. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_err() -> CResult_CVec_BlindedMessagePathZNoneZ { + CResult_CVec_BlindedMessagePathZNoneZ { + contents: CResult_CVec_BlindedMessagePathZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_is_ok(o: &CResult_CVec_BlindedMessagePathZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } -impl Drop for CResult_PaymentParametersDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_BlindedMessagePathZNoneZ. +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_free(_res: CResult_CVec_BlindedMessagePathZNoneZ) { } +impl Drop for CResult_CVec_BlindedMessagePathZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_PaymentParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_BlindedMessagePathZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentParametersDecodeErrorZPtr { result } + CResult_CVec_BlindedMessagePathZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentParametersDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_BlindedMessagePathZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -4649,47 +4631,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_BlindedMessagePathZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_BlindedMessagePathZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_BlindedMessagePathZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_BlindedMessagePathZNoneZ_clone(orig: &CResult_CVec_BlindedMessagePathZNoneZ) -> CResult_CVec_BlindedMessagePathZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHints of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::message::MessageForwardNodes of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_RouteHintZ { +pub struct CVec_MessageForwardNodeZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHint, + pub data: *mut crate::lightning::blinded_path::message::MessageForwardNode, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_RouteHintZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_MessageForwardNodeZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::message::MessageForwardNode] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_RouteHintZ { - fn from(v: Vec) -> Self { +impl From> for CVec_MessageForwardNodeZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -4697,14 +4679,14 @@ impl From> for CVec_RouteHintZ } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintZ_free(_res: CVec_RouteHintZ) { } -impl Drop for CVec_RouteHintZ { +pub extern "C" fn CVec_MessageForwardNodeZ_free(_res: CVec_MessageForwardNodeZ) { } +impl Drop for CVec_MessageForwardNodeZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_RouteHintZ { +impl Clone for CVec_MessageForwardNodeZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -4713,87 +4695,41 @@ impl Clone for CVec_RouteHintZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::router::RouteHintHops of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RouteHintHopZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::router::RouteHintHop, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RouteHintHopZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RouteHintHopZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } -impl Drop for CVec_RouteHintHopZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_RouteHintHopZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_RouteHintDecodeErrorZ -pub union CResult_RouteHintDecodeErrorZPtr { +/// The contents of CResult_InFlightHtlcsDecodeErrorZ +pub union CResult_InFlightHtlcsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHint, + pub result: *mut crate::lightning::routing::router::InFlightHtlcs, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InFlightHtlcsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::InFlightHtlcs on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintDecodeErrorZ { - /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either +pub struct CResult_InFlightHtlcsDecodeErrorZ { + /// The contents of this CResult_InFlightHtlcsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintDecodeErrorZPtr, - /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. + pub contents: CResult_InFlightHtlcsDecodeErrorZPtr, + /// Whether this CResult_InFlightHtlcsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHint) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the success state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_ok(o: crate::lightning::routing::router::InFlightHtlcs) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { - CResult_RouteHintDecodeErrorZ { - contents: CResult_RouteHintDecodeErrorZPtr { +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ in the error state. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InFlightHtlcsDecodeErrorZ { + CResult_InFlightHtlcsDecodeErrorZ { + contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4801,13 +4737,13 @@ pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_is_ok(o: &CResult_InFlightHtlcsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } -impl Drop for CResult_RouteHintDecodeErrorZ { +/// Frees any resources used by the CResult_InFlightHtlcsDecodeErrorZ. +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_free(_res: CResult_InFlightHtlcsDecodeErrorZ) { } +impl Drop for CResult_InFlightHtlcsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4820,16 +4756,16 @@ impl Drop for CResult_RouteHintDecodeErrorZ { } } } -impl From> for CResult_RouteHintDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InFlightHtlcsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintDecodeErrorZPtr { result } + CResult_InFlightHtlcsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintDecodeErrorZPtr { err } + CResult_InFlightHtlcsDecodeErrorZPtr { err } }; Self { contents, @@ -4837,59 +4773,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InFlightHtlcsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InFlightHtlcsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InFlightHtlcsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InFlightHtlcsDecodeErrorZ_clone(orig: &CResult_InFlightHtlcsDecodeErrorZ) -> CResult_InFlightHtlcsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RouteHintHopDecodeErrorZ -pub union CResult_RouteHintHopDecodeErrorZPtr { +/// The contents of CResult_RouteHopDecodeErrorZ +pub union CResult_RouteHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::router::RouteHintHop, + pub result: *mut crate::lightning::routing::router::RouteHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::router::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RouteHintHopDecodeErrorZ { - /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either +pub struct CResult_RouteHopDecodeErrorZ { + /// The contents of this CResult_RouteHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RouteHintHopDecodeErrorZPtr, - /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. + pub contents: CResult_RouteHopDecodeErrorZPtr, + /// Whether this CResult_RouteHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteHop) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { - CResult_RouteHintHopDecodeErrorZ { - contents: CResult_RouteHintHopDecodeErrorZPtr { +/// Creates a new CResult_RouteHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHopDecodeErrorZ { + CResult_RouteHopDecodeErrorZ { + contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4897,13 +4833,13 @@ pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHopDecodeErrorZ_is_ok(o: &CResult_RouteHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } -impl Drop for CResult_RouteHintHopDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHopDecodeErrorZ_free(_res: CResult_RouteHopDecodeErrorZ) { } +impl Drop for CResult_RouteHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4916,16 +4852,16 @@ impl Drop for CResult_RouteHintHopDecodeErrorZ { } } } -impl From> for CResult_RouteHintHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RouteHintHopDecodeErrorZPtr { result } + CResult_RouteHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RouteHintHopDecodeErrorZPtr { err } + CResult_RouteHopDecodeErrorZPtr { err } }; Self { contents, @@ -4933,59 +4869,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHopDecodeErrorZ_clone(orig: &CResult_RouteHopDecodeErrorZ) -> CResult_RouteHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ -pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::blinded_path::BlindedHops of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BlindedHopZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::blinded_path::BlindedHop, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BlindedHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::BlindedHop] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BlindedHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_BlindedHopZ_free(_res: CVec_BlindedHopZ) { } +impl Drop for CVec_BlindedHopZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_BlindedHopZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_BlindedTailDecodeErrorZ +pub union CResult_BlindedTailDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, + pub result: *mut crate::lightning::routing::router::BlindedTail, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedTailDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::BlindedTail on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FixedPenaltyScorerDecodeErrorZ { - /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either +pub struct CResult_BlindedTailDecodeErrorZ { + /// The contents of this CResult_BlindedTailDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, - /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. + pub contents: CResult_BlindedTailDecodeErrorZPtr, + /// Whether this CResult_BlindedTailDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_ok(o: crate::lightning::routing::router::BlindedTail) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { - CResult_FixedPenaltyScorerDecodeErrorZ { - contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { +/// Creates a new CResult_BlindedTailDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedTailDecodeErrorZ { + CResult_BlindedTailDecodeErrorZ { + contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -4993,13 +4975,13 @@ pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_is_ok(o: &CResult_BlindedTailDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } -impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedTailDecodeErrorZ. +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_free(_res: CResult_BlindedTailDecodeErrorZ) { } +impl Drop for CResult_BlindedTailDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5012,16 +4994,16 @@ impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { } } } -impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedTailDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FixedPenaltyScorerDecodeErrorZPtr { result } + CResult_BlindedTailDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FixedPenaltyScorerDecodeErrorZPtr { err } + CResult_BlindedTailDecodeErrorZPtr { err } }; Self { contents, @@ -5029,47 +5011,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedTailDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedTailDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedTailDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedTailDecodeErrorZ_clone(orig: &CResult_BlindedTailDecodeErrorZ) -> CResult_BlindedTailDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. +/// A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_NodeIdZ { +pub struct CVec_RouteHopZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::routing::gossip::NodeId, + pub data: *mut crate::lightning::routing::router::RouteHop, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_NodeIdZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::gossip::NodeId] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_NodeIdZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHopZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -5077,14 +5059,14 @@ impl From> for CVec_NodeIdZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_NodeIdZ_free(_res: CVec_NodeIdZ) { } -impl Drop for CVec_NodeIdZ { +pub extern "C" fn CVec_RouteHopZ_free(_res: CVec_RouteHopZ) { } +impl Drop for CVec_RouteHopZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_NodeIdZ { +impl Clone for CVec_RouteHopZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -5093,249 +5075,183 @@ impl Clone for CVec_NodeIdZ { } } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u64u64Z { - /// The element at position 0 - pub a: u64, - /// The element at position 1 - pub b: u64, +/// A dynamically-allocated array of crate::lightning::routing::router::Paths of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PathZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::router::Path, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From<(u64, u64)> for C2Tuple_u64u64Z { - fn from (tup: (u64, u64)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +impl CVec_PathZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -impl C2Tuple_u64u64Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { - (self.a, self.b) + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::Path] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl Clone for C2Tuple_u64u64Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +impl From> for CVec_PathZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_u64u64Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { - C2Tuple_u64u64Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u64u64Z. -pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not -pub enum COption_C2Tuple_u64u64ZZ { - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z - Some(crate::c_types::derived::C2Tuple_u64u64Z), - /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing - None -} -impl COption_C2Tuple_u64u64ZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { - if let Self::Some(v) = self { v } else { unreachable!() } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PathZ_free(_res: CVec_PathZ) { } +impl Drop for CVec_PathZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -#[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z -pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::Some(o) +impl Clone for CVec_PathZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } -#[no_mangle] -/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing -pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { - COption_C2Tuple_u64u64ZZ::None +#[repr(C)] +/// The contents of CResult_RouteDecodeErrorZ +pub union CResult_RouteDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::Route, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } -#[no_mangle] -/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_Z { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoU16s, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoU16s, +/// A CResult_RouteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::Route on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RouteDecodeErrorZ { + /// The contents of this CResult_RouteDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RouteDecodeErrorZPtr, + /// Whether this CResult_RouteDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl From<(crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)> for C2Tuple_Z { - fn from (tup: (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)) -> Self { - Self { - a: tup.0, - b: tup.1, - } +#[no_mangle] +/// Creates a new CResult_RouteDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteDecodeErrorZ_ok(o: crate::lightning::routing::router::Route) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl C2Tuple_Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_RouteDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteDecodeErrorZ { + CResult_RouteDecodeErrorZ { + contents: CResult_RouteDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -/// Creates a new C2Tuple_Z from the contained elements. +/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::ThirtyTwoU16s, b: crate::c_types::ThirtyTwoU16s) -> C2Tuple_Z { - C2Tuple_Z { a, b, } +pub extern "C" fn CResult_RouteDecodeErrorZ_is_ok(o: &CResult_RouteDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_Z. -pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u1632_u1632Z { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoU16s, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoU16s, +/// Frees any resources used by the CResult_RouteDecodeErrorZ. +pub extern "C" fn CResult_RouteDecodeErrorZ_free(_res: CResult_RouteDecodeErrorZ) { } +impl Drop for CResult_RouteDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } } -impl From<(crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)> for C2Tuple__u1632_u1632Z { - fn from (tup: (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)) -> Self { +impl From> for CResult_RouteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_RouteDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_RouteDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple__u1632_u1632Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s) { - (self.a, self.b) +impl Clone for CResult_RouteDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_RouteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RouteDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } -/// Creates a new C2Tuple__u1632_u1632Z from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple__u1632_u1632Z_new(a: crate::c_types::ThirtyTwoU16s, b: crate::c_types::ThirtyTwoU16s) -> C2Tuple__u1632_u1632Z { - C2Tuple__u1632_u1632Z { a, b, } +/// Creates a new CResult_RouteDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_RouteDecodeErrorZ_clone(orig: &CResult_RouteDecodeErrorZ) -> CResult_RouteDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_RouteParametersDecodeErrorZ +pub union CResult_RouteParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::RouteParameters, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u1632_u1632Z. -pub extern "C" fn C2Tuple__u1632_u1632Z_free(_res: C2Tuple__u1632_u1632Z) { } #[repr(C)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple__u1632_u1632Z or not -pub enum COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { - /// When we're in this state, this COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ contains a crate::c_types::derived::C2Tuple__u1632_u1632Z - Some(crate::c_types::derived::C2Tuple__u1632_u1632Z), - /// When we're in this state, this COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ contains nothing - None -} -impl COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u1632_u1632Z { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ containing a crate::c_types::derived::C2Tuple__u1632_u1632Z -pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(o: crate::c_types::derived::C2Tuple__u1632_u1632Z) -> COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { - COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ containing nothing -pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none() -> COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { - COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u1632_u1632Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(_res: COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ) { } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a f64 or not -pub enum COption_f64Z { - /// When we're in this state, this COption_f64Z contains a f64 - Some(f64), - /// When we're in this state, this COption_f64Z contains nothing - None -} -impl COption_f64Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> f64 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_f64Z containing a f64 -pub extern "C" fn COption_f64Z_some(o: f64) -> COption_f64Z { - COption_f64Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_f64Z containing nothing -pub extern "C" fn COption_f64Z_none() -> COption_f64Z { - COption_f64Z::None -} -#[no_mangle] -/// Frees any resources associated with the f64, if we are in the Some state -pub extern "C" fn COption_f64Z_free(_res: COption_f64Z) { } -#[no_mangle] -/// Creates a new COption_f64Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_f64Z_clone(orig: &COption_f64Z) -> COption_f64Z { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ProbabilisticScorerDecodeErrorZ -pub union CResult_ProbabilisticScorerDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} -#[repr(C)] -/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::RouteParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ProbabilisticScorerDecodeErrorZ { - /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either +pub struct CResult_RouteParametersDecodeErrorZ { + /// The contents of this CResult_RouteParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, - /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. + pub contents: CResult_RouteParametersDecodeErrorZPtr, + /// Whether this CResult_RouteParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::RouteParameters) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { - CResult_ProbabilisticScorerDecodeErrorZ { - contents: CResult_ProbabilisticScorerDecodeErrorZPtr { +/// Creates a new CResult_RouteParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteParametersDecodeErrorZ { + CResult_RouteParametersDecodeErrorZ { + contents: CResult_RouteParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5343,13 +5259,13 @@ pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_is_ok(o: &CResult_RouteParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. -pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } -impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { +/// Frees any resources used by the CResult_RouteParametersDecodeErrorZ. +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_free(_res: CResult_RouteParametersDecodeErrorZ) { } +impl Drop for CResult_RouteParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5362,16 +5278,16 @@ impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { } } } -impl From> for CResult_ProbabilisticScorerDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ProbabilisticScorerDecodeErrorZPtr { result } + CResult_RouteParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ProbabilisticScorerDecodeErrorZPtr { err } + CResult_RouteParametersDecodeErrorZPtr { err } }; Self { contents, @@ -5379,72 +5295,47 @@ impl From for C2Tuple_usizeTransactionZ { - fn from (tup: (usize, crate::c_types::Transaction)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_usizeTransactionZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_usizeTransactionZ { +impl Clone for CResult_RouteParametersDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_RouteParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_RouteParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_RouteParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { - C2Tuple_usizeTransactionZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_usizeTransactionZ. -pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } +pub extern "C" fn CResult_RouteParametersDecodeErrorZ_clone(orig: &CResult_RouteParametersDecodeErrorZ) -> CResult_RouteParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// A dynamically-allocated array of u64s of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_usizeTransactionZZ { +pub struct CVec_u64Z { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + pub data: *mut u64, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_usizeTransactionZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_u64Z { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_usizeTransactionZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_u64Z { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -5452,14 +5343,14 @@ impl From> for CVec_C2Tu } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } -impl Drop for CVec_C2Tuple_usizeTransactionZZ { +pub extern "C" fn CVec_u64Z_free(_res: CVec_u64Z) { } +impl Drop for CVec_u64Z { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_usizeTransactionZZ { +impl Clone for CVec_u64Z { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -5468,165 +5359,77 @@ impl Clone for CVec_C2Tuple_usizeTransactionZZ { } } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: u32, - /// The element at position 2 - pub c: crate::c_types::derived::COption_ThirtyTwoBytesZ, +/// The contents of CResult_PaymentParametersDecodeErrorZ +pub union CResult_PaymentParametersDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::router::PaymentParameters, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ)> for C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } +#[repr(C)] +/// A CResult_PaymentParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::router::PaymentParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentParametersDecodeErrorZ { + /// The contents of this CResult_PaymentParametersDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentParametersDecodeErrorZPtr, + /// Whether this CResult_PaymentParametersDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ) { - (self.a, self.b, self.c) +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_ok(o: crate::lightning::routing::router::PaymentParameters) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } +#[no_mangle] +/// Creates a new CResult_PaymentParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentParametersDecodeErrorZ { + CResult_PaymentParametersDecodeErrorZ { + contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_clone(orig: &C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ) -> C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_new(a: crate::c_types::ThirtyTwoBytes, b: u32, c: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { - C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ. -pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_free(_res: C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ_free(_res: CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ) { } -impl Drop for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_ChannelMonitorUpdateStatusNoneZ -pub union CResult_ChannelMonitorUpdateStatusNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::ChannelMonitorUpdateStatus, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} -#[repr(C)] -/// A CResult_ChannelMonitorUpdateStatusNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::ChannelMonitorUpdateStatus on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelMonitorUpdateStatusNoneZ { - /// The contents of this CResult_ChannelMonitorUpdateStatusNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelMonitorUpdateStatusNoneZPtr, - /// Whether this CResult_ChannelMonitorUpdateStatusNoneZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ in the success state. -pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_ok(o: crate::lightning::chain::ChannelMonitorUpdateStatus) -> CResult_ChannelMonitorUpdateStatusNoneZ { - CResult_ChannelMonitorUpdateStatusNoneZ { - contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ in the error state. -pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_err() -> CResult_ChannelMonitorUpdateStatusNoneZ { - CResult_ChannelMonitorUpdateStatusNoneZ { - contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(o: &CResult_ChannelMonitorUpdateStatusNoneZ) -> bool { +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_is_ok(o: &CResult_PaymentParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelMonitorUpdateStatusNoneZ. -pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_free(_res: CResult_ChannelMonitorUpdateStatusNoneZ) { } -impl Drop for CResult_ChannelMonitorUpdateStatusNoneZ { +/// Frees any resources used by the CResult_PaymentParametersDecodeErrorZ. +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_free(_res: CResult_PaymentParametersDecodeErrorZ) { } +impl Drop for CResult_PaymentParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_ChannelMonitorUpdateStatusNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelMonitorUpdateStatusNoneZPtr { result } + CResult_PaymentParametersDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_ChannelMonitorUpdateStatusNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PaymentParametersDecodeErrorZPtr { err } }; Self { contents, @@ -5634,139 +5437,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PaymentParametersDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_clone(orig: &CResult_ChannelMonitorUpdateStatusNoneZ) -> CResult_ChannelMonitorUpdateStatusNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MonitorEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MonitorEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MonitorEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } -impl Drop for CVec_MonitorEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MonitorEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorEventZ, - /// The element at position 2 - pub c: crate::c_types::PublicKey, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_PaymentParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig: &C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorEventZ, c: crate::c_types::PublicKey) -> C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { - C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ. -pub extern "C" fn C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res: C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) { } +pub extern "C" fn CResult_PaymentParametersDecodeErrorZ_clone(orig: &CResult_PaymentParametersDecodeErrorZ) -> CResult_PaymentParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning_types::routing::RouteHints of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { +pub struct CVec_RouteHintZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ, + pub data: *mut crate::lightning_types::routing::RouteHint, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_RouteHintZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_types::routing::RouteHint] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_RouteHintZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -5774,14 +5485,14 @@ impl From Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -5790,41 +5501,41 @@ impl Clone for CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { } } #[repr(C)] -/// The contents of CResult_InitFeaturesDecodeErrorZ -pub union CResult_InitFeaturesDecodeErrorZPtr { +/// The contents of CResult_RouteHintDecodeErrorZ +pub union CResult_RouteHintDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::InitFeatures, + pub result: *mut crate::lightning_types::routing::RouteHint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHintDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::routing::RouteHint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitFeaturesDecodeErrorZ { - /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either +pub struct CResult_RouteHintDecodeErrorZ { + /// The contents of this CResult_RouteHintDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitFeaturesDecodeErrorZPtr, - /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_RouteHintDecodeErrorZPtr, + /// Whether this CResult_RouteHintDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_ok(o: crate::lightning_types::routing::RouteHint) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { - CResult_InitFeaturesDecodeErrorZ { - contents: CResult_InitFeaturesDecodeErrorZPtr { +/// Creates a new CResult_RouteHintDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintDecodeErrorZ { + CResult_RouteHintDecodeErrorZ { + contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5832,13 +5543,13 @@ pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHintDecodeErrorZ_is_ok(o: &CResult_RouteHintDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } -impl Drop for CResult_InitFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHintDecodeErrorZ. +pub extern "C" fn CResult_RouteHintDecodeErrorZ_free(_res: CResult_RouteHintDecodeErrorZ) { } +impl Drop for CResult_RouteHintDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5851,16 +5562,16 @@ impl Drop for CResult_InitFeaturesDecodeErrorZ { } } } -impl From> for CResult_InitFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHintDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitFeaturesDecodeErrorZPtr { result } + CResult_RouteHintDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitFeaturesDecodeErrorZPtr { err } + CResult_RouteHintDecodeErrorZPtr { err } }; Self { contents, @@ -5868,59 +5579,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHintDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHintDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHintDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHintDecodeErrorZ_clone(orig: &CResult_RouteHintDecodeErrorZ) -> CResult_RouteHintDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelFeaturesDecodeErrorZ -pub union CResult_ChannelFeaturesDecodeErrorZPtr { +/// The contents of CResult_RouteHintHopDecodeErrorZ +pub union CResult_RouteHintHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelFeatures, + pub result: *mut crate::lightning_types::routing::RouteHintHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RouteHintHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::routing::RouteHintHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either +pub struct CResult_RouteHintHopDecodeErrorZ { + /// The contents of this CResult_RouteHintHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_RouteHintHopDecodeErrorZPtr, + /// Whether this CResult_RouteHintHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_ok(o: crate::lightning_types::routing::RouteHintHop) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { - CResult_ChannelFeaturesDecodeErrorZ { - contents: CResult_ChannelFeaturesDecodeErrorZPtr { +/// Creates a new CResult_RouteHintHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RouteHintHopDecodeErrorZ { + CResult_RouteHintHopDecodeErrorZ { + contents: CResult_RouteHintHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -5928,13 +5639,13 @@ pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_is_ok(o: &CResult_RouteHintHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_RouteHintHopDecodeErrorZ. +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_free(_res: CResult_RouteHintHopDecodeErrorZ) { } +impl Drop for CResult_RouteHintHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -5947,16 +5658,16 @@ impl Drop for CResult_ChannelFeaturesDecodeErrorZ { } } } -impl From> for CResult_ChannelFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RouteHintHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelFeaturesDecodeErrorZPtr { result } + CResult_RouteHintHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelFeaturesDecodeErrorZPtr { err } + CResult_RouteHintHopDecodeErrorZPtr { err } }; Self { contents, @@ -5964,59 +5675,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RouteHintHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RouteHintHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RouteHintHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RouteHintHopDecodeErrorZ_clone(orig: &CResult_RouteHintHopDecodeErrorZ) -> CResult_RouteHintHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeFeaturesDecodeErrorZ -pub union CResult_NodeFeaturesDecodeErrorZPtr { +/// The contents of CResult_FixedPenaltyScorerDecodeErrorZ +pub union CResult_FixedPenaltyScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::NodeFeatures, + pub result: *mut crate::lightning::routing::scoring::FixedPenaltyScorer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_FixedPenaltyScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::FixedPenaltyScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeFeaturesDecodeErrorZ { - /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either +pub struct CResult_FixedPenaltyScorerDecodeErrorZ { + /// The contents of this CResult_FixedPenaltyScorerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeFeaturesDecodeErrorZPtr, - /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_FixedPenaltyScorerDecodeErrorZPtr, + /// Whether this CResult_FixedPenaltyScorerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::FixedPenaltyScorer) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { - CResult_NodeFeaturesDecodeErrorZ { - contents: CResult_NodeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FixedPenaltyScorerDecodeErrorZ { + CResult_FixedPenaltyScorerDecodeErrorZ { + contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6024,13 +5735,13 @@ pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o: &CResult_FixedPenaltyScorerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } -impl Drop for CResult_NodeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_FixedPenaltyScorerDecodeErrorZ. +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_free(_res: CResult_FixedPenaltyScorerDecodeErrorZ) { } +impl Drop for CResult_FixedPenaltyScorerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6043,16 +5754,16 @@ impl Drop for CResult_NodeFeaturesDecodeErrorZ { } } } -impl From> for CResult_NodeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FixedPenaltyScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeFeaturesDecodeErrorZPtr { result } + CResult_FixedPenaltyScorerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeFeaturesDecodeErrorZPtr { err } + CResult_FixedPenaltyScorerDecodeErrorZPtr { err } }; Self { contents, @@ -6060,155 +5771,313 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_FixedPenaltyScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FixedPenaltyScorerDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_Bolt11InvoiceFeaturesDecodeErrorZ -pub union CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::Bolt11InvoiceFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig: &CResult_FixedPenaltyScorerDecodeErrorZ) -> CResult_FixedPenaltyScorerDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - /// The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr, - /// Whether this CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::routing::gossip::NodeIds of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_NodeIdZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::routing::gossip::NodeId, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_NodeIdZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::gossip::NodeId] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_NodeIdZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_Bolt11InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt11InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_NodeIdZ_free(_res: CVec_NodeIdZ) { } +impl Drop for CVec_NodeIdZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err } - }; +impl Clone for CVec_NodeIdZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u64u64Z { + /// The element at position 0 + pub a: u64, + /// The element at position 1 + pub b: u64, +} +impl From<(u64, u64)> for C2Tuple_u64u64Z { + fn from (tup: (u64, u64)) -> Self { Self { - contents, - result_ok: o.result_ok, + a: tup.0, + b: tup.1, } } } -impl Clone for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { +impl C2Tuple_u64u64Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u64) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u64u64Z { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_u64u64Z_clone(orig: &C2Tuple_u64u64Z) -> C2Tuple_u64u64Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_u64u64Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u64u64Z_new(a: u64, b: u64) -> C2Tuple_u64u64Z { + C2Tuple_u64u64Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u64u64Z. +pub extern "C" fn C2Tuple_u64u64Z_free(_res: C2Tuple_u64u64Z) { } #[repr(C)] -/// The contents of CResult_Bolt12InvoiceFeaturesDecodeErrorZ -pub union CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u64Z or not +pub enum COption_C2Tuple_u64u64ZZ { + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains a crate::c_types::derived::C2Tuple_u64u64Z + Some(crate::c_types::derived::C2Tuple_u64u64Z), + /// When we're in this state, this COption_C2Tuple_u64u64ZZ contains nothing + None +} +impl COption_C2Tuple_u64u64ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u64Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u64ZZ containing a crate::c_types::derived::C2Tuple_u64u64Z +pub extern "C" fn COption_C2Tuple_u64u64ZZ_some(o: crate::c_types::derived::C2Tuple_u64u64Z) -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u64ZZ containing nothing +pub extern "C" fn COption_C2Tuple_u64u64ZZ_none() -> COption_C2Tuple_u64u64ZZ { + COption_C2Tuple_u64u64ZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u64Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_u64u64ZZ_free(_res: COption_C2Tuple_u64u64ZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_u64u64ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_u64u64ZZ_clone(orig: &COption_C2Tuple_u64u64ZZ) -> COption_C2Tuple_u64u64ZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_Z { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoU16s, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoU16s, +} +impl From<(crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)> for C2Tuple_Z { + fn from (tup: (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_Z_new(a: crate::c_types::ThirtyTwoU16s, b: crate::c_types::ThirtyTwoU16s) -> C2Tuple_Z { + C2Tuple_Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_Z. +pub extern "C" fn C2Tuple_Z_free(_res: C2Tuple_Z) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u1632_u1632Z { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoU16s, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoU16s, +} +impl From<(crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)> for C2Tuple__u1632_u1632Z { + fn from (tup: (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple__u1632_u1632Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoU16s, crate::c_types::ThirtyTwoU16s) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple__u1632_u1632Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u1632_u1632Z_new(a: crate::c_types::ThirtyTwoU16s, b: crate::c_types::ThirtyTwoU16s) -> C2Tuple__u1632_u1632Z { + C2Tuple__u1632_u1632Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u1632_u1632Z. +pub extern "C" fn C2Tuple__u1632_u1632Z_free(_res: C2Tuple__u1632_u1632Z) { } +#[repr(C)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple__u1632_u1632Z or not +pub enum COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { + /// When we're in this state, this COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ contains a crate::c_types::derived::C2Tuple__u1632_u1632Z + Some(crate::c_types::derived::C2Tuple__u1632_u1632Z), + /// When we're in this state, this COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ contains nothing + None +} +impl COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple__u1632_u1632Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ containing a crate::c_types::derived::C2Tuple__u1632_u1632Z +pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(o: crate::c_types::derived::C2Tuple__u1632_u1632Z) -> COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { + COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ containing nothing +pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none() -> COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ { + COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple__u1632_u1632Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(_res: COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a f64 or not +pub enum COption_f64Z { + /// When we're in this state, this COption_f64Z contains a f64 + Some(f64), + /// When we're in this state, this COption_f64Z contains nothing + None +} +impl COption_f64Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> f64 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_f64Z containing a f64 +pub extern "C" fn COption_f64Z_some(o: f64) -> COption_f64Z { + COption_f64Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_f64Z containing nothing +pub extern "C" fn COption_f64Z_none() -> COption_f64Z { + COption_f64Z::None +} +#[no_mangle] +/// Frees any resources associated with the f64, if we are in the Some state +pub extern "C" fn COption_f64Z_free(_res: COption_f64Z) { } +#[no_mangle] +/// Creates a new COption_f64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_f64Z_clone(orig: &COption_f64Z) -> COption_f64Z { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ProbabilisticScorerDecodeErrorZ +pub union CResult_ProbabilisticScorerDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::Bolt12InvoiceFeatures, + pub result: *mut crate::lightning::routing::scoring::ProbabilisticScorer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ProbabilisticScorerDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::scoring::ProbabilisticScorer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - /// The contents of this CResult_Bolt12InvoiceFeaturesDecodeErrorZ, accessible via either +pub struct CResult_ProbabilisticScorerDecodeErrorZ { + /// The contents of this CResult_ProbabilisticScorerDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr, - /// Whether this CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_ProbabilisticScorerDecodeErrorZPtr, + /// Whether this CResult_ProbabilisticScorerDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the success state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_ok(o: crate::lightning::routing::scoring::ProbabilisticScorer) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ProbabilisticScorerDecodeErrorZ in the error state. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ProbabilisticScorerDecodeErrorZ { + CResult_ProbabilisticScorerDecodeErrorZ { + contents: CResult_ProbabilisticScorerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6216,13 +6085,13 @@ pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o: &CResult_ProbabilisticScorerDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_Bolt12InvoiceFeaturesDecodeErrorZ. -pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt12InvoiceFeaturesDecodeErrorZ) { } -impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ProbabilisticScorerDecodeErrorZ. +pub extern "C" fn CResult_ProbabilisticScorerDecodeErrorZ_free(_res: CResult_ProbabilisticScorerDecodeErrorZ) { } +impl Drop for CResult_ProbabilisticScorerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6235,16 +6104,16 @@ impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { } } } -impl From> for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ProbabilisticScorerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { result } + CResult_ProbabilisticScorerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { err } + CResult_ProbabilisticScorerDecodeErrorZPtr { err } }; Self { contents, @@ -6252,59 +6121,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ -pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { +/// The contents of CResult_BestBlockDecodeErrorZ +pub union CResult_BestBlockDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::BlindedHopFeatures, + pub result: *mut crate::lightning::chain::BestBlock, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BestBlockDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::BestBlock on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopFeaturesDecodeErrorZ { - /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either +pub struct CResult_BestBlockDecodeErrorZ { + /// The contents of this CResult_BestBlockDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, - /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_BestBlockDecodeErrorZPtr, + /// Whether this CResult_BestBlockDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { +/// Creates a new CResult_BestBlockDecodeErrorZ in the success state. +pub extern "C" fn CResult_BestBlockDecodeErrorZ_ok(o: crate::lightning::chain::BestBlock) -> CResult_BestBlockDecodeErrorZ { + CResult_BestBlockDecodeErrorZ { + contents: CResult_BestBlockDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { - CResult_BlindedHopFeaturesDecodeErrorZ { - contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { +/// Creates a new CResult_BestBlockDecodeErrorZ in the error state. +pub extern "C" fn CResult_BestBlockDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BestBlockDecodeErrorZ { + CResult_BestBlockDecodeErrorZ { + contents: CResult_BestBlockDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6312,13 +6164,13 @@ pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BestBlockDecodeErrorZ_is_ok(o: &CResult_BestBlockDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } -impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_BestBlockDecodeErrorZ. +pub extern "C" fn CResult_BestBlockDecodeErrorZ_free(_res: CResult_BestBlockDecodeErrorZ) { } +impl Drop for CResult_BestBlockDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6331,16 +6183,16 @@ impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { } } } -impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BestBlockDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopFeaturesDecodeErrorZPtr { result } + CResult_BestBlockDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopFeaturesDecodeErrorZPtr { err } + CResult_BestBlockDecodeErrorZPtr { err } }; Self { contents, @@ -6348,95 +6200,271 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BestBlockDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BestBlockDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BestBlockDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BestBlockDecodeErrorZ_clone(orig: &CResult_BestBlockDecodeErrorZ) -> CResult_BestBlockDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ -pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::features::ChannelTypeFeatures, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_usizeTransactionZ { + /// The element at position 0 + pub a: usize, + /// The element at position 1 + pub b: crate::c_types::Transaction, +} +impl From<(usize, crate::c_types::Transaction)> for C2Tuple_usizeTransactionZ { + fn from (tup: (usize, crate::c_types::Transaction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_usizeTransactionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (usize, crate::c_types::Transaction) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_usizeTransactionZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_usizeTransactionZ_clone(orig: &C2Tuple_usizeTransactionZ) -> C2Tuple_usizeTransactionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_usizeTransactionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_usizeTransactionZ_new(a: usize, b: crate::c_types::Transaction) -> C2Tuple_usizeTransactionZ { + C2Tuple_usizeTransactionZ { a, b, } } + +#[no_mangle] +/// Frees any resources used by the C2Tuple_usizeTransactionZ. +pub extern "C" fn C2Tuple_usizeTransactionZ_free(_res: C2Tuple_usizeTransactionZ) { } #[repr(C)] -/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_usizeTransactionZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_usizeTransactionZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_usizeTransactionZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_usizeTransactionZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_usizeTransactionZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_usizeTransactionZZ_free(_res: CVec_C2Tuple_usizeTransactionZZ) { } +impl Drop for CVec_C2Tuple_usizeTransactionZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_usizeTransactionZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: u32, + /// The element at position 2 + pub c: crate::c_types::derived::COption_ThirtyTwoBytesZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ)> for C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u32, crate::c_types::derived::COption_ThirtyTwoBytesZ) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_clone(orig: &C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ) -> C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_new(a: crate::c_types::ThirtyTwoBytes, b: u32, c: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { + C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ. +pub extern "C" fn C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ_free(_res: C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ_free(_res: CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ) { } +impl Drop for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_ChannelMonitorUpdateStatusNoneZ +pub union CResult_ChannelMonitorUpdateStatusNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::chain::ChannelMonitorUpdateStatus, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_ChannelMonitorUpdateStatusNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::ChannelMonitorUpdateStatus on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { - /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either +pub struct CResult_ChannelMonitorUpdateStatusNoneZ { + /// The contents of this CResult_ChannelMonitorUpdateStatusNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, - /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. + pub contents: CResult_ChannelMonitorUpdateStatusNoneZPtr, + /// Whether this CResult_ChannelMonitorUpdateStatusNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning::ln::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { +/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ in the success state. +pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_ok(o: crate::lightning::chain::ChannelMonitorUpdateStatus) -> CResult_ChannelMonitorUpdateStatusNoneZ { + CResult_ChannelMonitorUpdateStatusNoneZ { + contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { - CResult_ChannelTypeFeaturesDecodeErrorZ { - contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ in the error state. +pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_err() -> CResult_ChannelMonitorUpdateStatusNoneZ { + CResult_ChannelMonitorUpdateStatusNoneZ { + contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(o: &CResult_ChannelMonitorUpdateStatusNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } -impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelMonitorUpdateStatusNoneZ. +pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_free(_res: CResult_ChannelMonitorUpdateStatusNoneZ) { } +impl Drop for CResult_ChannelMonitorUpdateStatusNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelMonitorUpdateStatusNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } + CResult_ChannelMonitorUpdateStatusNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_ChannelMonitorUpdateStatusNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -6444,59 +6472,201 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelMonitorUpdateStatusNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelMonitorUpdateStatusNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelMonitorUpdateStatusNoneZ_clone(orig: &CResult_ChannelMonitorUpdateStatusNoneZ) -> CResult_ChannelMonitorUpdateStatusNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OfferBolt12ParseErrorZ -pub union CResult_OfferBolt12ParseErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::offer::Offer, +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::MonitorEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MonitorEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::MonitorEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MonitorEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MonitorEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MonitorEventZ_free(_res: CVec_MonitorEventZ) { } +impl Drop for CVec_MonitorEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_MonitorEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 4 elements. See the individual fields for the types contained. +pub struct C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::lightning::ln::types::ChannelId, + /// The element at position 2 + pub c: crate::c_types::derived::CVec_MonitorEventZ, + /// The element at position 3 + pub d: crate::c_types::PublicKey, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)> for C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + d: tup.3, + } + } +} +impl C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId, crate::c_types::derived::CVec_MonitorEventZ, crate::c_types::PublicKey) { + (self.a, self.b, self.c, self.d) + } +} +impl Clone for C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + d: Clone::clone(&self.d), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_clone(orig: &C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ) -> C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { Clone::clone(&orig) } +/// Creates a new C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ from the contained elements. +#[no_mangle] +pub extern "C" fn C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::lightning::ln::types::ChannelId, c: crate::c_types::derived::CVec_MonitorEventZ, d: crate::c_types::PublicKey) -> C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { + C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ { a, b, c, d, } +} + +#[no_mangle] +/// Frees any resources used by the C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ. +pub extern "C" fn C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ_free(_res: C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ_free(_res: CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ) { } +impl Drop for CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_InitFeaturesDecodeErrorZ +pub union CResult_InitFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_types::features::InitFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. +/// A CResult_InitFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::InitFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OfferBolt12ParseErrorZ { - /// The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either +pub struct CResult_InitFeaturesDecodeErrorZ { + /// The contents of this CResult_InitFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OfferBolt12ParseErrorZPtr, - /// Whether this CResult_OfferBolt12ParseErrorZ represents a success state. + pub contents: CResult_InitFeaturesDecodeErrorZPtr, + /// Whether this CResult_InitFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OfferBolt12ParseErrorZ in the success state. -pub extern "C" fn CResult_OfferBolt12ParseErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferBolt12ParseErrorZ { - CResult_OfferBolt12ParseErrorZ { - contents: CResult_OfferBolt12ParseErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::InitFeatures) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OfferBolt12ParseErrorZ in the error state. -pub extern "C" fn CResult_OfferBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_OfferBolt12ParseErrorZ { - CResult_OfferBolt12ParseErrorZ { - contents: CResult_OfferBolt12ParseErrorZPtr { +/// Creates a new CResult_InitFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitFeaturesDecodeErrorZ { + CResult_InitFeaturesDecodeErrorZ { + contents: CResult_InitFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6504,13 +6674,13 @@ pub extern "C" fn CResult_OfferBolt12ParseErrorZ_err(e: crate::lightning::offers } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OfferBolt12ParseErrorZ_is_ok(o: &CResult_OfferBolt12ParseErrorZ) -> bool { +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_is_ok(o: &CResult_InitFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OfferBolt12ParseErrorZ. -pub extern "C" fn CResult_OfferBolt12ParseErrorZ_free(_res: CResult_OfferBolt12ParseErrorZ) { } -impl Drop for CResult_OfferBolt12ParseErrorZ { +/// Frees any resources used by the CResult_InitFeaturesDecodeErrorZ. +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_free(_res: CResult_InitFeaturesDecodeErrorZ) { } +impl Drop for CResult_InitFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6523,16 +6693,16 @@ impl Drop for CResult_OfferBolt12ParseErrorZ { } } } -impl From> for CResult_OfferBolt12ParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InitFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OfferBolt12ParseErrorZPtr { result } + CResult_InitFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OfferBolt12ParseErrorZPtr { err } + CResult_InitFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -6540,59 +6710,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OfferBolt12ParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InitFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OfferBolt12ParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InitFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` +/// Creates a new CResult_InitFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OfferBolt12ParseErrorZ_clone(orig: &CResult_OfferBolt12ParseErrorZ) -> CResult_OfferBolt12ParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InitFeaturesDecodeErrorZ_clone(orig: &CResult_InitFeaturesDecodeErrorZ) -> CResult_InitFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PublicKeySecp256k1ErrorZ -pub union CResult_PublicKeySecp256k1ErrorZPtr { +/// The contents of CResult_ChannelFeaturesDecodeErrorZ +pub union CResult_ChannelFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::PublicKey, + pub result: *mut crate::lightning_types::features::ChannelFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PublicKeySecp256k1ErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_ChannelFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::ChannelFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PublicKeySecp256k1ErrorZ { - /// The contents of this CResult_PublicKeySecp256k1ErrorZ, accessible via either +pub struct CResult_ChannelFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PublicKeySecp256k1ErrorZPtr, - /// Whether this CResult_PublicKeySecp256k1ErrorZ represents a success state. + pub contents: CResult_ChannelFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PublicKeySecp256k1ErrorZ in the success state. -pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeySecp256k1ErrorZ { - CResult_PublicKeySecp256k1ErrorZ { - contents: CResult_PublicKeySecp256k1ErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::ChannelFeatures) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PublicKeySecp256k1ErrorZ in the error state. -pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PublicKeySecp256k1ErrorZ { - CResult_PublicKeySecp256k1ErrorZ { - contents: CResult_PublicKeySecp256k1ErrorZPtr { +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelFeaturesDecodeErrorZ { + CResult_ChannelFeaturesDecodeErrorZ { + contents: CResult_ChannelFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6600,13 +6770,13 @@ pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_err(e: crate::c_types::Secp25 } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_is_ok(o: &CResult_PublicKeySecp256k1ErrorZ) -> bool { +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PublicKeySecp256k1ErrorZ. -pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_free(_res: CResult_PublicKeySecp256k1ErrorZ) { } -impl Drop for CResult_PublicKeySecp256k1ErrorZ { +/// Frees any resources used by the CResult_ChannelFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_free(_res: CResult_ChannelFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6619,16 +6789,16 @@ impl Drop for CResult_PublicKeySecp256k1ErrorZ { } } } -impl From> for CResult_PublicKeySecp256k1ErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PublicKeySecp256k1ErrorZPtr { result } + CResult_ChannelFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PublicKeySecp256k1ErrorZPtr { err } + CResult_ChannelFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -6636,59 +6806,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PublicKeySecp256k1ErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PublicKeySecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PublicKeySecp256k1ErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_clone(orig: &CResult_PublicKeySecp256k1ErrorZ) -> CResult_PublicKeySecp256k1ErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelFeaturesDecodeErrorZ) -> CResult_ChannelFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeIdDecodeErrorZ -pub union CResult_NodeIdDecodeErrorZPtr { +/// The contents of CResult_NodeFeaturesDecodeErrorZ +pub union CResult_NodeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::NodeId, + pub result: *mut crate::lightning_types::features::NodeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::NodeId on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NodeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::NodeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeIdDecodeErrorZ { - /// The contents of this CResult_NodeIdDecodeErrorZ, accessible via either +pub struct CResult_NodeFeaturesDecodeErrorZ { + /// The contents of this CResult_NodeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeIdDecodeErrorZPtr, - /// Whether this CResult_NodeIdDecodeErrorZ represents a success state. + pub contents: CResult_NodeFeaturesDecodeErrorZPtr, + /// Whether this CResult_NodeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeIdDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeIdDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeId) -> CResult_NodeIdDecodeErrorZ { - CResult_NodeIdDecodeErrorZ { - contents: CResult_NodeIdDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::NodeFeatures) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeIdDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeIdDecodeErrorZ { - CResult_NodeIdDecodeErrorZ { - contents: CResult_NodeIdDecodeErrorZPtr { +/// Creates a new CResult_NodeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeFeaturesDecodeErrorZ { + CResult_NodeFeaturesDecodeErrorZ { + contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6696,13 +6866,13 @@ pub extern "C" fn CResult_NodeIdDecodeErrorZ_err(e: crate::lightning::ln::msgs:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeIdDecodeErrorZ_is_ok(o: &CResult_NodeIdDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_is_ok(o: &CResult_NodeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeIdDecodeErrorZ. -pub extern "C" fn CResult_NodeIdDecodeErrorZ_free(_res: CResult_NodeIdDecodeErrorZ) { } -impl Drop for CResult_NodeIdDecodeErrorZ { +/// Frees any resources used by the CResult_NodeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_free(_res: CResult_NodeFeaturesDecodeErrorZ) { } +impl Drop for CResult_NodeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6715,16 +6885,16 @@ impl Drop for CResult_NodeIdDecodeErrorZ { } } } -impl From> for CResult_NodeIdDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeIdDecodeErrorZPtr { result } + CResult_NodeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeIdDecodeErrorZPtr { err } + CResult_NodeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -6732,96 +6902,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeIdDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeIdDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_NodeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeIdDecodeErrorZ_clone(orig: &CResult_NodeIdDecodeErrorZ) -> CResult_NodeIdDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not -pub enum COption_NetworkUpdateZ { - /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate - Some(crate::lightning::routing::gossip::NetworkUpdate), - /// When we're in this state, this COption_NetworkUpdateZ contains nothing - None -} -impl COption_NetworkUpdateZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate -pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_NetworkUpdateZ containing nothing -pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { - COption_NetworkUpdateZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state -pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } -#[no_mangle] -/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` +/// Creates a new CResult_NodeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeFeaturesDecodeErrorZ_clone(orig: &CResult_NodeFeaturesDecodeErrorZ) -> CResult_NodeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ -pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, + pub result: *mut crate::lightning_types::features::Bolt11InvoiceFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::Bolt11InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { - /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt11InvoiceFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr, - /// Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt11InvoiceFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o: crate::c_types::derived::COption_NetworkUpdateZ) -> CResult_COption_NetworkUpdateZDecodeErrorZ { - CResult_COption_NetworkUpdateZDecodeErrorZ { - contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::Bolt11InvoiceFeatures) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_NetworkUpdateZDecodeErrorZ { - CResult_COption_NetworkUpdateZDecodeErrorZ { - contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6829,13 +6962,13 @@ pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o: &CResult_COption_NetworkUpdateZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. -pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res: CResult_COption_NetworkUpdateZDecodeErrorZ) { } -impl Drop for CResult_COption_NetworkUpdateZDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt11InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -6848,16 +6981,16 @@ impl Drop for CResult_COption_NetworkUpdateZDecodeErrorZ { } } } -impl From> for CResult_COption_NetworkUpdateZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_NetworkUpdateZDecodeErrorZPtr { result } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_NetworkUpdateZDecodeErrorZPtr { err } + CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -6865,90 +6998,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt11InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig: &CResult_COption_NetworkUpdateZDecodeErrorZ) -> CResult_COption_NetworkUpdateZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a crate::lightning::routing::utxo::UtxoLookup or not -pub enum COption_UtxoLookupZ { - /// When we're in this state, this COption_UtxoLookupZ contains a crate::lightning::routing::utxo::UtxoLookup - Some(crate::lightning::routing::utxo::UtxoLookup), - /// When we're in this state, this COption_UtxoLookupZ contains nothing - None -} -impl COption_UtxoLookupZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::utxo::UtxoLookup { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_UtxoLookupZ containing a crate::lightning::routing::utxo::UtxoLookup -pub extern "C" fn COption_UtxoLookupZ_some(o: crate::lightning::routing::utxo::UtxoLookup) -> COption_UtxoLookupZ { - COption_UtxoLookupZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_UtxoLookupZ containing nothing -pub extern "C" fn COption_UtxoLookupZ_none() -> COption_UtxoLookupZ { - COption_UtxoLookupZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state -pub extern "C" fn COption_UtxoLookupZ_free(_res: COption_UtxoLookupZ) { } +pub extern "C" fn CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt11InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt11InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneLightningErrorZ -pub union CResult_NoneLightningErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_Bolt12InvoiceFeaturesDecodeErrorZ +pub union CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_types::features::Bolt12InvoiceFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. +/// A CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::Bolt12InvoiceFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneLightningErrorZ { - /// The contents of this CResult_NoneLightningErrorZ, accessible via either +pub struct CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + /// The contents of this CResult_Bolt12InvoiceFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneLightningErrorZPtr, - /// Whether this CResult_NoneLightningErrorZ represents a success state. + pub contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr, + /// Whether this CResult_Bolt12InvoiceFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the success state. -pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::Bolt12InvoiceFeatures) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ in the error state. -pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { - CResult_NoneLightningErrorZ { - contents: CResult_NoneLightningErrorZPtr { +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -6956,15 +7058,18 @@ pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneLightningErrorZ. -pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } -impl Drop for CResult_NoneLightningErrorZ { +/// Frees any resources used by the CResult_Bolt12InvoiceFeaturesDecodeErrorZ. +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res: CResult_Bolt12InvoiceFeaturesDecodeErrorZ) { } +impl Drop for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -6972,16 +7077,16 @@ impl Drop for CResult_NoneLightningErrorZ { } } } -impl From> for CResult_NoneLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { +impl From> for CResult_Bolt12InvoiceFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneLightningErrorZPtr { err } + CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -6989,59 +7094,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt12InvoiceFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12InvoiceFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig: &CResult_Bolt12InvoiceFeaturesDecodeErrorZ) -> CResult_Bolt12InvoiceFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_boolLightningErrorZ -pub union CResult_boolLightningErrorZPtr { +/// The contents of CResult_BlindedHopFeaturesDecodeErrorZ +pub union CResult_BlindedHopFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, + pub result: *mut crate::lightning_types::features::BlindedHopFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::LightningError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_boolLightningErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. +/// A CResult_BlindedHopFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::BlindedHopFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolLightningErrorZ { - /// The contents of this CResult_boolLightningErrorZ, accessible via either +pub struct CResult_BlindedHopFeaturesDecodeErrorZ { + /// The contents of this CResult_BlindedHopFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolLightningErrorZPtr, - /// Whether this CResult_boolLightningErrorZ represents a success state. + pub contents: CResult_BlindedHopFeaturesDecodeErrorZPtr, + /// Whether this CResult_BlindedHopFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ in the success state. -pub extern "C" fn CResult_boolLightningErrorZ_ok(o: bool) -> CResult_boolLightningErrorZ { - CResult_boolLightningErrorZ { - contents: CResult_boolLightningErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::BlindedHopFeatures) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ in the error state. -pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_boolLightningErrorZ { - CResult_boolLightningErrorZ { - contents: CResult_boolLightningErrorZPtr { +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopFeaturesDecodeErrorZ { + CResult_BlindedHopFeaturesDecodeErrorZ { + contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7049,13 +7154,13 @@ pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_boolLightningErrorZ_is_ok(o: &CResult_boolLightningErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o: &CResult_BlindedHopFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_boolLightningErrorZ. -pub extern "C" fn CResult_boolLightningErrorZ_free(_res: CResult_boolLightningErrorZ) { } -impl Drop for CResult_boolLightningErrorZ { +/// Frees any resources used by the CResult_BlindedHopFeaturesDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_free(_res: CResult_BlindedHopFeaturesDecodeErrorZ) { } +impl Drop for CResult_BlindedHopFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7068,16 +7173,16 @@ impl Drop for CResult_boolLightningErrorZ { } } } -impl From> for CResult_boolLightningErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_boolLightningErrorZPtr { result } + CResult_BlindedHopFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_boolLightningErrorZPtr { err } + CResult_BlindedHopFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -7085,188 +7190,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_boolLightningErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_boolLightningErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedHopFeaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_boolLightningErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolLightningErrorZ_clone(orig: &CResult_boolLightningErrorZ) -> CResult_boolLightningErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - /// The element at position 0 - pub a: crate::lightning::ln::msgs::ChannelAnnouncement, - /// The element at position 1 - pub b: crate::lightning::ln::msgs::ChannelUpdate, - /// The element at position 2 - pub c: crate::lightning::ln::msgs::ChannelUpdate, -} -impl From<(crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)> for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - fn from (tup: (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig: &C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::lightning::ln::msgs::ChannelAnnouncement, b: crate::lightning::ln::msgs::ChannelUpdate, c: crate::lightning::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. -pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not -pub enum COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ - Some(crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), - /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing - None -} -impl COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ -pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o: crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing -pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state -pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { } -#[no_mangle] -/// Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig: &COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MessageSendEventZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::MessageSendEvent, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MessageSendEventZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MessageSendEventZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } -impl Drop for CVec_MessageSendEventZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MessageSendEventZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig: &CResult_BlindedHopFeaturesDecodeErrorZ) -> CResult_BlindedHopFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelUpdateInfoDecodeErrorZ -pub union CResult_ChannelUpdateInfoDecodeErrorZPtr { +/// The contents of CResult_ChannelTypeFeaturesDecodeErrorZ +pub union CResult_ChannelTypeFeaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::ChannelUpdateInfo, + pub result: *mut crate::lightning_types::features::ChannelTypeFeatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelTypeFeaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::features::ChannelTypeFeatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelUpdateInfoDecodeErrorZ { - /// The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either +pub struct CResult_ChannelTypeFeaturesDecodeErrorZ { + /// The contents of this CResult_ChannelTypeFeaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelUpdateInfoDecodeErrorZPtr, - /// Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. + pub contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr, + /// Whether this CResult_ChannelTypeFeaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::ChannelUpdateInfo) -> CResult_ChannelUpdateInfoDecodeErrorZ { - CResult_ChannelUpdateInfoDecodeErrorZ { - contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o: crate::lightning_types::features::ChannelTypeFeatures) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateInfoDecodeErrorZ { - CResult_ChannelUpdateInfoDecodeErrorZ { - contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTypeFeaturesDecodeErrorZ { + CResult_ChannelTypeFeaturesDecodeErrorZ { + contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7274,13 +7250,13 @@ pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. -pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_free(_res: CResult_ChannelUpdateInfoDecodeErrorZ) { } -impl Drop for CResult_ChannelUpdateInfoDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelTypeFeaturesDecodeErrorZ. +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res: CResult_ChannelTypeFeaturesDecodeErrorZ) { } +impl Drop for CResult_ChannelTypeFeaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7293,16 +7269,16 @@ impl Drop for CResult_ChannelUpdateInfoDecodeErrorZ { } } } -impl From> for CResult_ChannelUpdateInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelTypeFeaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelUpdateInfoDecodeErrorZPtr { result } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelUpdateInfoDecodeErrorZPtr { err } + CResult_ChannelTypeFeaturesDecodeErrorZPtr { err } }; Self { contents, @@ -7310,59 +7286,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelTypeFeaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTypeFeaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig: &CResult_ChannelUpdateInfoDecodeErrorZ) -> CResult_ChannelUpdateInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig: &CResult_ChannelTypeFeaturesDecodeErrorZ) -> CResult_ChannelTypeFeaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelInfoDecodeErrorZ -pub union CResult_ChannelInfoDecodeErrorZPtr { +/// The contents of CResult_OfferIdDecodeErrorZ +pub union CResult_OfferIdDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::ChannelInfo, + pub result: *mut crate::lightning::offers::offer::OfferId, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferIdDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::OfferId on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelInfoDecodeErrorZ { - /// The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either +pub struct CResult_OfferIdDecodeErrorZ { + /// The contents of this CResult_OfferIdDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelInfoDecodeErrorZPtr, - /// Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. + pub contents: CResult_OfferIdDecodeErrorZPtr, + /// Whether this CResult_OfferIdDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::ChannelInfo) -> CResult_ChannelInfoDecodeErrorZ { - CResult_ChannelInfoDecodeErrorZ { - contents: CResult_ChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_OfferIdDecodeErrorZ in the success state. +pub extern "C" fn CResult_OfferIdDecodeErrorZ_ok(o: crate::lightning::offers::offer::OfferId) -> CResult_OfferIdDecodeErrorZ { + CResult_OfferIdDecodeErrorZ { + contents: CResult_OfferIdDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelInfoDecodeErrorZ { - CResult_ChannelInfoDecodeErrorZ { - contents: CResult_ChannelInfoDecodeErrorZPtr { +/// Creates a new CResult_OfferIdDecodeErrorZ in the error state. +pub extern "C" fn CResult_OfferIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OfferIdDecodeErrorZ { + CResult_OfferIdDecodeErrorZ { + contents: CResult_OfferIdDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7370,13 +7346,13 @@ pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_is_ok(o: &CResult_ChannelInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferIdDecodeErrorZ_is_ok(o: &CResult_OfferIdDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_free(_res: CResult_ChannelInfoDecodeErrorZ) { } -impl Drop for CResult_ChannelInfoDecodeErrorZ { +/// Frees any resources used by the CResult_OfferIdDecodeErrorZ. +pub extern "C" fn CResult_OfferIdDecodeErrorZ_free(_res: CResult_OfferIdDecodeErrorZ) { } +impl Drop for CResult_OfferIdDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7389,16 +7365,16 @@ impl Drop for CResult_ChannelInfoDecodeErrorZ { } } } -impl From> for CResult_ChannelInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferIdDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelInfoDecodeErrorZPtr { result } + CResult_OfferIdDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelInfoDecodeErrorZPtr { err } + CResult_OfferIdDecodeErrorZPtr { err } }; Self { contents, @@ -7406,59 +7382,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OfferIdDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelInfoDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OfferIdDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OfferIdDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OfferIdDecodeErrorZ_clone(orig: &CResult_OfferIdDecodeErrorZ) -> CResult_OfferIdDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RoutingFeesDecodeErrorZ -pub union CResult_RoutingFeesDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::RoutingFees, +/// The contents of CResult_NoneBolt12SemanticErrorZ +pub union CResult_NoneBolt12SemanticErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RoutingFeesDecodeErrorZ { - /// The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either +pub struct CResult_NoneBolt12SemanticErrorZ { + /// The contents of this CResult_NoneBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RoutingFeesDecodeErrorZPtr, - /// Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + pub contents: CResult_NoneBolt12SemanticErrorZPtr, + /// Whether this CResult_NoneBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::lightning::routing::gossip::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { - CResult_RoutingFeesDecodeErrorZ { - contents: CResult_RoutingFeesDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_ok() -> CResult_NoneBolt12SemanticErrorZ { + CResult_NoneBolt12SemanticErrorZ { + contents: CResult_NoneBolt12SemanticErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RoutingFeesDecodeErrorZ { - CResult_RoutingFeesDecodeErrorZ { - contents: CResult_RoutingFeesDecodeErrorZPtr { +/// Creates a new CResult_NoneBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_NoneBolt12SemanticErrorZ { + CResult_NoneBolt12SemanticErrorZ { + contents: CResult_NoneBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7466,18 +7441,15 @@ pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_is_ok(o: &CResult_RoutingFeesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_is_ok(o: &CResult_NoneBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_free(_res: CResult_RoutingFeesDecodeErrorZ) { } -impl Drop for CResult_RoutingFeesDecodeErrorZ { +/// Frees any resources used by the CResult_NoneBolt12SemanticErrorZ. +pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_free(_res: CResult_NoneBolt12SemanticErrorZ) { } +impl Drop for CResult_NoneBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -7485,16 +7457,16 @@ impl Drop for CResult_RoutingFeesDecodeErrorZ { } } } -impl From> for CResult_RoutingFeesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::offers::parse::Bolt12SemanticError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RoutingFeesDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneBolt12SemanticErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RoutingFeesDecodeErrorZPtr { err } + CResult_NoneBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -7502,105 +7474,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneBolt12SemanticErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneBolt12SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::SocketAddresss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_SocketAddressZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::SocketAddress, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_SocketAddressZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::SocketAddress] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_SocketAddressZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_SocketAddressZ_free(_res: CVec_SocketAddressZ) { } -impl Drop for CVec_SocketAddressZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_SocketAddressZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_clone(orig: &CResult_NoneBolt12SemanticErrorZ) -> CResult_NoneBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeAnnouncementInfoDecodeErrorZ -pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr { +/// The contents of CResult_OfferBolt12SemanticErrorZ +pub union CResult_OfferBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::NodeAnnouncementInfo, + pub result: *mut crate::lightning::offers::offer::Offer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementInfoDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either +pub struct CResult_OfferBolt12SemanticErrorZ { + /// The contents of this CResult_OfferBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. + pub contents: CResult_OfferBolt12SemanticErrorZPtr, + /// Whether this CResult_OfferBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> CResult_NodeAnnouncementInfoDecodeErrorZ { - CResult_NodeAnnouncementInfoDecodeErrorZ { - contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_OfferBolt12SemanticErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferBolt12SemanticErrorZ { + CResult_OfferBolt12SemanticErrorZ { + contents: CResult_OfferBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementInfoDecodeErrorZ { - CResult_NodeAnnouncementInfoDecodeErrorZ { - contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { +/// Creates a new CResult_OfferBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_OfferBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_OfferBolt12SemanticErrorZ { + CResult_OfferBolt12SemanticErrorZ { + contents: CResult_OfferBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7608,13 +7534,13 @@ pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferBolt12SemanticErrorZ_is_ok(o: &CResult_OfferBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res: CResult_NodeAnnouncementInfoDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { +/// Frees any resources used by the CResult_OfferBolt12SemanticErrorZ. +pub extern "C" fn CResult_OfferBolt12SemanticErrorZ_free(_res: CResult_OfferBolt12SemanticErrorZ) { } +impl Drop for CResult_OfferBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7627,16 +7553,16 @@ impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { } } } -impl From> for CResult_NodeAnnouncementInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeAnnouncementInfoDecodeErrorZPtr { result } + CResult_OfferBolt12SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeAnnouncementInfoDecodeErrorZPtr { err } + CResult_OfferBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -7644,59 +7570,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OfferBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OfferBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OfferBolt12SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OfferBolt12SemanticErrorZ_clone(orig: &CResult_OfferBolt12SemanticErrorZ) -> CResult_OfferBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeAliasDecodeErrorZ -pub union CResult_NodeAliasDecodeErrorZPtr { +/// The contents of CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ +pub union CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::NodeAlias, + pub result: *mut crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_NodeAliasDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::NodeAlias on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAliasDecodeErrorZ { - /// The contents of this CResult_NodeAliasDecodeErrorZ, accessible via either +pub struct CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAliasDecodeErrorZPtr, - /// Whether this CResult_NodeAliasDecodeErrorZ represents a success state. + pub contents: CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAliasDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAliasDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeAlias) -> CResult_NodeAliasDecodeErrorZ { - CResult_NodeAliasDecodeErrorZ { - contents: CResult_NodeAliasDecodeErrorZPtr { +/// Creates a new CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder) -> CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAliasDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAliasDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAliasDecodeErrorZ { - CResult_NodeAliasDecodeErrorZ { - contents: CResult_NodeAliasDecodeErrorZPtr { +/// Creates a new CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7704,13 +7630,13 @@ pub extern "C" fn CResult_NodeAliasDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeAliasDecodeErrorZ_is_ok(o: &CResult_NodeAliasDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeAliasDecodeErrorZ. -pub extern "C" fn CResult_NodeAliasDecodeErrorZ_free(_res: CResult_NodeAliasDecodeErrorZ) { } -impl Drop for CResult_NodeAliasDecodeErrorZ { +/// Frees any resources used by the CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ_free(_res: CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7723,16 +7649,16 @@ impl Drop for CResult_NodeAliasDecodeErrorZ { } } } -impl From> for CResult_NodeAliasDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeAliasDecodeErrorZPtr { result } + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeAliasDecodeErrorZPtr { err } + CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -7740,59 +7666,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAliasDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeAliasDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_NodeAliasDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAliasDecodeErrorZ_clone(orig: &CResult_NodeAliasDecodeErrorZ) -> CResult_NodeAliasDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeInfoDecodeErrorZ -pub union CResult_NodeInfoDecodeErrorZPtr { +/// The contents of CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ +pub union CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::NodeInfo, + pub result: *mut crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeInfoDecodeErrorZ { - /// The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either +pub struct CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeInfoDecodeErrorZPtr, - /// Whether this CResult_NodeInfoDecodeErrorZ represents a success state. + pub contents: CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeInfo) -> CResult_NodeInfoDecodeErrorZ { - CResult_NodeInfoDecodeErrorZ { - contents: CResult_NodeInfoDecodeErrorZPtr { +/// Creates a new CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder) -> CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeInfoDecodeErrorZ { - CResult_NodeInfoDecodeErrorZ { - contents: CResult_NodeInfoDecodeErrorZPtr { +/// Creates a new CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7800,13 +7709,13 @@ pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_is_ok(o: &CResult_NodeInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeInfoDecodeErrorZ. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_free(_res: CResult_NodeInfoDecodeErrorZ) { } -impl Drop for CResult_NodeInfoDecodeErrorZ { +/// Frees any resources used by the CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ_free(_res: CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7819,16 +7728,16 @@ impl Drop for CResult_NodeInfoDecodeErrorZ { } } } -impl From> for CResult_NodeInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeInfoDecodeErrorZPtr { result } + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeInfoDecodeErrorZPtr { err } + CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -7836,59 +7745,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NodeInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_NodeInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeInfoDecodeErrorZ_clone(orig: &CResult_NodeInfoDecodeErrorZ) -> CResult_NodeInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NetworkGraphDecodeErrorZ -pub union CResult_NetworkGraphDecodeErrorZPtr { +/// The contents of CResult_OfferDecodeErrorZ +pub union CResult_OfferDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::routing::gossip::NetworkGraph, + pub result: *mut crate::lightning::offers::offer::Offer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::routing::gossip::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NetworkGraphDecodeErrorZ { - /// The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either +pub struct CResult_OfferDecodeErrorZ { + /// The contents of this CResult_OfferDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NetworkGraphDecodeErrorZPtr, - /// Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. + pub contents: CResult_OfferDecodeErrorZPtr, + /// Whether this CResult_OfferDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NetworkGraph) -> CResult_NetworkGraphDecodeErrorZ { - CResult_NetworkGraphDecodeErrorZ { - contents: CResult_NetworkGraphDecodeErrorZPtr { +/// Creates a new CResult_OfferDecodeErrorZ in the success state. +pub extern "C" fn CResult_OfferDecodeErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferDecodeErrorZ { + CResult_OfferDecodeErrorZ { + contents: CResult_OfferDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetworkGraphDecodeErrorZ { - CResult_NetworkGraphDecodeErrorZ { - contents: CResult_NetworkGraphDecodeErrorZPtr { +/// Creates a new CResult_OfferDecodeErrorZ in the error state. +pub extern "C" fn CResult_OfferDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OfferDecodeErrorZ { + CResult_OfferDecodeErrorZ { + contents: CResult_OfferDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -7896,13 +7788,13 @@ pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_is_ok(o: &CResult_NetworkGraphDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferDecodeErrorZ_is_ok(o: &CResult_OfferDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. -pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_free(_res: CResult_NetworkGraphDecodeErrorZ) { } -impl Drop for CResult_NetworkGraphDecodeErrorZ { +/// Frees any resources used by the CResult_OfferDecodeErrorZ. +pub extern "C" fn CResult_OfferDecodeErrorZ_free(_res: CResult_OfferDecodeErrorZ) { } +impl Drop for CResult_OfferDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -7915,16 +7807,16 @@ impl Drop for CResult_NetworkGraphDecodeErrorZ { } } } -impl From> for CResult_NetworkGraphDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NetworkGraphDecodeErrorZPtr { result } + CResult_OfferDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NetworkGraphDecodeErrorZPtr { err } + CResult_OfferDecodeErrorZPtr { err } }; Self { contents, @@ -7932,79 +7824,59 @@ impl From bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_SocketAddressZ { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_OfferDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OfferDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OfferDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_CVec_SocketAddressZZ containing a crate::c_types::derived::CVec_SocketAddressZ -pub extern "C" fn COption_CVec_SocketAddressZZ_some(o: crate::c_types::derived::CVec_SocketAddressZ) -> COption_CVec_SocketAddressZZ { - COption_CVec_SocketAddressZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_CVec_SocketAddressZZ containing nothing -pub extern "C" fn COption_CVec_SocketAddressZZ_none() -> COption_CVec_SocketAddressZZ { - COption_CVec_SocketAddressZZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::CVec_SocketAddressZ, if we are in the Some state -pub extern "C" fn COption_CVec_SocketAddressZZ_free(_res: COption_CVec_SocketAddressZZ) { } -#[no_mangle] -/// Creates a new COption_CVec_SocketAddressZZ which has the same data as `orig` +/// Creates a new CResult_OfferDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_CVec_SocketAddressZZ_clone(orig: &COption_CVec_SocketAddressZZ) -> COption_CVec_SocketAddressZZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OfferDecodeErrorZ_clone(orig: &CResult_OfferDecodeErrorZ) -> CResult_OfferDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PendingHTLCInfoInboundHTLCErrZ -pub union CResult_PendingHTLCInfoInboundHTLCErrZPtr { +/// The contents of CResult_OfferBolt12ParseErrorZ +pub union CResult_OfferBolt12ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCInfo, + pub result: *mut crate::lightning::offers::offer::Offer, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::onion_payment::InboundHTLCErr, + pub err: *mut crate::lightning::offers::parse::Bolt12ParseError, } #[repr(C)] -/// A CResult_PendingHTLCInfoInboundHTLCErrZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PendingHTLCInfo on success and a crate::lightning::ln::onion_payment::InboundHTLCErr on failure. +/// A CResult_OfferBolt12ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::Offer on success and a crate::lightning::offers::parse::Bolt12ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PendingHTLCInfoInboundHTLCErrZ { - /// The contents of this CResult_PendingHTLCInfoInboundHTLCErrZ, accessible via either +pub struct CResult_OfferBolt12ParseErrorZ { + /// The contents of this CResult_OfferBolt12ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr, - /// Whether this CResult_PendingHTLCInfoInboundHTLCErrZ represents a success state. + pub contents: CResult_OfferBolt12ParseErrorZPtr, + /// Whether this CResult_OfferBolt12ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ in the success state. -pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCInfo) -> CResult_PendingHTLCInfoInboundHTLCErrZ { - CResult_PendingHTLCInfoInboundHTLCErrZ { - contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the success state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_ok(o: crate::lightning::offers::offer::Offer) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ in the error state. -pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_err(e: crate::lightning::ln::onion_payment::InboundHTLCErr) -> CResult_PendingHTLCInfoInboundHTLCErrZ { - CResult_PendingHTLCInfoInboundHTLCErrZ { - contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { +/// Creates a new CResult_OfferBolt12ParseErrorZ in the error state. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_err(e: crate::lightning::offers::parse::Bolt12ParseError) -> CResult_OfferBolt12ParseErrorZ { + CResult_OfferBolt12ParseErrorZ { + contents: CResult_OfferBolt12ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8012,13 +7884,13 @@ pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_is_ok(o: &CResult_PendingHTLCInfoInboundHTLCErrZ) -> bool { +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_is_ok(o: &CResult_OfferBolt12ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PendingHTLCInfoInboundHTLCErrZ. -pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_free(_res: CResult_PendingHTLCInfoInboundHTLCErrZ) { } -impl Drop for CResult_PendingHTLCInfoInboundHTLCErrZ { +/// Frees any resources used by the CResult_OfferBolt12ParseErrorZ. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_free(_res: CResult_OfferBolt12ParseErrorZ) { } +impl Drop for CResult_OfferBolt12ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8031,16 +7903,16 @@ impl Drop for CResult_PendingHTLCInfoInboundHTLCErrZ { } } } -impl From> for CResult_PendingHTLCInfoInboundHTLCErrZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferBolt12ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PendingHTLCInfoInboundHTLCErrZPtr { result } + CResult_OfferBolt12ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PendingHTLCInfoInboundHTLCErrZPtr { err } + CResult_OfferBolt12ParseErrorZPtr { err } }; Self { contents, @@ -8048,295 +7920,191 @@ impl From Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::HTLCOutputInCommitment] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_HTLCOutputInCommitmentZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +impl Clone for CResult_OfferBolt12ParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OfferBolt12ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OfferBolt12ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_HTLCOutputInCommitmentZ_free(_res: CVec_HTLCOutputInCommitmentZ) { } -impl Drop for CVec_HTLCOutputInCommitmentZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_HTLCOutputInCommitmentZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// Creates a new CResult_OfferBolt12ParseErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OfferBolt12ParseErrorZ_clone(orig: &CResult_OfferBolt12ParseErrorZ) -> CResult_OfferBolt12ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_NodeIdDecodeErrorZ +pub union CResult_NodeIdDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::gossip::NodeId, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::sign::HTLCDescriptors of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_HTLCDescriptorZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::sign::HTLCDescriptor, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_NodeIdDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::NodeId on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeIdDecodeErrorZ { + /// The contents of this CResult_NodeIdDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeIdDecodeErrorZPtr, + /// Whether this CResult_NodeIdDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_HTLCDescriptorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::HTLCDescriptor] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_NodeIdDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeIdDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeId) -> CResult_NodeIdDecodeErrorZ { + CResult_NodeIdDecodeErrorZ { + contents: CResult_NodeIdDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_HTLCDescriptorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_NodeIdDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeIdDecodeErrorZ { + CResult_NodeIdDecodeErrorZ { + contents: CResult_NodeIdDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_HTLCDescriptorZ_free(_res: CVec_HTLCDescriptorZ) { } -impl Drop for CVec_HTLCDescriptorZ { +pub extern "C" fn CResult_NodeIdDecodeErrorZ_is_ok(o: &CResult_NodeIdDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NodeIdDecodeErrorZ. +pub extern "C" fn CResult_NodeIdDecodeErrorZ_free(_res: CResult_NodeIdDecodeErrorZ) { } +impl Drop for CResult_NodeIdDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_HTLCDescriptorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +impl From> for CResult_NodeIdDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NodeIdDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NodeIdDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Utxos of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UtxoZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::bump_transaction::Utxo, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UtxoZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Utxo] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UtxoZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UtxoZ_free(_res: CVec_UtxoZ) { } -impl Drop for CVec_UtxoZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UtxoZ { +impl Clone for CResult_NodeIdDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::TxOut or not -pub enum COption_TxOutZ { - /// When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut - Some(crate::c_types::TxOut), - /// When we're in this state, this COption_TxOutZ contains nothing - None -} -impl COption_TxOutZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::TxOut { - if let Self::Some(v) = self { v } else { unreachable!() } + if self.result_ok { + Self { result_ok: true, contents: CResult_NodeIdDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NodeIdDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_TxOutZ containing a crate::c_types::TxOut -pub extern "C" fn COption_TxOutZ_some(o: crate::c_types::TxOut) -> COption_TxOutZ { - COption_TxOutZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_TxOutZ containing nothing -pub extern "C" fn COption_TxOutZ_none() -> COption_TxOutZ { - COption_TxOutZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::TxOut, if we are in the Some state -pub extern "C" fn COption_TxOutZ_free(_res: COption_TxOutZ) { } -#[no_mangle] -/// Creates a new COption_TxOutZ which has the same data as `orig` +/// Creates a new CResult_NodeIdDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_TxOutZ_clone(orig: &COption_TxOutZ) -> COption_TxOutZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Inputs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_InputZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::bump_transaction::Input, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_InputZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Input] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_InputZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_InputZ_free(_res: CVec_InputZ) { } -impl Drop for CVec_InputZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_InputZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_NodeIdDecodeErrorZ_clone(orig: &CResult_NodeIdDecodeErrorZ) -> CResult_NodeIdDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CoinSelectionNoneZ -pub union CResult_CoinSelectionNoneZPtr { +/// The contents of CResult_PublicKeySecp256k1ErrorZ +pub union CResult_PublicKeySecp256k1ErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::bump_transaction::CoinSelection, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::PublicKey, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_CoinSelectionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::events::bump_transaction::CoinSelection on success and a () on failure. +/// A CResult_PublicKeySecp256k1ErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::PublicKey on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CoinSelectionNoneZ { - /// The contents of this CResult_CoinSelectionNoneZ, accessible via either +pub struct CResult_PublicKeySecp256k1ErrorZ { + /// The contents of this CResult_PublicKeySecp256k1ErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CoinSelectionNoneZPtr, - /// Whether this CResult_CoinSelectionNoneZ represents a success state. + pub contents: CResult_PublicKeySecp256k1ErrorZPtr, + /// Whether this CResult_PublicKeySecp256k1ErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CoinSelectionNoneZ in the success state. -pub extern "C" fn CResult_CoinSelectionNoneZ_ok(o: crate::lightning::events::bump_transaction::CoinSelection) -> CResult_CoinSelectionNoneZ { - CResult_CoinSelectionNoneZ { - contents: CResult_CoinSelectionNoneZPtr { +/// Creates a new CResult_PublicKeySecp256k1ErrorZ in the success state. +pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_ok(o: crate::c_types::PublicKey) -> CResult_PublicKeySecp256k1ErrorZ { + CResult_PublicKeySecp256k1ErrorZ { + contents: CResult_PublicKeySecp256k1ErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CoinSelectionNoneZ in the error state. -pub extern "C" fn CResult_CoinSelectionNoneZ_err() -> CResult_CoinSelectionNoneZ { - CResult_CoinSelectionNoneZ { - contents: CResult_CoinSelectionNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PublicKeySecp256k1ErrorZ in the error state. +pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PublicKeySecp256k1ErrorZ { + CResult_PublicKeySecp256k1ErrorZ { + contents: CResult_PublicKeySecp256k1ErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CoinSelectionNoneZ_is_ok(o: &CResult_CoinSelectionNoneZ) -> bool { +pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_is_ok(o: &CResult_PublicKeySecp256k1ErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CoinSelectionNoneZ. -pub extern "C" fn CResult_CoinSelectionNoneZ_free(_res: CResult_CoinSelectionNoneZ) { } -impl Drop for CResult_CoinSelectionNoneZ { +/// Frees any resources used by the CResult_PublicKeySecp256k1ErrorZ. +pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_free(_res: CResult_PublicKeySecp256k1ErrorZ) { } +impl Drop for CResult_PublicKeySecp256k1ErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CoinSelectionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PublicKeySecp256k1ErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CoinSelectionNoneZPtr { result } + CResult_PublicKeySecp256k1ErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CoinSelectionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PublicKeySecp256k1ErrorZPtr { err } }; Self { contents, @@ -8344,91 +8112,132 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CoinSelectionNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PublicKeySecp256k1ErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CoinSelectionNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PublicKeySecp256k1ErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CoinSelectionNoneZ which has the same data as `orig` +/// Creates a new CResult_PublicKeySecp256k1ErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CoinSelectionNoneZ_clone(orig: &CResult_CoinSelectionNoneZ) -> CResult_CoinSelectionNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PublicKeySecp256k1ErrorZ_clone(orig: &CResult_PublicKeySecp256k1ErrorZ) -> CResult_PublicKeySecp256k1ErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_UtxoZNoneZ -pub union CResult_CVec_UtxoZNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_UtxoZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::routing::gossip::NetworkUpdate or not +pub enum COption_NetworkUpdateZ { + /// When we're in this state, this COption_NetworkUpdateZ contains a crate::lightning::routing::gossip::NetworkUpdate + Some(crate::lightning::routing::gossip::NetworkUpdate), + /// When we're in this state, this COption_NetworkUpdateZ contains nothing + None } -#[repr(C)] -/// A CResult_CVec_UtxoZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_UtxoZ on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_UtxoZNoneZ { - /// The contents of this CResult_CVec_UtxoZNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_UtxoZNoneZPtr, - /// Whether this CResult_CVec_UtxoZNoneZ represents a success state. - pub result_ok: bool, +impl COption_NetworkUpdateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NetworkUpdate { + if let Self::Some(v) = self { v } else { unreachable!() } + } } #[no_mangle] -/// Creates a new CResult_CVec_UtxoZNoneZ in the success state. -pub extern "C" fn CResult_CVec_UtxoZNoneZ_ok(o: crate::c_types::derived::CVec_UtxoZ) -> CResult_CVec_UtxoZNoneZ { - CResult_CVec_UtxoZNoneZ { - contents: CResult_CVec_UtxoZNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// Constructs a new COption_NetworkUpdateZ containing a crate::lightning::routing::gossip::NetworkUpdate +pub extern "C" fn COption_NetworkUpdateZ_some(o: crate::lightning::routing::gossip::NetworkUpdate) -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::Some(o) } #[no_mangle] -/// Creates a new CResult_CVec_UtxoZNoneZ in the error state. -pub extern "C" fn CResult_CVec_UtxoZNoneZ_err() -> CResult_CVec_UtxoZNoneZ { - CResult_CVec_UtxoZNoneZ { - contents: CResult_CVec_UtxoZNoneZPtr { - err: core::ptr::null_mut(), +/// Constructs a new COption_NetworkUpdateZ containing nothing +pub extern "C" fn COption_NetworkUpdateZ_none() -> COption_NetworkUpdateZ { + COption_NetworkUpdateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::routing::gossip::NetworkUpdate, if we are in the Some state +pub extern "C" fn COption_NetworkUpdateZ_free(_res: COption_NetworkUpdateZ) { } +#[no_mangle] +/// Creates a new COption_NetworkUpdateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_NetworkUpdateZ_clone(orig: &COption_NetworkUpdateZ) -> COption_NetworkUpdateZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_NetworkUpdateZDecodeErrorZ +pub union CResult_COption_NetworkUpdateZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_NetworkUpdateZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_NetworkUpdateZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_NetworkUpdateZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_NetworkUpdateZDecodeErrorZ { + /// The contents of this CResult_COption_NetworkUpdateZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr, + /// Whether this CResult_COption_NetworkUpdateZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o: crate::c_types::derived::COption_NetworkUpdateZ) -> CResult_COption_NetworkUpdateZDecodeErrorZ { + CResult_COption_NetworkUpdateZDecodeErrorZ { + contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_NetworkUpdateZDecodeErrorZ { + CResult_COption_NetworkUpdateZDecodeErrorZ { + contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_UtxoZNoneZ_is_ok(o: &CResult_CVec_UtxoZNoneZ) -> bool { +pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o: &CResult_COption_NetworkUpdateZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_UtxoZNoneZ. -pub extern "C" fn CResult_CVec_UtxoZNoneZ_free(_res: CResult_CVec_UtxoZNoneZ) { } -impl Drop for CResult_CVec_UtxoZNoneZ { +/// Frees any resources used by the CResult_COption_NetworkUpdateZDecodeErrorZ. +pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res: CResult_COption_NetworkUpdateZDecodeErrorZ) { } +impl Drop for CResult_COption_NetworkUpdateZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_UtxoZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_NetworkUpdateZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_UtxoZNoneZPtr { result } + CResult_COption_NetworkUpdateZDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CVec_UtxoZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_NetworkUpdateZDecodeErrorZPtr { err } }; Self { contents, @@ -8436,175 +8245,90 @@ impl From> } } } -impl Clone for CResult_CVec_UtxoZNoneZ { +impl Clone for CResult_COption_NetworkUpdateZDecodeErrorZ { fn clone(&self) -> Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_UtxoZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_UtxoZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_COption_NetworkUpdateZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_UtxoZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_UtxoZNoneZ_clone(orig: &CResult_CVec_UtxoZNoneZ) -> CResult_CVec_UtxoZNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u64u16Z { - /// The element at position 0 - pub a: u64, - /// The element at position 1 - pub b: u16, -} -impl From<(u64, u16)> for C2Tuple_u64u16Z { - fn from (tup: (u64, u16)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_u64u16Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u16) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_u64u16Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u64u16Z_clone(orig: &C2Tuple_u64u16Z) -> C2Tuple_u64u16Z { Clone::clone(&orig) } -/// Creates a new C2Tuple_u64u16Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u64u16Z_new(a: u64, b: u16) -> C2Tuple_u64u16Z { - C2Tuple_u64u16Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u64u16Z. -pub extern "C" fn C2Tuple_u64u16Z_free(_res: C2Tuple_u64u16Z) { } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u16Z or not -pub enum COption_C2Tuple_u64u16ZZ { - /// When we're in this state, this COption_C2Tuple_u64u16ZZ contains a crate::c_types::derived::C2Tuple_u64u16Z - Some(crate::c_types::derived::C2Tuple_u64u16Z), - /// When we're in this state, this COption_C2Tuple_u64u16ZZ contains nothing - None -} -impl COption_C2Tuple_u64u16ZZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u16Z { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_u64u16ZZ containing a crate::c_types::derived::C2Tuple_u64u16Z -pub extern "C" fn COption_C2Tuple_u64u16ZZ_some(o: crate::c_types::derived::C2Tuple_u64u16Z) -> COption_C2Tuple_u64u16ZZ { - COption_C2Tuple_u64u16ZZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_C2Tuple_u64u16ZZ containing nothing -pub extern "C" fn COption_C2Tuple_u64u16ZZ_none() -> COption_C2Tuple_u64u16ZZ { - COption_C2Tuple_u64u16ZZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u16Z, if we are in the Some state -pub extern "C" fn COption_C2Tuple_u64u16ZZ_free(_res: COption_C2Tuple_u64u16ZZ) { } -#[no_mangle] -/// Creates a new COption_C2Tuple_u64u16ZZ which has the same data as `orig` +/// Creates a new CResult_COption_NetworkUpdateZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_C2Tuple_u64u16ZZ_clone(orig: &COption_C2Tuple_u64u16ZZ) -> COption_C2Tuple_u64u16ZZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig: &CResult_COption_NetworkUpdateZDecodeErrorZ) -> CResult_COption_NetworkUpdateZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::ln::channelmanager::ChannelShutdownState or not -pub enum COption_ChannelShutdownStateZ { - /// When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channelmanager::ChannelShutdownState - Some(crate::lightning::ln::channelmanager::ChannelShutdownState), - /// When we're in this state, this COption_ChannelShutdownStateZ contains nothing +/// An enum which can either contain a crate::lightning::routing::utxo::UtxoLookup or not +pub enum COption_UtxoLookupZ { + /// When we're in this state, this COption_UtxoLookupZ contains a crate::lightning::routing::utxo::UtxoLookup + Some(crate::lightning::routing::utxo::UtxoLookup), + /// When we're in this state, this COption_UtxoLookupZ contains nothing None } -impl COption_ChannelShutdownStateZ { +impl COption_UtxoLookupZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channelmanager::ChannelShutdownState { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::utxo::UtxoLookup { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channelmanager::ChannelShutdownState -pub extern "C" fn COption_ChannelShutdownStateZ_some(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> COption_ChannelShutdownStateZ { - COption_ChannelShutdownStateZ::Some(o) +/// Constructs a new COption_UtxoLookupZ containing a crate::lightning::routing::utxo::UtxoLookup +pub extern "C" fn COption_UtxoLookupZ_some(o: crate::lightning::routing::utxo::UtxoLookup) -> COption_UtxoLookupZ { + COption_UtxoLookupZ::Some(o) } #[no_mangle] -/// Constructs a new COption_ChannelShutdownStateZ containing nothing -pub extern "C" fn COption_ChannelShutdownStateZ_none() -> COption_ChannelShutdownStateZ { - COption_ChannelShutdownStateZ::None +/// Constructs a new COption_UtxoLookupZ containing nothing +pub extern "C" fn COption_UtxoLookupZ_none() -> COption_UtxoLookupZ { + COption_UtxoLookupZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::channelmanager::ChannelShutdownState, if we are in the Some state -pub extern "C" fn COption_ChannelShutdownStateZ_free(_res: COption_ChannelShutdownStateZ) { } -#[no_mangle] -/// Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ChannelShutdownStateZ_clone(orig: &COption_ChannelShutdownStateZ) -> COption_ChannelShutdownStateZ { Clone::clone(&orig) } +/// Frees any resources associated with the crate::lightning::routing::utxo::UtxoLookup, if we are in the Some state +pub extern "C" fn COption_UtxoLookupZ_free(_res: COption_UtxoLookupZ) { } #[repr(C)] -/// The contents of CResult_ThirtyTwoBytesAPIErrorZ -pub union CResult_ThirtyTwoBytesAPIErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, +/// The contents of CResult_NoneLightningErrorZ +pub union CResult_NoneLightningErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::util::errors::APIError, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_ThirtyTwoBytesAPIErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. +/// A CResult_NoneLightningErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ThirtyTwoBytesAPIErrorZ { - /// The contents of this CResult_ThirtyTwoBytesAPIErrorZ, accessible via either +pub struct CResult_NoneLightningErrorZ { + /// The contents of this CResult_NoneLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ThirtyTwoBytesAPIErrorZPtr, - /// Whether this CResult_ThirtyTwoBytesAPIErrorZ represents a success state. + pub contents: CResult_NoneLightningErrorZPtr, + /// Whether this CResult_NoneLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the success state. -pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesAPIErrorZ { - CResult_ThirtyTwoBytesAPIErrorZ { - contents: CResult_ThirtyTwoBytesAPIErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneLightningErrorZ in the success state. +pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the error state. -pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_ThirtyTwoBytesAPIErrorZ { - CResult_ThirtyTwoBytesAPIErrorZ { - contents: CResult_ThirtyTwoBytesAPIErrorZPtr { +/// Creates a new CResult_NoneLightningErrorZ in the error state. +pub extern "C" fn CResult_NoneLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_NoneLightningErrorZ { + CResult_NoneLightningErrorZ { + contents: CResult_NoneLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8612,18 +8336,15 @@ pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_err(e: crate::lightning::util: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_is_ok(o: &CResult_ThirtyTwoBytesAPIErrorZ) -> bool { +pub extern "C" fn CResult_NoneLightningErrorZ_is_ok(o: &CResult_NoneLightningErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ThirtyTwoBytesAPIErrorZ. -pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_free(_res: CResult_ThirtyTwoBytesAPIErrorZ) { } -impl Drop for CResult_ThirtyTwoBytesAPIErrorZ { +/// Frees any resources used by the CResult_NoneLightningErrorZ. +pub extern "C" fn CResult_NoneLightningErrorZ_free(_res: CResult_NoneLightningErrorZ) { } +impl Drop for CResult_NoneLightningErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8631,16 +8352,16 @@ impl Drop for CResult_ThirtyTwoBytesAPIErrorZ { } } } -impl From> for CResult_ThirtyTwoBytesAPIErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ThirtyTwoBytesAPIErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ThirtyTwoBytesAPIErrorZPtr { err } + CResult_NoneLightningErrorZPtr { err } }; Self { contents, @@ -8648,96 +8369,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ThirtyTwoBytesAPIErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_ThirtyTwoBytesAPIErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_clone(orig: &CResult_ThirtyTwoBytesAPIErrorZ) -> CResult_ThirtyTwoBytesAPIErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_RecentPaymentDetailsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_RecentPaymentDetailsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_RecentPaymentDetailsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } -impl Drop for CVec_RecentPaymentDetailsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} +pub extern "C" fn CResult_NoneLightningErrorZ_clone(orig: &CResult_NoneLightningErrorZ) -> CResult_NoneLightningErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePaymentSendFailureZ -pub union CResult_NonePaymentSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_boolLightningErrorZ +pub union CResult_boolLightningErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut bool, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, + pub err: *mut crate::lightning::ln::msgs::LightningError, } #[repr(C)] -/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// A CResult_boolLightningErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::msgs::LightningError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePaymentSendFailureZ { - /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either +pub struct CResult_boolLightningErrorZ { + /// The contents of this CResult_boolLightningErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePaymentSendFailureZPtr, - /// Whether this CResult_NonePaymentSendFailureZ represents a success state. + pub contents: CResult_boolLightningErrorZPtr, + /// Whether this CResult_boolLightningErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the success state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_boolLightningErrorZ in the success state. +pub extern "C" fn CResult_boolLightningErrorZ_ok(o: bool) -> CResult_boolLightningErrorZ { + CResult_boolLightningErrorZ { + contents: CResult_boolLightningErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ in the error state. -pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { - CResult_NonePaymentSendFailureZ { - contents: CResult_NonePaymentSendFailureZPtr { +/// Creates a new CResult_boolLightningErrorZ in the error state. +pub extern "C" fn CResult_boolLightningErrorZ_err(e: crate::lightning::ln::msgs::LightningError) -> CResult_boolLightningErrorZ { + CResult_boolLightningErrorZ { + contents: CResult_boolLightningErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8745,15 +8429,18 @@ pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::o } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_boolLightningErrorZ_is_ok(o: &CResult_boolLightningErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePaymentSendFailureZ. -pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } -impl Drop for CResult_NonePaymentSendFailureZ { +/// Frees any resources used by the CResult_boolLightningErrorZ. +pub extern "C" fn CResult_boolLightningErrorZ_free(_res: CResult_boolLightningErrorZ) { } +impl Drop for CResult_boolLightningErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -8761,16 +8448,16 @@ impl Drop for CResult_NonePaymentSendFailureZ { } } } -impl From> for CResult_NonePaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { +impl From> for CResult_boolLightningErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_boolLightningErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePaymentSendFailureZPtr { err } + CResult_boolLightningErrorZPtr { err } }; Self { contents, @@ -8778,151 +8465,188 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_boolLightningErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_boolLightningErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_boolLightningErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_NoneRetryableSendFailureZ -pub union CResult_NoneRetryableSendFailureZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, -} +pub extern "C" fn CResult_boolLightningErrorZ_clone(orig: &CResult_boolLightningErrorZ) -> CResult_boolLightningErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneRetryableSendFailureZ { - /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneRetryableSendFailureZPtr, - /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut(), - }, - result_ok: true, - } -} -#[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { - CResult_NoneRetryableSendFailureZ { - contents: CResult_NoneRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } -} -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { - o.result_ok +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + /// The element at position 0 + pub a: crate::lightning::ln::msgs::ChannelAnnouncement, + /// The element at position 1 + pub b: crate::lightning::ln::msgs::ChannelUpdate, + /// The element at position 2 + pub c: crate::lightning::ln::msgs::ChannelUpdate, } -#[no_mangle] -/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } -impl Drop for CResult_NoneRetryableSendFailureZ { - fn drop(&mut self) { - if self.result_ok { - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } +impl From<(crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)> for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + fn from (tup: (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, } } } -impl From> for CResult_NoneRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { - let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneRetryableSendFailureZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::ChannelUpdate) { + (self.a, self.b, self.c) } } -impl Clone for CResult_NoneRetryableSendFailureZ { +impl Clone for C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { - result: core::ptr::null_mut() - } } - } else { - Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), } } } #[no_mangle] -/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ThirtyTwoBytesPaymentSendFailureZ -pub union CResult_ThirtyTwoBytesPaymentSendFailureZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig: &C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a: crate::lightning::ln::msgs::ChannelAnnouncement, b: crate::lightning::ln::msgs::ChannelUpdate, c: crate::lightning::ln::msgs::ChannelUpdate) -> C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { a, b, c, } } + +#[no_mangle] +/// Frees any resources used by the C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ. +pub extern "C" fn C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res: C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) { } #[repr(C)] -/// A CResult_ThirtyTwoBytesPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ or not +pub enum COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ + Some(crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), + /// When we're in this state, this COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ contains nothing + None +} +impl COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing a crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ +pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o: crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ containing nothing +pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { + COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ, if we are in the Some state +pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res: COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) { } +#[no_mangle] +/// Creates a new COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig: &COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ) -> COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::MessageSendEvents of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_MessageSendEventZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::MessageSendEvent, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_MessageSendEventZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::MessageSendEvent] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_MessageSendEventZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_MessageSendEventZ_free(_res: CVec_MessageSendEventZ) { } +impl Drop for CVec_MessageSendEventZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_MessageSendEventZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_ChannelUpdateInfoDecodeErrorZ +pub union CResult_ChannelUpdateInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::gossip::ChannelUpdateInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelUpdateInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::ChannelUpdateInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ThirtyTwoBytesPaymentSendFailureZ { - /// The contents of this CResult_ThirtyTwoBytesPaymentSendFailureZ, accessible via either +pub struct CResult_ChannelUpdateInfoDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr, - /// Whether this CResult_ThirtyTwoBytesPaymentSendFailureZ represents a success state. + pub contents: CResult_ChannelUpdateInfoDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { - CResult_ThirtyTwoBytesPaymentSendFailureZ { - contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::ChannelUpdateInfo) -> CResult_ChannelUpdateInfoDecodeErrorZ { + CResult_ChannelUpdateInfoDecodeErrorZ { + contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { - CResult_ThirtyTwoBytesPaymentSendFailureZ { - contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateInfoDecodeErrorZ { + CResult_ChannelUpdateInfoDecodeErrorZ { + contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -8930,13 +8654,13 @@ pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(o: &CResult_ThirtyTwoBytesPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ThirtyTwoBytesPaymentSendFailureZ. -pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_free(_res: CResult_ThirtyTwoBytesPaymentSendFailureZ) { } -impl Drop for CResult_ThirtyTwoBytesPaymentSendFailureZ { +/// Frees any resources used by the CResult_ChannelUpdateInfoDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_free(_res: CResult_ChannelUpdateInfoDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -8949,16 +8673,16 @@ impl Drop for CResult_ThirtyTwoBytesPaymentSendFailureZ { } } } -impl From> for CResult_ThirtyTwoBytesPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ThirtyTwoBytesPaymentSendFailureZPtr { result } + CResult_ChannelUpdateInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ThirtyTwoBytesPaymentSendFailureZPtr { err } + CResult_ChannelUpdateInfoDecodeErrorZPtr { err } }; Self { contents, @@ -8966,59 +8690,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelUpdateInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelUpdateInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(orig: &CResult_ThirtyTwoBytesPaymentSendFailureZ) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig: &CResult_ChannelUpdateInfoDecodeErrorZ) -> CResult_ChannelUpdateInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ThirtyTwoBytesRetryableSendFailureZ -pub union CResult_ThirtyTwoBytesRetryableSendFailureZPtr { +/// The contents of CResult_ChannelInfoDecodeErrorZ +pub union CResult_ChannelInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::ThirtyTwoBytes, + pub result: *mut crate::lightning::routing::gossip::ChannelInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ThirtyTwoBytesRetryableSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. +/// A CResult_ChannelInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::ChannelInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ThirtyTwoBytesRetryableSendFailureZ { - /// The contents of this CResult_ThirtyTwoBytesRetryableSendFailureZ, accessible via either +pub struct CResult_ChannelInfoDecodeErrorZ { + /// The contents of this CResult_ChannelInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr, - /// Whether this CResult_ThirtyTwoBytesRetryableSendFailureZ represents a success state. + pub contents: CResult_ChannelInfoDecodeErrorZPtr, + /// Whether this CResult_ChannelInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ in the success state. -pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { - CResult_ThirtyTwoBytesRetryableSendFailureZ { - contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { +/// Creates a new CResult_ChannelInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::ChannelInfo) -> CResult_ChannelInfoDecodeErrorZ { + CResult_ChannelInfoDecodeErrorZ { + contents: CResult_ChannelInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ in the error state. -pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { - CResult_ThirtyTwoBytesRetryableSendFailureZ { - contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { +/// Creates a new CResult_ChannelInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelInfoDecodeErrorZ { + CResult_ChannelInfoDecodeErrorZ { + contents: CResult_ChannelInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9026,13 +8750,13 @@ pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(o: &CResult_ThirtyTwoBytesRetryableSendFailureZ) -> bool { +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_is_ok(o: &CResult_ChannelInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ThirtyTwoBytesRetryableSendFailureZ. -pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_free(_res: CResult_ThirtyTwoBytesRetryableSendFailureZ) { } -impl Drop for CResult_ThirtyTwoBytesRetryableSendFailureZ { +/// Frees any resources used by the CResult_ChannelInfoDecodeErrorZ. +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_free(_res: CResult_ChannelInfoDecodeErrorZ) { } +impl Drop for CResult_ChannelInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9045,16 +8769,16 @@ impl Drop for CResult_ThirtyTwoBytesRetryableSendFailureZ { } } } -impl From> for CResult_ThirtyTwoBytesRetryableSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ThirtyTwoBytesRetryableSendFailureZPtr { result } + CResult_ChannelInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ThirtyTwoBytesRetryableSendFailureZPtr { err } + CResult_ChannelInfoDecodeErrorZPtr { err } }; Self { contents, @@ -9062,101 +8786,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ which has the same data as `orig` +/// Creates a new CResult_ChannelInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(orig: &CResult_ThirtyTwoBytesRetryableSendFailureZ) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelInfoDecodeErrorZ_clone(orig: &CResult_ChannelInfoDecodeErrorZ) -> CResult_ChannelInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, +/// The contents of CResult_RoutingFeesDecodeErrorZ +pub union CResult_RoutingFeesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning_types::routing::RoutingFees, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_RoutingFeesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::routing::RoutingFees on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_RoutingFeesDecodeErrorZ { + /// The contents of this CResult_RoutingFeesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_RoutingFeesDecodeErrorZPtr, + /// Whether this CResult_RoutingFeesDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(orig: &C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { - C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(_res: C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ -pub union CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, -} -#[repr(C)] -/// A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - /// The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr, - /// Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ in the success state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +#[no_mangle] +/// Creates a new CResult_RoutingFeesDecodeErrorZ in the success state. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_ok(o: crate::lightning_types::routing::RoutingFees) -> CResult_RoutingFeesDecodeErrorZ { + CResult_RoutingFeesDecodeErrorZ { + contents: CResult_RoutingFeesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ in the error state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { +/// Creates a new CResult_RoutingFeesDecodeErrorZ in the error state. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RoutingFeesDecodeErrorZ { + CResult_RoutingFeesDecodeErrorZ { + contents: CResult_RoutingFeesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9164,13 +8846,13 @@ pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailur } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) -> bool { +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_is_ok(o: &CResult_RoutingFeesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) { } -impl Drop for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { +/// Frees any resources used by the CResult_RoutingFeesDecodeErrorZ. +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_free(_res: CResult_RoutingFeesDecodeErrorZ) { } +impl Drop for CResult_RoutingFeesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9183,16 +8865,16 @@ impl Drop for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { } } } -impl From> for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RoutingFeesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { result } + CResult_RoutingFeesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { err } + CResult_RoutingFeesDecodeErrorZPtr { err } }; Self { contents, @@ -9200,47 +8882,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RoutingFeesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_RoutingFeesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ which has the same data as `orig` +/// Creates a new CResult_RoutingFeesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RoutingFeesDecodeErrorZ_clone(orig: &CResult_RoutingFeesDecodeErrorZ) -> CResult_RoutingFeesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZs of arbitrary size. +/// A dynamically-allocated array of crate::lightning::ln::msgs::SocketAddresss of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { +pub struct CVec_SocketAddressZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, + pub data: *mut crate::lightning::ln::msgs::SocketAddress, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_SocketAddressZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::SocketAddress] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_SocketAddressZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -9248,14 +8930,14 @@ impl From> f } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ) { } -impl Drop for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { +pub extern "C" fn CVec_SocketAddressZ_free(_res: CVec_SocketAddressZ) { } +impl Drop for CVec_SocketAddressZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { +impl Clone for CVec_SocketAddressZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -9264,41 +8946,41 @@ impl Clone for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { } } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ -pub union CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { +/// The contents of CResult_NodeAnnouncementInfoDecodeErrorZ +pub union CResult_NodeAnnouncementInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ, + pub result: *mut crate::lightning::routing::gossip::NodeAnnouncementInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::outbound_payment::ProbeSendFailure, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ on success and a crate::lightning::ln::outbound_payment::ProbeSendFailure on failure. +/// A CResult_NodeAnnouncementInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::NodeAnnouncementInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - /// The contents of this CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ, accessible via either +pub struct CResult_NodeAnnouncementInfoDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr, - /// Whether this CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ represents a success state. + pub contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(o: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> CResult_NodeAnnouncementInfoDecodeErrorZ { + CResult_NodeAnnouncementInfoDecodeErrorZ { + contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(e: crate::lightning::ln::outbound_payment::ProbeSendFailure) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementInfoDecodeErrorZ { + CResult_NodeAnnouncementInfoDecodeErrorZ { + contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9306,13 +8988,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFa } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(o: &CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) -> bool { +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(_res: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) { } -impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { +/// Frees any resources used by the CResult_NodeAnnouncementInfoDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res: CResult_NodeAnnouncementInfoDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9325,16 +9007,16 @@ impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailur } } } -impl From> for CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeAnnouncementInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { result } + CResult_NodeAnnouncementInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { err } + CResult_NodeAnnouncementInfoDecodeErrorZPtr { err } }; Self { contents, @@ -9342,183 +9024,192 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NodeAnnouncementInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ which has the same data as `orig` +/// Creates a new CResult_NodeAnnouncementInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(orig: &CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementInfoDecodeErrorZ) -> CResult_NodeAnnouncementInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesPublicKeyZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::PublicKey, +/// The contents of CResult_NodeAliasDecodeErrorZ +pub union CResult_NodeAliasDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::gossip::NodeAlias, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::PublicKey)> for C2Tuple_ThirtyTwoBytesPublicKeyZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::PublicKey)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } +#[repr(C)] +/// A CResult_NodeAliasDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::NodeAlias on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NodeAliasDecodeErrorZ { + /// The contents of this CResult_NodeAliasDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NodeAliasDecodeErrorZPtr, + /// Whether this CResult_NodeAliasDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl C2Tuple_ThirtyTwoBytesPublicKeyZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::PublicKey) { - (self.a, self.b) +#[no_mangle] +/// Creates a new CResult_NodeAliasDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAliasDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeAlias) -> CResult_NodeAliasDecodeErrorZ { + CResult_NodeAliasDecodeErrorZ { + contents: CResult_NodeAliasDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for C2Tuple_ThirtyTwoBytesPublicKeyZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } +#[no_mangle] +/// Creates a new CResult_NodeAliasDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAliasDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAliasDecodeErrorZ { + CResult_NodeAliasDecodeErrorZ { + contents: CResult_NodeAliasDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(orig: &C2Tuple_ThirtyTwoBytesPublicKeyZ) -> C2Tuple_ThirtyTwoBytesPublicKeyZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ThirtyTwoBytesPublicKeyZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesPublicKeyZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::PublicKey) -> C2Tuple_ThirtyTwoBytesPublicKeyZ { - C2Tuple_ThirtyTwoBytesPublicKeyZ { a, b, } +pub extern "C" fn CResult_NodeAliasDecodeErrorZ_is_ok(o: &CResult_NodeAliasDecodeErrorZ) -> bool { + o.result_ok } - #[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesPublicKeyZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesPublicKeyZ_free(_res: C2Tuple_ThirtyTwoBytesPublicKeyZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesPublicKeyZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesPublicKeyZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesPublicKeyZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Frees any resources used by the CResult_NodeAliasDecodeErrorZ. +pub extern "C" fn CResult_NodeAliasDecodeErrorZ_free(_res: CResult_NodeAliasDecodeErrorZ) { } +impl Drop for CResult_NodeAliasDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ) { } -impl Drop for CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +impl From> for CResult_NodeAliasDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NodeAliasDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NodeAliasDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ { +impl Clone for CResult_NodeAliasDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_NodeAliasDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_NodeAliasDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_NodeAliasDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NodeAliasDecodeErrorZ_clone(orig: &CResult_NodeAliasDecodeErrorZ) -> CResult_NodeAliasDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::c_types::Str or not -pub enum COption_StrZ { - /// When we're in this state, this COption_StrZ contains a crate::c_types::Str - Some(crate::c_types::Str), - /// When we're in this state, this COption_StrZ contains nothing +/// An enum which can either contain a crate::lightning::routing::gossip::NodeAnnouncementInfo or not +pub enum COption_NodeAnnouncementInfoZ { + /// When we're in this state, this COption_NodeAnnouncementInfoZ contains a crate::lightning::routing::gossip::NodeAnnouncementInfo + Some(crate::lightning::routing::gossip::NodeAnnouncementInfo), + /// When we're in this state, this COption_NodeAnnouncementInfoZ contains nothing None } -impl COption_StrZ { +impl COption_NodeAnnouncementInfoZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::Str { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::routing::gossip::NodeAnnouncementInfo { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_StrZ containing a crate::c_types::Str -pub extern "C" fn COption_StrZ_some(o: crate::c_types::Str) -> COption_StrZ { - COption_StrZ::Some(o) +/// Constructs a new COption_NodeAnnouncementInfoZ containing a crate::lightning::routing::gossip::NodeAnnouncementInfo +pub extern "C" fn COption_NodeAnnouncementInfoZ_some(o: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> COption_NodeAnnouncementInfoZ { + COption_NodeAnnouncementInfoZ::Some(o) } #[no_mangle] -/// Constructs a new COption_StrZ containing nothing -pub extern "C" fn COption_StrZ_none() -> COption_StrZ { - COption_StrZ::None +/// Constructs a new COption_NodeAnnouncementInfoZ containing nothing +pub extern "C" fn COption_NodeAnnouncementInfoZ_none() -> COption_NodeAnnouncementInfoZ { + COption_NodeAnnouncementInfoZ::None } #[no_mangle] -/// Frees any resources associated with the crate::c_types::Str, if we are in the Some state -pub extern "C" fn COption_StrZ_free(_res: COption_StrZ) { } +/// Frees any resources associated with the crate::lightning::routing::gossip::NodeAnnouncementInfo, if we are in the Some state +pub extern "C" fn COption_NodeAnnouncementInfoZ_free(_res: COption_NodeAnnouncementInfoZ) { } #[no_mangle] -/// Creates a new COption_StrZ which has the same data as `orig` +/// Creates a new COption_NodeAnnouncementInfoZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_StrZ_clone(orig: &COption_StrZ) -> COption_StrZ { Clone::clone(&orig) } +pub extern "C" fn COption_NodeAnnouncementInfoZ_clone(orig: &COption_NodeAnnouncementInfoZ) -> COption_NodeAnnouncementInfoZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneBolt12SemanticErrorZ -pub union CResult_NoneBolt12SemanticErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_NodeInfoDecodeErrorZ +pub union CResult_NodeInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::routing::gossip::NodeInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneBolt12SemanticErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// A CResult_NodeInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::NodeInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneBolt12SemanticErrorZ { - /// The contents of this CResult_NoneBolt12SemanticErrorZ, accessible via either +pub struct CResult_NodeInfoDecodeErrorZ { + /// The contents of this CResult_NodeInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneBolt12SemanticErrorZPtr, - /// Whether this CResult_NoneBolt12SemanticErrorZ represents a success state. + pub contents: CResult_NodeInfoDecodeErrorZPtr, + /// Whether this CResult_NodeInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneBolt12SemanticErrorZ in the success state. -pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_ok() -> CResult_NoneBolt12SemanticErrorZ { - CResult_NoneBolt12SemanticErrorZ { - contents: CResult_NoneBolt12SemanticErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_NodeInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NodeInfo) -> CResult_NodeInfoDecodeErrorZ { + CResult_NodeInfoDecodeErrorZ { + contents: CResult_NodeInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneBolt12SemanticErrorZ in the error state. -pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_NoneBolt12SemanticErrorZ { - CResult_NoneBolt12SemanticErrorZ { - contents: CResult_NoneBolt12SemanticErrorZPtr { +/// Creates a new CResult_NodeInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeInfoDecodeErrorZ { + CResult_NodeInfoDecodeErrorZ { + contents: CResult_NodeInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9526,15 +9217,18 @@ pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_err(e: crate::lightning::offe } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_is_ok(o: &CResult_NoneBolt12SemanticErrorZ) -> bool { +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_is_ok(o: &CResult_NodeInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneBolt12SemanticErrorZ. -pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_free(_res: CResult_NoneBolt12SemanticErrorZ) { } -impl Drop for CResult_NoneBolt12SemanticErrorZ { +/// Frees any resources used by the CResult_NodeInfoDecodeErrorZ. +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_free(_res: CResult_NodeInfoDecodeErrorZ) { } +impl Drop for CResult_NodeInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -9542,16 +9236,16 @@ impl Drop for CResult_NoneBolt12SemanticErrorZ { } } } -impl From> for CResult_NoneBolt12SemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::offers::parse::Bolt12SemanticError>) -> Self { +impl From> for CResult_NodeInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneBolt12SemanticErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_NodeInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneBolt12SemanticErrorZPtr { err } + CResult_NodeInfoDecodeErrorZPtr { err } }; Self { contents, @@ -9559,91 +9253,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneBolt12SemanticErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_NodeInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneBolt12SemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NodeInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneBolt12SemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_NodeInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneBolt12SemanticErrorZ_clone(orig: &CResult_NoneBolt12SemanticErrorZ) -> CResult_NoneBolt12SemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeInfoDecodeErrorZ_clone(orig: &CResult_NodeInfoDecodeErrorZ) -> CResult_NodeInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ -pub union CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { +/// The contents of CResult_NetworkGraphDecodeErrorZ +pub union CResult_NetworkGraphDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::routing::gossip::NetworkGraph, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a () on failure. +/// A CResult_NetworkGraphDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::routing::gossip::NetworkGraph on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - /// The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ, accessible via either +pub struct CResult_NetworkGraphDecodeErrorZ { + /// The contents of this CResult_NetworkGraphDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr, - /// Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents a success state. + pub contents: CResult_NetworkGraphDecodeErrorZPtr, + /// Whether this CResult_NetworkGraphDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { +/// Creates a new CResult_NetworkGraphDecodeErrorZ in the success state. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_ok(o: crate::lightning::routing::gossip::NetworkGraph) -> CResult_NetworkGraphDecodeErrorZ { + CResult_NetworkGraphDecodeErrorZ { + contents: CResult_NetworkGraphDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err() -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_NetworkGraphDecodeErrorZ in the error state. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NetworkGraphDecodeErrorZ { + CResult_NetworkGraphDecodeErrorZ { + contents: CResult_NetworkGraphDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) -> bool { +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_is_ok(o: &CResult_NetworkGraphDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) { } -impl Drop for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { +/// Frees any resources used by the CResult_NetworkGraphDecodeErrorZ. +pub extern "C" fn CResult_NetworkGraphDecodeErrorZ_free(_res: CResult_NetworkGraphDecodeErrorZ) { } +impl Drop for CResult_NetworkGraphDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NetworkGraphDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { result } + CResult_NetworkGraphDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NetworkGraphDecodeErrorZPtr { err } }; Self { contents, @@ -9651,188 +9349,79 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { Clone::clone(&orig) } #[repr(C)] #[derive(Clone)] -/// An enum which can either contain a crate::lightning::onion_message::offers::OffersMessage or not -pub enum COption_OffersMessageZ { - /// When we're in this state, this COption_OffersMessageZ contains a crate::lightning::onion_message::offers::OffersMessage - Some(crate::lightning::onion_message::offers::OffersMessage), - /// When we're in this state, this COption_OffersMessageZ contains nothing +/// An enum which can either contain a crate::c_types::derived::CVec_SocketAddressZ or not +pub enum COption_CVec_SocketAddressZZ { + /// When we're in this state, this COption_CVec_SocketAddressZZ contains a crate::c_types::derived::CVec_SocketAddressZ + Some(crate::c_types::derived::CVec_SocketAddressZ), + /// When we're in this state, this COption_CVec_SocketAddressZZ contains nothing None } -impl COption_OffersMessageZ { +impl COption_CVec_SocketAddressZZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::offers::OffersMessage { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::CVec_SocketAddressZ { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_OffersMessageZ containing a crate::lightning::onion_message::offers::OffersMessage -pub extern "C" fn COption_OffersMessageZ_some(o: crate::lightning::onion_message::offers::OffersMessage) -> COption_OffersMessageZ { - COption_OffersMessageZ::Some(o) +/// Constructs a new COption_CVec_SocketAddressZZ containing a crate::c_types::derived::CVec_SocketAddressZ +pub extern "C" fn COption_CVec_SocketAddressZZ_some(o: crate::c_types::derived::CVec_SocketAddressZ) -> COption_CVec_SocketAddressZZ { + COption_CVec_SocketAddressZZ::Some(o) } #[no_mangle] -/// Constructs a new COption_OffersMessageZ containing nothing -pub extern "C" fn COption_OffersMessageZ_none() -> COption_OffersMessageZ { - COption_OffersMessageZ::None +/// Constructs a new COption_CVec_SocketAddressZZ containing nothing +pub extern "C" fn COption_CVec_SocketAddressZZ_none() -> COption_CVec_SocketAddressZZ { + COption_CVec_SocketAddressZZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::onion_message::offers::OffersMessage, if we are in the Some state -pub extern "C" fn COption_OffersMessageZ_free(_res: COption_OffersMessageZ) { } +/// Frees any resources associated with the crate::c_types::derived::CVec_SocketAddressZ, if we are in the Some state +pub extern "C" fn COption_CVec_SocketAddressZZ_free(_res: COption_CVec_SocketAddressZZ) { } #[no_mangle] -/// Creates a new COption_OffersMessageZ which has the same data as `orig` +/// Creates a new COption_CVec_SocketAddressZZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_OffersMessageZ_clone(orig: &COption_OffersMessageZ) -> COption_OffersMessageZ { Clone::clone(&orig) } +pub extern "C" fn COption_CVec_SocketAddressZZ_clone(orig: &COption_CVec_SocketAddressZZ) -> COption_CVec_SocketAddressZZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OffersMessageDestinationBlindedPathZ { - /// The element at position 0 - pub a: crate::lightning::onion_message::offers::OffersMessage, - /// The element at position 1 - pub b: crate::lightning::onion_message::messenger::Destination, - /// The element at position 2 - pub c: crate::lightning::blinded_path::BlindedPath, -} -impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)> for C3Tuple_OffersMessageDestinationBlindedPathZ { - fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_OffersMessageDestinationBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_OffersMessageDestinationBlindedPathZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OffersMessageDestinationBlindedPathZ_clone(orig: &C3Tuple_OffersMessageDestinationBlindedPathZ) -> C3Tuple_OffersMessageDestinationBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OffersMessageDestinationBlindedPathZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OffersMessageDestinationBlindedPathZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::Destination, c: crate::lightning::blinded_path::BlindedPath) -> C3Tuple_OffersMessageDestinationBlindedPathZ { - C3Tuple_OffersMessageDestinationBlindedPathZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_OffersMessageDestinationBlindedPathZ. -pub extern "C" fn C3Tuple_OffersMessageDestinationBlindedPathZ_free(_res: C3Tuple_OffersMessageDestinationBlindedPathZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OffersMessageDestinationBlindedPathZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(_res: CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ) { } -impl Drop for CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ -pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// The contents of CResult_u64ShortChannelIdErrorZ +pub union CResult_u64ShortChannelIdErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut u64, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::util::scid_utils::ShortChannelIdError, } #[repr(C)] -/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_u64ShortChannelIdErrorZ represents the result of a fallible operation, +/// containing a u64 on success and a crate::lightning::util::scid_utils::ShortChannelIdError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { - /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either +pub struct CResult_u64ShortChannelIdErrorZ { + /// The contents of this CResult_u64ShortChannelIdErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, - /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. + pub contents: CResult_u64ShortChannelIdErrorZPtr, + /// Whether this CResult_u64ShortChannelIdErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { +/// Creates a new CResult_u64ShortChannelIdErrorZ in the success state. +pub extern "C" fn CResult_u64ShortChannelIdErrorZ_ok(o: u64) -> CResult_u64ShortChannelIdErrorZ { + CResult_u64ShortChannelIdErrorZ { + contents: CResult_u64ShortChannelIdErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { - CResult_CounterpartyForwardingInfoDecodeErrorZ { - contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { +/// Creates a new CResult_u64ShortChannelIdErrorZ in the error state. +pub extern "C" fn CResult_u64ShortChannelIdErrorZ_err(e: crate::lightning::util::scid_utils::ShortChannelIdError) -> CResult_u64ShortChannelIdErrorZ { + CResult_u64ShortChannelIdErrorZ { + contents: CResult_u64ShortChannelIdErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9840,13 +9429,13 @@ pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_u64ShortChannelIdErrorZ_is_ok(o: &CResult_u64ShortChannelIdErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } -impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { +/// Frees any resources used by the CResult_u64ShortChannelIdErrorZ. +pub extern "C" fn CResult_u64ShortChannelIdErrorZ_free(_res: CResult_u64ShortChannelIdErrorZ) { } +impl Drop for CResult_u64ShortChannelIdErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9859,16 +9448,16 @@ impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { } } } -impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_u64ShortChannelIdErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } + CResult_u64ShortChannelIdErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } + CResult_u64ShortChannelIdErrorZPtr { err } }; Self { contents, @@ -9876,59 +9465,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelCounterpartyDecodeErrorZ -pub union CResult_ChannelCounterpartyDecodeErrorZPtr { +/// The contents of CResult_PendingHTLCInfoInboundHTLCErrZ +pub union CResult_PendingHTLCInfoInboundHTLCErrZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelCounterparty, + pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::onion_payment::InboundHTLCErr, } #[repr(C)] -/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PendingHTLCInfoInboundHTLCErrZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PendingHTLCInfo on success and a crate::lightning::ln::onion_payment::InboundHTLCErr on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelCounterpartyDecodeErrorZ { - /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either +pub struct CResult_PendingHTLCInfoInboundHTLCErrZ { + /// The contents of this CResult_PendingHTLCInfoInboundHTLCErrZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, - /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. + pub contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr, + /// Whether this CResult_PendingHTLCInfoInboundHTLCErrZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { +/// Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ in the success state. +pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCInfo) -> CResult_PendingHTLCInfoInboundHTLCErrZ { + CResult_PendingHTLCInfoInboundHTLCErrZ { + contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { - CResult_ChannelCounterpartyDecodeErrorZ { - contents: CResult_ChannelCounterpartyDecodeErrorZPtr { +/// Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ in the error state. +pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_err(e: crate::lightning::ln::onion_payment::InboundHTLCErr) -> CResult_PendingHTLCInfoInboundHTLCErrZ { + CResult_PendingHTLCInfoInboundHTLCErrZ { + contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -9936,13 +9508,13 @@ pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_is_ok(o: &CResult_PendingHTLCInfoInboundHTLCErrZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } -impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { +/// Frees any resources used by the CResult_PendingHTLCInfoInboundHTLCErrZ. +pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_free(_res: CResult_PendingHTLCInfoInboundHTLCErrZ) { } +impl Drop for CResult_PendingHTLCInfoInboundHTLCErrZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -9955,16 +9527,16 @@ impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { } } } -impl From> for CResult_ChannelCounterpartyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PendingHTLCInfoInboundHTLCErrZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelCounterpartyDecodeErrorZPtr { result } + CResult_PendingHTLCInfoInboundHTLCErrZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelCounterpartyDecodeErrorZPtr { err } + CResult_PendingHTLCInfoInboundHTLCErrZPtr { err } }; Self { contents, @@ -9972,191 +9544,312 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PendingHTLCInfoInboundHTLCErrZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PendingHTLCInfoInboundHTLCErrZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelDetailsDecodeErrorZ -pub union CResult_ChannelDetailsDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelDetails, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_PendingHTLCInfoInboundHTLCErrZ_clone(orig: &CResult_PendingHTLCInfoInboundHTLCErrZ) -> CResult_PendingHTLCInfoInboundHTLCErrZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelDetailsDecodeErrorZ { - /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelDetailsDecodeErrorZPtr, - /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::ln::chan_utils::HTLCOutputInCommitments of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCOutputInCommitmentZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_HTLCOutputInCommitmentZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { - CResult_ChannelDetailsDecodeErrorZ { - contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::HTLCOutputInCommitment] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_HTLCOutputInCommitmentZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } -impl Drop for CResult_ChannelDetailsDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCOutputInCommitmentZ_free(_res: CVec_HTLCOutputInCommitmentZ) { } +impl Drop for CVec_HTLCOutputInCommitmentZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelDetailsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelDetailsDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelDetailsDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelDetailsDecodeErrorZ { +impl Clone for CVec_HTLCOutputInCommitmentZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::sign::HTLCDescriptors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_HTLCDescriptorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::sign::HTLCDescriptor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_HTLCDescriptorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::sign::HTLCDescriptor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_HTLCDescriptorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_HTLCDescriptorZ_free(_res: CVec_HTLCDescriptorZ) { } +impl Drop for CVec_HTLCDescriptorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_HTLCDescriptorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Utxos of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UtxoZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Utxo, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UtxoZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Utxo] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UtxoZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UtxoZ_free(_res: CVec_UtxoZ) { } +impl Drop for CVec_UtxoZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UtxoZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::TxOut or not +pub enum COption_TxOutZ { + /// When we're in this state, this COption_TxOutZ contains a crate::c_types::TxOut + Some(crate::c_types::TxOut), + /// When we're in this state, this COption_TxOutZ contains nothing + None +} +impl COption_TxOutZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::TxOut { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing a crate::c_types::TxOut +pub extern "C" fn COption_TxOutZ_some(o: crate::c_types::TxOut) -> COption_TxOutZ { + COption_TxOutZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_TxOutZ containing nothing +pub extern "C" fn COption_TxOutZ_none() -> COption_TxOutZ { + COption_TxOutZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::TxOut, if we are in the Some state +pub extern "C" fn COption_TxOutZ_free(_res: COption_TxOutZ) { } +#[no_mangle] +/// Creates a new COption_TxOutZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_TxOutZ_clone(orig: &COption_TxOutZ) -> COption_TxOutZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PhantomRouteHintsDecodeErrorZ -pub union CResult_PhantomRouteHintsDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::events::bump_transaction::Inputs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_InputZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::bump_transaction::Input, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_InputZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::bump_transaction::Input] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_InputZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_InputZ_free(_res: CVec_InputZ) { } +impl Drop for CVec_InputZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_InputZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CoinSelectionNoneZ +pub union CResult_CoinSelectionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::events::bump_transaction::CoinSelection, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CoinSelectionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::events::bump_transaction::CoinSelection on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PhantomRouteHintsDecodeErrorZ { - /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either +pub struct CResult_CoinSelectionNoneZ { + /// The contents of this CResult_CoinSelectionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, - /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. + pub contents: CResult_CoinSelectionNoneZPtr, + /// Whether this CResult_CoinSelectionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { +/// Creates a new CResult_CoinSelectionNoneZ in the success state. +pub extern "C" fn CResult_CoinSelectionNoneZ_ok(o: crate::lightning::events::bump_transaction::CoinSelection) -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { - CResult_PhantomRouteHintsDecodeErrorZ { - contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CoinSelectionNoneZ in the error state. +pub extern "C" fn CResult_CoinSelectionNoneZ_err() -> CResult_CoinSelectionNoneZ { + CResult_CoinSelectionNoneZ { + contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CoinSelectionNoneZ_is_ok(o: &CResult_CoinSelectionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } -impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { +/// Frees any resources used by the CResult_CoinSelectionNoneZ. +pub extern "C" fn CResult_CoinSelectionNoneZ_free(_res: CResult_CoinSelectionNoneZ) { } +impl Drop for CResult_CoinSelectionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_PhantomRouteHintsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CoinSelectionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PhantomRouteHintsDecodeErrorZPtr { result } + CResult_CoinSelectionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PhantomRouteHintsDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CoinSelectionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -10164,95 +9857,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CoinSelectionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CoinSelectionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CoinSelectionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CoinSelectionNoneZ_clone(orig: &CResult_CoinSelectionNoneZ) -> CResult_CoinSelectionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedForwardDecodeErrorZ -pub union CResult_BlindedForwardDecodeErrorZPtr { - /// A pointer to the contents in the success state. +/// The contents of CResult_CVec_UtxoZNoneZ +pub union CResult_CVec_UtxoZNoneZPtr { + /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::BlindedForward, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_UtxoZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_BlindedForwardDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::BlindedForward on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_UtxoZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_UtxoZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedForwardDecodeErrorZ { - /// The contents of this CResult_BlindedForwardDecodeErrorZ, accessible via either +pub struct CResult_CVec_UtxoZNoneZ { + /// The contents of this CResult_CVec_UtxoZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedForwardDecodeErrorZPtr, - /// Whether this CResult_BlindedForwardDecodeErrorZ represents a success state. + pub contents: CResult_CVec_UtxoZNoneZPtr, + /// Whether this CResult_CVec_UtxoZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedForwardDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::BlindedForward) -> CResult_BlindedForwardDecodeErrorZ { - CResult_BlindedForwardDecodeErrorZ { - contents: CResult_BlindedForwardDecodeErrorZPtr { +/// Creates a new CResult_CVec_UtxoZNoneZ in the success state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_ok(o: crate::c_types::derived::CVec_UtxoZ) -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedForwardDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedForwardDecodeErrorZ { - CResult_BlindedForwardDecodeErrorZ { - contents: CResult_BlindedForwardDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_UtxoZNoneZ in the error state. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_err() -> CResult_CVec_UtxoZNoneZ { + CResult_CVec_UtxoZNoneZ { + contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_is_ok(o: &CResult_BlindedForwardDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_UtxoZNoneZ_is_ok(o: &CResult_CVec_UtxoZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedForwardDecodeErrorZ. -pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_free(_res: CResult_BlindedForwardDecodeErrorZ) { } -impl Drop for CResult_BlindedForwardDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_UtxoZNoneZ. +pub extern "C" fn CResult_CVec_UtxoZNoneZ_free(_res: CResult_CVec_UtxoZNoneZ) { } +impl Drop for CResult_CVec_UtxoZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_BlindedForwardDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_UtxoZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedForwardDecodeErrorZPtr { result } + CResult_CVec_UtxoZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedForwardDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_UtxoZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -10260,59 +9949,175 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedForwardDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_UtxoZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedForwardDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_UtxoZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_BlindedForwardDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_UtxoZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_clone(orig: &CResult_BlindedForwardDecodeErrorZ) -> CResult_BlindedForwardDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_UtxoZNoneZ_clone(orig: &CResult_CVec_UtxoZNoneZ) -> CResult_CVec_UtxoZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PendingHTLCRoutingDecodeErrorZ -pub union CResult_PendingHTLCRoutingDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::blinded_path::payment::PaymentContext or not +pub enum COption_PaymentContextZ { + /// When we're in this state, this COption_PaymentContextZ contains a crate::lightning::blinded_path::payment::PaymentContext + Some(crate::lightning::blinded_path::payment::PaymentContext), + /// When we're in this state, this COption_PaymentContextZ contains nothing + None +} +impl COption_PaymentContextZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::blinded_path::payment::PaymentContext { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentContextZ containing a crate::lightning::blinded_path::payment::PaymentContext +pub extern "C" fn COption_PaymentContextZ_some(o: crate::lightning::blinded_path::payment::PaymentContext) -> COption_PaymentContextZ { + COption_PaymentContextZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentContextZ containing nothing +pub extern "C" fn COption_PaymentContextZ_none() -> COption_PaymentContextZ { + COption_PaymentContextZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::blinded_path::payment::PaymentContext, if we are in the Some state +pub extern "C" fn COption_PaymentContextZ_free(_res: COption_PaymentContextZ) { } +#[no_mangle] +/// Creates a new COption_PaymentContextZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentContextZ_clone(orig: &COption_PaymentContextZ) -> COption_PaymentContextZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u64u16Z { + /// The element at position 0 + pub a: u64, + /// The element at position 1 + pub b: u16, +} +impl From<(u64, u16)> for C2Tuple_u64u16Z { + fn from (tup: (u64, u16)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_u64u16Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u64, u16) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u64u16Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u64u16Z_clone(orig: &C2Tuple_u64u16Z) -> C2Tuple_u64u16Z { Clone::clone(&orig) } +/// Creates a new C2Tuple_u64u16Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u64u16Z_new(a: u64, b: u16) -> C2Tuple_u64u16Z { + C2Tuple_u64u16Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u64u16Z. +pub extern "C" fn C2Tuple_u64u16Z_free(_res: C2Tuple_u64u16Z) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_u64u16Z or not +pub enum COption_C2Tuple_u64u16ZZ { + /// When we're in this state, this COption_C2Tuple_u64u16ZZ contains a crate::c_types::derived::C2Tuple_u64u16Z + Some(crate::c_types::derived::C2Tuple_u64u16Z), + /// When we're in this state, this COption_C2Tuple_u64u16ZZ contains nothing + None +} +impl COption_C2Tuple_u64u16ZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_u64u16Z { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u16ZZ containing a crate::c_types::derived::C2Tuple_u64u16Z +pub extern "C" fn COption_C2Tuple_u64u16ZZ_some(o: crate::c_types::derived::C2Tuple_u64u16Z) -> COption_C2Tuple_u64u16ZZ { + COption_C2Tuple_u64u16ZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_u64u16ZZ containing nothing +pub extern "C" fn COption_C2Tuple_u64u16ZZ_none() -> COption_C2Tuple_u64u16ZZ { + COption_C2Tuple_u64u16ZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_u64u16Z, if we are in the Some state +pub extern "C" fn COption_C2Tuple_u64u16ZZ_free(_res: COption_C2Tuple_u64u16ZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_u64u16ZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_u64u16ZZ_clone(orig: &COption_C2Tuple_u64u16ZZ) -> COption_C2Tuple_u64u16ZZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelIdAPIErrorZ +pub union CResult_ChannelIdAPIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCRouting, + pub result: *mut crate::lightning::ln::types::ChannelId, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_PendingHTLCRoutingDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PendingHTLCRouting on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelIdAPIErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PendingHTLCRoutingDecodeErrorZ { - /// The contents of this CResult_PendingHTLCRoutingDecodeErrorZ, accessible via either +pub struct CResult_ChannelIdAPIErrorZ { + /// The contents of this CResult_ChannelIdAPIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PendingHTLCRoutingDecodeErrorZPtr, - /// Whether this CResult_PendingHTLCRoutingDecodeErrorZ represents a success state. + pub contents: CResult_ChannelIdAPIErrorZPtr, + /// Whether this CResult_ChannelIdAPIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ in the success state. -pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCRouting) -> CResult_PendingHTLCRoutingDecodeErrorZ { - CResult_PendingHTLCRoutingDecodeErrorZ { - contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { +/// Creates a new CResult_ChannelIdAPIErrorZ in the success state. +pub extern "C" fn CResult_ChannelIdAPIErrorZ_ok(o: crate::lightning::ln::types::ChannelId) -> CResult_ChannelIdAPIErrorZ { + CResult_ChannelIdAPIErrorZ { + contents: CResult_ChannelIdAPIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ in the error state. -pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PendingHTLCRoutingDecodeErrorZ { - CResult_PendingHTLCRoutingDecodeErrorZ { - contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { +/// Creates a new CResult_ChannelIdAPIErrorZ in the error state. +pub extern "C" fn CResult_ChannelIdAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_ChannelIdAPIErrorZ { + CResult_ChannelIdAPIErrorZ { + contents: CResult_ChannelIdAPIErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10320,13 +10125,13 @@ pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_is_ok(o: &CResult_PendingHTLCRoutingDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelIdAPIErrorZ_is_ok(o: &CResult_ChannelIdAPIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PendingHTLCRoutingDecodeErrorZ. -pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_free(_res: CResult_PendingHTLCRoutingDecodeErrorZ) { } -impl Drop for CResult_PendingHTLCRoutingDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelIdAPIErrorZ. +pub extern "C" fn CResult_ChannelIdAPIErrorZ_free(_res: CResult_ChannelIdAPIErrorZ) { } +impl Drop for CResult_ChannelIdAPIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10339,16 +10144,16 @@ impl Drop for CResult_PendingHTLCRoutingDecodeErrorZ { } } } -impl From> for CResult_PendingHTLCRoutingDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelIdAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PendingHTLCRoutingDecodeErrorZPtr { result } + CResult_ChannelIdAPIErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PendingHTLCRoutingDecodeErrorZPtr { err } + CResult_ChannelIdAPIErrorZPtr { err } }; Self { contents, @@ -10356,59 +10161,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelIdAPIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelIdAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelIdAPIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_clone(orig: &CResult_PendingHTLCRoutingDecodeErrorZ) -> CResult_PendingHTLCRoutingDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_PendingHTLCInfoDecodeErrorZ -pub union CResult_PendingHTLCInfoDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCInfo, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_ChannelIdAPIErrorZ_clone(orig: &CResult_ChannelIdAPIErrorZ) -> CResult_ChannelIdAPIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_PendingHTLCInfoDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::PendingHTLCInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PendingHTLCInfoDecodeErrorZ { - /// The contents of this CResult_PendingHTLCInfoDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PendingHTLCInfoDecodeErrorZPtr, - /// Whether this CResult_PendingHTLCInfoDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::RecentPaymentDetailss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RecentPaymentDetailsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::RecentPaymentDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ in the success state. -pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCInfo) -> CResult_PendingHTLCInfoDecodeErrorZ { - CResult_PendingHTLCInfoDecodeErrorZ { - contents: CResult_PendingHTLCInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_RecentPaymentDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::RecentPaymentDetails] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_RecentPaymentDetailsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ in the error state. -pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PendingHTLCInfoDecodeErrorZ { - CResult_PendingHTLCInfoDecodeErrorZ { - contents: CResult_PendingHTLCInfoDecodeErrorZPtr { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RecentPaymentDetailsZ_free(_res: CVec_RecentPaymentDetailsZ) { } +impl Drop for CVec_RecentPaymentDetailsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// The contents of CResult_NonePaymentSendFailureZ +pub union CResult_NonePaymentSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, +} +#[repr(C)] +/// A CResult_NonePaymentSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NonePaymentSendFailureZ { + /// The contents of this CResult_NonePaymentSendFailureZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NonePaymentSendFailureZPtr, + /// Whether this CResult_NonePaymentSendFailureZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NonePaymentSendFailureZ in the success state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NonePaymentSendFailureZ in the error state. +pub extern "C" fn CResult_NonePaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_NonePaymentSendFailureZ { + CResult_NonePaymentSendFailureZ { + contents: CResult_NonePaymentSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10416,18 +10258,15 @@ pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_is_ok(o: &CResult_PendingHTLCInfoDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NonePaymentSendFailureZ_is_ok(o: &CResult_NonePaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PendingHTLCInfoDecodeErrorZ. -pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_free(_res: CResult_PendingHTLCInfoDecodeErrorZ) { } -impl Drop for CResult_PendingHTLCInfoDecodeErrorZ { +/// Frees any resources used by the CResult_NonePaymentSendFailureZ. +pub extern "C" fn CResult_NonePaymentSendFailureZ_free(_res: CResult_NonePaymentSendFailureZ) { } +impl Drop for CResult_NonePaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -10435,16 +10274,16 @@ impl Drop for CResult_PendingHTLCInfoDecodeErrorZ { } } } -impl From> for CResult_PendingHTLCInfoDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonePaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::PaymentSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PendingHTLCInfoDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PendingHTLCInfoDecodeErrorZPtr { err } + CResult_NonePaymentSendFailureZPtr { err } }; Self { contents, @@ -10452,59 +10291,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PendingHTLCInfoDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_PendingHTLCInfoDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonePaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_clone(orig: &CResult_PendingHTLCInfoDecodeErrorZ) -> CResult_PendingHTLCInfoDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedFailureDecodeErrorZ -pub union CResult_BlindedFailureDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::BlindedFailure, +/// The contents of CResult_NoneRetryableSendFailureZ +pub union CResult_NoneRetryableSendFailureZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } #[repr(C)] -/// A CResult_BlindedFailureDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::BlindedFailure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneRetryableSendFailureZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedFailureDecodeErrorZ { - /// The contents of this CResult_BlindedFailureDecodeErrorZ, accessible via either +pub struct CResult_NoneRetryableSendFailureZ { + /// The contents of this CResult_NoneRetryableSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedFailureDecodeErrorZPtr, - /// Whether this CResult_BlindedFailureDecodeErrorZ represents a success state. + pub contents: CResult_NoneRetryableSendFailureZPtr, + /// Whether this CResult_NoneRetryableSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedFailureDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::BlindedFailure) -> CResult_BlindedFailureDecodeErrorZ { - CResult_BlindedFailureDecodeErrorZ { - contents: CResult_BlindedFailureDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_ok() -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedFailureDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedFailureDecodeErrorZ { - CResult_BlindedFailureDecodeErrorZ { - contents: CResult_BlindedFailureDecodeErrorZPtr { +/// Creates a new CResult_NoneRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_NoneRetryableSendFailureZ { + CResult_NoneRetryableSendFailureZ { + contents: CResult_NoneRetryableSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10512,18 +10350,15 @@ pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_is_ok(o: &CResult_BlindedFailureDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneRetryableSendFailureZ_is_ok(o: &CResult_NoneRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedFailureDecodeErrorZ. -pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_free(_res: CResult_BlindedFailureDecodeErrorZ) { } -impl Drop for CResult_BlindedFailureDecodeErrorZ { +/// Frees any resources used by the CResult_NoneRetryableSendFailureZ. +pub extern "C" fn CResult_NoneRetryableSendFailureZ_free(_res: CResult_NoneRetryableSendFailureZ) { } +impl Drop for CResult_NoneRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -10531,16 +10366,16 @@ impl Drop for CResult_BlindedFailureDecodeErrorZ { } } } -impl From> for CResult_BlindedFailureDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::outbound_payment::RetryableSendFailure>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedFailureDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneRetryableSendFailureZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedFailureDecodeErrorZPtr { err } + CResult_NoneRetryableSendFailureZPtr { err } }; Self { contents, @@ -10548,59 +10383,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedFailureDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneRetryableSendFailureZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_BlindedFailureDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedFailureDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneRetryableSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_clone(orig: &CResult_BlindedFailureDecodeErrorZ) -> CResult_BlindedFailureDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneRetryableSendFailureZ_clone(orig: &CResult_NoneRetryableSendFailureZ) -> CResult_NoneRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelShutdownStateDecodeErrorZ -pub union CResult_ChannelShutdownStateDecodeErrorZPtr { +/// The contents of CResult_ThirtyTwoBytesPaymentSendFailureZ +pub union CResult_ThirtyTwoBytesPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channelmanager::ChannelShutdownState, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channelmanager::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ThirtyTwoBytesPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelShutdownStateDecodeErrorZ { - /// The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either +pub struct CResult_ThirtyTwoBytesPaymentSendFailureZ { + /// The contents of this CResult_ThirtyTwoBytesPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelShutdownStateDecodeErrorZPtr, - /// Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. + pub contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr, + /// Whether this CResult_ThirtyTwoBytesPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::ChannelShutdownState) -> CResult_ChannelShutdownStateDecodeErrorZ { - CResult_ChannelShutdownStateDecodeErrorZ { - contents: CResult_ChannelShutdownStateDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { + CResult_ThirtyTwoBytesPaymentSendFailureZ { + contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelShutdownStateDecodeErrorZ { - CResult_ChannelShutdownStateDecodeErrorZ { - contents: CResult_ChannelShutdownStateDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { + CResult_ThirtyTwoBytesPaymentSendFailureZ { + contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10608,13 +10443,13 @@ pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o: &CResult_ChannelShutdownStateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(o: &CResult_ThirtyTwoBytesPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. -pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_free(_res: CResult_ChannelShutdownStateDecodeErrorZ) { } -impl Drop for CResult_ChannelShutdownStateDecodeErrorZ { +/// Frees any resources used by the CResult_ThirtyTwoBytesPaymentSendFailureZ. +pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_free(_res: CResult_ThirtyTwoBytesPaymentSendFailureZ) { } +impl Drop for CResult_ThirtyTwoBytesPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10627,16 +10462,16 @@ impl Drop for CResult_ChannelShutdownStateDecodeErrorZ { } } } -impl From> for CResult_ChannelShutdownStateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ThirtyTwoBytesPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelShutdownStateDecodeErrorZPtr { result } + CResult_ThirtyTwoBytesPaymentSendFailureZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelShutdownStateDecodeErrorZPtr { err } + CResult_ThirtyTwoBytesPaymentSendFailureZPtr { err } }; Self { contents, @@ -10644,135 +10479,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ThirtyTwoBytesPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ThirtyTwoBytesPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_clone(orig: &CResult_ChannelShutdownStateDecodeErrorZ) -> CResult_ChannelShutdownStateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(orig: &CResult_ThirtyTwoBytesPaymentSendFailureZ) -> CResult_ThirtyTwoBytesPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ChannelMonitorZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ChannelMonitorZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ChannelMonitorZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } -impl Drop for CVec_ChannelMonitorZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ChannelMonitorZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesChannelManagerZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::ln::channelmanager::ChannelManager, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_ThirtyTwoBytesChannelManagerZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_ThirtyTwoBytesChannelManagerZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { - (self.a, self.b) - } -} -/// Creates a new C2Tuple_ThirtyTwoBytesChannelManagerZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_ThirtyTwoBytesChannelManagerZ { - C2Tuple_ThirtyTwoBytesChannelManagerZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesChannelManagerZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_free(_res: C2Tuple_ThirtyTwoBytesChannelManagerZ) { } -#[repr(C)] -/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ -pub union CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// The contents of CResult_ThirtyTwoBytesRetryableSendFailureZ +pub union CResult_ThirtyTwoBytesRetryableSendFailureZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::RetryableSendFailure, } #[repr(C)] -/// A CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ThirtyTwoBytesRetryableSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::outbound_payment::RetryableSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ, accessible via either +pub struct CResult_ThirtyTwoBytesRetryableSendFailureZ { + /// The contents of this CResult_ThirtyTwoBytesRetryableSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ represents a success state. + pub contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr, + /// Whether this CResult_ThirtyTwoBytesRetryableSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ in the success state. +pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { + CResult_ThirtyTwoBytesRetryableSendFailureZ { + contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ in the error state. +pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_err(e: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { + CResult_ThirtyTwoBytesRetryableSendFailureZ { + contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10780,13 +10539,13 @@ pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err( } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(o: &CResult_ThirtyTwoBytesRetryableSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { +/// Frees any resources used by the CResult_ThirtyTwoBytesRetryableSendFailureZ. +pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_free(_res: CResult_ThirtyTwoBytesRetryableSendFailureZ) { } +impl Drop for CResult_ThirtyTwoBytesRetryableSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10799,16 +10558,16 @@ impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ThirtyTwoBytesRetryableSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { result } + CResult_ThirtyTwoBytesRetryableSendFailureZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { err } + CResult_ThirtyTwoBytesRetryableSendFailureZPtr { err } }; Self { contents, @@ -10816,42 +10575,101 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ThirtyTwoBytesRetryableSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ThirtyTwoBytesRetryableSendFailureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(orig: &CResult_ThirtyTwoBytesRetryableSendFailureZ) -> CResult_ThirtyTwoBytesRetryableSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_MaxDustHTLCExposureDecodeErrorZ -pub union CResult_MaxDustHTLCExposureDecodeErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)> for C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::ThirtyTwoBytes) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(orig: &C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::ThirtyTwoBytes) -> C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { + C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ. +pub extern "C" fn C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(_res: C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ +pub union CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::config::MaxDustHTLCExposure, + pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::outbound_payment::PaymentSendFailure, } #[repr(C)] -/// A CResult_MaxDustHTLCExposureDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::config::MaxDustHTLCExposure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a crate::lightning::ln::outbound_payment::PaymentSendFailure on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_MaxDustHTLCExposureDecodeErrorZ { - /// The contents of this CResult_MaxDustHTLCExposureDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + /// The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr, - /// Whether this CResult_MaxDustHTLCExposureDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr, + /// Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the success state. -pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o: crate::lightning::util::config::MaxDustHTLCExposure) -> CResult_MaxDustHTLCExposureDecodeErrorZ { - CResult_MaxDustHTLCExposureDecodeErrorZ { - contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the error state. -pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MaxDustHTLCExposureDecodeErrorZ { - CResult_MaxDustHTLCExposureDecodeErrorZ { - contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(e: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10859,13 +10677,13 @@ pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_MaxDustHTLCExposureDecodeErrorZ. -pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res: CResult_MaxDustHTLCExposureDecodeErrorZ) { } -impl Drop for CResult_MaxDustHTLCExposureDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) { } +impl Drop for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10878,16 +10696,16 @@ impl Drop for CResult_MaxDustHTLCExposureDecodeErrorZ { } } } -impl From> for CResult_MaxDustHTLCExposureDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_MaxDustHTLCExposureDecodeErrorZPtr { result } + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_MaxDustHTLCExposureDecodeErrorZPtr { err } + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { err } }; Self { contents, @@ -10895,59 +10713,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> CResult_MaxDustHTLCExposureDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelConfigDecodeErrorZ -pub union CResult_ChannelConfigDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::config::ChannelConfig, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[repr(C)] -/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelConfigDecodeErrorZ { - /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either +impl CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ) { } +impl Drop for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ +pub union CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::outbound_payment::ProbeSendFailure, +} +#[repr(C)] +/// A CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ on success and a crate::lightning::ln::outbound_payment::ProbeSendFailure on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + /// The contents of this CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelConfigDecodeErrorZPtr, - /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr, + /// Whether this CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ in the success state. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(o: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { - CResult_ChannelConfigDecodeErrorZ { - contents: CResult_ChannelConfigDecodeErrorZPtr { +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ in the error state. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(e: crate::lightning::ln::outbound_payment::ProbeSendFailure) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -10955,13 +10819,13 @@ pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(o: &CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } -impl Drop for CResult_ChannelConfigDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(_res: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) { } +impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -10974,16 +10838,16 @@ impl Drop for CResult_ChannelConfigDecodeErrorZ { } } } -impl From> for CResult_ChannelConfigDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelConfigDecodeErrorZPtr { result } + CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelConfigDecodeErrorZPtr { err } + CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { err } }; Self { contents, @@ -10991,133 +10855,193 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(orig: &CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ { Clone::clone(&orig) } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::config::MaxDustHTLCExposure or not -pub enum COption_MaxDustHTLCExposureZ { - /// When we're in this state, this COption_MaxDustHTLCExposureZ contains a crate::lightning::util::config::MaxDustHTLCExposure - Some(crate::lightning::util::config::MaxDustHTLCExposure), - /// When we're in this state, this COption_MaxDustHTLCExposureZ contains nothing - None +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ChannelIdPublicKeyZ { + /// The element at position 0 + pub a: crate::lightning::ln::types::ChannelId, + /// The element at position 1 + pub b: crate::c_types::PublicKey, } -impl COption_MaxDustHTLCExposureZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl From<(crate::lightning::ln::types::ChannelId, crate::c_types::PublicKey)> for C2Tuple_ChannelIdPublicKeyZ { + fn from (tup: (crate::lightning::ln::types::ChannelId, crate::c_types::PublicKey)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() +} +impl C2Tuple_ChannelIdPublicKeyZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::ln::types::ChannelId, crate::c_types::PublicKey) { + (self.a, self.b) } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::config::MaxDustHTLCExposure { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl Clone for C2Tuple_ChannelIdPublicKeyZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } #[no_mangle] -/// Constructs a new COption_MaxDustHTLCExposureZ containing a crate::lightning::util::config::MaxDustHTLCExposure -pub extern "C" fn COption_MaxDustHTLCExposureZ_some(o: crate::lightning::util::config::MaxDustHTLCExposure) -> COption_MaxDustHTLCExposureZ { - COption_MaxDustHTLCExposureZ::Some(o) -} +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ChannelIdPublicKeyZ_clone(orig: &C2Tuple_ChannelIdPublicKeyZ) -> C2Tuple_ChannelIdPublicKeyZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ChannelIdPublicKeyZ from the contained elements. #[no_mangle] -/// Constructs a new COption_MaxDustHTLCExposureZ containing nothing -pub extern "C" fn COption_MaxDustHTLCExposureZ_none() -> COption_MaxDustHTLCExposureZ { - COption_MaxDustHTLCExposureZ::None +pub extern "C" fn C2Tuple_ChannelIdPublicKeyZ_new(a: crate::lightning::ln::types::ChannelId, b: crate::c_types::PublicKey) -> C2Tuple_ChannelIdPublicKeyZ { + C2Tuple_ChannelIdPublicKeyZ { a, b, } } + #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::config::MaxDustHTLCExposure, if we are in the Some state -pub extern "C" fn COption_MaxDustHTLCExposureZ_free(_res: COption_MaxDustHTLCExposureZ) { } -#[no_mangle] -/// Creates a new COption_MaxDustHTLCExposureZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_MaxDustHTLCExposureZ_clone(orig: &COption_MaxDustHTLCExposureZ) -> COption_MaxDustHTLCExposureZ { Clone::clone(&orig) } +/// Frees any resources used by the C2Tuple_ChannelIdPublicKeyZ. +pub extern "C" fn C2Tuple_ChannelIdPublicKeyZ_free(_res: C2Tuple_ChannelIdPublicKeyZ) { } #[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::util::errors::APIError or not -pub enum COption_APIErrorZ { - /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError - Some(crate::lightning::util::errors::APIError), - /// When we're in this state, this COption_APIErrorZ contains nothing - None +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ChannelIdPublicKeyZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_ChannelIdPublicKeyZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_ChannelIdPublicKeyZ, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl COption_APIErrorZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } +impl CVec_C2Tuple_ChannelIdPublicKeyZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ChannelIdPublicKeyZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { - if let Self::Some(v) = self { v } else { unreachable!() } +} +impl From> for CVec_C2Tuple_ChannelIdPublicKeyZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError -pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { - COption_APIErrorZ::Some(o) +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_ChannelIdPublicKeyZZ_free(_res: CVec_C2Tuple_ChannelIdPublicKeyZZ) { } +impl Drop for CVec_C2Tuple_ChannelIdPublicKeyZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } } -#[no_mangle] -/// Constructs a new COption_APIErrorZ containing nothing -pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { - COption_APIErrorZ::None +impl Clone for CVec_C2Tuple_ChannelIdPublicKeyZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::types::ChannelIds of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelIdZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::types::ChannelId, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChannelIdZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::types::ChannelId] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ChannelIdZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state -pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } -#[no_mangle] -/// Creates a new COption_APIErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelIdZ_free(_res: CVec_ChannelIdZ) { } +impl Drop for CVec_ChannelIdZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_ChannelIdZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] -/// The contents of CResult_COption_APIErrorZDecodeErrorZ -pub union CResult_COption_APIErrorZDecodeErrorZPtr { +/// The contents of CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ +pub union CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_APIErrorZ, + pub result: *mut crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, } #[repr(C)] -/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_APIErrorZDecodeErrorZ { - /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either +pub struct CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, - /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. + pub contents: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { +/// Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder) -> CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + contents: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { - CResult_COption_APIErrorZDecodeErrorZ { - contents: CResult_COption_APIErrorZDecodeErrorZPtr { +/// Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + contents: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11125,13 +11049,13 @@ pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } -impl Drop for CResult_COption_APIErrorZDecodeErrorZ { +/// Frees any resources used by the CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_free(_res: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11144,16 +11068,16 @@ impl Drop for CResult_COption_APIErrorZDecodeErrorZ { } } } -impl From> for CResult_COption_APIErrorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_APIErrorZDecodeErrorZPtr { result } + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_APIErrorZDecodeErrorZPtr { err } + CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { err } }; Self { contents, @@ -11161,95 +11085,128 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ_clone(orig: &CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ) -> CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ -pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::Str or not +pub enum COption_StrZ { + /// When we're in this state, this COption_StrZ contains a crate::c_types::Str + Some(crate::c_types::Str), + /// When we're in this state, this COption_StrZ contains nothing + None +} +impl COption_StrZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::Str { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_StrZ containing a crate::c_types::Str +pub extern "C" fn COption_StrZ_some(o: crate::c_types::Str) -> COption_StrZ { + COption_StrZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_StrZ containing nothing +pub extern "C" fn COption_StrZ_none() -> COption_StrZ { + COption_StrZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::Str, if we are in the Some state +pub extern "C" fn COption_StrZ_free(_res: COption_StrZ) { } +#[no_mangle] +/// Creates a new COption_StrZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_StrZ_clone(orig: &COption_StrZ) -> COption_StrZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ +pub union CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either +pub struct CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + /// The contents of this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + pub contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr, + /// Whether this CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the success state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { - CResult_ChannelMonitorUpdateDecodeErrorZ { - contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ in the error state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err() -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) { } +impl Drop for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -11257,96 +11214,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not -pub enum COption_MonitorEventZ { - /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent - Some(crate::lightning::chain::channelmonitor::MonitorEvent), - /// When we're in this state, this COption_MonitorEventZ contains nothing - None -} -impl COption_MonitorEventZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent -pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { - COption_MonitorEventZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_MonitorEventZ containing nothing -pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { - COption_MonitorEventZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state -pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } -#[no_mangle] -/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ) -> CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_MonitorEventZDecodeErrorZ -pub union CResult_COption_MonitorEventZDecodeErrorZPtr { +/// The contents of CResult_ThirtyTwoBytesAPIErrorZ +pub union CResult_ThirtyTwoBytesAPIErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_MonitorEventZ, + pub result: *mut crate::c_types::ThirtyTwoBytes, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::util::errors::APIError, } #[repr(C)] -/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ThirtyTwoBytesAPIErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::util::errors::APIError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_MonitorEventZDecodeErrorZ { - /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either +pub struct CResult_ThirtyTwoBytesAPIErrorZ { + /// The contents of this CResult_ThirtyTwoBytesAPIErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, - /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + pub contents: CResult_ThirtyTwoBytesAPIErrorZPtr, + /// Whether this CResult_ThirtyTwoBytesAPIErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the success state. +pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_ThirtyTwoBytesAPIErrorZ { + CResult_ThirtyTwoBytesAPIErrorZ { + contents: CResult_ThirtyTwoBytesAPIErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { - CResult_COption_MonitorEventZDecodeErrorZ { - contents: CResult_COption_MonitorEventZDecodeErrorZPtr { +/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ in the error state. +pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_err(e: crate::lightning::util::errors::APIError) -> CResult_ThirtyTwoBytesAPIErrorZ { + CResult_ThirtyTwoBytesAPIErrorZ { + contents: CResult_ThirtyTwoBytesAPIErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -11354,13 +11274,13 @@ pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_is_ok(o: &CResult_ThirtyTwoBytesAPIErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } -impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { +/// Frees any resources used by the CResult_ThirtyTwoBytesAPIErrorZ. +pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_free(_res: CResult_ThirtyTwoBytesAPIErrorZ) { } +impl Drop for CResult_ThirtyTwoBytesAPIErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -11373,16 +11293,16 @@ impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { } } } -impl From> for CResult_COption_MonitorEventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ThirtyTwoBytesAPIErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_MonitorEventZDecodeErrorZPtr { result } + CResult_ThirtyTwoBytesAPIErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_MonitorEventZDecodeErrorZPtr { err } + CResult_ThirtyTwoBytesAPIErrorZPtr { err } }; Self { contents, @@ -11390,141 +11310,82 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ThirtyTwoBytesAPIErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ThirtyTwoBytesAPIErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ThirtyTwoBytesAPIErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_HTLCUpdateDecodeErrorZ -pub union CResult_HTLCUpdateDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_ThirtyTwoBytesAPIErrorZ_clone(orig: &CResult_ThirtyTwoBytesAPIErrorZ) -> CResult_ThirtyTwoBytesAPIErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCUpdateDecodeErrorZ { - /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCUpdateDecodeErrorZPtr, - /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. - pub result_ok: bool, +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::blinded_path::message::OffersContext or not +pub enum COption_OffersContextZ { + /// When we're in this state, this COption_OffersContextZ contains a crate::lightning::blinded_path::message::OffersContext + Some(crate::lightning::blinded_path::message::OffersContext), + /// When we're in this state, this COption_OffersContextZ contains nothing + None } -#[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl COption_OffersContextZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } -} -#[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { - CResult_HTLCUpdateDecodeErrorZ { - contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::blinded_path::message::OffersContext { + if let Self::Some(v) = self { v } else { unreachable!() } } } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { - o.result_ok +/// Constructs a new COption_OffersContextZ containing a crate::lightning::blinded_path::message::OffersContext +pub extern "C" fn COption_OffersContextZ_some(o: crate::lightning::blinded_path::message::OffersContext) -> COption_OffersContextZ { + COption_OffersContextZ::Some(o) } #[no_mangle] -/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } -impl Drop for CResult_HTLCUpdateDecodeErrorZ { - fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_HTLCUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCUpdateDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCUpdateDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_HTLCUpdateDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } +/// Constructs a new COption_OffersContextZ containing nothing +pub extern "C" fn COption_OffersContextZ_none() -> COption_OffersContextZ { + COption_OffersContextZ::None } #[no_mangle] -/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// Frees any resources associated with the crate::lightning::blinded_path::message::OffersContext, if we are in the Some state +pub extern "C" fn COption_OffersContextZ_free(_res: COption_OffersContextZ) { } +#[no_mangle] +/// Creates a new COption_OffersContextZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_OffersContextZ_clone(orig: &COption_OffersContextZ) -> COption_OffersContextZ { Clone::clone(&orig) } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_OutPointCVec_u8ZZ { +pub struct C2Tuple_OffersMessageResponseInstructionZ { /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, + pub a: crate::lightning::onion_message::offers::OffersMessage, /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, } -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointCVec_u8ZZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { +impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_OffersMessageResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_OutPointCVec_u8ZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { +impl C2Tuple_OffersMessageResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::ResponseInstruction) { (self.a, self.b) } } -impl Clone for C2Tuple_OutPointCVec_u8ZZ { +impl Clone for C2Tuple_OffersMessageResponseInstructionZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -11535,38 +11396,75 @@ impl Clone for C2Tuple_OutPointCVec_u8ZZ { #[no_mangle] /// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_clone(orig: &C2Tuple_OutPointCVec_u8ZZ) -> C2Tuple_OutPointCVec_u8ZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointCVec_u8ZZ from the contained elements. +pub extern "C" fn C2Tuple_OffersMessageResponseInstructionZ_clone(orig: &C2Tuple_OffersMessageResponseInstructionZ) -> C2Tuple_OffersMessageResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OffersMessageResponseInstructionZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointCVec_u8ZZ { - C2Tuple_OutPointCVec_u8ZZ { a, b, } +pub extern "C" fn C2Tuple_OffersMessageResponseInstructionZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_OffersMessageResponseInstructionZ { + C2Tuple_OffersMessageResponseInstructionZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointCVec_u8ZZ. -pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_free(_res: C2Tuple_OutPointCVec_u8ZZ) { } +/// Frees any resources used by the C2Tuple_OffersMessageResponseInstructionZ. +pub extern "C" fn C2Tuple_OffersMessageResponseInstructionZ_free(_res: C2Tuple_OffersMessageResponseInstructionZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ or not +pub enum COption_C2Tuple_OffersMessageResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_OffersMessageResponseInstructionZZ contains nothing + None +} +impl COption_C2Tuple_OffersMessageResponseInstructionZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ) -> COption_C2Tuple_OffersMessageResponseInstructionZZ { + COption_C2Tuple_OffersMessageResponseInstructionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OffersMessageResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_none() -> COption_C2Tuple_OffersMessageResponseInstructionZZ { + COption_C2Tuple_OffersMessageResponseInstructionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_OffersMessageResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_free(_res: COption_C2Tuple_OffersMessageResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_OffersMessageResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_OffersMessageResponseInstructionZZ_clone(orig: &COption_C2Tuple_OffersMessageResponseInstructionZZ) -> COption_C2Tuple_OffersMessageResponseInstructionZZ { Clone::clone(&orig) } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32CVec_u8ZZ { +pub struct C2Tuple_OffersMessageMessageSendInstructionsZ { /// The element at position 0 - pub a: u32, + pub a: crate::lightning::onion_message::offers::OffersMessage, /// The element at position 1 - pub b: crate::c_types::derived::CVec_u8Z, + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, } -impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32CVec_u8ZZ { - fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { +impl From<(crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_OffersMessageMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_u32CVec_u8ZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { +impl C2Tuple_OffersMessageMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::offers::OffersMessage, crate::lightning::onion_message::messenger::MessageSendInstructions) { (self.a, self.b) } } -impl Clone for C2Tuple_u32CVec_u8ZZ { +impl Clone for C2Tuple_OffersMessageMessageSendInstructionsZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -11577,40 +11475,40 @@ impl Clone for C2Tuple_u32CVec_u8ZZ { #[no_mangle] /// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32CVec_u8ZZ_clone(orig: &C2Tuple_u32CVec_u8ZZ) -> C2Tuple_u32CVec_u8ZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32CVec_u8ZZ from the contained elements. +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_clone(orig: &C2Tuple_OffersMessageMessageSendInstructionsZ) -> C2Tuple_OffersMessageMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OffersMessageMessageSendInstructionsZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_u32CVec_u8ZZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32CVec_u8ZZ { - C2Tuple_u32CVec_u8ZZ { a, b, } +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_new(a: crate::lightning::onion_message::offers::OffersMessage, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_OffersMessageMessageSendInstructionsZ { + C2Tuple_OffersMessageMessageSendInstructionsZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_u32CVec_u8ZZ. -pub extern "C" fn C2Tuple_u32CVec_u8ZZ_free(_res: C2Tuple_u32CVec_u8ZZ) { } +/// Frees any resources used by the C2Tuple_OffersMessageMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_OffersMessageMessageSendInstructionsZ_free(_res: C2Tuple_OffersMessageMessageSendInstructionsZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32CVec_u8ZZs of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32CVec_u8ZZZ { +pub struct CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32CVec_u8ZZ, + pub data: *mut crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_C2Tuple_u32CVec_u8ZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32CVec_u8ZZ] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OffersMessageMessageSendInstructionsZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_C2Tuple_u32CVec_u8ZZZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11618,14 +11516,14 @@ impl From> for CVec_C2Tuple_u } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32CVec_u8ZZZ_free(_res: CVec_C2Tuple_u32CVec_u8ZZZ) { } -impl Drop for CVec_C2Tuple_u32CVec_u8ZZZ { +pub extern "C" fn CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ_free(_res: CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ) { } +impl Drop for CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_C2Tuple_u32CVec_u8ZZZ { +impl Clone for CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11635,26 +11533,26 @@ impl Clone for CVec_C2Tuple_u32CVec_u8ZZZ { } #[repr(C)] /// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { +pub struct C2Tuple_ReleaseHeldHtlcResponseInstructionZ { /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, + pub a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ, + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, } -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ)> for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ)) -> Self { +impl From<(crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { Self { a: tup.0, b: tup.1, } } } -impl C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ) { +impl C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, crate::lightning::onion_message::messenger::ResponseInstruction) { (self.a, self.b) } } -impl Clone for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { +impl Clone for C2Tuple_ReleaseHeldHtlcResponseInstructionZ { fn clone(&self) -> Self { Self { a: Clone::clone(&self.a), @@ -11665,86 +11563,119 @@ impl Clone for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { #[no_mangle] /// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(orig: &C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ from the contained elements. +pub extern "C" fn C2Tuple_ReleaseHeldHtlcResponseInstructionZ_clone(orig: &C2Tuple_ReleaseHeldHtlcResponseInstructionZ) -> C2Tuple_ReleaseHeldHtlcResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ReleaseHeldHtlcResponseInstructionZ from the contained elements. #[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { - C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { a, b, } +pub extern "C" fn C2Tuple_ReleaseHeldHtlcResponseInstructionZ_new(a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + C2Tuple_ReleaseHeldHtlcResponseInstructionZ { a, b, } } #[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(_res: C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ) { } +/// Frees any resources used by the C2Tuple_ReleaseHeldHtlcResponseInstructionZ. +pub extern "C" fn C2Tuple_ReleaseHeldHtlcResponseInstructionZ_free(_res: C2Tuple_ReleaseHeldHtlcResponseInstructionZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ or not +pub enum COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ contains nothing + None } -impl CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ) { } -impl Drop for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ) -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_none() -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_ReleaseHeldHtlcResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_free(_res: COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ_clone(orig: &COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ) -> COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, +} +impl From<(crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { + Self { + a: tup.0, + b: tup.1, + } } } -impl Clone for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { +impl C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, crate::lightning::onion_message::messenger::MessageSendInstructions) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } } } +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_clone(orig: &C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ) -> C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_new(a: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { + C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ_free(_res: C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::chan_utils::CommitmentTransactions of arbitrary size. +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_CommitmentTransactionZ { +pub struct CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, + pub data: *mut crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_CommitmentTransactionZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::CommitmentTransaction] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZ] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_CommitmentTransactionZ { - fn from(v: Vec) -> Self { +impl From> for CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -11752,14 +11683,14 @@ impl From> for CVec } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_CommitmentTransactionZ_free(_res: CVec_CommitmentTransactionZ) { } -impl Drop for CVec_CommitmentTransactionZ { +pub extern "C" fn CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ_free(_res: CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ) { } +impl Drop for CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_CommitmentTransactionZ { +impl Clone for CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -11768,351 +11699,5875 @@ impl Clone for CVec_CommitmentTransactionZ { } } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_TransactionZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Transaction, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_TransactionZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// The contents of CResult_PhantomRouteHintsDecodeErrorZ +pub union CResult_PhantomRouteHintsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From> for CVec_TransactionZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +#[repr(C)] +/// A CResult_PhantomRouteHintsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PhantomRouteHints on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PhantomRouteHintsDecodeErrorZ { + /// The contents of this CResult_PhantomRouteHintsDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PhantomRouteHintsDecodeErrorZPtr, + /// Whether this CResult_PhantomRouteHintsDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } -impl Drop for CVec_TransactionZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the success state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PhantomRouteHints) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for CVec_TransactionZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ in the error state. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PhantomRouteHintsDecodeErrorZ { + CResult_PhantomRouteHintsDecodeErrorZ { + contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_u32TxOutZ { - /// The element at position 0 - pub a: u32, - /// The element at position 1 - pub b: crate::c_types::TxOut, +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o: &CResult_PhantomRouteHintsDecodeErrorZ) -> bool { + o.result_ok } -impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { - fn from (tup: (u32, crate::c_types::TxOut)) -> Self { - Self { - a: tup.0, - b: tup.1, +#[no_mangle] +/// Frees any resources used by the CResult_PhantomRouteHintsDecodeErrorZ. +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_free(_res: CResult_PhantomRouteHintsDecodeErrorZ) { } +impl Drop for CResult_PhantomRouteHintsDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl C2Tuple_u32TxOutZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { - (self.a, self.b) +impl From> for CResult_PhantomRouteHintsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PhantomRouteHintsDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PhantomRouteHintsDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C2Tuple_u32TxOutZ { +impl Clone for CResult_PhantomRouteHintsDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PhantomRouteHintsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_PhantomRouteHintsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_u32TxOutZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { - C2Tuple_u32TxOutZ { a, b, } +pub extern "C" fn CResult_PhantomRouteHintsDecodeErrorZ_clone(orig: &CResult_PhantomRouteHintsDecodeErrorZ) -> CResult_PhantomRouteHintsDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_BlindedForwardDecodeErrorZ +pub union CResult_BlindedForwardDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::BlindedForward, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } - -#[no_mangle] -/// Frees any resources used by the C2Tuple_u32TxOutZ. -pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } #[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_u32TxOutZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, - /// The number of elements pointed to by `data`. - pub datalen: usize +/// A CResult_BlindedForwardDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::BlindedForward on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedForwardDecodeErrorZ { + /// The contents of this CResult_BlindedForwardDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_BlindedForwardDecodeErrorZPtr, + /// Whether this CResult_BlindedForwardDecodeErrorZ represents a success state. + pub result_ok: bool, } -impl CVec_C2Tuple_u32TxOutZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +#[no_mangle] +/// Creates a new CResult_BlindedForwardDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::BlindedForward) -> CResult_BlindedForwardDecodeErrorZ { + CResult_BlindedForwardDecodeErrorZ { + contents: CResult_BlindedForwardDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_C2Tuple_u32TxOutZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_BlindedForwardDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedForwardDecodeErrorZ { + CResult_BlindedForwardDecodeErrorZ { + contents: CResult_BlindedForwardDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } -impl Drop for CVec_C2Tuple_u32TxOutZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_is_ok(o: &CResult_BlindedForwardDecodeErrorZ) -> bool { + o.result_ok } -impl Clone for CVec_C2Tuple_u32TxOutZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Frees any resources used by the CResult_BlindedForwardDecodeErrorZ. +pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_free(_res: CResult_BlindedForwardDecodeErrorZ) { } +impl Drop for CResult_BlindedForwardDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, -} -impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { +impl From> for CResult_BlindedForwardDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedForwardDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedForwardDecodeErrorZPtr { err } + }; Self { - a: tup.0, - b: tup.1, + contents, + result_ok: o.result_ok, } } } -impl C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { +impl Clone for CResult_BlindedForwardDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_BlindedForwardDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BlindedForwardDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_BlindedForwardDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { - C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ) { } +pub extern "C" fn CResult_BlindedForwardDecodeErrorZ_clone(orig: &CResult_BlindedForwardDecodeErrorZ) -> CResult_BlindedForwardDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PendingHTLCRoutingDecodeErrorZ +pub union CResult_PendingHTLCRoutingDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCRouting, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PendingHTLCRoutingDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PendingHTLCRouting on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PendingHTLCRoutingDecodeErrorZ { + /// The contents of this CResult_PendingHTLCRoutingDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PendingHTLCRoutingDecodeErrorZPtr, + /// Whether this CResult_PendingHTLCRoutingDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ in the success state. +pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCRouting) -> CResult_PendingHTLCRoutingDecodeErrorZ { + CResult_PendingHTLCRoutingDecodeErrorZ { + contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ in the error state. +pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PendingHTLCRoutingDecodeErrorZ { + CResult_PendingHTLCRoutingDecodeErrorZ { + contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_is_ok(o: &CResult_PendingHTLCRoutingDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PendingHTLCRoutingDecodeErrorZ. +pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_free(_res: CResult_PendingHTLCRoutingDecodeErrorZ) { } +impl Drop for CResult_PendingHTLCRoutingDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PendingHTLCRoutingDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PendingHTLCRoutingDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PendingHTLCRoutingDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PendingHTLCRoutingDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PendingHTLCRoutingDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCRoutingDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PendingHTLCRoutingDecodeErrorZ_clone(orig: &CResult_PendingHTLCRoutingDecodeErrorZ) -> CResult_PendingHTLCRoutingDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_PendingHTLCInfoDecodeErrorZ +pub union CResult_PendingHTLCInfoDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::PendingHTLCInfo, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_PendingHTLCInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::PendingHTLCInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PendingHTLCInfoDecodeErrorZ { + /// The contents of this CResult_PendingHTLCInfoDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PendingHTLCInfoDecodeErrorZPtr, + /// Whether this CResult_PendingHTLCInfoDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::PendingHTLCInfo) -> CResult_PendingHTLCInfoDecodeErrorZ { + CResult_PendingHTLCInfoDecodeErrorZ { + contents: CResult_PendingHTLCInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PendingHTLCInfoDecodeErrorZ { + CResult_PendingHTLCInfoDecodeErrorZ { + contents: CResult_PendingHTLCInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_is_ok(o: &CResult_PendingHTLCInfoDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_PendingHTLCInfoDecodeErrorZ. +pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_free(_res: CResult_PendingHTLCInfoDecodeErrorZ) { } +impl Drop for CResult_PendingHTLCInfoDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PendingHTLCInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PendingHTLCInfoDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PendingHTLCInfoDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PendingHTLCInfoDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PendingHTLCInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PendingHTLCInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PendingHTLCInfoDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PendingHTLCInfoDecodeErrorZ_clone(orig: &CResult_PendingHTLCInfoDecodeErrorZ) -> CResult_PendingHTLCInfoDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_BlindedFailureDecodeErrorZ +pub union CResult_BlindedFailureDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::channelmanager::BlindedFailure, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_BlindedFailureDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channelmanager::BlindedFailure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_BlindedFailureDecodeErrorZ { + /// The contents of this CResult_BlindedFailureDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_BlindedFailureDecodeErrorZPtr, + /// Whether this CResult_BlindedFailureDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_BlindedFailureDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_ok(o: crate::lightning::ln::channelmanager::BlindedFailure) -> CResult_BlindedFailureDecodeErrorZ { + CResult_BlindedFailureDecodeErrorZ { + contents: CResult_BlindedFailureDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_BlindedFailureDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedFailureDecodeErrorZ { + CResult_BlindedFailureDecodeErrorZ { + contents: CResult_BlindedFailureDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_is_ok(o: &CResult_BlindedFailureDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_BlindedFailureDecodeErrorZ. +pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_free(_res: CResult_BlindedFailureDecodeErrorZ) { } +impl Drop for CResult_BlindedFailureDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_BlindedFailureDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_BlindedFailureDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_BlindedFailureDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_BlindedFailureDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_BlindedFailureDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BlindedFailureDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_BlindedFailureDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_BlindedFailureDecodeErrorZ_clone(orig: &CResult_BlindedFailureDecodeErrorZ) -> CResult_BlindedFailureDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::ChannelMonitors of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ChannelMonitorZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::ChannelMonitor, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ChannelMonitorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ChannelMonitorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ChannelMonitorZ_free(_res: CVec_ChannelMonitorZ) { } +impl Drop for CVec_ChannelMonitorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_ChannelMonitorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ThirtyTwoBytesChannelManagerZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::ln::channelmanager::ChannelManager, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)> for C2Tuple_ThirtyTwoBytesChannelManagerZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ThirtyTwoBytesChannelManagerZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::ChannelManager) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_ThirtyTwoBytesChannelManagerZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::channelmanager::ChannelManager) -> C2Tuple_ThirtyTwoBytesChannelManagerZ { + C2Tuple_ThirtyTwoBytesChannelManagerZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ThirtyTwoBytesChannelManagerZ. +pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelManagerZ_free(_res: C2Tuple_ThirtyTwoBytesChannelManagerZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ +pub union CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelManagerZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_MaxDustHTLCExposureDecodeErrorZ +pub union CResult_MaxDustHTLCExposureDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::config::MaxDustHTLCExposure, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_MaxDustHTLCExposureDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::MaxDustHTLCExposure on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_MaxDustHTLCExposureDecodeErrorZ { + /// The contents of this CResult_MaxDustHTLCExposureDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr, + /// Whether this CResult_MaxDustHTLCExposureDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the success state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o: crate::lightning::util::config::MaxDustHTLCExposure) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ in the error state. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MaxDustHTLCExposureDecodeErrorZ { + CResult_MaxDustHTLCExposureDecodeErrorZ { + contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_MaxDustHTLCExposureDecodeErrorZ. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res: CResult_MaxDustHTLCExposureDecodeErrorZ) { } +impl Drop for CResult_MaxDustHTLCExposureDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_MaxDustHTLCExposureDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_MaxDustHTLCExposureDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_MaxDustHTLCExposureDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_MaxDustHTLCExposureDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_MaxDustHTLCExposureDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_MaxDustHTLCExposureDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig: &CResult_MaxDustHTLCExposureDecodeErrorZ) -> CResult_MaxDustHTLCExposureDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelConfigDecodeErrorZ +pub union CResult_ChannelConfigDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::util::config::ChannelConfig, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelConfigDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::config::ChannelConfig on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelConfigDecodeErrorZ { + /// The contents of this CResult_ChannelConfigDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelConfigDecodeErrorZPtr, + /// Whether this CResult_ChannelConfigDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_ok(o: crate::lightning::util::config::ChannelConfig) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelConfigDecodeErrorZ { + CResult_ChannelConfigDecodeErrorZ { + contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_is_ok(o: &CResult_ChannelConfigDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelConfigDecodeErrorZ. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_free(_res: CResult_ChannelConfigDecodeErrorZ) { } +impl Drop for CResult_ChannelConfigDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelConfigDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelConfigDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelConfigDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelConfigDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelConfigDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelConfigDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelConfigDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelConfigDecodeErrorZ_clone(orig: &CResult_ChannelConfigDecodeErrorZ) -> CResult_ChannelConfigDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::config::MaxDustHTLCExposure or not +pub enum COption_MaxDustHTLCExposureZ { + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains a crate::lightning::util::config::MaxDustHTLCExposure + Some(crate::lightning::util::config::MaxDustHTLCExposure), + /// When we're in this state, this COption_MaxDustHTLCExposureZ contains nothing + None +} +impl COption_MaxDustHTLCExposureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::config::MaxDustHTLCExposure { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing a crate::lightning::util::config::MaxDustHTLCExposure +pub extern "C" fn COption_MaxDustHTLCExposureZ_some(o: crate::lightning::util::config::MaxDustHTLCExposure) -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MaxDustHTLCExposureZ containing nothing +pub extern "C" fn COption_MaxDustHTLCExposureZ_none() -> COption_MaxDustHTLCExposureZ { + COption_MaxDustHTLCExposureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::config::MaxDustHTLCExposure, if we are in the Some state +pub extern "C" fn COption_MaxDustHTLCExposureZ_free(_res: COption_MaxDustHTLCExposureZ) { } +#[no_mangle] +/// Creates a new COption_MaxDustHTLCExposureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MaxDustHTLCExposureZ_clone(orig: &COption_MaxDustHTLCExposureZ) -> COption_MaxDustHTLCExposureZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::util::errors::APIError or not +pub enum COption_APIErrorZ { + /// When we're in this state, this COption_APIErrorZ contains a crate::lightning::util::errors::APIError + Some(crate::lightning::util::errors::APIError), + /// When we're in this state, this COption_APIErrorZ contains nothing + None +} +impl COption_APIErrorZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::util::errors::APIError { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing a crate::lightning::util::errors::APIError +pub extern "C" fn COption_APIErrorZ_some(o: crate::lightning::util::errors::APIError) -> COption_APIErrorZ { + COption_APIErrorZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_APIErrorZ containing nothing +pub extern "C" fn COption_APIErrorZ_none() -> COption_APIErrorZ { + COption_APIErrorZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::util::errors::APIError, if we are in the Some state +pub extern "C" fn COption_APIErrorZ_free(_res: COption_APIErrorZ) { } +#[no_mangle] +/// Creates a new COption_APIErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_APIErrorZ_clone(orig: &COption_APIErrorZ) -> COption_APIErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_APIErrorZDecodeErrorZ +pub union CResult_COption_APIErrorZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_APIErrorZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_APIErrorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_APIErrorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_APIErrorZDecodeErrorZ { + /// The contents of this CResult_COption_APIErrorZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_APIErrorZDecodeErrorZPtr, + /// Whether this CResult_COption_APIErrorZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_ok(o: crate::c_types::derived::COption_APIErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_APIErrorZDecodeErrorZ { + CResult_COption_APIErrorZDecodeErrorZ { + contents: CResult_COption_APIErrorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_is_ok(o: &CResult_COption_APIErrorZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_COption_APIErrorZDecodeErrorZ. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_free(_res: CResult_COption_APIErrorZDecodeErrorZ) { } +impl Drop for CResult_COption_APIErrorZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_COption_APIErrorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_COption_APIErrorZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_APIErrorZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_APIErrorZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_COption_APIErrorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_COption_APIErrorZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_APIErrorZDecodeErrorZ_clone(orig: &CResult_COption_APIErrorZDecodeErrorZ) -> CResult_COption_APIErrorZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ChannelMonitorUpdateDecodeErrorZ +pub union CResult_ChannelMonitorUpdateDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_ChannelMonitorUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::ChannelMonitorUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelMonitorUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelMonitorUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelMonitorUpdateDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelMonitorUpdateDecodeErrorZ { + CResult_ChannelMonitorUpdateDecodeErrorZ { + contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_ChannelMonitorUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res: CResult_ChannelMonitorUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelMonitorUpdateDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelMonitorUpdateDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_ChannelMonitorUpdateDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelMonitorUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ChannelMonitorUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig: &CResult_ChannelMonitorUpdateDecodeErrorZ) -> CResult_ChannelMonitorUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::chain::channelmonitor::MonitorEvent or not +pub enum COption_MonitorEventZ { + /// When we're in this state, this COption_MonitorEventZ contains a crate::lightning::chain::channelmonitor::MonitorEvent + Some(crate::lightning::chain::channelmonitor::MonitorEvent), + /// When we're in this state, this COption_MonitorEventZ contains nothing + None +} +impl COption_MonitorEventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::channelmonitor::MonitorEvent { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing a crate::lightning::chain::channelmonitor::MonitorEvent +pub extern "C" fn COption_MonitorEventZ_some(o: crate::lightning::chain::channelmonitor::MonitorEvent) -> COption_MonitorEventZ { + COption_MonitorEventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MonitorEventZ containing nothing +pub extern "C" fn COption_MonitorEventZ_none() -> COption_MonitorEventZ { + COption_MonitorEventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::chain::channelmonitor::MonitorEvent, if we are in the Some state +pub extern "C" fn COption_MonitorEventZ_free(_res: COption_MonitorEventZ) { } +#[no_mangle] +/// Creates a new COption_MonitorEventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MonitorEventZ_clone(orig: &COption_MonitorEventZ) -> COption_MonitorEventZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_MonitorEventZDecodeErrorZ +pub union CResult_COption_MonitorEventZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_MonitorEventZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_MonitorEventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_MonitorEventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_MonitorEventZDecodeErrorZ { + /// The contents of this CResult_COption_MonitorEventZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_MonitorEventZDecodeErrorZPtr, + /// Whether this CResult_COption_MonitorEventZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_MonitorEventZ) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_MonitorEventZDecodeErrorZ { + CResult_COption_MonitorEventZDecodeErrorZ { + contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o: &CResult_COption_MonitorEventZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_COption_MonitorEventZDecodeErrorZ. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_free(_res: CResult_COption_MonitorEventZDecodeErrorZ) { } +impl Drop for CResult_COption_MonitorEventZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_COption_MonitorEventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_COption_MonitorEventZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_MonitorEventZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_MonitorEventZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_COption_MonitorEventZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_COption_MonitorEventZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_MonitorEventZDecodeErrorZ_clone(orig: &CResult_COption_MonitorEventZDecodeErrorZ) -> CResult_COption_MonitorEventZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_HTLCUpdateDecodeErrorZ +pub union CResult_HTLCUpdateDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::chain::channelmonitor::HTLCUpdate, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_HTLCUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::channelmonitor::HTLCUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_HTLCUpdateDecodeErrorZ { + /// The contents of this CResult_HTLCUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_HTLCUpdateDecodeErrorZPtr, + /// Whether this CResult_HTLCUpdateDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_ok(o: crate::lightning::chain::channelmonitor::HTLCUpdate) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCUpdateDecodeErrorZ { + CResult_HTLCUpdateDecodeErrorZ { + contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_is_ok(o: &CResult_HTLCUpdateDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_HTLCUpdateDecodeErrorZ. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_free(_res: CResult_HTLCUpdateDecodeErrorZ) { } +impl Drop for CResult_HTLCUpdateDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_HTLCUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_HTLCUpdateDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_HTLCUpdateDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_HTLCUpdateDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_HTLCUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_HTLCUpdateDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_HTLCUpdateDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_HTLCUpdateDecodeErrorZ_clone(orig: &CResult_HTLCUpdateDecodeErrorZ) -> CResult_HTLCUpdateDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointCVec_u8ZZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)> for C2Tuple_OutPointCVec_u8ZZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OutPointCVec_u8ZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OutPointCVec_u8ZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_clone(orig: &C2Tuple_OutPointCVec_u8ZZ) -> C2Tuple_OutPointCVec_u8ZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointCVec_u8ZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_OutPointCVec_u8ZZ { + C2Tuple_OutPointCVec_u8ZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointCVec_u8ZZ. +pub extern "C" fn C2Tuple_OutPointCVec_u8ZZ_free(_res: C2Tuple_OutPointCVec_u8ZZ) { } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32CVec_u8ZZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u8Z, +} +impl From<(u32, crate::c_types::derived::CVec_u8Z)> for C2Tuple_u32CVec_u8ZZ { + fn from (tup: (u32, crate::c_types::derived::CVec_u8Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_u32CVec_u8ZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::derived::CVec_u8Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32CVec_u8ZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u32CVec_u8ZZ_clone(orig: &C2Tuple_u32CVec_u8ZZ) -> C2Tuple_u32CVec_u8ZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32CVec_u8ZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32CVec_u8ZZ_new(a: u32, b: crate::c_types::derived::CVec_u8Z) -> C2Tuple_u32CVec_u8ZZ { + C2Tuple_u32CVec_u8ZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32CVec_u8ZZ. +pub extern "C" fn C2Tuple_u32CVec_u8ZZ_free(_res: C2Tuple_u32CVec_u8ZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32CVec_u8ZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_u32CVec_u8ZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_u32CVec_u8ZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_u32CVec_u8ZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32CVec_u8ZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_u32CVec_u8ZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_u32CVec_u8ZZZ_free(_res: CVec_C2Tuple_u32CVec_u8ZZZ) { } +impl Drop for CVec_C2Tuple_u32CVec_u8ZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_u32CVec_u8ZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ)> for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(orig: &C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32CVec_u8ZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { + C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ. +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(_res: C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ) { } +impl Drop for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_NoneReplayEventZ +pub union CResult_NoneReplayEventZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::events::ReplayEvent, +} +#[repr(C)] +/// A CResult_NoneReplayEventZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::events::ReplayEvent on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NoneReplayEventZ { + /// The contents of this CResult_NoneReplayEventZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NoneReplayEventZPtr, + /// Whether this CResult_NoneReplayEventZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ in the success state. +pub extern "C" fn CResult_NoneReplayEventZ_ok() -> CResult_NoneReplayEventZ { + CResult_NoneReplayEventZ { + contents: CResult_NoneReplayEventZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ in the error state. +pub extern "C" fn CResult_NoneReplayEventZ_err(e: crate::lightning::events::ReplayEvent) -> CResult_NoneReplayEventZ { + CResult_NoneReplayEventZ { + contents: CResult_NoneReplayEventZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NoneReplayEventZ_is_ok(o: &CResult_NoneReplayEventZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NoneReplayEventZ. +pub extern "C" fn CResult_NoneReplayEventZ_free(_res: CResult_NoneReplayEventZ) { } +impl Drop for CResult_NoneReplayEventZ { + fn drop(&mut self) { + if self.result_ok { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NoneReplayEventZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::events::ReplayEvent>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneReplayEventZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NoneReplayEventZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NoneReplayEventZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NoneReplayEventZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NoneReplayEventZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NoneReplayEventZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NoneReplayEventZ_clone(orig: &CResult_NoneReplayEventZ) -> CResult_NoneReplayEventZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::chan_utils::CommitmentTransactions of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_CommitmentTransactionZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_CommitmentTransactionZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::chan_utils::CommitmentTransaction] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CommitmentTransactionZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_CommitmentTransactionZ_free(_res: CVec_CommitmentTransactionZ) { } +impl Drop for CVec_CommitmentTransactionZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CommitmentTransactionZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_u32TxOutZ { + /// The element at position 0 + pub a: u32, + /// The element at position 1 + pub b: crate::c_types::TxOut, +} +impl From<(u32, crate::c_types::TxOut)> for C2Tuple_u32TxOutZ { + fn from (tup: (u32, crate::c_types::TxOut)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_u32TxOutZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (u32, crate::c_types::TxOut) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_u32TxOutZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_u32TxOutZ_clone(orig: &C2Tuple_u32TxOutZ) -> C2Tuple_u32TxOutZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_u32TxOutZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_u32TxOutZ_new(a: u32, b: crate::c_types::TxOut) -> C2Tuple_u32TxOutZ { + C2Tuple_u32TxOutZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_u32TxOutZ. +pub extern "C" fn C2Tuple_u32TxOutZ_free(_res: C2Tuple_u32TxOutZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_u32TxOutZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_u32TxOutZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_u32TxOutZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_u32TxOutZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_u32TxOutZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_u32TxOutZZ_free(_res: CVec_C2Tuple_u32TxOutZZ) { } +impl Drop for CVec_C2Tuple_u32TxOutZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_u32TxOutZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)> for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(orig: &C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::c_types::derived::CVec_C2Tuple_u32TxOutZZ) -> C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { + C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ. +pub extern "C" fn C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(_res: C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ) { } #[repr(C)] /// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZs of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_TransactionOutputsZ { +pub struct CVec_TransactionOutputsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TransactionOutputsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TransactionOutputsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } +impl Drop for CVec_TransactionOutputsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_TransactionOutputsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_BalanceZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::chain::channelmonitor::Balance, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_BalanceZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_BalanceZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } +impl Drop for CVec_BalanceZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_BalanceZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_ThirtyTwoBytesChannelMonitorZ { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +} +impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_ThirtyTwoBytesChannelMonitorZ { + fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_ThirtyTwoBytesChannelMonitorZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_ThirtyTwoBytesChannelMonitorZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(orig: &C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> C2Tuple_ThirtyTwoBytesChannelMonitorZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_ThirtyTwoBytesChannelMonitorZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_ThirtyTwoBytesChannelMonitorZ { + C2Tuple_ThirtyTwoBytesChannelMonitorZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_ThirtyTwoBytesChannelMonitorZ. +pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(_res: C2Tuple_ThirtyTwoBytesChannelMonitorZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ +pub union CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_PublicKeyTypeZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::lightning::ln::wire::Type, +} +impl From<(crate::c_types::PublicKey, crate::lightning::ln::wire::Type)> for C2Tuple_PublicKeyTypeZ { + fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_PublicKeyTypeZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_PublicKeyTypeZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_PublicKeyTypeZ_clone(orig: &C2Tuple_PublicKeyTypeZ) -> C2Tuple_PublicKeyTypeZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { + C2Tuple_PublicKeyTypeZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. +pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_PublicKeyTypeZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_PublicKeyTypeZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_PublicKeyTypeZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } +impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_PublicKeyTypeZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OnionMessageContentsResponseInstructionZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::packet::OnionMessageContents, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::ResponseInstruction, +} +impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction)> for C2Tuple_OnionMessageContentsResponseInstructionZ { + fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OnionMessageContentsResponseInstructionZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::ResponseInstruction) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OnionMessageContentsResponseInstructionZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_clone(orig: &C2Tuple_OnionMessageContentsResponseInstructionZ) -> C2Tuple_OnionMessageContentsResponseInstructionZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OnionMessageContentsResponseInstructionZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::ResponseInstruction) -> C2Tuple_OnionMessageContentsResponseInstructionZ { + C2Tuple_OnionMessageContentsResponseInstructionZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OnionMessageContentsResponseInstructionZ. +pub extern "C" fn C2Tuple_OnionMessageContentsResponseInstructionZ_free(_res: C2Tuple_OnionMessageContentsResponseInstructionZ) { } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ or not +pub enum COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + /// When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ + Some(crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ), + /// When we're in this state, this COption_C2Tuple_OnionMessageContentsResponseInstructionZZ contains nothing + None +} +impl COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing a crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_some(o: crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ) -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ containing nothing +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_none() -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { + COption_C2Tuple_OnionMessageContentsResponseInstructionZZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::derived::C2Tuple_OnionMessageContentsResponseInstructionZ, if we are in the Some state +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_free(_res: COption_C2Tuple_OnionMessageContentsResponseInstructionZZ) { } +#[no_mangle] +/// Creates a new COption_C2Tuple_OnionMessageContentsResponseInstructionZZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_C2Tuple_OnionMessageContentsResponseInstructionZZ_clone(orig: &COption_C2Tuple_OnionMessageContentsResponseInstructionZZ) -> COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::onion_message::packet::OnionMessageContents or not +pub enum COption_OnionMessageContentsZ { + /// When we're in this state, this COption_OnionMessageContentsZ contains a crate::lightning::onion_message::packet::OnionMessageContents + Some(crate::lightning::onion_message::packet::OnionMessageContents), + /// When we're in this state, this COption_OnionMessageContentsZ contains nothing + None +} +impl COption_OnionMessageContentsZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::OnionMessageContents { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_OnionMessageContentsZ containing a crate::lightning::onion_message::packet::OnionMessageContents +pub extern "C" fn COption_OnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::OnionMessageContents) -> COption_OnionMessageContentsZ { + COption_OnionMessageContentsZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_OnionMessageContentsZ containing nothing +pub extern "C" fn COption_OnionMessageContentsZ_none() -> COption_OnionMessageContentsZ { + COption_OnionMessageContentsZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::onion_message::packet::OnionMessageContents, if we are in the Some state +pub extern "C" fn COption_OnionMessageContentsZ_free(_res: COption_OnionMessageContentsZ) { } +#[no_mangle] +/// Creates a new COption_OnionMessageContentsZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_OnionMessageContentsZ_clone(orig: &COption_OnionMessageContentsZ) -> COption_OnionMessageContentsZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_OnionMessageContentsZDecodeErrorZ +pub union CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_OnionMessageContentsZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_OnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_OnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_OnionMessageContentsZDecodeErrorZ { + /// The contents of this CResult_COption_OnionMessageContentsZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr, + /// Whether this CResult_COption_OnionMessageContentsZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_OnionMessageContentsZ) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { + CResult_COption_OnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { + CResult_COption_OnionMessageContentsZDecodeErrorZ { + contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_OnionMessageContentsZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_COption_OnionMessageContentsZDecodeErrorZ. +pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_OnionMessageContentsZDecodeErrorZ) { } +impl Drop for CResult_COption_OnionMessageContentsZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_COption_OnionMessageContentsZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_COption_OnionMessageContentsZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_OnionMessageContentsZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_OnionMessageContentsZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(orig: &CResult_COption_OnionMessageContentsZDecodeErrorZ) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + /// The element at position 0 + pub a: crate::lightning::onion_message::packet::OnionMessageContents, + /// The element at position 1 + pub b: crate::lightning::onion_message::messenger::MessageSendInstructions, +} +impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions)> for C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::MessageSendInstructions) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_clone(orig: &C2Tuple_OnionMessageContentsMessageSendInstructionsZ) -> C2Tuple_OnionMessageContentsMessageSendInstructionsZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OnionMessageContentsMessageSendInstructionsZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::MessageSendInstructions) -> C2Tuple_OnionMessageContentsMessageSendInstructionsZ { + C2Tuple_OnionMessageContentsMessageSendInstructionsZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OnionMessageContentsMessageSendInstructionsZ. +pub extern "C" fn C2Tuple_OnionMessageContentsMessageSendInstructionsZ_free(_res: C2Tuple_OnionMessageContentsMessageSendInstructionsZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OnionMessageContentsMessageSendInstructionsZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ_free(_res: CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ) { } +impl Drop for CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::wire::Type or not +pub enum COption_TypeZ { + /// When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type + Some(crate::lightning::ln::wire::Type), + /// When we're in this state, this COption_TypeZ contains nothing + None +} +impl COption_TypeZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::wire::Type { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type +pub extern "C" fn COption_TypeZ_some(o: crate::lightning::ln::wire::Type) -> COption_TypeZ { + COption_TypeZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_TypeZ containing nothing +pub extern "C" fn COption_TypeZ_none() -> COption_TypeZ { + COption_TypeZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state +pub extern "C" fn COption_TypeZ_free(_res: COption_TypeZ) { } +#[no_mangle] +/// Creates a new COption_TypeZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_TypeZ_clone(orig: &COption_TypeZ) -> COption_TypeZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_TypeZDecodeErrorZ +pub union CResult_COption_TypeZDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::COption_TypeZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_COption_TypeZDecodeErrorZ { + /// The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_COption_TypeZDecodeErrorZPtr, + /// Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_ok(o: crate::c_types::derived::COption_TypeZ) -> CResult_COption_TypeZDecodeErrorZ { + CResult_COption_TypeZDecodeErrorZ { + contents: CResult_COption_TypeZDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_TypeZDecodeErrorZ { + CResult_COption_TypeZDecodeErrorZ { + contents: CResult_COption_TypeZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_is_ok(o: &CResult_COption_TypeZDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. +pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_free(_res: CResult_COption_TypeZDecodeErrorZ) { } +impl Drop for CResult_COption_TypeZDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_COption_TypeZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_COption_TypeZDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_COption_TypeZDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_COption_TypeZDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_COption_TypeZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_COption_TypeZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_COption_TypeZDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_clone(orig: &CResult_COption_TypeZDecodeErrorZ) -> CResult_COption_TypeZDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::msgs::SocketAddress or not +pub enum COption_SocketAddressZ { + /// When we're in this state, this COption_SocketAddressZ contains a crate::lightning::ln::msgs::SocketAddress + Some(crate::lightning::ln::msgs::SocketAddress), + /// When we're in this state, this COption_SocketAddressZ contains nothing + None +} +impl COption_SocketAddressZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::SocketAddress { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_SocketAddressZ containing a crate::lightning::ln::msgs::SocketAddress +pub extern "C" fn COption_SocketAddressZ_some(o: crate::lightning::ln::msgs::SocketAddress) -> COption_SocketAddressZ { + COption_SocketAddressZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_SocketAddressZ containing nothing +pub extern "C" fn COption_SocketAddressZ_none() -> COption_SocketAddressZ { + COption_SocketAddressZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::msgs::SocketAddress, if we are in the Some state +pub extern "C" fn COption_SocketAddressZ_free(_res: COption_SocketAddressZ) { } +#[no_mangle] +/// Creates a new COption_SocketAddressZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_SocketAddressZ_clone(orig: &COption_SocketAddressZ) -> COption_SocketAddressZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::peer_handler::PeerDetailss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PeerDetailsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::peer_handler::PeerDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_PeerDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::peer_handler::PeerDetails] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_PeerDetailsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PeerDetailsZ_free(_res: CVec_PeerDetailsZ) { } +impl Drop for CVec_PeerDetailsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// The contents of CResult_CVec_u8ZPeerHandleErrorZ +pub union CResult_CVec_u8ZPeerHandleErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, +} +#[repr(C)] +/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_u8ZPeerHandleErrorZ { + /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, + /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { + CResult_CVec_u8ZPeerHandleErrorZ { + contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } +impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CVec_u8ZPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CVec_u8ZPeerHandleErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CVec_u8ZPeerHandleErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CVec_u8ZPeerHandleErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_NonePeerHandleErrorZ +pub union CResult_NonePeerHandleErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, +} +#[repr(C)] +/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_NonePeerHandleErrorZ { + /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_NonePeerHandleErrorZPtr, + /// Whether this CResult_NonePeerHandleErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_NonePeerHandleErrorZ in the success state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { + result: core::ptr::null_mut(), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_NonePeerHandleErrorZ in the error state. +pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { + CResult_NonePeerHandleErrorZ { + contents: CResult_NonePeerHandleErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_NonePeerHandleErrorZ. +pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } +impl Drop for CResult_NonePeerHandleErrorZ { + fn drop(&mut self) { + if self.result_ok { + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_NonePeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { + let contents = if o.result_ok { + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_NonePeerHandleErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_NonePeerHandleErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { + result: core::ptr::null_mut() + } } + } else { + Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_boolPeerHandleErrorZ +pub union CResult_boolPeerHandleErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut bool, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, +} +#[repr(C)] +/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, +/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_boolPeerHandleErrorZ { + /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_boolPeerHandleErrorZPtr, + /// Whether this CResult_boolPeerHandleErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_boolPeerHandleErrorZ in the success state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_boolPeerHandleErrorZ in the error state. +pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { + CResult_boolPeerHandleErrorZ { + contents: CResult_boolPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_boolPeerHandleErrorZ. +pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } +impl Drop for CResult_boolPeerHandleErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_boolPeerHandleErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_boolPeerHandleErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_boolPeerHandleErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_boolPeerHandleErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_u32GraphSyncErrorZ +pub union CResult_u32GraphSyncErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut u32, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_rapid_gossip_sync::GraphSyncError, +} +#[repr(C)] +/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, +/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::GraphSyncError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_u32GraphSyncErrorZ { + /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_u32GraphSyncErrorZPtr, + /// Whether this CResult_u32GraphSyncErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_u32GraphSyncErrorZ in the success state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_u32GraphSyncErrorZ in the error state. +pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::GraphSyncError) -> CResult_u32GraphSyncErrorZ { + CResult_u32GraphSyncErrorZ { + contents: CResult_u32GraphSyncErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_u32GraphSyncErrorZ. +pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } +impl Drop for CResult_u32GraphSyncErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_u32GraphSyncErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_u32GraphSyncErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_u32GraphSyncErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_CVec_u8ZIOErrorZ +pub union CResult_CVec_u8ZIOErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_u8Z, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::IOError, +} +#[repr(C)] +/// A CResult_CVec_u8ZIOErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::c_types::IOError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_u8ZIOErrorZ { + /// The contents of this CResult_CVec_u8ZIOErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_u8ZIOErrorZPtr, + /// Whether this CResult_CVec_u8ZIOErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZIOErrorZ in the success state. +pub extern "C" fn CResult_CVec_u8ZIOErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZIOErrorZ { + CResult_CVec_u8ZIOErrorZ { + contents: CResult_CVec_u8ZIOErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZIOErrorZ in the error state. +pub extern "C" fn CResult_CVec_u8ZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_u8ZIOErrorZ { + CResult_CVec_u8ZIOErrorZ { + contents: CResult_CVec_u8ZIOErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CVec_u8ZIOErrorZ_is_ok(o: &CResult_CVec_u8ZIOErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CVec_u8ZIOErrorZ. +pub extern "C" fn CResult_CVec_u8ZIOErrorZ_free(_res: CResult_CVec_u8ZIOErrorZ) { } +impl Drop for CResult_CVec_u8ZIOErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CVec_u8ZIOErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CVec_u8ZIOErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CVec_u8ZIOErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CVec_u8ZIOErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CVec_u8ZIOErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CVec_u8ZIOErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CVec_u8ZIOErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CVec_u8ZIOErrorZ_clone(orig: &CResult_CVec_u8ZIOErrorZ) -> CResult_CVec_u8ZIOErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_CVec_StrZIOErrorZ +pub union CResult_CVec_StrZIOErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_StrZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::IOError, +} +#[repr(C)] +/// A CResult_CVec_StrZIOErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_StrZ on success and a crate::c_types::IOError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_StrZIOErrorZ { + /// The contents of this CResult_CVec_StrZIOErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_StrZIOErrorZPtr, + /// Whether this CResult_CVec_StrZIOErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_StrZIOErrorZ in the success state. +pub extern "C" fn CResult_CVec_StrZIOErrorZ_ok(o: crate::c_types::derived::CVec_StrZ) -> CResult_CVec_StrZIOErrorZ { + CResult_CVec_StrZIOErrorZ { + contents: CResult_CVec_StrZIOErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CVec_StrZIOErrorZ in the error state. +pub extern "C" fn CResult_CVec_StrZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_StrZIOErrorZ { + CResult_CVec_StrZIOErrorZ { + contents: CResult_CVec_StrZIOErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CVec_StrZIOErrorZ_is_ok(o: &CResult_CVec_StrZIOErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CVec_StrZIOErrorZ. +pub extern "C" fn CResult_CVec_StrZIOErrorZ_free(_res: CResult_CVec_StrZIOErrorZ) { } +impl Drop for CResult_CVec_StrZIOErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CVec_StrZIOErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CVec_StrZIOErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CVec_StrZIOErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CVec_StrZIOErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CVec_StrZIOErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CVec_StrZIOErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CVec_StrZIOErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CVec_StrZIOErrorZ_clone(orig: &CResult_CVec_StrZIOErrorZ) -> CResult_CVec_StrZIOErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ) { } +impl Drop for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ +pub union CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::IOError, +} +#[repr(C)] +/// A CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ on success and a crate::c_types::IOError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + /// The contents of this CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr, + /// Whether this CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ in the success state. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ in the error state. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(o: &CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(_res: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) { } +impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(orig: &CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ +pub union CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::c_types::IOError, +} +#[repr(C)] +/// A CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ on success and a crate::c_types::IOError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr, + /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) { } +impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ +pub union CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice_request::UnsignedInvoiceRequest, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::UnsignedInvoiceRequest on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + /// The contents of this CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr, + /// Whether this CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + contents: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + contents: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_is_ok(o: &CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ. +pub extern "C" fn CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_free(_res: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ) { } +impl Drop for CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UnsignedInvoiceRequestBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ_clone(orig: &CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ) -> CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InvoiceRequestBolt12SemanticErrorZ +pub union CResult_InvoiceRequestBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice_request::InvoiceRequest, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_InvoiceRequestBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::InvoiceRequest on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceRequestBolt12SemanticErrorZ { + /// The contents of this CResult_InvoiceRequestBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceRequestBolt12SemanticErrorZPtr, + /// Whether this CResult_InvoiceRequestBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice_request::InvoiceRequest) -> CResult_InvoiceRequestBolt12SemanticErrorZ { + CResult_InvoiceRequestBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_InvoiceRequestBolt12SemanticErrorZ { + CResult_InvoiceRequestBolt12SemanticErrorZ { + contents: CResult_InvoiceRequestBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_is_ok(o: &CResult_InvoiceRequestBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceRequestBolt12SemanticErrorZ. +pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_free(_res: CResult_InvoiceRequestBolt12SemanticErrorZ) { } +impl Drop for CResult_InvoiceRequestBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InvoiceRequestBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InvoiceRequestBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InvoiceRequestBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InvoiceRequestBolt12SemanticErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InvoiceRequestBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InvoiceRequestBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestBolt12SemanticErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InvoiceRequestBolt12SemanticErrorZ_clone(orig: &CResult_InvoiceRequestBolt12SemanticErrorZ) -> CResult_InvoiceRequestBolt12SemanticErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ +pub union CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) -> CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ_free(_res: CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_VerifiedInvoiceRequestNoneZ +pub union CResult_VerifiedInvoiceRequestNoneZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, +} +#[repr(C)] +/// A CResult_VerifiedInvoiceRequestNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::VerifiedInvoiceRequest on success and a () on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_VerifiedInvoiceRequestNoneZ { + /// The contents of this CResult_VerifiedInvoiceRequestNoneZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_VerifiedInvoiceRequestNoneZPtr, + /// Whether this CResult_VerifiedInvoiceRequestNoneZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_VerifiedInvoiceRequestNoneZ in the success state. +pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_ok(o: crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> CResult_VerifiedInvoiceRequestNoneZ { + CResult_VerifiedInvoiceRequestNoneZ { + contents: CResult_VerifiedInvoiceRequestNoneZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_VerifiedInvoiceRequestNoneZ in the error state. +pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_err() -> CResult_VerifiedInvoiceRequestNoneZ { + CResult_VerifiedInvoiceRequestNoneZ { + contents: CResult_VerifiedInvoiceRequestNoneZPtr { + err: core::ptr::null_mut(), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_is_ok(o: &CResult_VerifiedInvoiceRequestNoneZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_VerifiedInvoiceRequestNoneZ. +pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_free(_res: CResult_VerifiedInvoiceRequestNoneZ) { } +impl Drop for CResult_VerifiedInvoiceRequestNoneZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + } + } +} +impl From> for CResult_VerifiedInvoiceRequestNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_VerifiedInvoiceRequestNoneZPtr { result } + } else { + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_VerifiedInvoiceRequestNoneZPtr { err: core::ptr::null_mut() } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_VerifiedInvoiceRequestNoneZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_VerifiedInvoiceRequestNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_VerifiedInvoiceRequestNoneZPtr { + err: core::ptr::null_mut() + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_VerifiedInvoiceRequestNoneZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_clone(orig: &CResult_VerifiedInvoiceRequestNoneZ) -> CResult_VerifiedInvoiceRequestNoneZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ +pub union CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::offers::parse::Bolt12SemanticError, +} +#[repr(C)] +/// A CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder on success and a crate::lightning::offers::parse::Bolt12SemanticError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + /// The contents of this CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr, + /// Whether this CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ in the success state. +pub extern "C" fn CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_ok(o: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) -> CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ in the error state. +pub extern "C" fn CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_err(e: crate::lightning::offers::parse::Bolt12SemanticError) -> CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + contents: CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_is_ok(o: &CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ. +pub extern "C" fn CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ_free(_res: CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ) { } +impl Drop for CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +#[repr(C)] +/// The contents of CResult_InvoiceRequestFieldsDecodeErrorZ +pub union CResult_InvoiceRequestFieldsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::offers::invoice_request::InvoiceRequestFields, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_InvoiceRequestFieldsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_request::InvoiceRequestFields on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_InvoiceRequestFieldsDecodeErrorZ { + /// The contents of this CResult_InvoiceRequestFieldsDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_InvoiceRequestFieldsDecodeErrorZPtr, + /// Whether this CResult_InvoiceRequestFieldsDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceRequestFieldsDecodeErrorZ_ok(o: crate::lightning::offers::invoice_request::InvoiceRequestFields) -> CResult_InvoiceRequestFieldsDecodeErrorZ { + CResult_InvoiceRequestFieldsDecodeErrorZ { + contents: CResult_InvoiceRequestFieldsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceRequestFieldsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceRequestFieldsDecodeErrorZ { + CResult_InvoiceRequestFieldsDecodeErrorZ { + contents: CResult_InvoiceRequestFieldsDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_InvoiceRequestFieldsDecodeErrorZ_is_ok(o: &CResult_InvoiceRequestFieldsDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_InvoiceRequestFieldsDecodeErrorZ. +pub extern "C" fn CResult_InvoiceRequestFieldsDecodeErrorZ_free(_res: CResult_InvoiceRequestFieldsDecodeErrorZ) { } +impl Drop for CResult_InvoiceRequestFieldsDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_InvoiceRequestFieldsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_InvoiceRequestFieldsDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_InvoiceRequestFieldsDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_InvoiceRequestFieldsDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_InvoiceRequestFieldsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_InvoiceRequestFieldsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_InvoiceRequestFieldsDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_InvoiceRequestFieldsDecodeErrorZ_clone(orig: &CResult_InvoiceRequestFieldsDecodeErrorZ) -> CResult_InvoiceRequestFieldsDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// An enum which can either contain a or not +pub enum COption_NoneZ { + /// When we're in this state, this COption_NoneZ contains a + Some, + /// When we're in this state, this COption_NoneZ contains nothing + None +} +impl COption_NoneZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } +} +#[no_mangle] +/// Constructs a new COption_NoneZ containing a +pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { + COption_NoneZ::Some +} +#[no_mangle] +/// Constructs a new COption_NoneZ containing nothing +pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { + COption_NoneZ::None +} +#[no_mangle] +/// Frees any resources associated with the , if we are in the Some state +pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_WitnessZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Witness, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_WitnessZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Witness] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_WitnessZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_WitnessZ_free(_res: CVec_WitnessZ) { } +impl Drop for CVec_WitnessZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_WitnessZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::ECDSASignature or not +pub enum COption_ECDSASignatureZ { + /// When we're in this state, this COption_ECDSASignatureZ contains a crate::c_types::ECDSASignature + Some(crate::c_types::ECDSASignature), + /// When we're in this state, this COption_ECDSASignatureZ contains nothing + None +} +impl COption_ECDSASignatureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::ECDSASignature { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ECDSASignatureZ containing a crate::c_types::ECDSASignature +pub extern "C" fn COption_ECDSASignatureZ_some(o: crate::c_types::ECDSASignature) -> COption_ECDSASignatureZ { + COption_ECDSASignatureZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ECDSASignatureZ containing nothing +pub extern "C" fn COption_ECDSASignatureZ_none() -> COption_ECDSASignatureZ { + COption_ECDSASignatureZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::c_types::ECDSASignature, if we are in the Some state +pub extern "C" fn COption_ECDSASignatureZ_free(_res: COption_ECDSASignatureZ) { } +#[no_mangle] +/// Creates a new COption_ECDSASignatureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ECDSASignatureZ_clone(orig: &COption_ECDSASignatureZ) -> COption_ECDSASignatureZ { Clone::clone(&orig) } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a i64 or not +pub enum COption_i64Z { + /// When we're in this state, this COption_i64Z contains a i64 + Some(i64), + /// When we're in this state, this COption_i64Z contains nothing + None +} +impl COption_i64Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> i64 { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_i64Z containing a i64 +pub extern "C" fn COption_i64Z_some(o: i64) -> COption_i64Z { + COption_i64Z::Some(o) +} +#[no_mangle] +/// Constructs a new COption_i64Z containing nothing +pub extern "C" fn COption_i64Z_none() -> COption_i64Z { + COption_i64Z::None +} +#[no_mangle] +/// Frees any resources associated with the i64, if we are in the Some state +pub extern "C" fn COption_i64Z_free(_res: COption_i64Z) { } +#[no_mangle] +/// Creates a new COption_i64Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_i64Z_clone(orig: &COption_i64Z) -> COption_i64Z { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SocketAddressDecodeErrorZ +pub union CResult_SocketAddressDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::SocketAddress, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_SocketAddressDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SocketAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SocketAddressDecodeErrorZ { + /// The contents of this CResult_SocketAddressDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SocketAddressDecodeErrorZPtr, + /// Whether this CResult_SocketAddressDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SocketAddressDecodeErrorZ in the success state. +pub extern "C" fn CResult_SocketAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SocketAddress) -> CResult_SocketAddressDecodeErrorZ { + CResult_SocketAddressDecodeErrorZ { + contents: CResult_SocketAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SocketAddressDecodeErrorZ in the error state. +pub extern "C" fn CResult_SocketAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SocketAddressDecodeErrorZ { + CResult_SocketAddressDecodeErrorZ { + contents: CResult_SocketAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SocketAddressDecodeErrorZ_is_ok(o: &CResult_SocketAddressDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SocketAddressDecodeErrorZ. +pub extern "C" fn CResult_SocketAddressDecodeErrorZ_free(_res: CResult_SocketAddressDecodeErrorZ) { } +impl Drop for CResult_SocketAddressDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_SocketAddressDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SocketAddressDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SocketAddressDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SocketAddressDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SocketAddressDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SocketAddressDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SocketAddressDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SocketAddressDecodeErrorZ_clone(orig: &CResult_SocketAddressDecodeErrorZ) -> CResult_SocketAddressDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SocketAddressSocketAddressParseErrorZ +pub union CResult_SocketAddressSocketAddressParseErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::SocketAddress, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::SocketAddressParseError, +} +#[repr(C)] +/// A CResult_SocketAddressSocketAddressParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SocketAddress on success and a crate::lightning::ln::msgs::SocketAddressParseError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SocketAddressSocketAddressParseErrorZ { + /// The contents of this CResult_SocketAddressSocketAddressParseErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SocketAddressSocketAddressParseErrorZPtr, + /// Whether this CResult_SocketAddressSocketAddressParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ in the success state. +pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_ok(o: crate::lightning::ln::msgs::SocketAddress) -> CResult_SocketAddressSocketAddressParseErrorZ { + CResult_SocketAddressSocketAddressParseErrorZ { + contents: CResult_SocketAddressSocketAddressParseErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ in the error state. +pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_err(e: crate::lightning::ln::msgs::SocketAddressParseError) -> CResult_SocketAddressSocketAddressParseErrorZ { + CResult_SocketAddressSocketAddressParseErrorZ { + contents: CResult_SocketAddressSocketAddressParseErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_is_ok(o: &CResult_SocketAddressSocketAddressParseErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SocketAddressSocketAddressParseErrorZ. +pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_free(_res: CResult_SocketAddressSocketAddressParseErrorZ) { } +impl Drop for CResult_SocketAddressSocketAddressParseErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_SocketAddressSocketAddressParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SocketAddressSocketAddressParseErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SocketAddressSocketAddressParseErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SocketAddressSocketAddressParseErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SocketAddressSocketAddressParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SocketAddressSocketAddressParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_clone(orig: &CResult_SocketAddressSocketAddressParseErrorZ) -> CResult_SocketAddressSocketAddressParseErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateAddHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UpdateAddHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UpdateAddHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } +impl Drop for CVec_UpdateAddHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateAddHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateFulfillHTLCZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ, + pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UpdateFulfillHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UpdateFulfillHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } +impl Drop for CVec_UpdateFulfillHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateFulfillHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateFailHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_UpdateFailHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UpdateFailHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } +impl Drop for CVec_UpdateFailHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateFailHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_UpdateFailMalformedHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_TransactionOutputsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl CVec_UpdateFailMalformedHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_UpdateFailMalformedHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } +impl Drop for CVec_UpdateFailMalformedHTLCZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_UpdateFailMalformedHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_AcceptChannelDecodeErrorZ +pub union CResult_AcceptChannelDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannel, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelDecodeErrorZ { + /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelDecodeErrorZPtr, + /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { + CResult_AcceptChannelDecodeErrorZ { + contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } +impl Drop for CResult_AcceptChannelDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_AcceptChannelV2DecodeErrorZ +pub union CResult_AcceptChannelV2DecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::AcceptChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_AcceptChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AcceptChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_AcceptChannelV2DecodeErrorZ { + /// The contents of this CResult_AcceptChannelV2DecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_AcceptChannelV2DecodeErrorZPtr, + /// Whether this CResult_AcceptChannelV2DecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannelV2) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelV2DecodeErrorZ { + CResult_AcceptChannelV2DecodeErrorZ { + contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_is_ok(o: &CResult_AcceptChannelV2DecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_AcceptChannelV2DecodeErrorZ. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_free(_res: CResult_AcceptChannelV2DecodeErrorZ) { } +impl Drop for CResult_AcceptChannelV2DecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_AcceptChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_AcceptChannelV2DecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_AcceptChannelV2DecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_AcceptChannelV2DecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_AcceptChannelV2DecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_clone(orig: &CResult_AcceptChannelV2DecodeErrorZ) -> CResult_AcceptChannelV2DecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_StfuDecodeErrorZ +pub union CResult_StfuDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::Stfu, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_StfuDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Stfu on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_StfuDecodeErrorZ { + /// The contents of this CResult_StfuDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_StfuDecodeErrorZPtr, + /// Whether this CResult_StfuDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_StfuDecodeErrorZ in the success state. +pub extern "C" fn CResult_StfuDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Stfu) -> CResult_StfuDecodeErrorZ { + CResult_StfuDecodeErrorZ { + contents: CResult_StfuDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_StfuDecodeErrorZ in the error state. +pub extern "C" fn CResult_StfuDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StfuDecodeErrorZ { + CResult_StfuDecodeErrorZ { + contents: CResult_StfuDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_StfuDecodeErrorZ_is_ok(o: &CResult_StfuDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_StfuDecodeErrorZ. +pub extern "C" fn CResult_StfuDecodeErrorZ_free(_res: CResult_StfuDecodeErrorZ) { } +impl Drop for CResult_StfuDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_StfuDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_StfuDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_StfuDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_StfuDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_StfuDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_StfuDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_StfuDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_StfuDecodeErrorZ_clone(orig: &CResult_StfuDecodeErrorZ) -> CResult_StfuDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SpliceInitDecodeErrorZ +pub union CResult_SpliceInitDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::SpliceInit, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_SpliceInitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SpliceInit on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SpliceInitDecodeErrorZ { + /// The contents of this CResult_SpliceInitDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SpliceInitDecodeErrorZPtr, + /// Whether this CResult_SpliceInitDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SpliceInitDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceInit) -> CResult_SpliceInitDecodeErrorZ { + CResult_SpliceInitDecodeErrorZ { + contents: CResult_SpliceInitDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SpliceInitDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceInitDecodeErrorZ { + CResult_SpliceInitDecodeErrorZ { + contents: CResult_SpliceInitDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_is_ok(o: &CResult_SpliceInitDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SpliceInitDecodeErrorZ. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_free(_res: CResult_SpliceInitDecodeErrorZ) { } +impl Drop for CResult_SpliceInitDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_SpliceInitDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SpliceInitDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SpliceInitDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SpliceInitDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SpliceInitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SpliceInitDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SpliceInitDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SpliceInitDecodeErrorZ_clone(orig: &CResult_SpliceInitDecodeErrorZ) -> CResult_SpliceInitDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SpliceAckDecodeErrorZ +pub union CResult_SpliceAckDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::SpliceAck, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_SpliceAckDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SpliceAck on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SpliceAckDecodeErrorZ { + /// The contents of this CResult_SpliceAckDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SpliceAckDecodeErrorZPtr, + /// Whether this CResult_SpliceAckDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SpliceAckDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpliceAckDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceAck) -> CResult_SpliceAckDecodeErrorZ { + CResult_SpliceAckDecodeErrorZ { + contents: CResult_SpliceAckDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SpliceAckDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpliceAckDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceAckDecodeErrorZ { + CResult_SpliceAckDecodeErrorZ { + contents: CResult_SpliceAckDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SpliceAckDecodeErrorZ_is_ok(o: &CResult_SpliceAckDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SpliceAckDecodeErrorZ. +pub extern "C" fn CResult_SpliceAckDecodeErrorZ_free(_res: CResult_SpliceAckDecodeErrorZ) { } +impl Drop for CResult_SpliceAckDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_SpliceAckDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SpliceAckDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SpliceAckDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SpliceAckDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SpliceAckDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SpliceAckDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SpliceAckDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SpliceAckDecodeErrorZ_clone(orig: &CResult_SpliceAckDecodeErrorZ) -> CResult_SpliceAckDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_SpliceLockedDecodeErrorZ +pub union CResult_SpliceLockedDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::SpliceLocked, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_SpliceLockedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::SpliceLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_SpliceLockedDecodeErrorZ { + /// The contents of this CResult_SpliceLockedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_SpliceLockedDecodeErrorZPtr, + /// Whether this CResult_SpliceLockedDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SpliceLockedDecodeErrorZ in the success state. +pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceLocked) -> CResult_SpliceLockedDecodeErrorZ { + CResult_SpliceLockedDecodeErrorZ { + contents: CResult_SpliceLockedDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_SpliceLockedDecodeErrorZ in the error state. +pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceLockedDecodeErrorZ { + CResult_SpliceLockedDecodeErrorZ { + contents: CResult_SpliceLockedDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_is_ok(o: &CResult_SpliceLockedDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_SpliceLockedDecodeErrorZ. +pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_free(_res: CResult_SpliceLockedDecodeErrorZ) { } +impl Drop for CResult_SpliceLockedDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_SpliceLockedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_SpliceLockedDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SpliceLockedDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_SpliceLockedDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SpliceLockedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SpliceLockedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SpliceLockedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_clone(orig: &CResult_SpliceLockedDecodeErrorZ) -> CResult_SpliceLockedDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddInputDecodeErrorZ +pub union CResult_TxAddInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddInputDecodeErrorZ { + /// The contents of this CResult_TxAddInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddInputDecodeErrorZPtr, + /// Whether this CResult_TxAddInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddInput) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddInputDecodeErrorZ { + CResult_TxAddInputDecodeErrorZ { + contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_is_ok(o: &CResult_TxAddInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddInputDecodeErrorZ. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_free(_res: CResult_TxAddInputDecodeErrorZ) { } +impl Drop for CResult_TxAddInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddInputDecodeErrorZ_clone(orig: &CResult_TxAddInputDecodeErrorZ) -> CResult_TxAddInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxAddOutputDecodeErrorZ +pub union CResult_TxAddOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAddOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxAddOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAddOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAddOutputDecodeErrorZ { + /// The contents of this CResult_TxAddOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAddOutputDecodeErrorZPtr, + /// Whether this CResult_TxAddOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddOutput) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddOutputDecodeErrorZ { + CResult_TxAddOutputDecodeErrorZ { + contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_is_ok(o: &CResult_TxAddOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxAddOutputDecodeErrorZ. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_free(_res: CResult_TxAddOutputDecodeErrorZ) { } +impl Drop for CResult_TxAddOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxAddOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAddOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAddOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxAddOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAddOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAddOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxAddOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_clone(orig: &CResult_TxAddOutputDecodeErrorZ) -> CResult_TxAddOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveInputDecodeErrorZ +pub union CResult_TxRemoveInputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveInput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveInputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveInputDecodeErrorZ { + /// The contents of this CResult_TxRemoveInputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveInputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveInputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveInput) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveInputDecodeErrorZ { + CResult_TxRemoveInputDecodeErrorZ { + contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_is_ok(o: &CResult_TxRemoveInputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveInputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_free(_res: CResult_TxRemoveInputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveInputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveInputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveInputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveInputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveInputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveInputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveInputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveInputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_clone(orig: &CResult_TxRemoveInputDecodeErrorZ) -> CResult_TxRemoveInputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxRemoveOutputDecodeErrorZ +pub union CResult_TxRemoveOutputDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxRemoveOutput, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxRemoveOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxRemoveOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxRemoveOutputDecodeErrorZ { + /// The contents of this CResult_TxRemoveOutputDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxRemoveOutputDecodeErrorZPtr, + /// Whether this CResult_TxRemoveOutputDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveOutput) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveOutputDecodeErrorZ { + CResult_TxRemoveOutputDecodeErrorZ { + contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_is_ok(o: &CResult_TxRemoveOutputDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxRemoveOutputDecodeErrorZ. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_free(_res: CResult_TxRemoveOutputDecodeErrorZ) { } +impl Drop for CResult_TxRemoveOutputDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxRemoveOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxRemoveOutputDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxRemoveOutputDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxRemoveOutputDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxRemoveOutputDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_clone(orig: &CResult_TxRemoveOutputDecodeErrorZ) -> CResult_TxRemoveOutputDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxCompleteDecodeErrorZ +pub union CResult_TxCompleteDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxComplete, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxCompleteDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxComplete on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxCompleteDecodeErrorZ { + /// The contents of this CResult_TxCompleteDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxCompleteDecodeErrorZPtr, + /// Whether this CResult_TxCompleteDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxComplete) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCompleteDecodeErrorZ { + CResult_TxCompleteDecodeErrorZ { + contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_is_ok(o: &CResult_TxCompleteDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxCompleteDecodeErrorZ. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_free(_res: CResult_TxCompleteDecodeErrorZ) { } +impl Drop for CResult_TxCompleteDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxCompleteDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxCompleteDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxCompleteDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxCompleteDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxCompleteDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxCompleteDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_TxCompleteDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxCompleteDecodeErrorZ_clone(orig: &CResult_TxCompleteDecodeErrorZ) -> CResult_TxCompleteDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxSignaturesDecodeErrorZ +pub union CResult_TxSignaturesDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxSignatures, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxSignaturesDecodeErrorZ { + /// The contents of this CResult_TxSignaturesDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxSignaturesDecodeErrorZPtr, + /// Whether this CResult_TxSignaturesDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxSignatures) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxSignaturesDecodeErrorZ { + CResult_TxSignaturesDecodeErrorZ { + contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_is_ok(o: &CResult_TxSignaturesDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxSignaturesDecodeErrorZ. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_free(_res: CResult_TxSignaturesDecodeErrorZ) { } +impl Drop for CResult_TxSignaturesDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_TxSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxSignaturesDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxSignaturesDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxSignaturesDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_TxSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxSignaturesDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +} +#[no_mangle] +/// Creates a new CResult_TxSignaturesDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_clone(orig: &CResult_TxSignaturesDecodeErrorZ) -> CResult_TxSignaturesDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_TxInitRbfDecodeErrorZ +pub union CResult_TxInitRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxInitRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, +} +#[repr(C)] +/// A CResult_TxInitRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxInitRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxInitRbfDecodeErrorZ { + /// The contents of this CResult_TxInitRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxInitRbfDecodeErrorZPtr, + /// Whether this CResult_TxInitRbfDecodeErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxInitRbf) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl From> for CVec_TransactionOutputsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxInitRbfDecodeErrorZ { + CResult_TxInitRbfDecodeErrorZ { + contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } +/// Checks if the given object is currently in the success state #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_TransactionOutputsZ_free(_res: CVec_TransactionOutputsZ) { } -impl Drop for CVec_TransactionOutputsZ { +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_is_ok(o: &CResult_TxInitRbfDecodeErrorZ) -> bool { + o.result_ok +} +#[no_mangle] +/// Frees any resources used by the CResult_TxInitRbfDecodeErrorZ. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_free(_res: CResult_TxInitRbfDecodeErrorZ) { } +impl Drop for CResult_TxInitRbfDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_TransactionOutputsZ { +impl From> for CResult_TxInitRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxInitRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxInitRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_TxInitRbfDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_TxInitRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxInitRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_TxInitRbfDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_clone(orig: &CResult_TxInitRbfDecodeErrorZ) -> CResult_TxInitRbfDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::channelmonitor::Balances of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_BalanceZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::channelmonitor::Balance, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_BalanceZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } +/// The contents of CResult_TxAckRbfDecodeErrorZ +pub union CResult_TxAckRbfDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::TxAckRbf, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl From> for CVec_BalanceZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +#[repr(C)] +/// A CResult_TxAckRbfDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAckRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_TxAckRbfDecodeErrorZ { + /// The contents of this CResult_TxAckRbfDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_TxAckRbfDecodeErrorZPtr, + /// Whether this CResult_TxAckRbfDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_BalanceZ_free(_res: CVec_BalanceZ) { } -impl Drop for CVec_BalanceZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAckRbf) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } -impl Clone for CVec_BalanceZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +#[no_mangle] +/// Creates a new CResult_TxAckRbfDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAckRbfDecodeErrorZ { + CResult_TxAckRbfDecodeErrorZ { + contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_ThirtyTwoBytesChannelMonitorZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::chain::channelmonitor::ChannelMonitor, +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_is_ok(o: &CResult_TxAckRbfDecodeErrorZ) -> bool { + o.result_ok } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)> for C2Tuple_ThirtyTwoBytesChannelMonitorZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor)) -> Self { - Self { - a: tup.0, - b: tup.1, +#[no_mangle] +/// Frees any resources used by the CResult_TxAckRbfDecodeErrorZ. +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_free(_res: CResult_TxAckRbfDecodeErrorZ) { } +impl Drop for CResult_TxAckRbfDecodeErrorZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl C2Tuple_ThirtyTwoBytesChannelMonitorZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::chain::channelmonitor::ChannelMonitor) { - (self.a, self.b) +impl From> for CResult_TxAckRbfDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_TxAckRbfDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_TxAckRbfDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -impl Clone for C2Tuple_ThirtyTwoBytesChannelMonitorZ { +impl Clone for CResult_TxAckRbfDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_TxAckRbfDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_TxAckRbfDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_TxAckRbfDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(orig: &C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> C2Tuple_ThirtyTwoBytesChannelMonitorZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_ThirtyTwoBytesChannelMonitorZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::chain::channelmonitor::ChannelMonitor) -> C2Tuple_ThirtyTwoBytesChannelMonitorZ { - C2Tuple_ThirtyTwoBytesChannelMonitorZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_ThirtyTwoBytesChannelMonitorZ. -pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(_res: C2Tuple_ThirtyTwoBytesChannelMonitorZ) { } +pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_clone(orig: &CResult_TxAckRbfDecodeErrorZ) -> CResult_TxAckRbfDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ -pub union CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { +/// The contents of CResult_TxAbortDecodeErrorZ +pub union CResult_TxAbortDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, + pub result: *mut crate::lightning::ln::msgs::TxAbort, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TxAbortDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::TxAbort on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ, accessible via either +pub struct CResult_TxAbortDecodeErrorZ { + /// The contents of this CResult_TxAbortDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr, - /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ represents a success state. + pub contents: CResult_TxAbortDecodeErrorZPtr, + /// Whether this CResult_TxAbortDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_TxAbortDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAbort) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { +/// Creates a new CResult_TxAbortDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAbortDecodeErrorZ { + CResult_TxAbortDecodeErrorZ { + contents: CResult_TxAbortDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12120,13 +17575,13 @@ pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err( } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TxAbortDecodeErrorZ_is_ok(o: &CResult_TxAbortDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) { } -impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { +/// Frees any resources used by the CResult_TxAbortDecodeErrorZ. +pub extern "C" fn CResult_TxAbortDecodeErrorZ_free(_res: CResult_TxAbortDecodeErrorZ) { } +impl Drop for CResult_TxAbortDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12139,16 +17594,16 @@ impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { } } } -impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxAbortDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { result } + CResult_TxAbortDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { err } + CResult_TxAbortDecodeErrorZPtr { err } }; Self { contents, @@ -12156,272 +17611,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxAbortDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_TxAbortDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyTypeZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::lightning::ln::wire::Type, -} -impl From<(crate::c_types::PublicKey, crate::lightning::ln::wire::Type)> for C2Tuple_PublicKeyTypeZ { - fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::wire::Type)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_PublicKeyTypeZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::wire::Type) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PublicKeyTypeZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PublicKeyTypeZ_clone(orig: &C2Tuple_PublicKeyTypeZ) -> C2Tuple_PublicKeyTypeZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyTypeZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyTypeZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::wire::Type) -> C2Tuple_PublicKeyTypeZ { - C2Tuple_PublicKeyTypeZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyTypeZ. -pub extern "C" fn C2Tuple_PublicKeyTypeZ_free(_res: C2Tuple_PublicKeyTypeZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyTypeZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyTypeZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyTypeZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_PublicKeyTypeZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_PublicKeyTypeZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyTypeZZ_free(_res: CVec_C2Tuple_PublicKeyTypeZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyTypeZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_PublicKeyTypeZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyCVec_SocketAddressZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_SocketAddressZ, -} -impl From<(crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ)> for C2Tuple_PublicKeyCVec_SocketAddressZZ { - fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_PublicKeyCVec_SocketAddressZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::CVec_SocketAddressZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PublicKeyCVec_SocketAddressZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PublicKeyCVec_SocketAddressZZ_clone(orig: &C2Tuple_PublicKeyCVec_SocketAddressZZ) -> C2Tuple_PublicKeyCVec_SocketAddressZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyCVec_SocketAddressZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyCVec_SocketAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::CVec_SocketAddressZ) -> C2Tuple_PublicKeyCVec_SocketAddressZZ { - C2Tuple_PublicKeyCVec_SocketAddressZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyCVec_SocketAddressZZ. -pub extern "C" fn C2Tuple_PublicKeyCVec_SocketAddressZZ_free(_res: C2Tuple_PublicKeyCVec_SocketAddressZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCVec_SocketAddressZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::onion_message::packet::OnionMessageContents or not -pub enum COption_OnionMessageContentsZ { - /// When we're in this state, this COption_OnionMessageContentsZ contains a crate::lightning::onion_message::packet::OnionMessageContents - Some(crate::lightning::onion_message::packet::OnionMessageContents), - /// When we're in this state, this COption_OnionMessageContentsZ contains nothing - None -} -impl COption_OnionMessageContentsZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::onion_message::packet::OnionMessageContents { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_OnionMessageContentsZ containing a crate::lightning::onion_message::packet::OnionMessageContents -pub extern "C" fn COption_OnionMessageContentsZ_some(o: crate::lightning::onion_message::packet::OnionMessageContents) -> COption_OnionMessageContentsZ { - COption_OnionMessageContentsZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_OnionMessageContentsZ containing nothing -pub extern "C" fn COption_OnionMessageContentsZ_none() -> COption_OnionMessageContentsZ { - COption_OnionMessageContentsZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::onion_message::packet::OnionMessageContents, if we are in the Some state -pub extern "C" fn COption_OnionMessageContentsZ_free(_res: COption_OnionMessageContentsZ) { } -#[no_mangle] -/// Creates a new COption_OnionMessageContentsZ which has the same data as `orig` +/// Creates a new CResult_TxAbortDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_OnionMessageContentsZ_clone(orig: &COption_OnionMessageContentsZ) -> COption_OnionMessageContentsZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxAbortDecodeErrorZ_clone(orig: &CResult_TxAbortDecodeErrorZ) -> CResult_TxAbortDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_OnionMessageContentsZDecodeErrorZ -pub union CResult_COption_OnionMessageContentsZDecodeErrorZPtr { +/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ +pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_OnionMessageContentsZ, + pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } -#[repr(C)] -/// A CResult_COption_OnionMessageContentsZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_OnionMessageContentsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +#[repr(C)] +/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_OnionMessageContentsZDecodeErrorZ { - /// The contents of this CResult_COption_OnionMessageContentsZDecodeErrorZ, accessible via either +pub struct CResult_AnnouncementSignaturesDecodeErrorZ { + /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr, - /// Whether this CResult_COption_OnionMessageContentsZDecodeErrorZ represents a success state. + pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, + /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_OnionMessageContentsZ) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { - CResult_COption_OnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { - CResult_COption_OnionMessageContentsZDecodeErrorZ { - contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { + CResult_AnnouncementSignaturesDecodeErrorZ { + contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12429,13 +17671,13 @@ pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_err(e: crate } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(o: &CResult_COption_OnionMessageContentsZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_OnionMessageContentsZDecodeErrorZ. -pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_free(_res: CResult_COption_OnionMessageContentsZDecodeErrorZ) { } -impl Drop for CResult_COption_OnionMessageContentsZDecodeErrorZ { +/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } +impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12448,16 +17690,16 @@ impl Drop for CResult_COption_OnionMessageContentsZDecodeErrorZ { } } } -impl From> for CResult_COption_OnionMessageContentsZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_OnionMessageContentsZDecodeErrorZPtr { result } + CResult_AnnouncementSignaturesDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_OnionMessageContentsZDecodeErrorZPtr { err } + CResult_AnnouncementSignaturesDecodeErrorZPtr { err } }; Self { contents, @@ -12465,188 +17707,155 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_OnionMessageContentsZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_OnionMessageContentsZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(orig: &CResult_COption_OnionMessageContentsZDecodeErrorZ) -> CResult_COption_OnionMessageContentsZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - /// The element at position 0 - pub a: crate::lightning::onion_message::packet::OnionMessageContents, - /// The element at position 1 - pub b: crate::lightning::onion_message::messenger::Destination, - /// The element at position 2 - pub c: crate::lightning::blinded_path::BlindedPath, -} -impl From<(crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)> for C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - fn from (tup: (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::onion_message::packet::OnionMessageContents, crate::lightning::onion_message::messenger::Destination, crate::lightning::blinded_path::BlindedPath) { - (self.a, self.b, self.c) - } +/// The contents of CResult_ChannelReestablishDecodeErrorZ +pub union CResult_ChannelReestablishDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } -impl Clone for C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } +#[repr(C)] +/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_ChannelReestablishDecodeErrorZ { + /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelReestablishDecodeErrorZPtr, + /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(orig: &C3Tuple_OnionMessageContentsDestinationBlindedPathZ) -> C3Tuple_OnionMessageContentsDestinationBlindedPathZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_OnionMessageContentsDestinationBlindedPathZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(a: crate::lightning::onion_message::packet::OnionMessageContents, b: crate::lightning::onion_message::messenger::Destination, c: crate::lightning::blinded_path::BlindedPath) -> C3Tuple_OnionMessageContentsDestinationBlindedPathZ { - C3Tuple_OnionMessageContentsDestinationBlindedPathZ { a, b, c, } +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } } - #[no_mangle] -/// Frees any resources used by the C3Tuple_OnionMessageContentsDestinationBlindedPathZ. -pub extern "C" fn C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(_res: C3Tuple_OnionMessageContentsDestinationBlindedPathZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_OnionMessageContentsDestinationBlindedPathZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { + CResult_ChannelReestablishDecodeErrorZ { + contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -impl From> for CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(_res: CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ) { } -impl Drop for CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { +/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } +impl Drop for CResult_ChannelReestablishDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) +impl From> for CResult_ChannelReestablishDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_ChannelReestablishDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_ChannelReestablishDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } } } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::ln::wire::Type or not -pub enum COption_TypeZ { - /// When we're in this state, this COption_TypeZ contains a crate::lightning::ln::wire::Type - Some(crate::lightning::ln::wire::Type), - /// When we're in this state, this COption_TypeZ contains nothing - None -} -impl COption_TypeZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::wire::Type { - if let Self::Some(v) = self { v } else { unreachable!() } +impl Clone for CResult_ChannelReestablishDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } #[no_mangle] -/// Constructs a new COption_TypeZ containing a crate::lightning::ln::wire::Type -pub extern "C" fn COption_TypeZ_some(o: crate::lightning::ln::wire::Type) -> COption_TypeZ { - COption_TypeZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_TypeZ containing nothing -pub extern "C" fn COption_TypeZ_none() -> COption_TypeZ { - COption_TypeZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::wire::Type, if we are in the Some state -pub extern "C" fn COption_TypeZ_free(_res: COption_TypeZ) { } -#[no_mangle] -/// Creates a new COption_TypeZ which has the same data as `orig` +/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_TypeZ_clone(orig: &COption_TypeZ) -> COption_TypeZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_TypeZDecodeErrorZ -pub union CResult_COption_TypeZDecodeErrorZPtr { +/// The contents of CResult_ClosingSignedDecodeErrorZ +pub union CResult_ClosingSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_TypeZ, + pub result: *mut crate::lightning::ln::msgs::ClosingSigned, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_TypeZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_TypeZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_TypeZDecodeErrorZ { - /// The contents of this CResult_COption_TypeZDecodeErrorZ, accessible via either +pub struct CResult_ClosingSignedDecodeErrorZ { + /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_TypeZDecodeErrorZPtr, - /// Whether this CResult_COption_TypeZDecodeErrorZ represents a success state. + pub contents: CResult_ClosingSignedDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_TypeZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_ok(o: crate::c_types::derived::COption_TypeZ) -> CResult_COption_TypeZDecodeErrorZ { - CResult_COption_TypeZDecodeErrorZ { - contents: CResult_COption_TypeZDecodeErrorZPtr { +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_TypeZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_TypeZDecodeErrorZ { - CResult_COption_TypeZDecodeErrorZ { - contents: CResult_COption_TypeZDecodeErrorZPtr { +/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { + CResult_ClosingSignedDecodeErrorZ { + contents: CResult_ClosingSignedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12654,13 +17863,13 @@ pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_is_ok(o: &CResult_COption_TypeZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_TypeZDecodeErrorZ. -pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_free(_res: CResult_COption_TypeZDecodeErrorZ) { } -impl Drop for CResult_COption_TypeZDecodeErrorZ { +/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12673,16 +17882,16 @@ impl Drop for CResult_COption_TypeZDecodeErrorZ { } } } -impl From> for CResult_COption_TypeZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ClosingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_TypeZDecodeErrorZPtr { result } + CResult_ClosingSignedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_TypeZDecodeErrorZPtr { err } + CResult_ClosingSignedDecodeErrorZPtr { err } }; Self { contents, @@ -12690,184 +17899,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_TypeZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_TypeZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_TypeZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_TypeZDecodeErrorZ_clone(orig: &CResult_COption_TypeZDecodeErrorZ) -> CResult_COption_TypeZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::ln::msgs::SocketAddress or not -pub enum COption_SocketAddressZ { - /// When we're in this state, this COption_SocketAddressZ contains a crate::lightning::ln::msgs::SocketAddress - Some(crate::lightning::ln::msgs::SocketAddress), - /// When we're in this state, this COption_SocketAddressZ contains nothing - None -} -impl COption_SocketAddressZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::msgs::SocketAddress { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_SocketAddressZ containing a crate::lightning::ln::msgs::SocketAddress -pub extern "C" fn COption_SocketAddressZ_some(o: crate::lightning::ln::msgs::SocketAddress) -> COption_SocketAddressZ { - COption_SocketAddressZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_SocketAddressZ containing nothing -pub extern "C" fn COption_SocketAddressZ_none() -> COption_SocketAddressZ { - COption_SocketAddressZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::msgs::SocketAddress, if we are in the Some state -pub extern "C" fn COption_SocketAddressZ_free(_res: COption_SocketAddressZ) { } -#[no_mangle] -/// Creates a new COption_SocketAddressZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_SocketAddressZ_clone(orig: &COption_SocketAddressZ) -> COption_SocketAddressZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_PublicKeyCOption_SocketAddressZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::c_types::derived::COption_SocketAddressZ, -} -impl From<(crate::c_types::PublicKey, crate::c_types::derived::COption_SocketAddressZ)> for C2Tuple_PublicKeyCOption_SocketAddressZZ { - fn from (tup: (crate::c_types::PublicKey, crate::c_types::derived::COption_SocketAddressZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_PublicKeyCOption_SocketAddressZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::c_types::derived::COption_SocketAddressZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_PublicKeyCOption_SocketAddressZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(orig: &C2Tuple_PublicKeyCOption_SocketAddressZZ) -> C2Tuple_PublicKeyCOption_SocketAddressZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_PublicKeyCOption_SocketAddressZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_PublicKeyCOption_SocketAddressZZ_new(a: crate::c_types::PublicKey, b: crate::c_types::derived::COption_SocketAddressZ) -> C2Tuple_PublicKeyCOption_SocketAddressZZ { - C2Tuple_PublicKeyCOption_SocketAddressZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_PublicKeyCOption_SocketAddressZZ. -pub extern "C" fn C2Tuple_PublicKeyCOption_SocketAddressZZ_free(_res: C2Tuple_PublicKeyCOption_SocketAddressZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_PublicKeyCOption_SocketAddressZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_PublicKeyCOption_SocketAddressZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyCOption_SocketAddressZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(_res: CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ) { } -impl Drop for CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_u8ZPeerHandleErrorZ -pub union CResult_CVec_u8ZPeerHandleErrorZPtr { +/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ +pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, + pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_u8ZPeerHandleErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZPeerHandleErrorZ { - /// The contents of this CResult_CVec_u8ZPeerHandleErrorZ, accessible via either +pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { + /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZPeerHandleErrorZPtr, - /// Whether this CResult_CVec_u8ZPeerHandleErrorZ represents a success state. + pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, + /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_CVec_u8ZPeerHandleErrorZ { - CResult_CVec_u8ZPeerHandleErrorZ { - contents: CResult_CVec_u8ZPeerHandleErrorZPtr { +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { + CResult_ClosingSignedFeeRangeDecodeErrorZ { + contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12875,13 +17959,13 @@ pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o: &CResult_CVec_u8ZPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZPeerHandleErrorZ. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_free(_res: CResult_CVec_u8ZPeerHandleErrorZ) { } -impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { +/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } +impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -12894,16 +17978,16 @@ impl Drop for CResult_CVec_u8ZPeerHandleErrorZ { } } } -impl From> for CResult_CVec_u8ZPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_u8ZPeerHandleErrorZPtr { result } + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_u8ZPeerHandleErrorZPtr { err } + CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } }; Self { contents, @@ -12911,58 +17995,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_u8ZPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZPeerHandleErrorZ_clone(orig: &CResult_CVec_u8ZPeerHandleErrorZ) -> CResult_CVec_u8ZPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NonePeerHandleErrorZ -pub union CResult_NonePeerHandleErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_CommitmentSignedBatchDecodeErrorZ +pub union CResult_CommitmentSignedBatchDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::CommitmentSignedBatch, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NonePeerHandleErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_CommitmentSignedBatchDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSignedBatch on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NonePeerHandleErrorZ { - /// The contents of this CResult_NonePeerHandleErrorZ, accessible via either +pub struct CResult_CommitmentSignedBatchDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedBatchDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NonePeerHandleErrorZPtr, - /// Whether this CResult_NonePeerHandleErrorZ represents a success state. + pub contents: CResult_CommitmentSignedBatchDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedBatchDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the success state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSignedBatch) -> CResult_CommitmentSignedBatchDecodeErrorZ { + CResult_CommitmentSignedBatchDecodeErrorZ { + contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ in the error state. -pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_NonePeerHandleErrorZ { - CResult_NonePeerHandleErrorZ { - contents: CResult_NonePeerHandleErrorZPtr { +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedBatchDecodeErrorZ { + CResult_CommitmentSignedBatchDecodeErrorZ { + contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -12970,15 +18055,18 @@ pub extern "C" fn CResult_NonePeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NonePeerHandleErrorZ_is_ok(o: &CResult_NonePeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedBatchDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NonePeerHandleErrorZ. -pub extern "C" fn CResult_NonePeerHandleErrorZ_free(_res: CResult_NonePeerHandleErrorZ) { } -impl Drop for CResult_NonePeerHandleErrorZ { +/// Frees any resources used by the CResult_CommitmentSignedBatchDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_free(_res: CResult_CommitmentSignedBatchDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedBatchDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -12986,16 +18074,16 @@ impl Drop for CResult_NonePeerHandleErrorZ { } } } -impl From> for CResult_NonePeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self { +impl From> for CResult_CommitmentSignedBatchDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_CommitmentSignedBatchDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NonePeerHandleErrorZPtr { err } + CResult_CommitmentSignedBatchDecodeErrorZPtr { err } }; Self { contents, @@ -13003,59 +18091,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CommitmentSignedBatchDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NonePeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_CommitmentSignedBatchDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NonePeerHandleErrorZ_clone(orig: &CResult_NonePeerHandleErrorZ) -> CResult_NonePeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentSignedBatchDecodeErrorZ_clone(orig: &CResult_CommitmentSignedBatchDecodeErrorZ) -> CResult_CommitmentSignedBatchDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_boolPeerHandleErrorZ -pub union CResult_boolPeerHandleErrorZPtr { +/// The contents of CResult_CommitmentSignedDecodeErrorZ +pub union CResult_CommitmentSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut bool, + pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_boolPeerHandleErrorZ represents the result of a fallible operation, -/// containing a bool on success and a crate::lightning::ln::peer_handler::PeerHandleError on failure. +/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_boolPeerHandleErrorZ { - /// The contents of this CResult_boolPeerHandleErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_boolPeerHandleErrorZPtr, - /// Whether this CResult_boolPeerHandleErrorZ represents a success state. +pub struct CResult_CommitmentSignedDecodeErrorZ { + /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_CommitmentSignedDecodeErrorZPtr, + /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the success state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_ok(o: bool) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ in the error state. -pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer_handler::PeerHandleError) -> CResult_boolPeerHandleErrorZ { - CResult_boolPeerHandleErrorZ { - contents: CResult_boolPeerHandleErrorZPtr { +/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { + CResult_CommitmentSignedDecodeErrorZ { + contents: CResult_CommitmentSignedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13063,13 +18151,13 @@ pub extern "C" fn CResult_boolPeerHandleErrorZ_err(e: crate::lightning::ln::peer } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_boolPeerHandleErrorZ_is_ok(o: &CResult_boolPeerHandleErrorZ) -> bool { +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_boolPeerHandleErrorZ. -pub extern "C" fn CResult_boolPeerHandleErrorZ_free(_res: CResult_boolPeerHandleErrorZ) { } -impl Drop for CResult_boolPeerHandleErrorZ { +/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } +impl Drop for CResult_CommitmentSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13082,16 +18170,16 @@ impl Drop for CResult_boolPeerHandleErrorZ { } } } -impl From> for CResult_boolPeerHandleErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_boolPeerHandleErrorZPtr { result } + CResult_CommitmentSignedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_boolPeerHandleErrorZPtr { err } + CResult_CommitmentSignedDecodeErrorZPtr { err } }; Self { contents, @@ -13099,59 +18187,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_boolPeerHandleErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_boolPeerHandleErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_boolPeerHandleErrorZ which has the same data as `orig` +/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_boolPeerHandleErrorZ_clone(orig: &CResult_boolPeerHandleErrorZ) -> CResult_boolPeerHandleErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_u32GraphSyncErrorZ -pub union CResult_u32GraphSyncErrorZPtr { +/// The contents of CResult_FundingCreatedDecodeErrorZ +pub union CResult_FundingCreatedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut u32, + pub result: *mut crate::lightning::ln::msgs::FundingCreated, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_rapid_gossip_sync::GraphSyncError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_u32GraphSyncErrorZ represents the result of a fallible operation, -/// containing a u32 on success and a crate::lightning_rapid_gossip_sync::GraphSyncError on failure. +/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_u32GraphSyncErrorZ { - /// The contents of this CResult_u32GraphSyncErrorZ, accessible via either +pub struct CResult_FundingCreatedDecodeErrorZ { + /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_u32GraphSyncErrorZPtr, - /// Whether this CResult_u32GraphSyncErrorZ represents a success state. + pub contents: CResult_FundingCreatedDecodeErrorZPtr, + /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the success state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_ok(o: u32) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_u32GraphSyncErrorZ in the error state. -pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossip_sync::GraphSyncError) -> CResult_u32GraphSyncErrorZ { - CResult_u32GraphSyncErrorZ { - contents: CResult_u32GraphSyncErrorZPtr { +/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { + CResult_FundingCreatedDecodeErrorZ { + contents: CResult_FundingCreatedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13159,13 +18247,13 @@ pub extern "C" fn CResult_u32GraphSyncErrorZ_err(e: crate::lightning_rapid_gossi } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_u32GraphSyncErrorZ_is_ok(o: &CResult_u32GraphSyncErrorZ) -> bool { +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_u32GraphSyncErrorZ. -pub extern "C" fn CResult_u32GraphSyncErrorZ_free(_res: CResult_u32GraphSyncErrorZ) { } -impl Drop for CResult_u32GraphSyncErrorZ { +/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } +impl Drop for CResult_FundingCreatedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13178,16 +18266,16 @@ impl Drop for CResult_u32GraphSyncErrorZ { } } } -impl From> for CResult_u32GraphSyncErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingCreatedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_u32GraphSyncErrorZPtr { result } + CResult_FundingCreatedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_u32GraphSyncErrorZPtr { err } + CResult_FundingCreatedDecodeErrorZPtr { err } }; Self { contents, @@ -13195,42 +18283,59 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_u8ZIOErrorZ -pub union CResult_CVec_u8ZIOErrorZPtr { +/// The contents of CResult_FundingSignedDecodeErrorZ +pub union CResult_FundingSignedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_u8Z, + pub result: *mut crate::lightning::ln::msgs::FundingSigned, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_u8ZIOErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_u8Z on success and a crate::c_types::IOError on failure. +/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_u8ZIOErrorZ { - /// The contents of this CResult_CVec_u8ZIOErrorZ, accessible via either +pub struct CResult_FundingSignedDecodeErrorZ { + /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_u8ZIOErrorZPtr, - /// Whether this CResult_CVec_u8ZIOErrorZ represents a success state. + pub contents: CResult_FundingSignedDecodeErrorZPtr, + /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_u8ZIOErrorZ in the success state. -pub extern "C" fn CResult_CVec_u8ZIOErrorZ_ok(o: crate::c_types::derived::CVec_u8Z) -> CResult_CVec_u8ZIOErrorZ { - CResult_CVec_u8ZIOErrorZ { - contents: CResult_CVec_u8ZIOErrorZPtr { +/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZIOErrorZ in the error state. -pub extern "C" fn CResult_CVec_u8ZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_u8ZIOErrorZ { - CResult_CVec_u8ZIOErrorZ { - contents: CResult_CVec_u8ZIOErrorZPtr { +/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { + CResult_FundingSignedDecodeErrorZ { + contents: CResult_FundingSignedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13238,13 +18343,13 @@ pub extern "C" fn CResult_CVec_u8ZIOErrorZ_err(e: crate::c_types::IOError) -> CR } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_u8ZIOErrorZ_is_ok(o: &CResult_CVec_u8ZIOErrorZ) -> bool { +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_u8ZIOErrorZ. -pub extern "C" fn CResult_CVec_u8ZIOErrorZ_free(_res: CResult_CVec_u8ZIOErrorZ) { } -impl Drop for CResult_CVec_u8ZIOErrorZ { +/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } +impl Drop for CResult_FundingSignedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13257,16 +18362,16 @@ impl Drop for CResult_CVec_u8ZIOErrorZ { } } } -impl From> for CResult_CVec_u8ZIOErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingSignedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_u8ZIOErrorZPtr { result } + CResult_FundingSignedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_u8ZIOErrorZPtr { err } + CResult_FundingSignedDecodeErrorZPtr { err } }; Self { contents, @@ -13274,105 +18379,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_u8ZIOErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_u8ZIOErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_u8ZIOErrorZ which has the same data as `orig` +/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_u8ZIOErrorZ_clone(orig: &CResult_CVec_u8ZIOErrorZ) -> CResult_CVec_u8ZIOErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::Strs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_StrZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Str, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_StrZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Str] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_StrZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_StrZ_free(_res: CVec_StrZ) { } -impl Drop for CVec_StrZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_StrZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_StrZIOErrorZ -pub union CResult_CVec_StrZIOErrorZPtr { +/// The contents of CResult_ChannelReadyDecodeErrorZ +pub union CResult_ChannelReadyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_StrZ, + pub result: *mut crate::lightning::ln::msgs::ChannelReady, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_StrZIOErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_StrZ on success and a crate::c_types::IOError on failure. +/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_StrZIOErrorZ { - /// The contents of this CResult_CVec_StrZIOErrorZ, accessible via either +pub struct CResult_ChannelReadyDecodeErrorZ { + /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_StrZIOErrorZPtr, - /// Whether this CResult_CVec_StrZIOErrorZ represents a success state. + pub contents: CResult_ChannelReadyDecodeErrorZPtr, + /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_CVec_StrZIOErrorZ in the success state. -pub extern "C" fn CResult_CVec_StrZIOErrorZ_ok(o: crate::c_types::derived::CVec_StrZ) -> CResult_CVec_StrZIOErrorZ { - CResult_CVec_StrZIOErrorZ { - contents: CResult_CVec_StrZIOErrorZPtr { +} +#[no_mangle] +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_StrZIOErrorZ in the error state. -pub extern "C" fn CResult_CVec_StrZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_StrZIOErrorZ { - CResult_CVec_StrZIOErrorZ { - contents: CResult_CVec_StrZIOErrorZPtr { +/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { + CResult_ChannelReadyDecodeErrorZ { + contents: CResult_ChannelReadyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13380,13 +18439,13 @@ pub extern "C" fn CResult_CVec_StrZIOErrorZ_err(e: crate::c_types::IOError) -> C } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_StrZIOErrorZ_is_ok(o: &CResult_CVec_StrZIOErrorZ) -> bool { +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_StrZIOErrorZ. -pub extern "C" fn CResult_CVec_StrZIOErrorZ_free(_res: CResult_CVec_StrZIOErrorZ) { } -impl Drop for CResult_CVec_StrZIOErrorZ { +/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } +impl Drop for CResult_ChannelReadyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13399,16 +18458,16 @@ impl Drop for CResult_CVec_StrZIOErrorZ { } } } -impl From> for CResult_CVec_StrZIOErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelReadyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_StrZIOErrorZPtr { result } + CResult_ChannelReadyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_StrZIOErrorZPtr { err } + CResult_ChannelReadyDecodeErrorZPtr { err } }; Self { contents, @@ -13416,105 +18475,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_StrZIOErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_StrZIOErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_StrZIOErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_StrZIOErrorZ_clone(orig: &CResult_CVec_StrZIOErrorZ) -> CResult_CVec_StrZIOErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(_res: CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ) { } -impl Drop for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ -pub union CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { +/// The contents of CResult_InitDecodeErrorZ +pub union CResult_InitDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ, + pub result: *mut crate::lightning::ln::msgs::Init, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ on success and a crate::c_types::IOError on failure. +/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - /// The contents of this CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ, accessible via either +pub struct CResult_InitDecodeErrorZ { + /// The contents of this CResult_InitDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr, - /// Whether this CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ represents a success state. + pub contents: CResult_InitDecodeErrorZPtr, + /// Whether this CResult_InitDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ in the success state. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(o: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { +/// Creates a new CResult_InitDecodeErrorZ in the success state. +pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ in the error state. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { +/// Creates a new CResult_InitDecodeErrorZ in the error state. +pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { + CResult_InitDecodeErrorZ { + contents: CResult_InitDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13522,13 +18535,13 @@ pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_er } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(o: &CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) -> bool { +pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(_res: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) { } -impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { +/// Frees any resources used by the CResult_InitDecodeErrorZ. +pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } +impl Drop for CResult_InitDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13541,16 +18554,16 @@ impl Drop for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { } } } -impl From> for CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InitDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { result } + CResult_InitDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { err } + CResult_InitDecodeErrorZPtr { err } }; Self { contents, @@ -13558,59 +18571,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ which has the same data as `orig` +/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(orig: &CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ) -> CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ -pub union CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { +/// The contents of CResult_OpenChannelDecodeErrorZ +pub union CResult_OpenChannelDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ, + pub result: *mut crate::lightning::ln::msgs::OpenChannel, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::IOError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ on success and a crate::c_types::IOError on failure. +/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - /// The contents of this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ, accessible via either +pub struct CResult_OpenChannelDecodeErrorZ { + /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr, - /// Whether this CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ represents a success state. + pub contents: CResult_OpenChannelDecodeErrorZPtr, + /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ in the success state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(o: crate::c_types::derived::C2Tuple_ThirtyTwoBytesChannelMonitorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { +/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ in the error state. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(e: crate::c_types::IOError) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { +/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { + CResult_OpenChannelDecodeErrorZ { + contents: CResult_OpenChannelDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13618,13 +18631,13 @@ pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(e: c } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(o: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) -> bool { +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(_res: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) { } -impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { +/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } +impl Drop for CResult_OpenChannelDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13637,16 +18650,16 @@ impl Drop for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { } } } -impl From> for CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OpenChannelDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { result } + CResult_OpenChannelDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { err } + CResult_OpenChannelDecodeErrorZPtr { err } }; Self { contents, @@ -13654,128 +18667,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(orig: &CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ) -> CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::SecretKey or not -pub enum COption_SecretKeyZ { - /// When we're in this state, this COption_SecretKeyZ contains a crate::c_types::SecretKey - Some(crate::c_types::SecretKey), - /// When we're in this state, this COption_SecretKeyZ contains nothing - None -} -impl COption_SecretKeyZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::SecretKey { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_SecretKeyZ containing a crate::c_types::SecretKey -pub extern "C" fn COption_SecretKeyZ_some(o: crate::c_types::SecretKey) -> COption_SecretKeyZ { - COption_SecretKeyZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_SecretKeyZ containing nothing -pub extern "C" fn COption_SecretKeyZ_none() -> COption_SecretKeyZ { - COption_SecretKeyZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::SecretKey, if we are in the Some state -pub extern "C" fn COption_SecretKeyZ_free(_res: COption_SecretKeyZ) { } -#[no_mangle] -/// Creates a new COption_SecretKeyZ which has the same data as `orig` +/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_SecretKeyZ_clone(orig: &COption_SecretKeyZ) -> COption_SecretKeyZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_VerifiedInvoiceRequestNoneZ -pub union CResult_VerifiedInvoiceRequestNoneZPtr { +/// The contents of CResult_OpenChannelV2DecodeErrorZ +pub union CResult_OpenChannelV2DecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::ln::msgs::OpenChannelV2, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_VerifiedInvoiceRequestNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::invoice_request::VerifiedInvoiceRequest on success and a () on failure. +/// A CResult_OpenChannelV2DecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OpenChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_VerifiedInvoiceRequestNoneZ { - /// The contents of this CResult_VerifiedInvoiceRequestNoneZ, accessible via either +pub struct CResult_OpenChannelV2DecodeErrorZ { + /// The contents of this CResult_OpenChannelV2DecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_VerifiedInvoiceRequestNoneZPtr, - /// Whether this CResult_VerifiedInvoiceRequestNoneZ represents a success state. + pub contents: CResult_OpenChannelV2DecodeErrorZPtr, + /// Whether this CResult_OpenChannelV2DecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_VerifiedInvoiceRequestNoneZ in the success state. -pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_ok(o: crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> CResult_VerifiedInvoiceRequestNoneZ { - CResult_VerifiedInvoiceRequestNoneZ { - contents: CResult_VerifiedInvoiceRequestNoneZPtr { +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the success state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannelV2) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_VerifiedInvoiceRequestNoneZ in the error state. -pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_err() -> CResult_VerifiedInvoiceRequestNoneZ { - CResult_VerifiedInvoiceRequestNoneZ { - contents: CResult_VerifiedInvoiceRequestNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the error state. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelV2DecodeErrorZ { + CResult_OpenChannelV2DecodeErrorZ { + contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_is_ok(o: &CResult_VerifiedInvoiceRequestNoneZ) -> bool { +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_is_ok(o: &CResult_OpenChannelV2DecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_VerifiedInvoiceRequestNoneZ. -pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_free(_res: CResult_VerifiedInvoiceRequestNoneZ) { } -impl Drop for CResult_VerifiedInvoiceRequestNoneZ { +/// Frees any resources used by the CResult_OpenChannelV2DecodeErrorZ. +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_free(_res: CResult_OpenChannelV2DecodeErrorZ) { } +impl Drop for CResult_OpenChannelV2DecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_VerifiedInvoiceRequestNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OpenChannelV2DecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_VerifiedInvoiceRequestNoneZPtr { result } + CResult_OpenChannelV2DecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_VerifiedInvoiceRequestNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OpenChannelV2DecodeErrorZPtr { err } }; Self { contents, @@ -13783,171 +18763,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_VerifiedInvoiceRequestNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OpenChannelV2DecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_VerifiedInvoiceRequestNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_OpenChannelV2DecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_VerifiedInvoiceRequestNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_VerifiedInvoiceRequestNoneZ_clone(orig: &CResult_VerifiedInvoiceRequestNoneZ) -> CResult_VerifiedInvoiceRequestNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a or not -pub enum COption_NoneZ { - /// When we're in this state, this COption_NoneZ contains a - Some, - /// When we're in this state, this COption_NoneZ contains nothing - None -} -impl COption_NoneZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } -} -#[no_mangle] -/// Constructs a new COption_NoneZ containing a -pub extern "C" fn COption_NoneZ_some() -> COption_NoneZ { - COption_NoneZ::Some -} -#[no_mangle] -/// Constructs a new COption_NoneZ containing nothing -pub extern "C" fn COption_NoneZ_none() -> COption_NoneZ { - COption_NoneZ::None -} -#[no_mangle] -/// Frees any resources associated with the , if we are in the Some state -pub extern "C" fn COption_NoneZ_free(_res: COption_NoneZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::Witnesss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_WitnessZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::Witness, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_WitnessZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Witness] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_WitnessZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_WitnessZ_free(_res: CVec_WitnessZ) { } -impl Drop for CVec_WitnessZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_WitnessZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a i64 or not -pub enum COption_i64Z { - /// When we're in this state, this COption_i64Z contains a i64 - Some(i64), - /// When we're in this state, this COption_i64Z contains nothing - None -} -impl COption_i64Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> i64 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_i64Z containing a i64 -pub extern "C" fn COption_i64Z_some(o: i64) -> COption_i64Z { - COption_i64Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_i64Z containing nothing -pub extern "C" fn COption_i64Z_none() -> COption_i64Z { - COption_i64Z::None -} -#[no_mangle] -/// Frees any resources associated with the i64, if we are in the Some state -pub extern "C" fn COption_i64Z_free(_res: COption_i64Z) { } -#[no_mangle] -/// Creates a new COption_i64Z which has the same data as `orig` +/// Creates a new CResult_OpenChannelV2DecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_i64Z_clone(orig: &COption_i64Z) -> COption_i64Z { Clone::clone(&orig) } +pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_clone(orig: &CResult_OpenChannelV2DecodeErrorZ) -> CResult_OpenChannelV2DecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SocketAddressDecodeErrorZ -pub union CResult_SocketAddressDecodeErrorZPtr { +/// The contents of CResult_RevokeAndACKDecodeErrorZ +pub union CResult_RevokeAndACKDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::SocketAddress, + pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SocketAddressDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::SocketAddress on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SocketAddressDecodeErrorZ { - /// The contents of this CResult_SocketAddressDecodeErrorZ, accessible via either +pub struct CResult_RevokeAndACKDecodeErrorZ { + /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SocketAddressDecodeErrorZPtr, - /// Whether this CResult_SocketAddressDecodeErrorZ represents a success state. + pub contents: CResult_RevokeAndACKDecodeErrorZPtr, + /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SocketAddressDecodeErrorZ in the success state. -pub extern "C" fn CResult_SocketAddressDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SocketAddress) -> CResult_SocketAddressDecodeErrorZ { - CResult_SocketAddressDecodeErrorZ { - contents: CResult_SocketAddressDecodeErrorZPtr { +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SocketAddressDecodeErrorZ in the error state. -pub extern "C" fn CResult_SocketAddressDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SocketAddressDecodeErrorZ { - CResult_SocketAddressDecodeErrorZ { - contents: CResult_SocketAddressDecodeErrorZPtr { +/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { + CResult_RevokeAndACKDecodeErrorZ { + contents: CResult_RevokeAndACKDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -13955,13 +18823,13 @@ pub extern "C" fn CResult_SocketAddressDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SocketAddressDecodeErrorZ_is_ok(o: &CResult_SocketAddressDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SocketAddressDecodeErrorZ. -pub extern "C" fn CResult_SocketAddressDecodeErrorZ_free(_res: CResult_SocketAddressDecodeErrorZ) { } -impl Drop for CResult_SocketAddressDecodeErrorZ { +/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } +impl Drop for CResult_RevokeAndACKDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -13974,16 +18842,16 @@ impl Drop for CResult_SocketAddressDecodeErrorZ { } } } -impl From> for CResult_SocketAddressDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevokeAndACKDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SocketAddressDecodeErrorZPtr { result } + CResult_RevokeAndACKDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SocketAddressDecodeErrorZPtr { err } + CResult_RevokeAndACKDecodeErrorZPtr { err } }; Self { contents, @@ -13991,59 +18859,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SocketAddressDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SocketAddressDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SocketAddressDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SocketAddressDecodeErrorZ_clone(orig: &CResult_SocketAddressDecodeErrorZ) -> CResult_SocketAddressDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SocketAddressSocketAddressParseErrorZ -pub union CResult_SocketAddressSocketAddressParseErrorZPtr { +/// The contents of CResult_ShutdownDecodeErrorZ +pub union CResult_ShutdownDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::SocketAddress, + pub result: *mut crate::lightning::ln::msgs::Shutdown, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::SocketAddressParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SocketAddressSocketAddressParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::SocketAddress on success and a crate::lightning::ln::msgs::SocketAddressParseError on failure. +/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SocketAddressSocketAddressParseErrorZ { - /// The contents of this CResult_SocketAddressSocketAddressParseErrorZ, accessible via either +pub struct CResult_ShutdownDecodeErrorZ { + /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SocketAddressSocketAddressParseErrorZPtr, - /// Whether this CResult_SocketAddressSocketAddressParseErrorZ represents a success state. + pub contents: CResult_ShutdownDecodeErrorZPtr, + /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ in the success state. -pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_ok(o: crate::lightning::ln::msgs::SocketAddress) -> CResult_SocketAddressSocketAddressParseErrorZ { - CResult_SocketAddressSocketAddressParseErrorZ { - contents: CResult_SocketAddressSocketAddressParseErrorZPtr { +/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ in the error state. -pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_err(e: crate::lightning::ln::msgs::SocketAddressParseError) -> CResult_SocketAddressSocketAddressParseErrorZ { - CResult_SocketAddressSocketAddressParseErrorZ { - contents: CResult_SocketAddressSocketAddressParseErrorZPtr { +/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { + CResult_ShutdownDecodeErrorZ { + contents: CResult_ShutdownDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14051,13 +18919,13 @@ pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_err(e: crate::li } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_is_ok(o: &CResult_SocketAddressSocketAddressParseErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SocketAddressSocketAddressParseErrorZ. -pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_free(_res: CResult_SocketAddressSocketAddressParseErrorZ) { } -impl Drop for CResult_SocketAddressSocketAddressParseErrorZ { +/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. +pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } +impl Drop for CResult_ShutdownDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14070,16 +18938,16 @@ impl Drop for CResult_SocketAddressSocketAddressParseErrorZ { } } } -impl From> for CResult_SocketAddressSocketAddressParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SocketAddressSocketAddressParseErrorZPtr { result } + CResult_ShutdownDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SocketAddressSocketAddressParseErrorZPtr { err } + CResult_ShutdownDecodeErrorZPtr { err } }; Self { contents, @@ -14087,243 +18955,155 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SocketAddressSocketAddressParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SocketAddressSocketAddressParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SocketAddressSocketAddressParseErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SocketAddressSocketAddressParseErrorZ_clone(orig: &CResult_SocketAddressSocketAddressParseErrorZ) -> CResult_SocketAddressSocketAddressParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateAddHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateAddHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateAddHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateAddHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateAddHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateAddHTLCZ_free(_res: CVec_UpdateAddHTLCZ) { } -impl Drop for CVec_UpdateAddHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateAddHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +/// The contents of CResult_UpdateFailHTLCDecodeErrorZ +pub union CResult_UpdateFailHTLCDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFulfillHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFulfillHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFulfillHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFulfillHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_UpdateFailHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub result_ok: bool, } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFulfillHTLCZ_free(_res: CVec_UpdateFulfillHTLCZ) { } -impl Drop for CVec_UpdateFulfillHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFulfillHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_UpdateFailHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailHTLCZ_free(_res: CVec_UpdateFailHTLCZ) { } -impl Drop for CVec_UpdateFailHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_UpdateFailHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::msgs::UpdateFailMalformedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_UpdateFailMalformedHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_UpdateFailMalformedHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { + CResult_UpdateFailHTLCDecodeErrorZ { + contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, } } -impl From> for CVec_UpdateFailMalformedHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } +/// Checks if the given object is currently in the success state +#[no_mangle] +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { + o.result_ok } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_UpdateFailMalformedHTLCZ_free(_res: CVec_UpdateFailMalformedHTLCZ) { } -impl Drop for CVec_UpdateFailMalformedHTLCZ { +/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } } } -impl Clone for CVec_UpdateFailMalformedHTLCZ { +impl From> for CResult_UpdateFailHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { + let contents = if o.result_ok { + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_UpdateFailHTLCDecodeErrorZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_UpdateFailHTLCDecodeErrorZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_UpdateFailHTLCDecodeErrorZ { fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) + if self.result_ok { + Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } } } +#[no_mangle] +/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_AcceptChannelDecodeErrorZ -pub union CResult_AcceptChannelDecodeErrorZPtr { +/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ +pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AcceptChannel, + pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AcceptChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AcceptChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AcceptChannelDecodeErrorZ { - /// The contents of this CResult_AcceptChannelDecodeErrorZ, accessible via either +pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AcceptChannelDecodeErrorZPtr, - /// Whether this CResult_AcceptChannelDecodeErrorZ represents a success state. + pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannel) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelDecodeErrorZ { - CResult_AcceptChannelDecodeErrorZ { - contents: CResult_AcceptChannelDecodeErrorZPtr { +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { + CResult_UpdateFailMalformedHTLCDecodeErrorZ { + contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14331,13 +19111,13 @@ pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_is_ok(o: &CResult_AcceptChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AcceptChannelDecodeErrorZ. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_free(_res: CResult_AcceptChannelDecodeErrorZ) { } -impl Drop for CResult_AcceptChannelDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14350,16 +19130,16 @@ impl Drop for CResult_AcceptChannelDecodeErrorZ { } } } -impl From> for CResult_AcceptChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AcceptChannelDecodeErrorZPtr { result } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AcceptChannelDecodeErrorZPtr { err } + CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -14367,59 +19147,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AcceptChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AcceptChannelDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AcceptChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AcceptChannelDecodeErrorZ_clone(orig: &CResult_AcceptChannelDecodeErrorZ) -> CResult_AcceptChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_AcceptChannelV2DecodeErrorZ -pub union CResult_AcceptChannelV2DecodeErrorZPtr { +/// The contents of CResult_UpdateFeeDecodeErrorZ +pub union CResult_UpdateFeeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AcceptChannelV2, + pub result: *mut crate::lightning::ln::msgs::UpdateFee, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AcceptChannelV2DecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AcceptChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AcceptChannelV2DecodeErrorZ { - /// The contents of this CResult_AcceptChannelV2DecodeErrorZ, accessible via either +pub struct CResult_UpdateFeeDecodeErrorZ { + /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AcceptChannelV2DecodeErrorZPtr, - /// Whether this CResult_AcceptChannelV2DecodeErrorZ represents a success state. + pub contents: CResult_UpdateFeeDecodeErrorZPtr, + /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the success state. -pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::AcceptChannelV2) -> CResult_AcceptChannelV2DecodeErrorZ { - CResult_AcceptChannelV2DecodeErrorZ { - contents: CResult_AcceptChannelV2DecodeErrorZPtr { +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AcceptChannelV2DecodeErrorZ in the error state. -pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AcceptChannelV2DecodeErrorZ { - CResult_AcceptChannelV2DecodeErrorZ { - contents: CResult_AcceptChannelV2DecodeErrorZPtr { +/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { + CResult_UpdateFeeDecodeErrorZ { + contents: CResult_UpdateFeeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14427,13 +19207,13 @@ pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_is_ok(o: &CResult_AcceptChannelV2DecodeErrorZ) -> bool { +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AcceptChannelV2DecodeErrorZ. -pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_free(_res: CResult_AcceptChannelV2DecodeErrorZ) { } -impl Drop for CResult_AcceptChannelV2DecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } +impl Drop for CResult_UpdateFeeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14446,16 +19226,16 @@ impl Drop for CResult_AcceptChannelV2DecodeErrorZ { } } } -impl From> for CResult_AcceptChannelV2DecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFeeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AcceptChannelV2DecodeErrorZPtr { result } + CResult_UpdateFeeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AcceptChannelV2DecodeErrorZPtr { err } + CResult_UpdateFeeDecodeErrorZPtr { err } }; Self { contents, @@ -14463,59 +19243,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AcceptChannelV2DecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AcceptChannelV2DecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AcceptChannelV2DecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AcceptChannelV2DecodeErrorZ_clone(orig: &CResult_AcceptChannelV2DecodeErrorZ) -> CResult_AcceptChannelV2DecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StfuDecodeErrorZ -pub union CResult_StfuDecodeErrorZPtr { +/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ +pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Stfu, + pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_StfuDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Stfu on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StfuDecodeErrorZ { - /// The contents of this CResult_StfuDecodeErrorZ, accessible via either +pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StfuDecodeErrorZPtr, - /// Whether this CResult_StfuDecodeErrorZ represents a success state. + pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StfuDecodeErrorZ in the success state. -pub extern "C" fn CResult_StfuDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Stfu) -> CResult_StfuDecodeErrorZ { - CResult_StfuDecodeErrorZ { - contents: CResult_StfuDecodeErrorZPtr { +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StfuDecodeErrorZ in the error state. -pub extern "C" fn CResult_StfuDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_StfuDecodeErrorZ { - CResult_StfuDecodeErrorZ { - contents: CResult_StfuDecodeErrorZPtr { +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { + CResult_UpdateFulfillHTLCDecodeErrorZ { + contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14523,13 +19303,13 @@ pub extern "C" fn CResult_StfuDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StfuDecodeErrorZ_is_ok(o: &CResult_StfuDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StfuDecodeErrorZ. -pub extern "C" fn CResult_StfuDecodeErrorZ_free(_res: CResult_StfuDecodeErrorZ) { } -impl Drop for CResult_StfuDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14542,16 +19322,16 @@ impl Drop for CResult_StfuDecodeErrorZ { } } } -impl From> for CResult_StfuDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StfuDecodeErrorZPtr { result } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StfuDecodeErrorZPtr { err } + CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -14559,59 +19339,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StfuDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StfuDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_StfuDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StfuDecodeErrorZ_clone(orig: &CResult_StfuDecodeErrorZ) -> CResult_StfuDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SpliceDecodeErrorZ -pub union CResult_SpliceDecodeErrorZPtr { +/// The contents of CResult_OnionPacketDecodeErrorZ +pub union CResult_OnionPacketDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Splice, + pub result: *mut crate::lightning::ln::msgs::OnionPacket, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SpliceDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Splice on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OnionPacketDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OnionPacket on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpliceDecodeErrorZ { - /// The contents of this CResult_SpliceDecodeErrorZ, accessible via either +pub struct CResult_OnionPacketDecodeErrorZ { + /// The contents of this CResult_OnionPacketDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpliceDecodeErrorZPtr, - /// Whether this CResult_SpliceDecodeErrorZ represents a success state. + pub contents: CResult_OnionPacketDecodeErrorZPtr, + /// Whether this CResult_OnionPacketDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpliceDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Splice) -> CResult_SpliceDecodeErrorZ { - CResult_SpliceDecodeErrorZ { - contents: CResult_SpliceDecodeErrorZPtr { +/// Creates a new CResult_OnionPacketDecodeErrorZ in the success state. +pub extern "C" fn CResult_OnionPacketDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionPacket) -> CResult_OnionPacketDecodeErrorZ { + CResult_OnionPacketDecodeErrorZ { + contents: CResult_OnionPacketDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpliceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceDecodeErrorZ { - CResult_SpliceDecodeErrorZ { - contents: CResult_SpliceDecodeErrorZPtr { +/// Creates a new CResult_OnionPacketDecodeErrorZ in the error state. +pub extern "C" fn CResult_OnionPacketDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionPacketDecodeErrorZ { + CResult_OnionPacketDecodeErrorZ { + contents: CResult_OnionPacketDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14619,13 +19399,13 @@ pub extern "C" fn CResult_SpliceDecodeErrorZ_err(e: crate::lightning::ln::msgs:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpliceDecodeErrorZ_is_ok(o: &CResult_SpliceDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OnionPacketDecodeErrorZ_is_ok(o: &CResult_OnionPacketDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpliceDecodeErrorZ. -pub extern "C" fn CResult_SpliceDecodeErrorZ_free(_res: CResult_SpliceDecodeErrorZ) { } -impl Drop for CResult_SpliceDecodeErrorZ { +/// Frees any resources used by the CResult_OnionPacketDecodeErrorZ. +pub extern "C" fn CResult_OnionPacketDecodeErrorZ_free(_res: CResult_OnionPacketDecodeErrorZ) { } +impl Drop for CResult_OnionPacketDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14638,16 +19418,16 @@ impl Drop for CResult_SpliceDecodeErrorZ { } } } -impl From> for CResult_SpliceDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OnionPacketDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpliceDecodeErrorZPtr { result } + CResult_OnionPacketDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpliceDecodeErrorZPtr { err } + CResult_OnionPacketDecodeErrorZPtr { err } }; Self { contents, @@ -14655,59 +19435,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpliceDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OnionPacketDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpliceDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OnionPacketDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpliceDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OnionPacketDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpliceDecodeErrorZ_clone(orig: &CResult_SpliceDecodeErrorZ) -> CResult_SpliceDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_SpliceAckDecodeErrorZ -pub union CResult_SpliceAckDecodeErrorZPtr { +pub extern "C" fn CResult_OnionPacketDecodeErrorZ_clone(orig: &CResult_OnionPacketDecodeErrorZ) -> CResult_OnionPacketDecodeErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_UpdateAddHTLCDecodeErrorZ +pub union CResult_UpdateAddHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::SpliceAck, + pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SpliceAckDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::SpliceAck on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpliceAckDecodeErrorZ { - /// The contents of this CResult_SpliceAckDecodeErrorZ, accessible via either +pub struct CResult_UpdateAddHTLCDecodeErrorZ { + /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpliceAckDecodeErrorZPtr, - /// Whether this CResult_SpliceAckDecodeErrorZ represents a success state. + pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, + /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpliceAckDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpliceAckDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceAck) -> CResult_SpliceAckDecodeErrorZ { - CResult_SpliceAckDecodeErrorZ { - contents: CResult_SpliceAckDecodeErrorZPtr { +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpliceAckDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpliceAckDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceAckDecodeErrorZ { - CResult_SpliceAckDecodeErrorZ { - contents: CResult_SpliceAckDecodeErrorZPtr { +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { + CResult_UpdateAddHTLCDecodeErrorZ { + contents: CResult_UpdateAddHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14715,13 +19495,13 @@ pub extern "C" fn CResult_SpliceAckDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpliceAckDecodeErrorZ_is_ok(o: &CResult_SpliceAckDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpliceAckDecodeErrorZ. -pub extern "C" fn CResult_SpliceAckDecodeErrorZ_free(_res: CResult_SpliceAckDecodeErrorZ) { } -impl Drop for CResult_SpliceAckDecodeErrorZ { +/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } +impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14734,16 +19514,16 @@ impl Drop for CResult_SpliceAckDecodeErrorZ { } } } -impl From> for CResult_SpliceAckDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UpdateAddHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpliceAckDecodeErrorZPtr { result } + CResult_UpdateAddHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpliceAckDecodeErrorZPtr { err } + CResult_UpdateAddHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -14751,59 +19531,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpliceAckDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpliceAckDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpliceAckDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpliceAckDecodeErrorZ_clone(orig: &CResult_SpliceAckDecodeErrorZ) -> CResult_SpliceAckDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SpliceLockedDecodeErrorZ -pub union CResult_SpliceLockedDecodeErrorZPtr { +/// The contents of CResult_OnionMessageDecodeErrorZ +pub union CResult_OnionMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::SpliceLocked, + pub result: *mut crate::lightning::ln::msgs::OnionMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SpliceLockedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::SpliceLocked on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SpliceLockedDecodeErrorZ { - /// The contents of this CResult_SpliceLockedDecodeErrorZ, accessible via either +pub struct CResult_OnionMessageDecodeErrorZ { + /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SpliceLockedDecodeErrorZPtr, - /// Whether this CResult_SpliceLockedDecodeErrorZ represents a success state. + pub contents: CResult_OnionMessageDecodeErrorZPtr, + /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SpliceLockedDecodeErrorZ in the success state. -pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::SpliceLocked) -> CResult_SpliceLockedDecodeErrorZ { - CResult_SpliceLockedDecodeErrorZ { - contents: CResult_SpliceLockedDecodeErrorZPtr { +/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SpliceLockedDecodeErrorZ in the error state. -pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_SpliceLockedDecodeErrorZ { - CResult_SpliceLockedDecodeErrorZ { - contents: CResult_SpliceLockedDecodeErrorZPtr { +/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { + CResult_OnionMessageDecodeErrorZ { + contents: CResult_OnionMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14811,13 +19591,13 @@ pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_is_ok(o: &CResult_SpliceLockedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SpliceLockedDecodeErrorZ. -pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_free(_res: CResult_SpliceLockedDecodeErrorZ) { } -impl Drop for CResult_SpliceLockedDecodeErrorZ { +/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } +impl Drop for CResult_OnionMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14830,16 +19610,16 @@ impl Drop for CResult_SpliceLockedDecodeErrorZ { } } } -impl From> for CResult_SpliceLockedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OnionMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SpliceLockedDecodeErrorZPtr { result } + CResult_OnionMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SpliceLockedDecodeErrorZPtr { err } + CResult_OnionMessageDecodeErrorZPtr { err } }; Self { contents, @@ -14847,59 +19627,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SpliceLockedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SpliceLockedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SpliceLockedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SpliceLockedDecodeErrorZ_clone(orig: &CResult_SpliceLockedDecodeErrorZ) -> CResult_SpliceLockedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxAddInputDecodeErrorZ -pub union CResult_TxAddInputDecodeErrorZPtr { +/// The contents of CResult_FinalOnionHopDataDecodeErrorZ +pub union CResult_FinalOnionHopDataDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxAddInput, + pub result: *mut crate::lightning::ln::msgs::FinalOnionHopData, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxAddInputDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxAddInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_FinalOnionHopDataDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::FinalOnionHopData on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxAddInputDecodeErrorZ { - /// The contents of this CResult_TxAddInputDecodeErrorZ, accessible via either +pub struct CResult_FinalOnionHopDataDecodeErrorZ { + /// The contents of this CResult_FinalOnionHopDataDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxAddInputDecodeErrorZPtr, - /// Whether this CResult_TxAddInputDecodeErrorZ represents a success state. + pub contents: CResult_FinalOnionHopDataDecodeErrorZPtr, + /// Whether this CResult_FinalOnionHopDataDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxAddInputDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxAddInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddInput) -> CResult_TxAddInputDecodeErrorZ { - CResult_TxAddInputDecodeErrorZ { - contents: CResult_TxAddInputDecodeErrorZPtr { +/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ in the success state. +pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FinalOnionHopData) -> CResult_FinalOnionHopDataDecodeErrorZ { + CResult_FinalOnionHopDataDecodeErrorZ { + contents: CResult_FinalOnionHopDataDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxAddInputDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxAddInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddInputDecodeErrorZ { - CResult_TxAddInputDecodeErrorZ { - contents: CResult_TxAddInputDecodeErrorZPtr { +/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ in the error state. +pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FinalOnionHopDataDecodeErrorZ { + CResult_FinalOnionHopDataDecodeErrorZ { + contents: CResult_FinalOnionHopDataDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -14907,13 +19687,13 @@ pub extern "C" fn CResult_TxAddInputDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxAddInputDecodeErrorZ_is_ok(o: &CResult_TxAddInputDecodeErrorZ) -> bool { +pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_is_ok(o: &CResult_FinalOnionHopDataDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxAddInputDecodeErrorZ. -pub extern "C" fn CResult_TxAddInputDecodeErrorZ_free(_res: CResult_TxAddInputDecodeErrorZ) { } -impl Drop for CResult_TxAddInputDecodeErrorZ { +/// Frees any resources used by the CResult_FinalOnionHopDataDecodeErrorZ. +pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_free(_res: CResult_FinalOnionHopDataDecodeErrorZ) { } +impl Drop for CResult_FinalOnionHopDataDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -14926,16 +19706,16 @@ impl Drop for CResult_TxAddInputDecodeErrorZ { } } } -impl From> for CResult_TxAddInputDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FinalOnionHopDataDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxAddInputDecodeErrorZPtr { result } + CResult_FinalOnionHopDataDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxAddInputDecodeErrorZPtr { err } + CResult_FinalOnionHopDataDecodeErrorZPtr { err } }; Self { contents, @@ -14943,59 +19723,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxAddInputDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FinalOnionHopDataDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxAddInputDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_FinalOnionHopDataDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxAddInputDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxAddInputDecodeErrorZ_clone(orig: &CResult_TxAddInputDecodeErrorZ) -> CResult_TxAddInputDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_clone(orig: &CResult_FinalOnionHopDataDecodeErrorZ) -> CResult_FinalOnionHopDataDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxAddOutputDecodeErrorZ -pub union CResult_TxAddOutputDecodeErrorZPtr { +/// The contents of CResult_PingDecodeErrorZ +pub union CResult_PingDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxAddOutput, + pub result: *mut crate::lightning::ln::msgs::Ping, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxAddOutputDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxAddOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxAddOutputDecodeErrorZ { - /// The contents of this CResult_TxAddOutputDecodeErrorZ, accessible via either +pub struct CResult_PingDecodeErrorZ { + /// The contents of this CResult_PingDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxAddOutputDecodeErrorZPtr, - /// Whether this CResult_TxAddOutputDecodeErrorZ represents a success state. + pub contents: CResult_PingDecodeErrorZPtr, + /// Whether this CResult_PingDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxAddOutputDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAddOutput) -> CResult_TxAddOutputDecodeErrorZ { - CResult_TxAddOutputDecodeErrorZ { - contents: CResult_TxAddOutputDecodeErrorZPtr { +/// Creates a new CResult_PingDecodeErrorZ in the success state. +pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxAddOutputDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAddOutputDecodeErrorZ { - CResult_TxAddOutputDecodeErrorZ { - contents: CResult_TxAddOutputDecodeErrorZPtr { +/// Creates a new CResult_PingDecodeErrorZ in the error state. +pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { + CResult_PingDecodeErrorZ { + contents: CResult_PingDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15003,13 +19783,13 @@ pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_is_ok(o: &CResult_TxAddOutputDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxAddOutputDecodeErrorZ. -pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_free(_res: CResult_TxAddOutputDecodeErrorZ) { } -impl Drop for CResult_TxAddOutputDecodeErrorZ { +/// Frees any resources used by the CResult_PingDecodeErrorZ. +pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } +impl Drop for CResult_PingDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15022,16 +19802,16 @@ impl Drop for CResult_TxAddOutputDecodeErrorZ { } } } -impl From> for CResult_TxAddOutputDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PingDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxAddOutputDecodeErrorZPtr { result } + CResult_PingDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxAddOutputDecodeErrorZPtr { err } + CResult_PingDecodeErrorZPtr { err } }; Self { contents, @@ -15039,59 +19819,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxAddOutputDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxAddOutputDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxAddOutputDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxAddOutputDecodeErrorZ_clone(orig: &CResult_TxAddOutputDecodeErrorZ) -> CResult_TxAddOutputDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxRemoveInputDecodeErrorZ -pub union CResult_TxRemoveInputDecodeErrorZPtr { +/// The contents of CResult_PongDecodeErrorZ +pub union CResult_PongDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxRemoveInput, + pub result: *mut crate::lightning::ln::msgs::Pong, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxRemoveInputDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxRemoveInput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxRemoveInputDecodeErrorZ { - /// The contents of this CResult_TxRemoveInputDecodeErrorZ, accessible via either +pub struct CResult_PongDecodeErrorZ { + /// The contents of this CResult_PongDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxRemoveInputDecodeErrorZPtr, - /// Whether this CResult_TxRemoveInputDecodeErrorZ represents a success state. + pub contents: CResult_PongDecodeErrorZPtr, + /// Whether this CResult_PongDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveInput) -> CResult_TxRemoveInputDecodeErrorZ { - CResult_TxRemoveInputDecodeErrorZ { - contents: CResult_TxRemoveInputDecodeErrorZPtr { +/// Creates a new CResult_PongDecodeErrorZ in the success state. +pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxRemoveInputDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveInputDecodeErrorZ { - CResult_TxRemoveInputDecodeErrorZ { - contents: CResult_TxRemoveInputDecodeErrorZPtr { +/// Creates a new CResult_PongDecodeErrorZ in the error state. +pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { + CResult_PongDecodeErrorZ { + contents: CResult_PongDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15099,13 +19879,13 @@ pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_is_ok(o: &CResult_TxRemoveInputDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxRemoveInputDecodeErrorZ. -pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_free(_res: CResult_TxRemoveInputDecodeErrorZ) { } -impl Drop for CResult_TxRemoveInputDecodeErrorZ { +/// Frees any resources used by the CResult_PongDecodeErrorZ. +pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } +impl Drop for CResult_PongDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15118,16 +19898,16 @@ impl Drop for CResult_TxRemoveInputDecodeErrorZ { } } } -impl From> for CResult_TxRemoveInputDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PongDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxRemoveInputDecodeErrorZPtr { result } + CResult_PongDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxRemoveInputDecodeErrorZPtr { err } + CResult_PongDecodeErrorZPtr { err } }; Self { contents, @@ -15135,59 +19915,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxRemoveInputDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxRemoveInputDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxRemoveInputDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxRemoveInputDecodeErrorZ_clone(orig: &CResult_TxRemoveInputDecodeErrorZ) -> CResult_TxRemoveInputDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxRemoveOutputDecodeErrorZ -pub union CResult_TxRemoveOutputDecodeErrorZPtr { +/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ +pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxRemoveOutput, + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxRemoveOutputDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxRemoveOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxRemoveOutputDecodeErrorZ { - /// The contents of this CResult_TxRemoveOutputDecodeErrorZ, accessible via either +pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxRemoveOutputDecodeErrorZPtr, - /// Whether this CResult_TxRemoveOutputDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxRemoveOutput) -> CResult_TxRemoveOutputDecodeErrorZ { - CResult_TxRemoveOutputDecodeErrorZ { - contents: CResult_TxRemoveOutputDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxRemoveOutputDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxRemoveOutputDecodeErrorZ { - CResult_TxRemoveOutputDecodeErrorZ { - contents: CResult_TxRemoveOutputDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { + CResult_UnsignedChannelAnnouncementDecodeErrorZ { + contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15195,13 +19975,13 @@ pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_is_ok(o: &CResult_TxRemoveOutputDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxRemoveOutputDecodeErrorZ. -pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_free(_res: CResult_TxRemoveOutputDecodeErrorZ) { } -impl Drop for CResult_TxRemoveOutputDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15214,16 +19994,16 @@ impl Drop for CResult_TxRemoveOutputDecodeErrorZ { } } } -impl From> for CResult_TxRemoveOutputDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxRemoveOutputDecodeErrorZPtr { result } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxRemoveOutputDecodeErrorZPtr { err } + CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -15231,59 +20011,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxRemoveOutputDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxRemoveOutputDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxRemoveOutputDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxRemoveOutputDecodeErrorZ_clone(orig: &CResult_TxRemoveOutputDecodeErrorZ) -> CResult_TxRemoveOutputDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxCompleteDecodeErrorZ -pub union CResult_TxCompleteDecodeErrorZPtr { +/// The contents of CResult_ChannelAnnouncementDecodeErrorZ +pub union CResult_ChannelAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxComplete, + pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxCompleteDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxComplete on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxCompleteDecodeErrorZ { - /// The contents of this CResult_TxCompleteDecodeErrorZ, accessible via either +pub struct CResult_ChannelAnnouncementDecodeErrorZ { + /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxCompleteDecodeErrorZPtr, - /// Whether this CResult_TxCompleteDecodeErrorZ represents a success state. + pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, + /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxCompleteDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxCompleteDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxComplete) -> CResult_TxCompleteDecodeErrorZ { - CResult_TxCompleteDecodeErrorZ { - contents: CResult_TxCompleteDecodeErrorZPtr { +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxCompleteDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxCompleteDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCompleteDecodeErrorZ { - CResult_TxCompleteDecodeErrorZ { - contents: CResult_TxCompleteDecodeErrorZPtr { +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { + CResult_ChannelAnnouncementDecodeErrorZ { + contents: CResult_ChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15291,13 +20071,13 @@ pub extern "C" fn CResult_TxCompleteDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxCompleteDecodeErrorZ_is_ok(o: &CResult_TxCompleteDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxCompleteDecodeErrorZ. -pub extern "C" fn CResult_TxCompleteDecodeErrorZ_free(_res: CResult_TxCompleteDecodeErrorZ) { } -impl Drop for CResult_TxCompleteDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } +impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15310,16 +20090,16 @@ impl Drop for CResult_TxCompleteDecodeErrorZ { } } } -impl From> for CResult_TxCompleteDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxCompleteDecodeErrorZPtr { result } + CResult_ChannelAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxCompleteDecodeErrorZPtr { err } + CResult_ChannelAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -15327,59 +20107,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxCompleteDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxCompleteDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxCompleteDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxCompleteDecodeErrorZ_clone(orig: &CResult_TxCompleteDecodeErrorZ) -> CResult_TxCompleteDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxSignaturesDecodeErrorZ -pub union CResult_TxSignaturesDecodeErrorZPtr { +/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ +pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxSignatures, + pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxSignaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxSignaturesDecodeErrorZ { - /// The contents of this CResult_TxSignaturesDecodeErrorZ, accessible via either +pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { + /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxSignaturesDecodeErrorZPtr, - /// Whether this CResult_TxSignaturesDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxSignaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxSignatures) -> CResult_TxSignaturesDecodeErrorZ { - CResult_TxSignaturesDecodeErrorZ { - contents: CResult_TxSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxSignaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxSignaturesDecodeErrorZ { - CResult_TxSignaturesDecodeErrorZ { - contents: CResult_TxSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { + CResult_UnsignedChannelUpdateDecodeErrorZ { + contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15387,13 +20167,13 @@ pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_is_ok(o: &CResult_TxSignaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxSignaturesDecodeErrorZ. -pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_free(_res: CResult_TxSignaturesDecodeErrorZ) { } -impl Drop for CResult_TxSignaturesDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15406,16 +20186,16 @@ impl Drop for CResult_TxSignaturesDecodeErrorZ { } } } -impl From> for CResult_TxSignaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxSignaturesDecodeErrorZPtr { result } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxSignaturesDecodeErrorZPtr { err } + CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -15423,59 +20203,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxSignaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxSignaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxSignaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxSignaturesDecodeErrorZ_clone(orig: &CResult_TxSignaturesDecodeErrorZ) -> CResult_TxSignaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxInitRbfDecodeErrorZ -pub union CResult_TxInitRbfDecodeErrorZPtr { +/// The contents of CResult_ChannelUpdateDecodeErrorZ +pub union CResult_ChannelUpdateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxInitRbf, + pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxInitRbfDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxInitRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxInitRbfDecodeErrorZ { - /// The contents of this CResult_TxInitRbfDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxInitRbfDecodeErrorZPtr, - /// Whether this CResult_TxInitRbfDecodeErrorZ represents a success state. +pub struct CResult_ChannelUpdateDecodeErrorZ { + /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_ChannelUpdateDecodeErrorZPtr, + /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxInitRbfDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxInitRbf) -> CResult_TxInitRbfDecodeErrorZ { - CResult_TxInitRbfDecodeErrorZ { - contents: CResult_TxInitRbfDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxInitRbfDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxInitRbfDecodeErrorZ { - CResult_TxInitRbfDecodeErrorZ { - contents: CResult_TxInitRbfDecodeErrorZPtr { +/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { + CResult_ChannelUpdateDecodeErrorZ { + contents: CResult_ChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15483,13 +20263,13 @@ pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_is_ok(o: &CResult_TxInitRbfDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxInitRbfDecodeErrorZ. -pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_free(_res: CResult_TxInitRbfDecodeErrorZ) { } -impl Drop for CResult_TxInitRbfDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } +impl Drop for CResult_ChannelUpdateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15502,16 +20282,16 @@ impl Drop for CResult_TxInitRbfDecodeErrorZ { } } } -impl From> for CResult_TxInitRbfDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelUpdateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxInitRbfDecodeErrorZPtr { result } + CResult_ChannelUpdateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxInitRbfDecodeErrorZPtr { err } + CResult_ChannelUpdateDecodeErrorZPtr { err } }; Self { contents, @@ -15519,59 +20299,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxInitRbfDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxInitRbfDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxInitRbfDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxInitRbfDecodeErrorZ_clone(orig: &CResult_TxInitRbfDecodeErrorZ) -> CResult_TxInitRbfDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxAckRbfDecodeErrorZ -pub union CResult_TxAckRbfDecodeErrorZPtr { +/// The contents of CResult_ErrorMessageDecodeErrorZ +pub union CResult_ErrorMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxAckRbf, + pub result: *mut crate::lightning::ln::msgs::ErrorMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxAckRbfDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxAckRbf on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxAckRbfDecodeErrorZ { - /// The contents of this CResult_TxAckRbfDecodeErrorZ, accessible via either +pub struct CResult_ErrorMessageDecodeErrorZ { + /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxAckRbfDecodeErrorZPtr, - /// Whether this CResult_TxAckRbfDecodeErrorZ represents a success state. + pub contents: CResult_ErrorMessageDecodeErrorZPtr, + /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxAckRbfDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAckRbf) -> CResult_TxAckRbfDecodeErrorZ { - CResult_TxAckRbfDecodeErrorZ { - contents: CResult_TxAckRbfDecodeErrorZPtr { +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxAckRbfDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAckRbfDecodeErrorZ { - CResult_TxAckRbfDecodeErrorZ { - contents: CResult_TxAckRbfDecodeErrorZPtr { +/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { + CResult_ErrorMessageDecodeErrorZ { + contents: CResult_ErrorMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15579,13 +20359,13 @@ pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_is_ok(o: &CResult_TxAckRbfDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxAckRbfDecodeErrorZ. -pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_free(_res: CResult_TxAckRbfDecodeErrorZ) { } -impl Drop for CResult_TxAckRbfDecodeErrorZ { +/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } +impl Drop for CResult_ErrorMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15598,16 +20378,16 @@ impl Drop for CResult_TxAckRbfDecodeErrorZ { } } } -impl From> for CResult_TxAckRbfDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ErrorMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxAckRbfDecodeErrorZPtr { result } + CResult_ErrorMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxAckRbfDecodeErrorZPtr { err } + CResult_ErrorMessageDecodeErrorZPtr { err } }; Self { contents, @@ -15615,59 +20395,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxAckRbfDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxAckRbfDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxAckRbfDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxAckRbfDecodeErrorZ_clone(orig: &CResult_TxAckRbfDecodeErrorZ) -> CResult_TxAckRbfDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxAbortDecodeErrorZ -pub union CResult_TxAbortDecodeErrorZPtr { +/// The contents of CResult_WarningMessageDecodeErrorZ +pub union CResult_WarningMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::TxAbort, + pub result: *mut crate::lightning::ln::msgs::WarningMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxAbortDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::TxAbort on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxAbortDecodeErrorZ { - /// The contents of this CResult_TxAbortDecodeErrorZ, accessible via either +pub struct CResult_WarningMessageDecodeErrorZ { + /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxAbortDecodeErrorZPtr, - /// Whether this CResult_TxAbortDecodeErrorZ represents a success state. + pub contents: CResult_WarningMessageDecodeErrorZPtr, + /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxAbortDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxAbortDecodeErrorZ_ok(o: crate::lightning::ln::msgs::TxAbort) -> CResult_TxAbortDecodeErrorZ { - CResult_TxAbortDecodeErrorZ { - contents: CResult_TxAbortDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxAbortDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxAbortDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxAbortDecodeErrorZ { - CResult_TxAbortDecodeErrorZ { - contents: CResult_TxAbortDecodeErrorZPtr { +/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { + CResult_WarningMessageDecodeErrorZ { + contents: CResult_WarningMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15675,13 +20455,13 @@ pub extern "C" fn CResult_TxAbortDecodeErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxAbortDecodeErrorZ_is_ok(o: &CResult_TxAbortDecodeErrorZ) -> bool { +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxAbortDecodeErrorZ. -pub extern "C" fn CResult_TxAbortDecodeErrorZ_free(_res: CResult_TxAbortDecodeErrorZ) { } -impl Drop for CResult_TxAbortDecodeErrorZ { +/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } +impl Drop for CResult_WarningMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15694,16 +20474,16 @@ impl Drop for CResult_TxAbortDecodeErrorZ { } } } -impl From> for CResult_TxAbortDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_WarningMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxAbortDecodeErrorZPtr { result } + CResult_WarningMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxAbortDecodeErrorZPtr { err } + CResult_WarningMessageDecodeErrorZPtr { err } }; Self { contents, @@ -15711,59 +20491,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxAbortDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxAbortDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxAbortDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxAbortDecodeErrorZ_clone(orig: &CResult_TxAbortDecodeErrorZ) -> CResult_TxAbortDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_AnnouncementSignaturesDecodeErrorZ -pub union CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ +pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::AnnouncementSignatures, + pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_AnnouncementSignaturesDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::AnnouncementSignatures on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_AnnouncementSignaturesDecodeErrorZ { - /// The contents of this CResult_AnnouncementSignaturesDecodeErrorZ, accessible via either +pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_AnnouncementSignaturesDecodeErrorZPtr, - /// Whether this CResult_AnnouncementSignaturesDecodeErrorZ represents a success state. + pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the success state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_ok(o: crate::lightning::ln::msgs::AnnouncementSignatures) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ in the error state. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AnnouncementSignaturesDecodeErrorZ { - CResult_AnnouncementSignaturesDecodeErrorZ { - contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { + CResult_UnsignedNodeAnnouncementDecodeErrorZ { + contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15771,13 +20551,13 @@ pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o: &CResult_AnnouncementSignaturesDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_AnnouncementSignaturesDecodeErrorZ. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_free(_res: CResult_AnnouncementSignaturesDecodeErrorZ) { } -impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { +/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15790,16 +20570,16 @@ impl Drop for CResult_AnnouncementSignaturesDecodeErrorZ { } } } -impl From> for CResult_AnnouncementSignaturesDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_AnnouncementSignaturesDecodeErrorZPtr { result } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_AnnouncementSignaturesDecodeErrorZPtr { err } + CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -15807,59 +20587,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_AnnouncementSignaturesDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_AnnouncementSignaturesDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig: &CResult_AnnouncementSignaturesDecodeErrorZ) -> CResult_AnnouncementSignaturesDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReestablishDecodeErrorZ -pub union CResult_ChannelReestablishDecodeErrorZPtr { +/// The contents of CResult_NodeAnnouncementDecodeErrorZ +pub union CResult_NodeAnnouncementDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReestablish, + pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelReestablishDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReestablish on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReestablishDecodeErrorZ { - /// The contents of this CResult_ChannelReestablishDecodeErrorZ, accessible via either +pub struct CResult_NodeAnnouncementDecodeErrorZ { + /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReestablishDecodeErrorZPtr, - /// Whether this CResult_ChannelReestablishDecodeErrorZ represents a success state. + pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, + /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReestablish) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReestablishDecodeErrorZ { - CResult_ChannelReestablishDecodeErrorZ { - contents: CResult_ChannelReestablishDecodeErrorZPtr { +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { + CResult_NodeAnnouncementDecodeErrorZ { + contents: CResult_NodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15867,13 +20647,13 @@ pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_is_ok(o: &CResult_ChannelReestablishDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReestablishDecodeErrorZ. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_free(_res: CResult_ChannelReestablishDecodeErrorZ) { } -impl Drop for CResult_ChannelReestablishDecodeErrorZ { +/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } +impl Drop for CResult_NodeAnnouncementDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15886,16 +20666,16 @@ impl Drop for CResult_ChannelReestablishDecodeErrorZ { } } } -impl From> for CResult_ChannelReestablishDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NodeAnnouncementDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReestablishDecodeErrorZPtr { result } + CResult_NodeAnnouncementDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReestablishDecodeErrorZPtr { err } + CResult_NodeAnnouncementDecodeErrorZPtr { err } }; Self { contents, @@ -15903,59 +20683,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReestablishDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReestablishDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReestablishDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReestablishDecodeErrorZ_clone(orig: &CResult_ChannelReestablishDecodeErrorZ) -> CResult_ChannelReestablishDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedDecodeErrorZ -pub union CResult_ClosingSignedDecodeErrorZPtr { +/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ +pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSigned, + pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedDecodeErrorZ { - /// The contents of this CResult_ClosingSignedDecodeErrorZ, accessible via either +pub struct CResult_QueryShortChannelIdsDecodeErrorZ { + /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedDecodeErrorZ represents a success state. + pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, + /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSigned) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedDecodeErrorZ { - CResult_ClosingSignedDecodeErrorZ { - contents: CResult_ClosingSignedDecodeErrorZPtr { +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { + CResult_QueryShortChannelIdsDecodeErrorZ { + contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -15963,13 +20743,13 @@ pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_is_ok(o: &CResult_ClosingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_free(_res: CResult_ClosingSignedDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } +impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -15982,16 +20762,16 @@ impl Drop for CResult_ClosingSignedDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedDecodeErrorZPtr { result } + CResult_QueryShortChannelIdsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedDecodeErrorZPtr { err } + CResult_QueryShortChannelIdsDecodeErrorZPtr { err } }; Self { contents, @@ -15999,59 +20779,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedDecodeErrorZ_clone(orig: &CResult_ClosingSignedDecodeErrorZ) -> CResult_ClosingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClosingSignedFeeRangeDecodeErrorZ -pub union CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ +pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ClosingSignedFeeRange, + pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ClosingSignedFeeRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ClosingSignedFeeRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClosingSignedFeeRangeDecodeErrorZ { - /// The contents of this CResult_ClosingSignedFeeRangeDecodeErrorZ, accessible via either +pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { + /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr, - /// Whether this CResult_ClosingSignedFeeRangeDecodeErrorZ represents a success state. + pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, + /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { - CResult_ClosingSignedFeeRangeDecodeErrorZ { - contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { + CResult_ReplyShortChannelIdsEndDecodeErrorZ { + contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16059,13 +20839,13 @@ pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClosingSignedFeeRangeDecodeErrorZ. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res: CResult_ClosingSignedFeeRangeDecodeErrorZ) { } -impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { +/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } +impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16078,16 +20858,16 @@ impl Drop for CResult_ClosingSignedFeeRangeDecodeErrorZ { } } } -impl From> for CResult_ClosingSignedFeeRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err } + CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } }; Self { contents, @@ -16095,59 +20875,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClosingSignedFeeRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClosingSignedFeeRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig: &CResult_ClosingSignedFeeRangeDecodeErrorZ) -> CResult_ClosingSignedFeeRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CommitmentSignedDecodeErrorZ -pub union CResult_CommitmentSignedDecodeErrorZPtr { +/// The contents of CResult_QueryChannelRangeDecodeErrorZ +pub union CResult_QueryChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::CommitmentSigned, + pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CommitmentSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::CommitmentSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentSignedDecodeErrorZ { - /// The contents of this CResult_CommitmentSignedDecodeErrorZ, accessible via either +pub struct CResult_QueryChannelRangeDecodeErrorZ { + /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentSignedDecodeErrorZPtr, - /// Whether this CResult_CommitmentSignedDecodeErrorZ represents a success state. + pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, + /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::CommitmentSigned) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentSignedDecodeErrorZ { - CResult_CommitmentSignedDecodeErrorZ { - contents: CResult_CommitmentSignedDecodeErrorZPtr { +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { + CResult_QueryChannelRangeDecodeErrorZ { + contents: CResult_QueryChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16155,13 +20935,13 @@ pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_err(e: crate::lightning:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_is_ok(o: &CResult_CommitmentSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentSignedDecodeErrorZ. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_free(_res: CResult_CommitmentSignedDecodeErrorZ) { } -impl Drop for CResult_CommitmentSignedDecodeErrorZ { +/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } +impl Drop for CResult_QueryChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16174,16 +20954,16 @@ impl Drop for CResult_CommitmentSignedDecodeErrorZ { } } } -impl From> for CResult_CommitmentSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_QueryChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentSignedDecodeErrorZPtr { result } + CResult_QueryChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentSignedDecodeErrorZPtr { err } + CResult_QueryChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -16191,59 +20971,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentSignedDecodeErrorZ_clone(orig: &CResult_CommitmentSignedDecodeErrorZ) -> CResult_CommitmentSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingCreatedDecodeErrorZ -pub union CResult_FundingCreatedDecodeErrorZPtr { +/// The contents of CResult_ReplyChannelRangeDecodeErrorZ +pub union CResult_ReplyChannelRangeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingCreated, + pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingCreatedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingCreated on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingCreatedDecodeErrorZ { - /// The contents of this CResult_FundingCreatedDecodeErrorZ, accessible via either +pub struct CResult_ReplyChannelRangeDecodeErrorZ { + /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingCreatedDecodeErrorZPtr, - /// Whether this CResult_FundingCreatedDecodeErrorZ represents a success state. + pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, + /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingCreated) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingCreatedDecodeErrorZ { - CResult_FundingCreatedDecodeErrorZ { - contents: CResult_FundingCreatedDecodeErrorZPtr { +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { + CResult_ReplyChannelRangeDecodeErrorZ { + contents: CResult_ReplyChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16251,13 +21031,13 @@ pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_is_ok(o: &CResult_FundingCreatedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingCreatedDecodeErrorZ. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_free(_res: CResult_FundingCreatedDecodeErrorZ) { } -impl Drop for CResult_FundingCreatedDecodeErrorZ { +/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } +impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16270,16 +21050,16 @@ impl Drop for CResult_FundingCreatedDecodeErrorZ { } } } -impl From> for CResult_FundingCreatedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReplyChannelRangeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingCreatedDecodeErrorZPtr { result } + CResult_ReplyChannelRangeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingCreatedDecodeErrorZPtr { err } + CResult_ReplyChannelRangeDecodeErrorZPtr { err } }; Self { contents, @@ -16287,59 +21067,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingCreatedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingCreatedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingCreatedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingCreatedDecodeErrorZ_clone(orig: &CResult_FundingCreatedDecodeErrorZ) -> CResult_FundingCreatedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FundingSignedDecodeErrorZ -pub union CResult_FundingSignedDecodeErrorZPtr { +/// The contents of CResult_GossipTimestampFilterDecodeErrorZ +pub union CResult_GossipTimestampFilterDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FundingSigned, + pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FundingSignedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FundingSigned on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FundingSignedDecodeErrorZ { - /// The contents of this CResult_FundingSignedDecodeErrorZ, accessible via either +pub struct CResult_GossipTimestampFilterDecodeErrorZ { + /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FundingSignedDecodeErrorZPtr, - /// Whether this CResult_FundingSignedDecodeErrorZ represents a success state. + pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, + /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the success state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FundingSigned) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ in the error state. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingSignedDecodeErrorZ { - CResult_FundingSignedDecodeErrorZ { - contents: CResult_FundingSignedDecodeErrorZPtr { +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { + CResult_GossipTimestampFilterDecodeErrorZ { + contents: CResult_GossipTimestampFilterDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16347,13 +21127,13 @@ pub extern "C" fn CResult_FundingSignedDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_is_ok(o: &CResult_FundingSignedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FundingSignedDecodeErrorZ. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_free(_res: CResult_FundingSignedDecodeErrorZ) { } -impl Drop for CResult_FundingSignedDecodeErrorZ { +/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } +impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16366,16 +21146,16 @@ impl Drop for CResult_FundingSignedDecodeErrorZ { } } } -impl From> for CResult_FundingSignedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_GossipTimestampFilterDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FundingSignedDecodeErrorZPtr { result } + CResult_GossipTimestampFilterDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FundingSignedDecodeErrorZPtr { err } + CResult_GossipTimestampFilterDecodeErrorZPtr { err } }; Self { contents, @@ -16383,59 +21163,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FundingSignedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FundingSignedDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FundingSignedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FundingSignedDecodeErrorZ_clone(orig: &CResult_FundingSignedDecodeErrorZ) -> CResult_FundingSignedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelReadyDecodeErrorZ -pub union CResult_ChannelReadyDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channel_state::InboundHTLCStateDetails or not +pub enum COption_InboundHTLCStateDetailsZ { + /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::InboundHTLCStateDetails + Some(crate::lightning::ln::channel_state::InboundHTLCStateDetails), + /// When we're in this state, this COption_InboundHTLCStateDetailsZ contains nothing + None +} +impl COption_InboundHTLCStateDetailsZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channel_state::InboundHTLCStateDetails { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_InboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::InboundHTLCStateDetails +pub extern "C" fn COption_InboundHTLCStateDetailsZ_some(o: crate::lightning::ln::channel_state::InboundHTLCStateDetails) -> COption_InboundHTLCStateDetailsZ { + COption_InboundHTLCStateDetailsZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_InboundHTLCStateDetailsZ containing nothing +pub extern "C" fn COption_InboundHTLCStateDetailsZ_none() -> COption_InboundHTLCStateDetailsZ { + COption_InboundHTLCStateDetailsZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channel_state::InboundHTLCStateDetails, if we are in the Some state +pub extern "C" fn COption_InboundHTLCStateDetailsZ_free(_res: COption_InboundHTLCStateDetailsZ) { } +#[no_mangle] +/// Creates a new COption_InboundHTLCStateDetailsZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_InboundHTLCStateDetailsZ_clone(orig: &COption_InboundHTLCStateDetailsZ) -> COption_InboundHTLCStateDetailsZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ +pub union CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelReady, + pub result: *mut crate::c_types::derived::COption_InboundHTLCStateDetailsZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelReadyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelReady on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_InboundHTLCStateDetailsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelReadyDecodeErrorZ { - /// The contents of this CResult_ChannelReadyDecodeErrorZ, accessible via either +pub struct CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + /// The contents of this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelReadyDecodeErrorZPtr, - /// Whether this CResult_ChannelReadyDecodeErrorZ represents a success state. + pub contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr, + /// Whether this CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelReady) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_InboundHTLCStateDetailsZ) -> CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelReadyDecodeErrorZ { - CResult_ChannelReadyDecodeErrorZ { - contents: CResult_ChannelReadyDecodeErrorZPtr { +/// Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16443,13 +21260,13 @@ pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_is_ok(o: &CResult_ChannelReadyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_is_ok(o: &CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelReadyDecodeErrorZ. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_free(_res: CResult_ChannelReadyDecodeErrorZ) { } -impl Drop for CResult_ChannelReadyDecodeErrorZ { +/// Frees any resources used by the CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ. +pub extern "C" fn CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_free(_res: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ) { } +impl Drop for CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16462,16 +21279,16 @@ impl Drop for CResult_ChannelReadyDecodeErrorZ { } } } -impl From> for CResult_ChannelReadyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelReadyDecodeErrorZPtr { result } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelReadyDecodeErrorZPtr { err } + CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { err } }; Self { contents, @@ -16479,59 +21296,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelReadyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelReadyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_InboundHTLCStateDetailsZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelReadyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelReadyDecodeErrorZ_clone(orig: &CResult_ChannelReadyDecodeErrorZ) -> CResult_ChannelReadyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ_clone(orig: &CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ) -> CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InitDecodeErrorZ -pub union CResult_InitDecodeErrorZPtr { +/// The contents of CResult_InboundHTLCDetailsDecodeErrorZ +pub union CResult_InboundHTLCDetailsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Init, + pub result: *mut crate::lightning::ln::channel_state::InboundHTLCDetails, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InitDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Init on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_InboundHTLCDetailsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::InboundHTLCDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InitDecodeErrorZ { - /// The contents of this CResult_InitDecodeErrorZ, accessible via either +pub struct CResult_InboundHTLCDetailsDecodeErrorZ { + /// The contents of this CResult_InboundHTLCDetailsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InitDecodeErrorZPtr, - /// Whether this CResult_InitDecodeErrorZ represents a success state. + pub contents: CResult_InboundHTLCDetailsDecodeErrorZPtr, + /// Whether this CResult_InboundHTLCDetailsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the success state. -pub extern "C" fn CResult_InitDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Init) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_InboundHTLCDetailsDecodeErrorZ in the success state. +pub extern "C" fn CResult_InboundHTLCDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::InboundHTLCDetails) -> CResult_InboundHTLCDetailsDecodeErrorZ { + CResult_InboundHTLCDetailsDecodeErrorZ { + contents: CResult_InboundHTLCDetailsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ in the error state. -pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InitDecodeErrorZ { - CResult_InitDecodeErrorZ { - contents: CResult_InitDecodeErrorZPtr { +/// Creates a new CResult_InboundHTLCDetailsDecodeErrorZ in the error state. +pub extern "C" fn CResult_InboundHTLCDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InboundHTLCDetailsDecodeErrorZ { + CResult_InboundHTLCDetailsDecodeErrorZ { + contents: CResult_InboundHTLCDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16539,13 +21356,13 @@ pub extern "C" fn CResult_InitDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InitDecodeErrorZ_is_ok(o: &CResult_InitDecodeErrorZ) -> bool { +pub extern "C" fn CResult_InboundHTLCDetailsDecodeErrorZ_is_ok(o: &CResult_InboundHTLCDetailsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InitDecodeErrorZ. -pub extern "C" fn CResult_InitDecodeErrorZ_free(_res: CResult_InitDecodeErrorZ) { } -impl Drop for CResult_InitDecodeErrorZ { +/// Frees any resources used by the CResult_InboundHTLCDetailsDecodeErrorZ. +pub extern "C" fn CResult_InboundHTLCDetailsDecodeErrorZ_free(_res: CResult_InboundHTLCDetailsDecodeErrorZ) { } +impl Drop for CResult_InboundHTLCDetailsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16558,16 +21375,16 @@ impl Drop for CResult_InitDecodeErrorZ { } } } -impl From> for CResult_InitDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InboundHTLCDetailsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InitDecodeErrorZPtr { result } + CResult_InboundHTLCDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InitDecodeErrorZPtr { err } + CResult_InboundHTLCDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -16575,59 +21392,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InitDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InboundHTLCDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InitDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InboundHTLCDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InitDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_InboundHTLCDetailsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InitDecodeErrorZ_clone(orig: &CResult_InitDecodeErrorZ) -> CResult_InitDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InboundHTLCDetailsDecodeErrorZ_clone(orig: &CResult_InboundHTLCDetailsDecodeErrorZ) -> CResult_InboundHTLCDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OpenChannelDecodeErrorZ -pub union CResult_OpenChannelDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channel_state::OutboundHTLCStateDetails or not +pub enum COption_OutboundHTLCStateDetailsZ { + /// When we're in this state, this COption_OutboundHTLCStateDetailsZ contains a crate::lightning::ln::channel_state::OutboundHTLCStateDetails + Some(crate::lightning::ln::channel_state::OutboundHTLCStateDetails), + /// When we're in this state, this COption_OutboundHTLCStateDetailsZ contains nothing + None +} +impl COption_OutboundHTLCStateDetailsZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channel_state::OutboundHTLCStateDetails { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_OutboundHTLCStateDetailsZ containing a crate::lightning::ln::channel_state::OutboundHTLCStateDetails +pub extern "C" fn COption_OutboundHTLCStateDetailsZ_some(o: crate::lightning::ln::channel_state::OutboundHTLCStateDetails) -> COption_OutboundHTLCStateDetailsZ { + COption_OutboundHTLCStateDetailsZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_OutboundHTLCStateDetailsZ containing nothing +pub extern "C" fn COption_OutboundHTLCStateDetailsZ_none() -> COption_OutboundHTLCStateDetailsZ { + COption_OutboundHTLCStateDetailsZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channel_state::OutboundHTLCStateDetails, if we are in the Some state +pub extern "C" fn COption_OutboundHTLCStateDetailsZ_free(_res: COption_OutboundHTLCStateDetailsZ) { } +#[no_mangle] +/// Creates a new COption_OutboundHTLCStateDetailsZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_OutboundHTLCStateDetailsZ_clone(orig: &COption_OutboundHTLCStateDetailsZ) -> COption_OutboundHTLCStateDetailsZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ +pub union CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OpenChannel, + pub result: *mut crate::c_types::derived::COption_OutboundHTLCStateDetailsZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OpenChannelDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OpenChannel on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_OutboundHTLCStateDetailsZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OpenChannelDecodeErrorZ { - /// The contents of this CResult_OpenChannelDecodeErrorZ, accessible via either +pub struct CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + /// The contents of this CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OpenChannelDecodeErrorZPtr, - /// Whether this CResult_OpenChannelDecodeErrorZ represents a success state. + pub contents: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr, + /// Whether this CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the success state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannel) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_ok(o: crate::c_types::derived::COption_OutboundHTLCStateDetailsZ) -> CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + contents: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ in the error state. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelDecodeErrorZ { - CResult_OpenChannelDecodeErrorZ { - contents: CResult_OpenChannelDecodeErrorZPtr { +/// Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + contents: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16635,13 +21489,13 @@ pub extern "C" fn CResult_OpenChannelDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_is_ok(o: &CResult_OpenChannelDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_is_ok(o: &CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OpenChannelDecodeErrorZ. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_free(_res: CResult_OpenChannelDecodeErrorZ) { } -impl Drop for CResult_OpenChannelDecodeErrorZ { +/// Frees any resources used by the CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ. +pub extern "C" fn CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_free(_res: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ) { } +impl Drop for CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16654,16 +21508,16 @@ impl Drop for CResult_OpenChannelDecodeErrorZ { } } } -impl From> for CResult_OpenChannelDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OpenChannelDecodeErrorZPtr { result } + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OpenChannelDecodeErrorZPtr { err } + CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { err } }; Self { contents, @@ -16671,59 +21525,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OpenChannelDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OpenChannelDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OpenChannelDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OpenChannelDecodeErrorZ_clone(orig: &CResult_OpenChannelDecodeErrorZ) -> CResult_OpenChannelDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ_clone(orig: &CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ) -> CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OpenChannelV2DecodeErrorZ -pub union CResult_OpenChannelV2DecodeErrorZPtr { +/// The contents of CResult_OutboundHTLCDetailsDecodeErrorZ +pub union CResult_OutboundHTLCDetailsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OpenChannelV2, + pub result: *mut crate::lightning::ln::channel_state::OutboundHTLCDetails, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OpenChannelV2DecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OpenChannelV2 on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OutboundHTLCDetailsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::OutboundHTLCDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OpenChannelV2DecodeErrorZ { - /// The contents of this CResult_OpenChannelV2DecodeErrorZ, accessible via either +pub struct CResult_OutboundHTLCDetailsDecodeErrorZ { + /// The contents of this CResult_OutboundHTLCDetailsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OpenChannelV2DecodeErrorZPtr, - /// Whether this CResult_OpenChannelV2DecodeErrorZ represents a success state. + pub contents: CResult_OutboundHTLCDetailsDecodeErrorZPtr, + /// Whether this CResult_OutboundHTLCDetailsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the success state. -pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_ok(o: crate::lightning::ln::msgs::OpenChannelV2) -> CResult_OpenChannelV2DecodeErrorZ { - CResult_OpenChannelV2DecodeErrorZ { - contents: CResult_OpenChannelV2DecodeErrorZPtr { +/// Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutboundHTLCDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::OutboundHTLCDetails) -> CResult_OutboundHTLCDetailsDecodeErrorZ { + CResult_OutboundHTLCDetailsDecodeErrorZ { + contents: CResult_OutboundHTLCDetailsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OpenChannelV2DecodeErrorZ in the error state. -pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OpenChannelV2DecodeErrorZ { - CResult_OpenChannelV2DecodeErrorZ { - contents: CResult_OpenChannelV2DecodeErrorZPtr { +/// Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutboundHTLCDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutboundHTLCDetailsDecodeErrorZ { + CResult_OutboundHTLCDetailsDecodeErrorZ { + contents: CResult_OutboundHTLCDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16731,13 +21585,13 @@ pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_is_ok(o: &CResult_OpenChannelV2DecodeErrorZ) -> bool { +pub extern "C" fn CResult_OutboundHTLCDetailsDecodeErrorZ_is_ok(o: &CResult_OutboundHTLCDetailsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OpenChannelV2DecodeErrorZ. -pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_free(_res: CResult_OpenChannelV2DecodeErrorZ) { } -impl Drop for CResult_OpenChannelV2DecodeErrorZ { +/// Frees any resources used by the CResult_OutboundHTLCDetailsDecodeErrorZ. +pub extern "C" fn CResult_OutboundHTLCDetailsDecodeErrorZ_free(_res: CResult_OutboundHTLCDetailsDecodeErrorZ) { } +impl Drop for CResult_OutboundHTLCDetailsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16750,16 +21604,16 @@ impl Drop for CResult_OpenChannelV2DecodeErrorZ { } } } -impl From> for CResult_OpenChannelV2DecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutboundHTLCDetailsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OpenChannelV2DecodeErrorZPtr { result } + CResult_OutboundHTLCDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OpenChannelV2DecodeErrorZPtr { err } + CResult_OutboundHTLCDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -16767,59 +21621,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OpenChannelV2DecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OutboundHTLCDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OpenChannelV2DecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OutboundHTLCDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OpenChannelV2DecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OutboundHTLCDetailsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OpenChannelV2DecodeErrorZ_clone(orig: &CResult_OpenChannelV2DecodeErrorZ) -> CResult_OpenChannelV2DecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OutboundHTLCDetailsDecodeErrorZ_clone(orig: &CResult_OutboundHTLCDetailsDecodeErrorZ) -> CResult_OutboundHTLCDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevokeAndACKDecodeErrorZ -pub union CResult_RevokeAndACKDecodeErrorZPtr { +/// The contents of CResult_CounterpartyForwardingInfoDecodeErrorZ +pub union CResult_CounterpartyForwardingInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::RevokeAndACK, + pub result: *mut crate::lightning::ln::channel_state::CounterpartyForwardingInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RevokeAndACKDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::RevokeAndACK on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CounterpartyForwardingInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::CounterpartyForwardingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevokeAndACKDecodeErrorZ { - /// The contents of this CResult_RevokeAndACKDecodeErrorZ, accessible via either +pub struct CResult_CounterpartyForwardingInfoDecodeErrorZ { + /// The contents of this CResult_CounterpartyForwardingInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevokeAndACKDecodeErrorZPtr, - /// Whether this CResult_RevokeAndACKDecodeErrorZ represents a success state. + pub contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr, + /// Whether this CResult_CounterpartyForwardingInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_ok(o: crate::lightning::ln::msgs::RevokeAndACK) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::CounterpartyForwardingInfo) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevokeAndACKDecodeErrorZ { - CResult_RevokeAndACKDecodeErrorZ { - contents: CResult_RevokeAndACKDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { + CResult_CounterpartyForwardingInfoDecodeErrorZ { + contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16827,13 +21681,13 @@ pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_is_ok(o: &CResult_RevokeAndACKDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevokeAndACKDecodeErrorZ. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_free(_res: CResult_RevokeAndACKDecodeErrorZ) { } -impl Drop for CResult_RevokeAndACKDecodeErrorZ { +/// Frees any resources used by the CResult_CounterpartyForwardingInfoDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res: CResult_CounterpartyForwardingInfoDecodeErrorZ) { } +impl Drop for CResult_CounterpartyForwardingInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16846,16 +21700,16 @@ impl Drop for CResult_RevokeAndACKDecodeErrorZ { } } } -impl From> for CResult_RevokeAndACKDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyForwardingInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RevokeAndACKDecodeErrorZPtr { result } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevokeAndACKDecodeErrorZPtr { err } + CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err } }; Self { contents, @@ -16863,59 +21717,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevokeAndACKDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevokeAndACKDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CounterpartyForwardingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevokeAndACKDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyForwardingInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevokeAndACKDecodeErrorZ_clone(orig: &CResult_RevokeAndACKDecodeErrorZ) -> CResult_RevokeAndACKDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig: &CResult_CounterpartyForwardingInfoDecodeErrorZ) -> CResult_CounterpartyForwardingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownDecodeErrorZ -pub union CResult_ShutdownDecodeErrorZPtr { +/// The contents of CResult_ChannelCounterpartyDecodeErrorZ +pub union CResult_ChannelCounterpartyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Shutdown, + pub result: *mut crate::lightning::ln::channel_state::ChannelCounterparty, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ShutdownDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Shutdown on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelCounterpartyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::ChannelCounterparty on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownDecodeErrorZ { - /// The contents of this CResult_ShutdownDecodeErrorZ, accessible via either +pub struct CResult_ChannelCounterpartyDecodeErrorZ { + /// The contents of this CResult_ChannelCounterpartyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownDecodeErrorZPtr, - /// Whether this CResult_ShutdownDecodeErrorZ represents a success state. + pub contents: CResult_ChannelCounterpartyDecodeErrorZPtr, + /// Whether this CResult_ChannelCounterpartyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Shutdown) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::ChannelCounterparty) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownDecodeErrorZ { - CResult_ShutdownDecodeErrorZ { - contents: CResult_ShutdownDecodeErrorZPtr { +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelCounterpartyDecodeErrorZ { + CResult_ChannelCounterpartyDecodeErrorZ { + contents: CResult_ChannelCounterpartyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -16923,13 +21777,13 @@ pub extern "C" fn CResult_ShutdownDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownDecodeErrorZ_is_ok(o: &CResult_ShutdownDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o: &CResult_ChannelCounterpartyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownDecodeErrorZ. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_free(_res: CResult_ShutdownDecodeErrorZ) { } -impl Drop for CResult_ShutdownDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelCounterpartyDecodeErrorZ. +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_free(_res: CResult_ChannelCounterpartyDecodeErrorZ) { } +impl Drop for CResult_ChannelCounterpartyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -16942,16 +21796,16 @@ impl Drop for CResult_ShutdownDecodeErrorZ { } } } -impl From> for CResult_ShutdownDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelCounterpartyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownDecodeErrorZPtr { result } + CResult_ChannelCounterpartyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownDecodeErrorZPtr { err } + CResult_ChannelCounterpartyDecodeErrorZPtr { err } }; Self { contents, @@ -16959,59 +21813,188 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelCounterpartyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelCounterpartyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownDecodeErrorZ_clone(orig: &CResult_ShutdownDecodeErrorZ) -> CResult_ShutdownDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelCounterpartyDecodeErrorZ_clone(orig: &CResult_ChannelCounterpartyDecodeErrorZ) -> CResult_ChannelCounterpartyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailHTLCDecodeErrorZ -pub union CResult_UpdateFailHTLCDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::ln::channel_state::ChannelShutdownState or not +pub enum COption_ChannelShutdownStateZ { + /// When we're in this state, this COption_ChannelShutdownStateZ contains a crate::lightning::ln::channel_state::ChannelShutdownState + Some(crate::lightning::ln::channel_state::ChannelShutdownState), + /// When we're in this state, this COption_ChannelShutdownStateZ contains nothing + None +} +impl COption_ChannelShutdownStateZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::channel_state::ChannelShutdownState { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing a crate::lightning::ln::channel_state::ChannelShutdownState +pub extern "C" fn COption_ChannelShutdownStateZ_some(o: crate::lightning::ln::channel_state::ChannelShutdownState) -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_ChannelShutdownStateZ containing nothing +pub extern "C" fn COption_ChannelShutdownStateZ_none() -> COption_ChannelShutdownStateZ { + COption_ChannelShutdownStateZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::channel_state::ChannelShutdownState, if we are in the Some state +pub extern "C" fn COption_ChannelShutdownStateZ_free(_res: COption_ChannelShutdownStateZ) { } +#[no_mangle] +/// Creates a new COption_ChannelShutdownStateZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ChannelShutdownStateZ_clone(orig: &COption_ChannelShutdownStateZ) -> COption_ChannelShutdownStateZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::channel_state::InboundHTLCDetailss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_InboundHTLCDetailsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channel_state::InboundHTLCDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_InboundHTLCDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channel_state::InboundHTLCDetails] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_InboundHTLCDetailsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_InboundHTLCDetailsZ_free(_res: CVec_InboundHTLCDetailsZ) { } +impl Drop for CVec_InboundHTLCDetailsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_InboundHTLCDetailsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::ln::channel_state::OutboundHTLCDetailss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_OutboundHTLCDetailsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channel_state::OutboundHTLCDetails, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_OutboundHTLCDetailsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channel_state::OutboundHTLCDetails] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_OutboundHTLCDetailsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_OutboundHTLCDetailsZ_free(_res: CVec_OutboundHTLCDetailsZ) { } +impl Drop for CVec_OutboundHTLCDetailsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_OutboundHTLCDetailsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_ChannelDetailsDecodeErrorZ +pub union CResult_ChannelDetailsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailHTLC, + pub result: *mut crate::lightning::ln::channel_state::ChannelDetails, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFailHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelDetailsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::ChannelDetails on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailHTLCDecodeErrorZ, accessible via either +pub struct CResult_ChannelDetailsDecodeErrorZ { + /// The contents of this CResult_ChannelDetailsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailHTLCDecodeErrorZ represents a success state. + pub contents: CResult_ChannelDetailsDecodeErrorZPtr, + /// Whether this CResult_ChannelDetailsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailHTLC) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::ChannelDetails) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailHTLCDecodeErrorZ { - CResult_UpdateFailHTLCDecodeErrorZ { - contents: CResult_UpdateFailHTLCDecodeErrorZPtr { +/// Creates a new CResult_ChannelDetailsDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelDetailsDecodeErrorZ { + CResult_ChannelDetailsDecodeErrorZ { + contents: CResult_ChannelDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17019,13 +22002,13 @@ pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_is_ok(o: &CResult_ChannelDetailsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_free(_res: CResult_UpdateFailHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelDetailsDecodeErrorZ. +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_free(_res: CResult_ChannelDetailsDecodeErrorZ) { } +impl Drop for CResult_ChannelDetailsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17038,16 +22021,16 @@ impl Drop for CResult_UpdateFailHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelDetailsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailHTLCDecodeErrorZPtr { result } + CResult_ChannelDetailsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailHTLCDecodeErrorZPtr { err } + CResult_ChannelDetailsDecodeErrorZPtr { err } }; Self { contents, @@ -17055,59 +22038,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelDetailsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailHTLCDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelDetailsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelDetailsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailHTLCDecodeErrorZ) -> CResult_UpdateFailHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelDetailsDecodeErrorZ_clone(orig: &CResult_ChannelDetailsDecodeErrorZ) -> CResult_ChannelDetailsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFailMalformedHTLCDecodeErrorZ -pub union CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// The contents of CResult_ChannelShutdownStateDecodeErrorZ +pub union CResult_ChannelShutdownStateDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFailMalformedHTLC, + pub result: *mut crate::lightning::ln::channel_state::ChannelShutdownState, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFailMalformedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFailMalformedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelShutdownStateDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_state::ChannelShutdownState on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFailMalformedHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFailMalformedHTLCDecodeErrorZ, accessible via either +pub struct CResult_ChannelShutdownStateDecodeErrorZ { + /// The contents of this CResult_ChannelShutdownStateDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFailMalformedHTLCDecodeErrorZ represents a success state. + pub contents: CResult_ChannelShutdownStateDecodeErrorZPtr, + /// Whether this CResult_ChannelShutdownStateDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFailMalformedHTLC) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_ok(o: crate::lightning::ln::channel_state::ChannelShutdownState) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { - CResult_UpdateFailMalformedHTLCDecodeErrorZ { - contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelShutdownStateDecodeErrorZ { + CResult_ChannelShutdownStateDecodeErrorZ { + contents: CResult_ChannelShutdownStateDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17115,13 +22098,13 @@ pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o: &CResult_ChannelShutdownStateDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFailMalformedHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res: CResult_UpdateFailMalformedHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelShutdownStateDecodeErrorZ. +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_free(_res: CResult_ChannelShutdownStateDecodeErrorZ) { } +impl Drop for CResult_ChannelShutdownStateDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17134,16 +22117,16 @@ impl Drop for CResult_UpdateFailMalformedHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFailMalformedHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelShutdownStateDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result } + CResult_ChannelShutdownStateDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err } + CResult_ChannelShutdownStateDecodeErrorZPtr { err } }; Self { contents, @@ -17151,59 +22134,97 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelShutdownStateDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFailMalformedHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelShutdownStateDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFailMalformedHTLCDecodeErrorZ) -> CResult_UpdateFailMalformedHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelShutdownStateDecodeErrorZ_clone(orig: &CResult_ChannelShutdownStateDecodeErrorZ) -> CResult_ChannelShutdownStateDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFeeDecodeErrorZ -pub union CResult_UpdateFeeDecodeErrorZPtr { +/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_FutureZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::wakers::Future, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_FutureZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_FutureZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } +impl Drop for CVec_FutureZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +#[repr(C)] +/// The contents of CResult_HeldHtlcAvailableDecodeErrorZ +pub union CResult_HeldHtlcAvailableDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFee, + pub result: *mut crate::lightning::onion_message::async_payments::HeldHtlcAvailable, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFeeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFee on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HeldHtlcAvailableDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::HeldHtlcAvailable on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFeeDecodeErrorZ { - /// The contents of this CResult_UpdateFeeDecodeErrorZ, accessible via either +pub struct CResult_HeldHtlcAvailableDecodeErrorZ { + /// The contents of this CResult_HeldHtlcAvailableDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFeeDecodeErrorZPtr, - /// Whether this CResult_UpdateFeeDecodeErrorZ represents a success state. + pub contents: CResult_HeldHtlcAvailableDecodeErrorZPtr, + /// Whether this CResult_HeldHtlcAvailableDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFee) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the success state. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> CResult_HeldHtlcAvailableDecodeErrorZ { + CResult_HeldHtlcAvailableDecodeErrorZ { + contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFeeDecodeErrorZ { - CResult_UpdateFeeDecodeErrorZ { - contents: CResult_UpdateFeeDecodeErrorZPtr { +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ in the error state. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HeldHtlcAvailableDecodeErrorZ { + CResult_HeldHtlcAvailableDecodeErrorZ { + contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17211,13 +22232,13 @@ pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_err(e: crate::lightning::ln::msg } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_is_ok(o: &CResult_UpdateFeeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_is_ok(o: &CResult_HeldHtlcAvailableDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFeeDecodeErrorZ. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_free(_res: CResult_UpdateFeeDecodeErrorZ) { } -impl Drop for CResult_UpdateFeeDecodeErrorZ { +/// Frees any resources used by the CResult_HeldHtlcAvailableDecodeErrorZ. +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_free(_res: CResult_HeldHtlcAvailableDecodeErrorZ) { } +impl Drop for CResult_HeldHtlcAvailableDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17230,16 +22251,16 @@ impl Drop for CResult_UpdateFeeDecodeErrorZ { } } } -impl From> for CResult_UpdateFeeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HeldHtlcAvailableDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFeeDecodeErrorZPtr { result } + CResult_HeldHtlcAvailableDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFeeDecodeErrorZPtr { err } + CResult_HeldHtlcAvailableDecodeErrorZPtr { err } }; Self { contents, @@ -17247,59 +22268,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFeeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFeeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HeldHtlcAvailableDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFeeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HeldHtlcAvailableDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFeeDecodeErrorZ_clone(orig: &CResult_UpdateFeeDecodeErrorZ) -> CResult_UpdateFeeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HeldHtlcAvailableDecodeErrorZ_clone(orig: &CResult_HeldHtlcAvailableDecodeErrorZ) -> CResult_HeldHtlcAvailableDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateFulfillHTLCDecodeErrorZ -pub union CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// The contents of CResult_ReleaseHeldHtlcDecodeErrorZ +pub union CResult_ReleaseHeldHtlcDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateFulfillHTLC, + pub result: *mut crate::lightning::onion_message::async_payments::ReleaseHeldHtlc, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateFulfillHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateFulfillHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ReleaseHeldHtlcDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::ReleaseHeldHtlc on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateFulfillHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateFulfillHTLCDecodeErrorZ, accessible via either +pub struct CResult_ReleaseHeldHtlcDecodeErrorZ { + /// The contents of this CResult_ReleaseHeldHtlcDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateFulfillHTLCDecodeErrorZ represents a success state. + pub contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr, + /// Whether this CResult_ReleaseHeldHtlcDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateFulfillHTLC) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the success state. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> CResult_ReleaseHeldHtlcDecodeErrorZ { + CResult_ReleaseHeldHtlcDecodeErrorZ { + contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateFulfillHTLCDecodeErrorZ { - CResult_UpdateFulfillHTLCDecodeErrorZ { - contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { +/// Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ in the error state. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReleaseHeldHtlcDecodeErrorZ { + CResult_ReleaseHeldHtlcDecodeErrorZ { + contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17307,13 +22328,13 @@ pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_is_ok(o: &CResult_ReleaseHeldHtlcDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateFulfillHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res: CResult_UpdateFulfillHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_ReleaseHeldHtlcDecodeErrorZ. +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_free(_res: CResult_ReleaseHeldHtlcDecodeErrorZ) { } +impl Drop for CResult_ReleaseHeldHtlcDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17326,16 +22347,16 @@ impl Drop for CResult_UpdateFulfillHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateFulfillHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ReleaseHeldHtlcDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateFulfillHTLCDecodeErrorZPtr { result } + CResult_ReleaseHeldHtlcDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateFulfillHTLCDecodeErrorZPtr { err } + CResult_ReleaseHeldHtlcDecodeErrorZPtr { err } }; Self { contents, @@ -17343,59 +22364,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateFulfillHTLCDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ReleaseHeldHtlcDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateFulfillHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ReleaseHeldHtlcDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig: &CResult_UpdateFulfillHTLCDecodeErrorZ) -> CResult_UpdateFulfillHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ReleaseHeldHtlcDecodeErrorZ_clone(orig: &CResult_ReleaseHeldHtlcDecodeErrorZ) -> CResult_ReleaseHeldHtlcDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OnionPacketDecodeErrorZ -pub union CResult_OnionPacketDecodeErrorZPtr { +/// The contents of CResult_AsyncPaymentsMessageDecodeErrorZ +pub union CResult_AsyncPaymentsMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OnionPacket, + pub result: *mut crate::lightning::onion_message::async_payments::AsyncPaymentsMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OnionPacketDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OnionPacket on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_AsyncPaymentsMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::async_payments::AsyncPaymentsMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OnionPacketDecodeErrorZ { - /// The contents of this CResult_OnionPacketDecodeErrorZ, accessible via either +pub struct CResult_AsyncPaymentsMessageDecodeErrorZ { + /// The contents of this CResult_AsyncPaymentsMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OnionPacketDecodeErrorZPtr, - /// Whether this CResult_OnionPacketDecodeErrorZ represents a success state. + pub contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr, + /// Whether this CResult_AsyncPaymentsMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OnionPacketDecodeErrorZ in the success state. -pub extern "C" fn CResult_OnionPacketDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionPacket) -> CResult_OnionPacketDecodeErrorZ { - CResult_OnionPacketDecodeErrorZ { - contents: CResult_OnionPacketDecodeErrorZPtr { +/// Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::async_payments::AsyncPaymentsMessage) -> CResult_AsyncPaymentsMessageDecodeErrorZ { + CResult_AsyncPaymentsMessageDecodeErrorZ { + contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OnionPacketDecodeErrorZ in the error state. -pub extern "C" fn CResult_OnionPacketDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionPacketDecodeErrorZ { - CResult_OnionPacketDecodeErrorZ { - contents: CResult_OnionPacketDecodeErrorZPtr { +/// Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_AsyncPaymentsMessageDecodeErrorZ { + CResult_AsyncPaymentsMessageDecodeErrorZ { + contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17403,13 +22424,13 @@ pub extern "C" fn CResult_OnionPacketDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OnionPacketDecodeErrorZ_is_ok(o: &CResult_OnionPacketDecodeErrorZ) -> bool { +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_is_ok(o: &CResult_AsyncPaymentsMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OnionPacketDecodeErrorZ. -pub extern "C" fn CResult_OnionPacketDecodeErrorZ_free(_res: CResult_OnionPacketDecodeErrorZ) { } -impl Drop for CResult_OnionPacketDecodeErrorZ { +/// Frees any resources used by the CResult_AsyncPaymentsMessageDecodeErrorZ. +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_free(_res: CResult_AsyncPaymentsMessageDecodeErrorZ) { } +impl Drop for CResult_AsyncPaymentsMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17422,16 +22443,16 @@ impl Drop for CResult_OnionPacketDecodeErrorZ { } } } -impl From> for CResult_OnionPacketDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_AsyncPaymentsMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OnionPacketDecodeErrorZPtr { result } + CResult_AsyncPaymentsMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OnionPacketDecodeErrorZPtr { err } + CResult_AsyncPaymentsMessageDecodeErrorZPtr { err } }; Self { contents, @@ -17439,59 +22460,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OnionPacketDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OnionPacketDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_AsyncPaymentsMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OnionPacketDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_AsyncPaymentsMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OnionPacketDecodeErrorZ_clone(orig: &CResult_OnionPacketDecodeErrorZ) -> CResult_OnionPacketDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_AsyncPaymentsMessageDecodeErrorZ_clone(orig: &CResult_AsyncPaymentsMessageDecodeErrorZ) -> CResult_AsyncPaymentsMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UpdateAddHTLCDecodeErrorZ -pub union CResult_UpdateAddHTLCDecodeErrorZPtr { +/// The contents of CResult_OffersMessageDecodeErrorZ +pub union CResult_OffersMessageDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UpdateAddHTLC, + pub result: *mut crate::lightning::onion_message::offers::OffersMessage, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UpdateAddHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UpdateAddHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OffersMessageDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::offers::OffersMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UpdateAddHTLCDecodeErrorZ { - /// The contents of this CResult_UpdateAddHTLCDecodeErrorZ, accessible via either +pub struct CResult_OffersMessageDecodeErrorZ { + /// The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UpdateAddHTLCDecodeErrorZPtr, - /// Whether this CResult_UpdateAddHTLCDecodeErrorZ represents a success state. + pub contents: CResult_OffersMessageDecodeErrorZPtr, + /// Whether this CResult_OffersMessageDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UpdateAddHTLC) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the success state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::offers::OffersMessage) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UpdateAddHTLCDecodeErrorZ { - CResult_UpdateAddHTLCDecodeErrorZ { - contents: CResult_UpdateAddHTLCDecodeErrorZPtr { +/// Creates a new CResult_OffersMessageDecodeErrorZ in the error state. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersMessageDecodeErrorZ { + CResult_OffersMessageDecodeErrorZ { + contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17499,13 +22520,13 @@ pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o: &CResult_UpdateAddHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UpdateAddHTLCDecodeErrorZ. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_free(_res: CResult_UpdateAddHTLCDecodeErrorZ) { } -impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_OffersMessageDecodeErrorZ. +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_free(_res: CResult_OffersMessageDecodeErrorZ) { } +impl Drop for CResult_OffersMessageDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17518,16 +22539,16 @@ impl Drop for CResult_UpdateAddHTLCDecodeErrorZ { } } } -impl From> for CResult_UpdateAddHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OffersMessageDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UpdateAddHTLCDecodeErrorZPtr { result } + CResult_OffersMessageDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UpdateAddHTLCDecodeErrorZPtr { err } + CResult_OffersMessageDecodeErrorZPtr { err } }; Self { contents, @@ -17535,59 +22556,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OffersMessageDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UpdateAddHTLCDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OffersMessageDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UpdateAddHTLCDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UpdateAddHTLCDecodeErrorZ_clone(orig: &CResult_UpdateAddHTLCDecodeErrorZ) -> CResult_UpdateAddHTLCDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OffersMessageDecodeErrorZ_clone(orig: &CResult_OffersMessageDecodeErrorZ) -> CResult_OffersMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OnionMessageDecodeErrorZ -pub union CResult_OnionMessageDecodeErrorZPtr { +/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not +pub enum COption_HTLCClaimZ { + /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim + Some(crate::lightning::ln::chan_utils::HTLCClaim), + /// When we're in this state, this COption_HTLCClaimZ contains nothing + None +} +impl COption_HTLCClaimZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim +pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { + COption_HTLCClaimZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_HTLCClaimZ containing nothing +pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { + COption_HTLCClaimZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state +pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } +#[repr(C)] +/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ +pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::OnionMessage, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OnionMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::OnionMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OnionMessageDecodeErrorZ { - /// The contents of this CResult_OnionMessageDecodeErrorZ, accessible via either +pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OnionMessageDecodeErrorZPtr, - /// Whether this CResult_OnionMessageDecodeErrorZ represents a success state. + pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, + /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::OnionMessage) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OnionMessageDecodeErrorZ { - CResult_OnionMessageDecodeErrorZ { - contents: CResult_OnionMessageDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17595,13 +22648,13 @@ pub extern "C" fn CResult_OnionMessageDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_is_ok(o: &CResult_OnionMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OnionMessageDecodeErrorZ. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_free(_res: CResult_OnionMessageDecodeErrorZ) { } -impl Drop for CResult_OnionMessageDecodeErrorZ { +/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } +impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17614,16 +22667,16 @@ impl Drop for CResult_OnionMessageDecodeErrorZ { } } } -impl From> for CResult_OnionMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OnionMessageDecodeErrorZPtr { result } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OnionMessageDecodeErrorZPtr { err } + CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } }; Self { contents, @@ -17631,59 +22684,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OnionMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OnionMessageDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OnionMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OnionMessageDecodeErrorZ_clone(orig: &CResult_OnionMessageDecodeErrorZ) -> CResult_OnionMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_FinalOnionHopDataDecodeErrorZ -pub union CResult_FinalOnionHopDataDecodeErrorZPtr { +/// The contents of CResult_TxCreationKeysDecodeErrorZ +pub union CResult_TxCreationKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::FinalOnionHopData, + pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_FinalOnionHopDataDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::FinalOnionHopData on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_FinalOnionHopDataDecodeErrorZ { - /// The contents of this CResult_FinalOnionHopDataDecodeErrorZ, accessible via either +pub struct CResult_TxCreationKeysDecodeErrorZ { + /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_FinalOnionHopDataDecodeErrorZPtr, - /// Whether this CResult_FinalOnionHopDataDecodeErrorZ represents a success state. + pub contents: CResult_TxCreationKeysDecodeErrorZPtr, + /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ in the success state. -pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_ok(o: crate::lightning::ln::msgs::FinalOnionHopData) -> CResult_FinalOnionHopDataDecodeErrorZ { - CResult_FinalOnionHopDataDecodeErrorZ { - contents: CResult_FinalOnionHopDataDecodeErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ in the error state. -pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FinalOnionHopDataDecodeErrorZ { - CResult_FinalOnionHopDataDecodeErrorZ { - contents: CResult_FinalOnionHopDataDecodeErrorZPtr { +/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { + CResult_TxCreationKeysDecodeErrorZ { + contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17691,13 +22744,13 @@ pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_is_ok(o: &CResult_FinalOnionHopDataDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_FinalOnionHopDataDecodeErrorZ. -pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_free(_res: CResult_FinalOnionHopDataDecodeErrorZ) { } -impl Drop for CResult_FinalOnionHopDataDecodeErrorZ { +/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } +impl Drop for CResult_TxCreationKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17710,16 +22763,16 @@ impl Drop for CResult_FinalOnionHopDataDecodeErrorZ { } } } -impl From> for CResult_FinalOnionHopDataDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxCreationKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_FinalOnionHopDataDecodeErrorZPtr { result } + CResult_TxCreationKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_FinalOnionHopDataDecodeErrorZPtr { err } + CResult_TxCreationKeysDecodeErrorZPtr { err } }; Self { contents, @@ -17727,59 +22780,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_FinalOnionHopDataDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_FinalOnionHopDataDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_FinalOnionHopDataDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_FinalOnionHopDataDecodeErrorZ_clone(orig: &CResult_FinalOnionHopDataDecodeErrorZ) -> CResult_FinalOnionHopDataDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PingDecodeErrorZ -pub union CResult_PingDecodeErrorZPtr { +/// The contents of CResult_ChannelPublicKeysDecodeErrorZ +pub union CResult_ChannelPublicKeysDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Ping, + pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PingDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Ping on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PingDecodeErrorZ { - /// The contents of this CResult_PingDecodeErrorZ, accessible via either +pub struct CResult_ChannelPublicKeysDecodeErrorZ { + /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PingDecodeErrorZPtr, - /// Whether this CResult_PingDecodeErrorZ represents a success state. + pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, + /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the success state. -pub extern "C" fn CResult_PingDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Ping) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ in the error state. -pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PingDecodeErrorZ { - CResult_PingDecodeErrorZ { - contents: CResult_PingDecodeErrorZPtr { +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { + CResult_ChannelPublicKeysDecodeErrorZ { + contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17787,13 +22840,13 @@ pub extern "C" fn CResult_PingDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PingDecodeErrorZ_is_ok(o: &CResult_PingDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PingDecodeErrorZ. -pub extern "C" fn CResult_PingDecodeErrorZ_free(_res: CResult_PingDecodeErrorZ) { } -impl Drop for CResult_PingDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } +impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17806,16 +22859,16 @@ impl Drop for CResult_PingDecodeErrorZ { } } } -impl From> for CResult_PingDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelPublicKeysDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PingDecodeErrorZPtr { result } + CResult_ChannelPublicKeysDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PingDecodeErrorZPtr { err } + CResult_ChannelPublicKeysDecodeErrorZPtr { err } }; Self { contents, @@ -17823,59 +22876,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PingDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PingDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PingDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PingDecodeErrorZ_clone(orig: &CResult_PingDecodeErrorZ) -> CResult_PingDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PongDecodeErrorZ -pub union CResult_PongDecodeErrorZPtr { +/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ +pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::Pong, + pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PongDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::Pong on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PongDecodeErrorZ { - /// The contents of this CResult_PongDecodeErrorZ, accessible via either +pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { + /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PongDecodeErrorZPtr, - /// Whether this CResult_PongDecodeErrorZ represents a success state. + pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, + /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the success state. -pub extern "C" fn CResult_PongDecodeErrorZ_ok(o: crate::lightning::ln::msgs::Pong) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ in the error state. -pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PongDecodeErrorZ { - CResult_PongDecodeErrorZ { - contents: CResult_PongDecodeErrorZPtr { +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { + CResult_HTLCOutputInCommitmentDecodeErrorZ { + contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17883,13 +22936,13 @@ pub extern "C" fn CResult_PongDecodeErrorZ_err(e: crate::lightning::ln::msgs::De } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PongDecodeErrorZ_is_ok(o: &CResult_PongDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PongDecodeErrorZ. -pub extern "C" fn CResult_PongDecodeErrorZ_free(_res: CResult_PongDecodeErrorZ) { } -impl Drop for CResult_PongDecodeErrorZ { +/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } +impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17902,16 +22955,16 @@ impl Drop for CResult_PongDecodeErrorZ { } } } -impl From> for CResult_PongDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PongDecodeErrorZPtr { result } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PongDecodeErrorZPtr { err } + CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } }; Self { contents, @@ -17919,59 +22972,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PongDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PongDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PongDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PongDecodeErrorZ_clone(orig: &CResult_PongDecodeErrorZ) -> CResult_PongDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelAnnouncementDecodeErrorZ -pub union CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ +pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelAnnouncement, + pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { - CResult_UnsignedChannelAnnouncementDecodeErrorZ { - contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -17979,13 +23032,13 @@ pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -17998,16 +23051,16 @@ impl Drop for CResult_UnsignedChannelAnnouncementDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err } + CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -18015,59 +23068,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedChannelAnnouncementDecodeErrorZ) -> CResult_UnsignedChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelAnnouncementDecodeErrorZ -pub union CResult_ChannelAnnouncementDecodeErrorZPtr { +/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ +pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelAnnouncement, + pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelAnnouncementDecodeErrorZ { - /// The contents of this CResult_ChannelAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_ChannelTransactionParametersDecodeErrorZ { + /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelAnnouncementDecodeErrorZPtr, - /// Whether this CResult_ChannelAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, + /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelAnnouncement) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelAnnouncementDecodeErrorZ { - CResult_ChannelAnnouncementDecodeErrorZ { - contents: CResult_ChannelAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { + CResult_ChannelTransactionParametersDecodeErrorZ { + contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18075,13 +23128,13 @@ pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o: &CResult_ChannelAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ChannelAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_free(_res: CResult_ChannelAnnouncementDecodeErrorZ) { } -impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } +impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18094,16 +23147,16 @@ impl Drop for CResult_ChannelAnnouncementDecodeErrorZ { } } } -impl From> for CResult_ChannelAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelAnnouncementDecodeErrorZPtr { result } + CResult_ChannelTransactionParametersDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelAnnouncementDecodeErrorZPtr { err } + CResult_ChannelTransactionParametersDecodeErrorZPtr { err } }; Self { contents, @@ -18111,59 +23164,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelAnnouncementDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelAnnouncementDecodeErrorZ_clone(orig: &CResult_ChannelAnnouncementDecodeErrorZ) -> CResult_ChannelAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedChannelUpdateDecodeErrorZ -pub union CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ +pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedChannelUpdate, + pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_UnsignedChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedChannelUpdateDecodeErrorZ { - /// The contents of this CResult_UnsignedChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_UnsignedChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedChannelUpdate) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedChannelUpdateDecodeErrorZ { - CResult_UnsignedChannelUpdateDecodeErrorZ { - contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { + CResult_HolderCommitmentTransactionDecodeErrorZ { + contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18171,13 +23224,13 @@ pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res: CResult_UnsignedChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { +/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18190,16 +23243,16 @@ impl Drop for CResult_UnsignedChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_UnsignedChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedChannelUpdateDecodeErrorZPtr { result } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedChannelUpdateDecodeErrorZPtr { err } + CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -18207,59 +23260,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UnsignedChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UnsignedChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig: &CResult_UnsignedChannelUpdateDecodeErrorZ) -> CResult_UnsignedChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelUpdateDecodeErrorZ -pub union CResult_ChannelUpdateDecodeErrorZPtr { +/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ +pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ChannelUpdate, + pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ChannelUpdateDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ChannelUpdate on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelUpdateDecodeErrorZ { - /// The contents of this CResult_ChannelUpdateDecodeErrorZ, accessible via either +pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelUpdateDecodeErrorZPtr, - /// Whether this CResult_ChannelUpdateDecodeErrorZ represents a success state. + pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ChannelUpdate) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelUpdateDecodeErrorZ { - CResult_ChannelUpdateDecodeErrorZ { - contents: CResult_ChannelUpdateDecodeErrorZPtr { +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { + CResult_BuiltCommitmentTransactionDecodeErrorZ { + contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18267,13 +23320,13 @@ pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_is_ok(o: &CResult_ChannelUpdateDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } -#[no_mangle] -/// Frees any resources used by the CResult_ChannelUpdateDecodeErrorZ. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_free(_res: CResult_ChannelUpdateDecodeErrorZ) { } -impl Drop for CResult_ChannelUpdateDecodeErrorZ { +#[no_mangle] +/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18286,16 +23339,16 @@ impl Drop for CResult_ChannelUpdateDecodeErrorZ { } } } -impl From> for CResult_ChannelUpdateDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelUpdateDecodeErrorZPtr { result } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelUpdateDecodeErrorZPtr { err } + CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -18303,95 +23356,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelUpdateDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelUpdateDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ChannelUpdateDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelUpdateDecodeErrorZ_clone(orig: &CResult_ChannelUpdateDecodeErrorZ) -> CResult_ChannelUpdateDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ErrorMessageDecodeErrorZ -pub union CResult_ErrorMessageDecodeErrorZPtr { +/// The contents of CResult_TrustedClosingTransactionNoneZ +pub union CResult_TrustedClosingTransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ErrorMessage, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_ErrorMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ErrorMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ErrorMessageDecodeErrorZ { - /// The contents of this CResult_ErrorMessageDecodeErrorZ, accessible via either +pub struct CResult_TrustedClosingTransactionNoneZ { + /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ErrorMessageDecodeErrorZPtr, - /// Whether this CResult_ErrorMessageDecodeErrorZ represents a success state. + pub contents: CResult_TrustedClosingTransactionNoneZPtr, + /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ErrorMessage) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ErrorMessageDecodeErrorZ { - CResult_ErrorMessageDecodeErrorZ { - contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { + CResult_TrustedClosingTransactionNoneZ { + contents: CResult_TrustedClosingTransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_is_ok(o: &CResult_ErrorMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ErrorMessageDecodeErrorZ. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_free(_res: CResult_ErrorMessageDecodeErrorZ) { } -impl Drop for CResult_ErrorMessageDecodeErrorZ { +/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. +pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } +impl Drop for CResult_TrustedClosingTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_ErrorMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrustedClosingTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ErrorMessageDecodeErrorZPtr { result } + CResult_TrustedClosingTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ErrorMessageDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -18399,59 +23448,42 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ErrorMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ErrorMessageDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_ErrorMessageDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ErrorMessageDecodeErrorZ_clone(orig: &CResult_ErrorMessageDecodeErrorZ) -> CResult_ErrorMessageDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_WarningMessageDecodeErrorZ -pub union CResult_WarningMessageDecodeErrorZPtr { +/// The contents of CResult_CommitmentTransactionDecodeErrorZ +pub union CResult_CommitmentTransactionDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::WarningMessage, + pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_WarningMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::WarningMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_WarningMessageDecodeErrorZ { - /// The contents of this CResult_WarningMessageDecodeErrorZ, accessible via either +pub struct CResult_CommitmentTransactionDecodeErrorZ { + /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_WarningMessageDecodeErrorZPtr, - /// Whether this CResult_WarningMessageDecodeErrorZ represents a success state. + pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, + /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_ok(o: crate::lightning::ln::msgs::WarningMessage) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_WarningMessageDecodeErrorZ { - CResult_WarningMessageDecodeErrorZ { - contents: CResult_WarningMessageDecodeErrorZPtr { +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { + CResult_CommitmentTransactionDecodeErrorZ { + contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18459,13 +23491,13 @@ pub extern "C" fn CResult_WarningMessageDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_is_ok(o: &CResult_WarningMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_WarningMessageDecodeErrorZ. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_free(_res: CResult_WarningMessageDecodeErrorZ) { } -impl Drop for CResult_WarningMessageDecodeErrorZ { +/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } +impl Drop for CResult_CommitmentTransactionDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18478,16 +23510,16 @@ impl Drop for CResult_WarningMessageDecodeErrorZ { } } } -impl From> for CResult_WarningMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CommitmentTransactionDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_WarningMessageDecodeErrorZPtr { result } + CResult_CommitmentTransactionDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_WarningMessageDecodeErrorZPtr { err } + CResult_CommitmentTransactionDecodeErrorZPtr { err } }; Self { contents, @@ -18495,95 +23527,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_WarningMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_WarningMessageDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_WarningMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_WarningMessageDecodeErrorZ_clone(orig: &CResult_WarningMessageDecodeErrorZ) -> CResult_WarningMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UnsignedNodeAnnouncementDecodeErrorZ -pub union CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_TrustedCommitmentTransactionNoneZ +pub union CResult_TrustedCommitmentTransactionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::UnsignedNodeAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_UnsignedNodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::UnsignedNodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UnsignedNodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_UnsignedNodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_TrustedCommitmentTransactionNoneZ { + /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_UnsignedNodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, + /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::UnsignedNodeAnnouncement) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { - CResult_UnsignedNodeAnnouncementDecodeErrorZ { - contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { + CResult_TrustedCommitmentTransactionNoneZ { + contents: CResult_TrustedCommitmentTransactionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UnsignedNodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res: CResult_UnsignedNodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_UnsignedNodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. +pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } +impl Drop for CResult_TrustedCommitmentTransactionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_UnsignedNodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrustedCommitmentTransactionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result } + CResult_TrustedCommitmentTransactionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -18591,95 +23619,74 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_UnsignedNodeAnnouncementDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig: &CResult_UnsignedNodeAnnouncementDecodeErrorZ) -> CResult_UnsignedNodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NodeAnnouncementDecodeErrorZ -pub union CResult_NodeAnnouncementDecodeErrorZPtr { +/// The contents of CResult_CVec_ECDSASignatureZNoneZ +pub union CResult_CVec_ECDSASignatureZNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::NodeAnnouncement, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::c_types::derived::CVec_ECDSASignatureZ, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_NodeAnnouncementDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::NodeAnnouncement on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_CVec_ECDSASignatureZNoneZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::CVec_ECDSASignatureZ on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NodeAnnouncementDecodeErrorZ { - /// The contents of this CResult_NodeAnnouncementDecodeErrorZ, accessible via either +pub struct CResult_CVec_ECDSASignatureZNoneZ { + /// The contents of this CResult_CVec_ECDSASignatureZNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NodeAnnouncementDecodeErrorZPtr, - /// Whether this CResult_NodeAnnouncementDecodeErrorZ represents a success state. + pub contents: CResult_CVec_ECDSASignatureZNoneZPtr, + /// Whether this CResult_CVec_ECDSASignatureZNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the success state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_ok(o: crate::lightning::ln::msgs::NodeAnnouncement) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { +/// Creates a new CResult_CVec_ECDSASignatureZNoneZ in the success state. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_ok(o: crate::c_types::derived::CVec_ECDSASignatureZ) -> CResult_CVec_ECDSASignatureZNoneZ { + CResult_CVec_ECDSASignatureZNoneZ { + contents: CResult_CVec_ECDSASignatureZNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ in the error state. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NodeAnnouncementDecodeErrorZ { - CResult_NodeAnnouncementDecodeErrorZ { - contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_CVec_ECDSASignatureZNoneZ in the error state. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_err() -> CResult_CVec_ECDSASignatureZNoneZ { + CResult_CVec_ECDSASignatureZNoneZ { + contents: CResult_CVec_ECDSASignatureZNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_is_ok(o: &CResult_NodeAnnouncementDecodeErrorZ) -> bool { +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_is_ok(o: &CResult_CVec_ECDSASignatureZNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NodeAnnouncementDecodeErrorZ. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_free(_res: CResult_NodeAnnouncementDecodeErrorZ) { } -impl Drop for CResult_NodeAnnouncementDecodeErrorZ { +/// Frees any resources used by the CResult_CVec_ECDSASignatureZNoneZ. +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_free(_res: CResult_CVec_ECDSASignatureZNoneZ) { } +impl Drop for CResult_CVec_ECDSASignatureZNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_NodeAnnouncementDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_CVec_ECDSASignatureZNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_NodeAnnouncementDecodeErrorZPtr { result } + CResult_CVec_ECDSASignatureZNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NodeAnnouncementDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_CVec_ECDSASignatureZNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -18687,59 +23694,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_CVec_ECDSASignatureZNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NodeAnnouncementDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_CVec_ECDSASignatureZNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_NodeAnnouncementDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_CVec_ECDSASignatureZNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NodeAnnouncementDecodeErrorZ_clone(orig: &CResult_NodeAnnouncementDecodeErrorZ) -> CResult_NodeAnnouncementDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_clone(orig: &CResult_CVec_ECDSASignatureZNoneZ) -> CResult_CVec_ECDSASignatureZNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_QueryShortChannelIdsDecodeErrorZ -pub union CResult_QueryShortChannelIdsDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a usize or not +pub enum COption_usizeZ { + /// When we're in this state, this COption_usizeZ contains a usize + Some(usize), + /// When we're in this state, this COption_usizeZ contains nothing + None +} +impl COption_usizeZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> usize { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_usizeZ containing a usize +pub extern "C" fn COption_usizeZ_some(o: usize) -> COption_usizeZ { + COption_usizeZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_usizeZ containing nothing +pub extern "C" fn COption_usizeZ_none() -> COption_usizeZ { + COption_usizeZ::None +} +#[no_mangle] +/// Frees any resources associated with the usize, if we are in the Some state +pub extern "C" fn COption_usizeZ_free(_res: COption_usizeZ) { } +#[no_mangle] +/// Creates a new COption_usizeZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_usizeZ_clone(orig: &COption_usizeZ) -> COption_usizeZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_ShutdownScriptDecodeErrorZ +pub union CResult_ShutdownScriptDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryShortChannelIds, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_QueryShortChannelIdsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryShortChannelIds on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryShortChannelIdsDecodeErrorZ { - /// The contents of this CResult_QueryShortChannelIdsDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptDecodeErrorZ { + /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryShortChannelIdsDecodeErrorZPtr, - /// Whether this CResult_QueryShortChannelIdsDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptDecodeErrorZPtr, + /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryShortChannelIds) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryShortChannelIdsDecodeErrorZ { - CResult_QueryShortChannelIdsDecodeErrorZ { - contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { + CResult_ShutdownScriptDecodeErrorZ { + contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18747,13 +23791,13 @@ pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o: &CResult_QueryShortChannelIdsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryShortChannelIdsDecodeErrorZ. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_free(_res: CResult_QueryShortChannelIdsDecodeErrorZ) { } -impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } +impl Drop for CResult_ShutdownScriptDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18766,16 +23810,16 @@ impl Drop for CResult_QueryShortChannelIdsDecodeErrorZ { } } } -impl From> for CResult_QueryShortChannelIdsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryShortChannelIdsDecodeErrorZPtr { result } + CResult_ShutdownScriptDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryShortChannelIdsDecodeErrorZPtr { err } + CResult_ShutdownScriptDecodeErrorZPtr { err } }; Self { contents, @@ -18783,59 +23827,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryShortChannelIdsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_QueryShortChannelIdsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig: &CResult_QueryShortChannelIdsDecodeErrorZ) -> CResult_QueryShortChannelIdsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyShortChannelIdsEndDecodeErrorZ -pub union CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ +pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, + pub result: *mut crate::lightning::ln::script::ShutdownScript, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, } #[repr(C)] -/// A CResult_ReplyShortChannelIdsEndDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyShortChannelIdsEnd on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyShortChannelIdsEndDecodeErrorZ { - /// The contents of this CResult_ReplyShortChannelIdsEndDecodeErrorZ, accessible via either +pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { + /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr, - /// Whether this CResult_ReplyShortChannelIdsEndDecodeErrorZ represents a success state. + pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, + /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { - CResult_ReplyShortChannelIdsEndDecodeErrorZ { - contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { + CResult_ShutdownScriptInvalidShutdownScriptZ { + contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18843,13 +23887,13 @@ pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyShortChannelIdsEndDecodeErrorZ. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res: CResult_ReplyShortChannelIdsEndDecodeErrorZ) { } -impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { +/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } +impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18862,16 +23906,16 @@ impl Drop for CResult_ReplyShortChannelIdsEndDecodeErrorZ { } } } -impl From> for CResult_ReplyShortChannelIdsEndDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err } + CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } }; Self { contents, @@ -18879,59 +23923,105 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } +impl Clone for CResult_ShutdownScriptInvalidShutdownScriptZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::Transactions of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TransactionZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::Transaction, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TransactionZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TransactionZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new CResult_ReplyShortChannelIdsEndDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig: &CResult_ReplyShortChannelIdsEndDecodeErrorZ) -> CResult_ReplyShortChannelIdsEndDecodeErrorZ { Clone::clone(&orig) } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TransactionZ_free(_res: CVec_TransactionZ) { } +impl Drop for CVec_TransactionZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_TransactionZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} #[repr(C)] -/// The contents of CResult_QueryChannelRangeDecodeErrorZ -pub union CResult_QueryChannelRangeDecodeErrorZPtr { +/// The contents of CResult_FundingInfoDecodeErrorZ +pub union CResult_FundingInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::QueryChannelRange, + pub result: *mut crate::lightning::events::FundingInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_QueryChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::QueryChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_FundingInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::FundingInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_QueryChannelRangeDecodeErrorZ { - /// The contents of this CResult_QueryChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_FundingInfoDecodeErrorZ { + /// The contents of this CResult_FundingInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_QueryChannelRangeDecodeErrorZPtr, - /// Whether this CResult_QueryChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_FundingInfoDecodeErrorZPtr, + /// Whether this CResult_FundingInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::QueryChannelRange) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_FundingInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_ok(o: crate::lightning::events::FundingInfo) -> CResult_FundingInfoDecodeErrorZ { + CResult_FundingInfoDecodeErrorZ { + contents: CResult_FundingInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_QueryChannelRangeDecodeErrorZ { - CResult_QueryChannelRangeDecodeErrorZ { - contents: CResult_QueryChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_FundingInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_FundingInfoDecodeErrorZ { + CResult_FundingInfoDecodeErrorZ { + contents: CResult_FundingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -18939,13 +24029,13 @@ pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_is_ok(o: &CResult_QueryChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_is_ok(o: &CResult_FundingInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_QueryChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_free(_res: CResult_QueryChannelRangeDecodeErrorZ) { } -impl Drop for CResult_QueryChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_FundingInfoDecodeErrorZ. +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_free(_res: CResult_FundingInfoDecodeErrorZ) { } +impl Drop for CResult_FundingInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -18958,16 +24048,16 @@ impl Drop for CResult_QueryChannelRangeDecodeErrorZ { } } } -impl From> for CResult_QueryChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_FundingInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_QueryChannelRangeDecodeErrorZPtr { result } + CResult_FundingInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_QueryChannelRangeDecodeErrorZPtr { err } + CResult_FundingInfoDecodeErrorZPtr { err } }; Self { contents, @@ -18975,59 +24065,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_QueryChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_FundingInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_QueryChannelRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_FundingInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_QueryChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_FundingInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_QueryChannelRangeDecodeErrorZ_clone(orig: &CResult_QueryChannelRangeDecodeErrorZ) -> CResult_QueryChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_FundingInfoDecodeErrorZ_clone(orig: &CResult_FundingInfoDecodeErrorZ) -> CResult_FundingInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ReplyChannelRangeDecodeErrorZ -pub union CResult_ReplyChannelRangeDecodeErrorZPtr { +/// The contents of CResult_PaymentPurposeDecodeErrorZ +pub union CResult_PaymentPurposeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::ReplyChannelRange, + pub result: *mut crate::lightning::events::PaymentPurpose, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_ReplyChannelRangeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::ReplyChannelRange on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ReplyChannelRangeDecodeErrorZ { - /// The contents of this CResult_ReplyChannelRangeDecodeErrorZ, accessible via either +pub struct CResult_PaymentPurposeDecodeErrorZ { + /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ReplyChannelRangeDecodeErrorZPtr, - /// Whether this CResult_ReplyChannelRangeDecodeErrorZ represents a success state. + pub contents: CResult_PaymentPurposeDecodeErrorZPtr, + /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the success state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_ok(o: crate::lightning::ln::msgs::ReplyChannelRange) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ in the error state. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ReplyChannelRangeDecodeErrorZ { - CResult_ReplyChannelRangeDecodeErrorZ { - contents: CResult_ReplyChannelRangeDecodeErrorZPtr { +/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { + CResult_PaymentPurposeDecodeErrorZ { + contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19035,13 +24125,13 @@ pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o: &CResult_ReplyChannelRangeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ReplyChannelRangeDecodeErrorZ. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_free(_res: CResult_ReplyChannelRangeDecodeErrorZ) { } -impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { +/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } +impl Drop for CResult_PaymentPurposeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19054,16 +24144,16 @@ impl Drop for CResult_ReplyChannelRangeDecodeErrorZ { } } } -impl From> for CResult_ReplyChannelRangeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentPurposeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ReplyChannelRangeDecodeErrorZPtr { result } + CResult_PaymentPurposeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ReplyChannelRangeDecodeErrorZPtr { err } + CResult_PaymentPurposeDecodeErrorZPtr { err } }; Self { contents, @@ -19071,59 +24161,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ReplyChannelRangeDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ReplyChannelRangeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ReplyChannelRangeDecodeErrorZ_clone(orig: &CResult_ReplyChannelRangeDecodeErrorZ) -> CResult_ReplyChannelRangeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_GossipTimestampFilterDecodeErrorZ -pub union CResult_GossipTimestampFilterDecodeErrorZPtr { +/// The contents of CResult_ClaimedHTLCDecodeErrorZ +pub union CResult_ClaimedHTLCDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::msgs::GossipTimestampFilter, + pub result: *mut crate::lightning::events::ClaimedHTLC, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_GossipTimestampFilterDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::msgs::GossipTimestampFilter on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ClaimedHTLCDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::events::ClaimedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_GossipTimestampFilterDecodeErrorZ { - /// The contents of this CResult_GossipTimestampFilterDecodeErrorZ, accessible via either +pub struct CResult_ClaimedHTLCDecodeErrorZ { + /// The contents of this CResult_ClaimedHTLCDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_GossipTimestampFilterDecodeErrorZPtr, - /// Whether this CResult_GossipTimestampFilterDecodeErrorZ represents a success state. + pub contents: CResult_ClaimedHTLCDecodeErrorZPtr, + /// Whether this CResult_ClaimedHTLCDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the success state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_ok(o: crate::lightning::ln::msgs::GossipTimestampFilter) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the success state. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_ok(o: crate::lightning::events::ClaimedHTLC) -> CResult_ClaimedHTLCDecodeErrorZ { + CResult_ClaimedHTLCDecodeErrorZ { + contents: CResult_ClaimedHTLCDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ in the error state. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_GossipTimestampFilterDecodeErrorZ { - CResult_GossipTimestampFilterDecodeErrorZ { - contents: CResult_GossipTimestampFilterDecodeErrorZPtr { +/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the error state. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClaimedHTLCDecodeErrorZ { + CResult_ClaimedHTLCDecodeErrorZ { + contents: CResult_ClaimedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19131,13 +24221,13 @@ pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o: &CResult_GossipTimestampFilterDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_is_ok(o: &CResult_ClaimedHTLCDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_GossipTimestampFilterDecodeErrorZ. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_free(_res: CResult_GossipTimestampFilterDecodeErrorZ) { } -impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { +/// Frees any resources used by the CResult_ClaimedHTLCDecodeErrorZ. +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_free(_res: CResult_ClaimedHTLCDecodeErrorZ) { } +impl Drop for CResult_ClaimedHTLCDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19150,16 +24240,16 @@ impl Drop for CResult_GossipTimestampFilterDecodeErrorZ { } } } -impl From> for CResult_GossipTimestampFilterDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ClaimedHTLCDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_GossipTimestampFilterDecodeErrorZPtr { result } + CResult_ClaimedHTLCDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_GossipTimestampFilterDecodeErrorZPtr { err } + CResult_ClaimedHTLCDecodeErrorZPtr { err } }; Self { contents, @@ -19167,105 +24257,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ClaimedHTLCDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_GossipTimestampFilterDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ClaimedHTLCDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_GossipTimestampFilterDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ClaimedHTLCDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_GossipTimestampFilterDecodeErrorZ_clone(orig: &CResult_GossipTimestampFilterDecodeErrorZ) -> CResult_GossipTimestampFilterDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_clone(orig: &CResult_ClaimedHTLCDecodeErrorZ) -> CResult_ClaimedHTLCDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_PhantomRouteHintsZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PathFailure or not +pub enum COption_PathFailureZ { + /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure + Some(crate::lightning::events::PathFailure), + /// When we're in this state, this COption_PathFailureZ contains nothing + None } -impl CVec_PhantomRouteHintsZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_PathFailureZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_PhantomRouteHintsZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } -impl Drop for CVec_PhantomRouteHintsZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure +pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { + COption_PathFailureZ::Some(o) } -impl Clone for CVec_PhantomRouteHintsZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +#[no_mangle] +/// Constructs a new COption_PathFailureZ containing nothing +pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { + COption_PathFailureZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state +pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } +#[no_mangle] +/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ -pub union CResult_Bolt11InvoiceSignOrCreationErrorZPtr { +/// The contents of CResult_COption_PathFailureZDecodeErrorZ +pub union CResult_COption_PathFailureZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Bolt11Invoice, + pub result: *mut crate::c_types::derived::COption_PathFailureZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::SignOrCreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. +/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_Bolt11InvoiceSignOrCreationErrorZ { - /// The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either +pub struct CResult_COption_PathFailureZDecodeErrorZ { + /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr, - /// Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. + pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, + /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { - CResult_Bolt11InvoiceSignOrCreationErrorZ { - contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { - CResult_Bolt11InvoiceSignOrCreationErrorZ { - contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { + CResult_COption_PathFailureZDecodeErrorZ { + contents: CResult_COption_PathFailureZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19273,13 +24354,13 @@ pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> bool { +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res: CResult_Bolt11InvoiceSignOrCreationErrorZ) { } -impl Drop for CResult_Bolt11InvoiceSignOrCreationErrorZ { +/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } +impl Drop for CResult_COption_PathFailureZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19292,16 +24373,16 @@ impl Drop for CResult_Bolt11InvoiceSignOrCreationErrorZ { } } } -impl From> for CResult_Bolt11InvoiceSignOrCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_PathFailureZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result } + CResult_COption_PathFailureZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } + CResult_COption_PathFailureZDecodeErrorZPtr { err } }; Self { contents, @@ -19309,105 +24390,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning::util::wakers::Futures of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_FutureZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::util::wakers::Future, - /// The number of elements pointed to by `data`. - pub datalen: usize +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::ClosureReason or not +pub enum COption_ClosureReasonZ { + /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason + Some(crate::lightning::events::ClosureReason), + /// When we're in this state, this COption_ClosureReasonZ contains nothing + None } -impl CVec_FutureZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret +impl COption_ClosureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::wakers::Future] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() } -} -impl From> for CVec_FutureZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_FutureZ_free(_res: CVec_FutureZ) { } -impl Drop for CVec_FutureZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } +/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason +pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { + COption_ClosureReasonZ::Some(o) } -impl Clone for CVec_FutureZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } +#[no_mangle] +/// Constructs a new COption_ClosureReasonZ containing nothing +pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { + COption_ClosureReasonZ::None } +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state +pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } +#[no_mangle] +/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OffersMessageDecodeErrorZ -pub union CResult_OffersMessageDecodeErrorZPtr { +/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ +pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::offers::OffersMessage, + pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OffersMessageDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::offers::OffersMessage on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OffersMessageDecodeErrorZ { - /// The contents of this CResult_OffersMessageDecodeErrorZ, accessible via either +pub struct CResult_COption_ClosureReasonZDecodeErrorZ { + /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OffersMessageDecodeErrorZPtr, - /// Whether this CResult_OffersMessageDecodeErrorZ represents a success state. + pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, + /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OffersMessageDecodeErrorZ in the success state. -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_ok(o: crate::lightning::onion_message::offers::OffersMessage) -> CResult_OffersMessageDecodeErrorZ { - CResult_OffersMessageDecodeErrorZ { - contents: CResult_OffersMessageDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OffersMessageDecodeErrorZ in the error state. -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersMessageDecodeErrorZ { - CResult_OffersMessageDecodeErrorZ { - contents: CResult_OffersMessageDecodeErrorZPtr { +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { + CResult_COption_ClosureReasonZDecodeErrorZ { + contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19415,13 +24487,13 @@ pub extern "C" fn CResult_OffersMessageDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_is_ok(o: &CResult_OffersMessageDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OffersMessageDecodeErrorZ. -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_free(_res: CResult_OffersMessageDecodeErrorZ) { } -impl Drop for CResult_OffersMessageDecodeErrorZ { +/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } +impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19434,16 +24506,16 @@ impl Drop for CResult_OffersMessageDecodeErrorZ { } } } -impl From> for CResult_OffersMessageDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OffersMessageDecodeErrorZPtr { result } + CResult_COption_ClosureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OffersMessageDecodeErrorZPtr { err } + CResult_COption_ClosureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -19451,91 +24523,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OffersMessageDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OffersMessageDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OffersMessageDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OffersMessageDecodeErrorZ_clone(orig: &CResult_OffersMessageDecodeErrorZ) -> CResult_OffersMessageDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not -pub enum COption_HTLCClaimZ { - /// When we're in this state, this COption_HTLCClaimZ contains a crate::lightning::ln::chan_utils::HTLCClaim - Some(crate::lightning::ln::chan_utils::HTLCClaim), - /// When we're in this state, this COption_HTLCClaimZ contains nothing +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::HTLCDestination or not +pub enum COption_HTLCDestinationZ { + /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination + Some(crate::lightning::events::HTLCDestination), + /// When we're in this state, this COption_HTLCDestinationZ contains nothing None } -impl COption_HTLCClaimZ { +impl COption_HTLCDestinationZ { #[allow(unused)] pub(crate) fn is_some(&self) -> bool { if let Self::None = self { false } else { true } } #[allow(unused)] pub(crate) fn is_none(&self) -> bool { !self.is_some() } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::ln::chan_utils::HTLCClaim { + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing a crate::lightning::ln::chan_utils::HTLCClaim -pub extern "C" fn COption_HTLCClaimZ_some(o: crate::lightning::ln::chan_utils::HTLCClaim) -> COption_HTLCClaimZ { - COption_HTLCClaimZ::Some(o) +/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination +pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::Some(o) } #[no_mangle] -/// Constructs a new COption_HTLCClaimZ containing nothing -pub extern "C" fn COption_HTLCClaimZ_none() -> COption_HTLCClaimZ { - COption_HTLCClaimZ::None +/// Constructs a new COption_HTLCDestinationZ containing nothing +pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { + COption_HTLCDestinationZ::None } #[no_mangle] -/// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state -pub extern "C" fn COption_HTLCClaimZ_free(_res: COption_HTLCClaimZ) { } +/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state +pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } +#[no_mangle] +/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyCommitmentSecretsDecodeErrorZ -pub union CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ +pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets, + pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - /// The contents of this CResult_CounterpartyCommitmentSecretsDecodeErrorZ, accessible via either +pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { + /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr, - /// Whether this CResult_CounterpartyCommitmentSecretsDecodeErrorZ represents a success state. + pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, + /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyCommitmentSecrets) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { + CResult_COption_HTLCDestinationZDecodeErrorZ { + contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19543,13 +24620,13 @@ pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e: crate } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyCommitmentSecretsDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res: CResult_CounterpartyCommitmentSecretsDecodeErrorZ) { } -impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { +/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } +impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19562,16 +24639,16 @@ impl Drop for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { } } } -impl From> for CResult_CounterpartyCommitmentSecretsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { result } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { err } + CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } }; Self { contents, @@ -19579,59 +24656,96 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CounterpartyCommitmentSecretsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyCommitmentSecretsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig: &CResult_CounterpartyCommitmentSecretsDecodeErrorZ) -> CResult_CounterpartyCommitmentSecretsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxCreationKeysDecodeErrorZ -pub union CResult_TxCreationKeysDecodeErrorZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not +pub enum COption_PaymentFailureReasonZ { + /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason + Some(crate::lightning::events::PaymentFailureReason), + /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing + None +} +impl COption_PaymentFailureReasonZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason +pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_PaymentFailureReasonZ containing nothing +pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { + COption_PaymentFailureReasonZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state +pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } +#[no_mangle] +/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } +#[repr(C)] +/// The contents of CResult_COption_PaymentFailureReasonZDecodeErrorZ +pub union CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TxCreationKeys, + pub result: *mut crate::c_types::derived::COption_PaymentFailureReasonZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxCreationKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TxCreationKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_PaymentFailureReasonZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_PaymentFailureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxCreationKeysDecodeErrorZ { - /// The contents of this CResult_TxCreationKeysDecodeErrorZ, accessible via either +pub struct CResult_COption_PaymentFailureReasonZDecodeErrorZ { + /// The contents of this CResult_COption_PaymentFailureReasonZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxCreationKeysDecodeErrorZPtr, - /// Whether this CResult_TxCreationKeysDecodeErrorZ represents a success state. + pub contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr, + /// Whether this CResult_COption_PaymentFailureReasonZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::TxCreationKeys) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PaymentFailureReasonZ) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { + CResult_COption_PaymentFailureReasonZDecodeErrorZ { + contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TxCreationKeysDecodeErrorZ { - CResult_TxCreationKeysDecodeErrorZ { - contents: CResult_TxCreationKeysDecodeErrorZPtr { +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { + CResult_COption_PaymentFailureReasonZDecodeErrorZ { + contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19639,13 +24753,13 @@ pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_is_ok(o: &CResult_TxCreationKeysDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_PaymentFailureReasonZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxCreationKeysDecodeErrorZ. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_free(_res: CResult_TxCreationKeysDecodeErrorZ) { } -impl Drop for CResult_TxCreationKeysDecodeErrorZ { +/// Frees any resources used by the CResult_COption_PaymentFailureReasonZDecodeErrorZ. +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_free(_res: CResult_COption_PaymentFailureReasonZDecodeErrorZ) { } +impl Drop for CResult_COption_PaymentFailureReasonZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19658,16 +24772,16 @@ impl Drop for CResult_TxCreationKeysDecodeErrorZ { } } } -impl From> for CResult_TxCreationKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_PaymentFailureReasonZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxCreationKeysDecodeErrorZPtr { result } + CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxCreationKeysDecodeErrorZPtr { err } + CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { err } }; Self { contents, @@ -19675,155 +24789,179 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxCreationKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxCreationKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_PaymentFailureReasonZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxCreationKeysDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_PaymentFailureReasonZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxCreationKeysDecodeErrorZ_clone(orig: &CResult_TxCreationKeysDecodeErrorZ) -> CResult_TxCreationKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_PaymentFailureReasonZDecodeErrorZ_clone(orig: &CResult_COption_PaymentFailureReasonZDecodeErrorZ) -> CResult_COption_PaymentFailureReasonZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ChannelPublicKeysDecodeErrorZ -pub union CResult_ChannelPublicKeysDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelPublicKeys, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, +#[derive(Clone)] +/// An enum which can either contain a crate::c_types::U128 or not +pub enum COption_U128Z { + /// When we're in this state, this COption_U128Z contains a crate::c_types::U128 + Some(crate::c_types::U128), + /// When we're in this state, this COption_U128Z contains nothing + None } -#[repr(C)] -/// A CResult_ChannelPublicKeysDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelPublicKeys on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelPublicKeysDecodeErrorZ { - /// The contents of this CResult_ChannelPublicKeysDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelPublicKeysDecodeErrorZPtr, - /// Whether this CResult_ChannelPublicKeysDecodeErrorZ represents a success state. - pub result_ok: bool, +impl COption_U128Z { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { + if let Self::Some(v) = self { v } else { unreachable!() } + } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelPublicKeys) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// Constructs a new COption_U128Z containing a crate::c_types::U128 +pub extern "C" fn COption_U128Z_some(o: crate::c_types::U128) -> COption_U128Z { + COption_U128Z::Some(o) } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelPublicKeysDecodeErrorZ { - CResult_ChannelPublicKeysDecodeErrorZ { - contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, - } +/// Constructs a new COption_U128Z containing nothing +pub extern "C" fn COption_U128Z_none() -> COption_U128Z { + COption_U128Z::None } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o: &CResult_ChannelPublicKeysDecodeErrorZ) -> bool { - o.result_ok +/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state +pub extern "C" fn COption_U128Z_free(_res: COption_U128Z) { } +#[no_mangle] +/// Creates a new COption_U128Z which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_U128Z_clone(orig: &COption_U128Z) -> COption_U128Z { Clone::clone(&orig) } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_ClaimedHTLCZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::events::ClaimedHTLC, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_ClaimedHTLCZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::ClaimedHTLC] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_ClaimedHTLCZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelPublicKeysDecodeErrorZ. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_free(_res: CResult_ChannelPublicKeysDecodeErrorZ) { } -impl Drop for CResult_ChannelPublicKeysDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_ClaimedHTLCZ_free(_res: CVec_ClaimedHTLCZ) { } +impl Drop for CVec_ClaimedHTLCZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_ChannelPublicKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelPublicKeysDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelPublicKeysDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_ClaimedHTLCZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -impl Clone for CResult_ChannelPublicKeysDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelPublicKeysDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } +#[repr(C)] +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::events::Event or not +pub enum COption_EventZ { + /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event + Some(crate::lightning::events::Event), + /// When we're in this state, this COption_EventZ contains nothing + None +} +impl COption_EventZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { + if let Self::Some(v) = self { v } else { unreachable!() } } } #[no_mangle] -/// Creates a new CResult_ChannelPublicKeysDecodeErrorZ which has the same data as `orig` +/// Constructs a new COption_EventZ containing a crate::lightning::events::Event +pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { + COption_EventZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_EventZ containing nothing +pub extern "C" fn COption_EventZ_none() -> COption_EventZ { + COption_EventZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state +pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } +#[no_mangle] +/// Creates a new COption_EventZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelPublicKeysDecodeErrorZ_clone(orig: &CResult_ChannelPublicKeysDecodeErrorZ) -> CResult_ChannelPublicKeysDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HTLCOutputInCommitmentDecodeErrorZ -pub union CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// The contents of CResult_COption_EventZDecodeErrorZ +pub union CResult_COption_EventZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HTLCOutputInCommitment, + pub result: *mut crate::c_types::derived::COption_EventZ, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_HTLCOutputInCommitmentDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HTLCOutputInCommitment on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HTLCOutputInCommitmentDecodeErrorZ { - /// The contents of this CResult_HTLCOutputInCommitmentDecodeErrorZ, accessible via either +pub struct CResult_COption_EventZDecodeErrorZ { + /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr, - /// Whether this CResult_HTLCOutputInCommitmentDecodeErrorZ represents a success state. + pub contents: CResult_COption_EventZDecodeErrorZPtr, + /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the success state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ in the error state. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { - CResult_HTLCOutputInCommitmentDecodeErrorZ { - contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { +/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { + CResult_COption_EventZDecodeErrorZ { + contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19831,13 +24969,13 @@ pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> bool { +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HTLCOutputInCommitmentDecodeErrorZ. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res: CResult_HTLCOutputInCommitmentDecodeErrorZ) { } -impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { +/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } +impl Drop for CResult_COption_EventZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19850,16 +24988,16 @@ impl Drop for CResult_HTLCOutputInCommitmentDecodeErrorZ { } } } -impl From> for CResult_HTLCOutputInCommitmentDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_COption_EventZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result } + CResult_COption_EventZDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err } + CResult_COption_EventZDecodeErrorZPtr { err } }; Self { contents, @@ -19867,59 +25005,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HTLCOutputInCommitmentDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HTLCOutputInCommitmentDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig: &CResult_HTLCOutputInCommitmentDecodeErrorZ) -> CResult_HTLCOutputInCommitmentDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_CounterpartyChannelTransactionParametersDecodeErrorZ -pub union CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { +/// The contents of CResult_NonceDecodeErrorZ +pub union CResult_NonceDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, + pub result: *mut crate::lightning::offers::nonce::Nonce, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NonceDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::nonce::Nonce on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ, accessible via either +pub struct CResult_NonceDecodeErrorZ { + /// The contents of this CResult_NonceDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_CounterpartyChannelTransactionParametersDecodeErrorZ represents a success state. + pub contents: CResult_NonceDecodeErrorZPtr, + /// Whether this CResult_NonceDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { +/// Creates a new CResult_NonceDecodeErrorZ in the success state. +pub extern "C" fn CResult_NonceDecodeErrorZ_ok(o: crate::lightning::offers::nonce::Nonce) -> CResult_NonceDecodeErrorZ { + CResult_NonceDecodeErrorZ { + contents: CResult_NonceDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { +/// Creates a new CResult_NonceDecodeErrorZ in the error state. +pub extern "C" fn CResult_NonceDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_NonceDecodeErrorZ { + CResult_NonceDecodeErrorZ { + contents: CResult_NonceDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -19927,13 +25065,13 @@ pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_e } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NonceDecodeErrorZ_is_ok(o: &CResult_NonceDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CounterpartyChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res: CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { +/// Frees any resources used by the CResult_NonceDecodeErrorZ. +pub extern "C" fn CResult_NonceDecodeErrorZ_free(_res: CResult_NonceDecodeErrorZ) { } +impl Drop for CResult_NonceDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -19946,16 +25084,16 @@ impl Drop for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { } } } -impl From> for CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NonceDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result } + CResult_NonceDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err } + CResult_NonceDecodeErrorZPtr { err } }; Self { contents, @@ -19963,155 +25101,105 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NonceDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_NonceDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CounterpartyChannelTransactionParametersDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NonceDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_CounterpartyChannelTransactionParametersDecodeErrorZ) -> CResult_CounterpartyChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_ChannelTransactionParametersDecodeErrorZ -pub union CResult_ChannelTransactionParametersDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::ChannelTransactionParameters, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, -} +pub extern "C" fn CResult_NonceDecodeErrorZ_clone(orig: &CResult_NonceDecodeErrorZ) -> CResult_NonceDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_ChannelTransactionParametersDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::ChannelTransactionParameters on success and a crate::lightning::ln::msgs::DecodeError on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ChannelTransactionParametersDecodeErrorZ { - /// The contents of this CResult_ChannelTransactionParametersDecodeErrorZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ChannelTransactionParametersDecodeErrorZPtr, - /// Whether this CResult_ChannelTransactionParametersDecodeErrorZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning_types::routing::RouteHintHops of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_RouteHintHopZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_types::routing::RouteHintHop, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the success state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_RouteHintHopZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ in the error state. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelTransactionParametersDecodeErrorZ { - CResult_ChannelTransactionParametersDecodeErrorZ { - contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_types::routing::RouteHintHop] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o: &CResult_ChannelTransactionParametersDecodeErrorZ) -> bool { - o.result_ok +impl From> for CVec_RouteHintHopZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_ChannelTransactionParametersDecodeErrorZ. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_free(_res: CResult_ChannelTransactionParametersDecodeErrorZ) { } -impl Drop for CResult_ChannelTransactionParametersDecodeErrorZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_RouteHintHopZ_free(_res: CVec_RouteHintHopZ) { } +impl Drop for CVec_RouteHintHopZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } - } - } -} -impl From> for CResult_ChannelTransactionParametersDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ChannelTransactionParametersDecodeErrorZPtr { result } - } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ChannelTransactionParametersDecodeErrorZPtr { err } - }; - Self { - contents, - result_ok: o.result_ok, - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CResult_ChannelTransactionParametersDecodeErrorZ { +impl Clone for CVec_RouteHintHopZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_ChannelTransactionParametersDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } -#[no_mangle] -/// Creates a new CResult_ChannelTransactionParametersDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig: &CResult_ChannelTransactionParametersDecodeErrorZ) -> CResult_ChannelTransactionParametersDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HolderCommitmentTransactionDecodeErrorZ -pub union CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_SiPrefixBolt11ParseErrorZ +pub union CResult_SiPrefixBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::HolderCommitmentTransaction, + pub result: *mut crate::lightning_invoice::SiPrefix, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_HolderCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::HolderCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SiPrefixBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HolderCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_HolderCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_SiPrefixBolt11ParseErrorZ { + /// The contents of this CResult_SiPrefixBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_HolderCommitmentTransactionDecodeErrorZ represents a success state. - pub result_ok: bool, -} -#[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { + pub contents: CResult_SiPrefixBolt11ParseErrorZPtr, + /// Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HolderCommitmentTransactionDecodeErrorZ { - CResult_HolderCommitmentTransactionDecodeErrorZ { - contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SiPrefixBolt11ParseErrorZ { + CResult_SiPrefixBolt11ParseErrorZ { + contents: CResult_SiPrefixBolt11ParseErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20119,13 +25207,13 @@ pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HolderCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res: CResult_HolderCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_SiPrefixBolt11ParseErrorZ. +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_free(_res: CResult_SiPrefixBolt11ParseErrorZ) { } +impl Drop for CResult_SiPrefixBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20138,16 +25226,16 @@ impl Drop for CResult_HolderCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_HolderCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SiPrefixBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HolderCommitmentTransactionDecodeErrorZPtr { result } + CResult_SiPrefixBolt11ParseErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HolderCommitmentTransactionDecodeErrorZPtr { err } + CResult_SiPrefixBolt11ParseErrorZPtr { err } }; Self { contents, @@ -20155,59 +25243,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HolderCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SiPrefixBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HolderCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_SiPrefixBolt11ParseErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_HolderCommitmentTransactionDecodeErrorZ) -> CResult_HolderCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BuiltCommitmentTransactionDecodeErrorZ -pub union CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ +pub union CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::ParseOrSemanticError, } #[repr(C)] -/// A CResult_BuiltCommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::BuiltCommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt11InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BuiltCommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_BuiltCommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_Bolt11InvoiceParseOrSemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_BuiltCommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::BuiltCommitmentTransaction) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { - CResult_BuiltCommitmentTransactionDecodeErrorZ { - contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { + CResult_Bolt11InvoiceParseOrSemanticErrorZ { + contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20215,13 +25303,13 @@ pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e: crate::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BuiltCommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res: CResult_BuiltCommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt11InvoiceParseOrSemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res: CResult_Bolt11InvoiceParseOrSemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20234,16 +25322,16 @@ impl Drop for CResult_BuiltCommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_BuiltCommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceParseOrSemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err } + CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } }; Self { contents, @@ -20251,91 +25339,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BuiltCommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BuiltCommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig: &CResult_BuiltCommitmentTransactionDecodeErrorZ) -> CResult_BuiltCommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TrustedClosingTransactionNoneZ -pub union CResult_TrustedClosingTransactionNoneZPtr { +/// The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ +pub union CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning_invoice::SignedRawBolt11Invoice, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::Bolt11ParseError, } #[repr(C)] -/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedClosingTransaction on success and a () on failure. +/// A CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::SignedRawBolt11Invoice on success and a crate::lightning_invoice::Bolt11ParseError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedClosingTransactionNoneZ { - /// The contents of this CResult_TrustedClosingTransactionNoneZ, accessible via either +pub struct CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedClosingTransactionNoneZPtr, - /// Whether this CResult_TrustedClosingTransactionNoneZ represents a success state. + pub contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, + /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedClosingTransaction) -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SignedRawBolt11Invoice) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TrustedClosingTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ { - CResult_TrustedClosingTransactionNoneZ { - contents: CResult_TrustedClosingTransactionNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_is_ok(o: &CResult_TrustedClosingTransactionNoneZ) -> bool { +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TrustedClosingTransactionNoneZ. -pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_free(_res: CResult_TrustedClosingTransactionNoneZ) { } -impl Drop for CResult_TrustedClosingTransactionNoneZ { +/// Frees any resources used by the CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) { } +impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_TrustedClosingTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedClosingTransactionNoneZPtr { result } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } }; Self { contents, @@ -20343,42 +25435,105 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + /// The element at position 0 + pub a: crate::lightning_invoice::RawBolt11Invoice, + /// The element at position 1 + pub b: crate::c_types::ThirtyTwoBytes, + /// The element at position 2 + pub c: crate::lightning_invoice::Bolt11InvoiceSignature, +} +impl From<(crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)> for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn from (tup: (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig: &C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a: crate::lightning_invoice::RawBolt11Invoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::Bolt11InvoiceSignature) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { + C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ. +pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res: C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) { } #[repr(C)] -/// The contents of CResult_CommitmentTransactionDecodeErrorZ -pub union CResult_CommitmentTransactionDecodeErrorZPtr { +/// The contents of CResult_PayeePubKeySecp256k1ErrorZ +pub union CResult_PayeePubKeySecp256k1ErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::CommitmentTransaction, + pub result: *mut crate::lightning_invoice::PayeePubKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::c_types::Secp256k1Error, } #[repr(C)] -/// A CResult_CommitmentTransactionDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::CommitmentTransaction on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PayeePubKeySecp256k1ErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CommitmentTransactionDecodeErrorZ { - /// The contents of this CResult_CommitmentTransactionDecodeErrorZ, accessible via either +pub struct CResult_PayeePubKeySecp256k1ErrorZ { + /// The contents of this CResult_PayeePubKeySecp256k1ErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CommitmentTransactionDecodeErrorZPtr, - /// Whether this CResult_CommitmentTransactionDecodeErrorZ represents a success state. + pub contents: CResult_PayeePubKeySecp256k1ErrorZPtr, + /// Whether this CResult_PayeePubKeySecp256k1ErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the success state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_ok(o: crate::lightning::ln::chan_utils::CommitmentTransaction) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the success state. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeySecp256k1ErrorZ { + CResult_PayeePubKeySecp256k1ErrorZ { + contents: CResult_PayeePubKeySecp256k1ErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ in the error state. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_CommitmentTransactionDecodeErrorZ { - CResult_CommitmentTransactionDecodeErrorZ { - contents: CResult_CommitmentTransactionDecodeErrorZPtr { +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the error state. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeySecp256k1ErrorZ { + CResult_PayeePubKeySecp256k1ErrorZ { + contents: CResult_PayeePubKeySecp256k1ErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20386,13 +25541,13 @@ pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_is_ok(o: &CResult_CommitmentTransactionDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_is_ok(o: &CResult_PayeePubKeySecp256k1ErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CommitmentTransactionDecodeErrorZ. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_free(_res: CResult_CommitmentTransactionDecodeErrorZ) { } -impl Drop for CResult_CommitmentTransactionDecodeErrorZ { +/// Frees any resources used by the CResult_PayeePubKeySecp256k1ErrorZ. +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_free(_res: CResult_PayeePubKeySecp256k1ErrorZ) { } +impl Drop for CResult_PayeePubKeySecp256k1ErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20405,16 +25560,16 @@ impl Drop for CResult_CommitmentTransactionDecodeErrorZ { } } } -impl From> for CResult_CommitmentTransactionDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PayeePubKeySecp256k1ErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CommitmentTransactionDecodeErrorZPtr { result } + CResult_PayeePubKeySecp256k1ErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_CommitmentTransactionDecodeErrorZPtr { err } + CResult_PayeePubKeySecp256k1ErrorZPtr { err } }; Self { contents, @@ -20422,166 +25577,141 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CommitmentTransactionDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CommitmentTransactionDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CommitmentTransactionDecodeErrorZ_clone(orig: &CResult_CommitmentTransactionDecodeErrorZ) -> CResult_CommitmentTransactionDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// The contents of CResult_TrustedCommitmentTransactionNoneZ -pub union CResult_TrustedCommitmentTransactionNoneZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, -} +pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_clone(orig: &CResult_PayeePubKeySecp256k1ErrorZ) -> CResult_PayeePubKeySecp256k1ErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::chan_utils::TrustedCommitmentTransaction on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TrustedCommitmentTransactionNoneZ { - /// The contents of this CResult_TrustedCommitmentTransactionNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TrustedCommitmentTransactionNoneZPtr, - /// Whether this CResult_TrustedCommitmentTransactionNoneZ represents a success state. - pub result_ok: bool, +/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PrivateRouteZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning_invoice::PrivateRoute, + /// The number of elements pointed to by `data`. + pub datalen: usize } -#[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the success state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_ok(o: crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, +impl CVec_PrivateRouteZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -#[no_mangle] -/// Creates a new CResult_TrustedCommitmentTransactionNoneZ in the error state. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ { - CResult_TrustedCommitmentTransactionNoneZ { - contents: CResult_TrustedCommitmentTransactionNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -/// Checks if the given object is currently in the success state -#[no_mangle] -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_is_ok(o: &CResult_TrustedCommitmentTransactionNoneZ) -> bool { - o.result_ok +impl From> for CVec_PrivateRouteZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_TrustedCommitmentTransactionNoneZ. -pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_free(_res: CResult_TrustedCommitmentTransactionNoneZ) { } -impl Drop for CResult_TrustedCommitmentTransactionNoneZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } +impl Drop for CVec_PrivateRouteZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_TrustedCommitmentTransactionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TrustedCommitmentTransactionNoneZPtr { result } - } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_PrivateRouteZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_CVec_ECDSASignatureZNoneZ -pub union CResult_CVec_ECDSASignatureZNoneZPtr { +/// The contents of CResult_PositiveTimestampCreationErrorZ +pub union CResult_PositiveTimestampCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::CVec_ECDSASignatureZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning_invoice::PositiveTimestamp, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_CVec_ECDSASignatureZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::CVec_ECDSASignatureZ on success and a () on failure. +/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_CVec_ECDSASignatureZNoneZ { - /// The contents of this CResult_CVec_ECDSASignatureZNoneZ, accessible via either +pub struct CResult_PositiveTimestampCreationErrorZ { + /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_CVec_ECDSASignatureZNoneZPtr, - /// Whether this CResult_CVec_ECDSASignatureZNoneZ represents a success state. + pub contents: CResult_PositiveTimestampCreationErrorZPtr, + /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_CVec_ECDSASignatureZNoneZ in the success state. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_ok(o: crate::c_types::derived::CVec_ECDSASignatureZ) -> CResult_CVec_ECDSASignatureZNoneZ { - CResult_CVec_ECDSASignatureZNoneZ { - contents: CResult_CVec_ECDSASignatureZNoneZPtr { +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_CVec_ECDSASignatureZNoneZ in the error state. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_err() -> CResult_CVec_ECDSASignatureZNoneZ { - CResult_CVec_ECDSASignatureZNoneZ { - contents: CResult_CVec_ECDSASignatureZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { + CResult_PositiveTimestampCreationErrorZ { + contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_is_ok(o: &CResult_CVec_ECDSASignatureZNoneZ) -> bool { +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_CVec_ECDSASignatureZNoneZ. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_free(_res: CResult_CVec_ECDSASignatureZNoneZ) { } -impl Drop for CResult_CVec_ECDSASignatureZNoneZ { +/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } +impl Drop for CResult_PositiveTimestampCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_CVec_ECDSASignatureZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PositiveTimestampCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_CVec_ECDSASignatureZNoneZPtr { result } + CResult_PositiveTimestampCreationErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_CVec_ECDSASignatureZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_PositiveTimestampCreationErrorZPtr { err } }; Self { contents, @@ -20589,96 +25719,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_CVec_ECDSASignatureZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_CVec_ECDSASignatureZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_CVec_ECDSASignatureZNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_CVec_ECDSASignatureZNoneZ_clone(orig: &CResult_CVec_ECDSASignatureZNoneZ) -> CResult_CVec_ECDSASignatureZNoneZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a usize or not -pub enum COption_usizeZ { - /// When we're in this state, this COption_usizeZ contains a usize - Some(usize), - /// When we're in this state, this COption_usizeZ contains nothing - None -} -impl COption_usizeZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> usize { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_usizeZ containing a usize -pub extern "C" fn COption_usizeZ_some(o: usize) -> COption_usizeZ { - COption_usizeZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_usizeZ containing nothing -pub extern "C" fn COption_usizeZ_none() -> COption_usizeZ { - COption_usizeZ::None -} -#[no_mangle] -/// Frees any resources associated with the usize, if we are in the Some state -pub extern "C" fn COption_usizeZ_free(_res: COption_usizeZ) { } -#[no_mangle] -/// Creates a new COption_usizeZ which has the same data as `orig` +/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_usizeZ_clone(orig: &COption_usizeZ) -> COption_usizeZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptDecodeErrorZ -pub union CResult_ShutdownScriptDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::script::ShutdownScript, +/// The contents of CResult_NoneBolt11SemanticErrorZ +pub union CResult_NoneBolt11SemanticErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_ShutdownScriptDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptDecodeErrorZ { - /// The contents of this CResult_ShutdownScriptDecodeErrorZ, accessible via either +pub struct CResult_NoneBolt11SemanticErrorZ { + /// The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptDecodeErrorZPtr, - /// Whether this CResult_ShutdownScriptDecodeErrorZ represents a success state. + pub contents: CResult_NoneBolt11SemanticErrorZPtr, + /// Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the success state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_ok() -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ in the error state. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ShutdownScriptDecodeErrorZ { - CResult_ShutdownScriptDecodeErrorZ { - contents: CResult_ShutdownScriptDecodeErrorZPtr { +/// Creates a new CResult_NoneBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_NoneBolt11SemanticErrorZ { + CResult_NoneBolt11SemanticErrorZ { + contents: CResult_NoneBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20686,18 +25778,15 @@ pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_is_ok(o: &CResult_ShutdownScriptDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptDecodeErrorZ. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_free(_res: CResult_ShutdownScriptDecodeErrorZ) { } -impl Drop for CResult_ShutdownScriptDecodeErrorZ { +/// Frees any resources used by the CResult_NoneBolt11SemanticErrorZ. +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_free(_res: CResult_NoneBolt11SemanticErrorZ) { } +impl Drop for CResult_NoneBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -20705,16 +25794,16 @@ impl Drop for CResult_ShutdownScriptDecodeErrorZ { } } } -impl From> for CResult_ShutdownScriptDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::Bolt11SemanticError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneBolt11SemanticErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptDecodeErrorZPtr { err } + CResult_NoneBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -20722,59 +25811,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptDecodeErrorZ_clone(orig: &CResult_ShutdownScriptDecodeErrorZ) -> CResult_ShutdownScriptDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ShutdownScriptInvalidShutdownScriptZ -pub union CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ +pub union CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::script::ShutdownScript, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::script::InvalidShutdownScript, + pub err: *mut crate::lightning_invoice::Bolt11SemanticError, } #[repr(C)] -/// A CResult_ShutdownScriptInvalidShutdownScriptZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::script::ShutdownScript on success and a crate::lightning::ln::script::InvalidShutdownScript on failure. +/// A CResult_Bolt11InvoiceBolt11SemanticErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::Bolt11SemanticError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ShutdownScriptInvalidShutdownScriptZ { - /// The contents of this CResult_ShutdownScriptInvalidShutdownScriptZ, accessible via either +pub struct CResult_Bolt11InvoiceBolt11SemanticErrorZ { + /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr, - /// Whether this CResult_ShutdownScriptInvalidShutdownScriptZ represents a success state. + pub contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr, + /// Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the success state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o: crate::lightning::ln::script::ShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ in the error state. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lightning::ln::script::InvalidShutdownScript) -> CResult_ShutdownScriptInvalidShutdownScriptZ { - CResult_ShutdownScriptInvalidShutdownScriptZ { - contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { + CResult_Bolt11InvoiceBolt11SemanticErrorZ { + contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20782,13 +25871,13 @@ pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ShutdownScriptInvalidShutdownScriptZ. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res: CResult_ShutdownScriptInvalidShutdownScriptZ) { } -impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { +/// Frees any resources used by the CResult_Bolt11InvoiceBolt11SemanticErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res: CResult_Bolt11InvoiceBolt11SemanticErrorZ) { } +impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20801,16 +25890,16 @@ impl Drop for CResult_ShutdownScriptInvalidShutdownScriptZ { } } } -impl From> for CResult_ShutdownScriptInvalidShutdownScriptZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceBolt11SemanticErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ShutdownScriptInvalidShutdownScriptZPtr { result } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ShutdownScriptInvalidShutdownScriptZPtr { err } + CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } }; Self { contents, @@ -20818,59 +25907,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ShutdownScriptInvalidShutdownScriptZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ShutdownScriptInvalidShutdownScriptZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig: &CResult_ShutdownScriptInvalidShutdownScriptZ) -> CResult_ShutdownScriptInvalidShutdownScriptZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentPurposeDecodeErrorZ -pub union CResult_PaymentPurposeDecodeErrorZPtr { +/// The contents of CResult_DescriptionCreationErrorZ +pub union CResult_DescriptionCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentPurpose, + pub result: *mut crate::lightning_invoice::Description, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_PaymentPurposeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentPurpose on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentPurposeDecodeErrorZ { - /// The contents of this CResult_PaymentPurposeDecodeErrorZ, accessible via either +pub struct CResult_DescriptionCreationErrorZ { + /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentPurposeDecodeErrorZPtr, - /// Whether this CResult_PaymentPurposeDecodeErrorZ represents a success state. + pub contents: CResult_DescriptionCreationErrorZPtr, + /// Whether this CResult_DescriptionCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_ok(o: crate::lightning::events::PaymentPurpose) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the success state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentPurposeDecodeErrorZ { - CResult_PaymentPurposeDecodeErrorZ { - contents: CResult_PaymentPurposeDecodeErrorZPtr { +/// Creates a new CResult_DescriptionCreationErrorZ in the error state. +pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { + CResult_DescriptionCreationErrorZ { + contents: CResult_DescriptionCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20878,13 +25967,13 @@ pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_err(e: crate::lightning::ln } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_is_ok(o: &CResult_PaymentPurposeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentPurposeDecodeErrorZ. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_free(_res: CResult_PaymentPurposeDecodeErrorZ) { } -impl Drop for CResult_PaymentPurposeDecodeErrorZ { +/// Frees any resources used by the CResult_DescriptionCreationErrorZ. +pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } +impl Drop for CResult_DescriptionCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20897,16 +25986,16 @@ impl Drop for CResult_PaymentPurposeDecodeErrorZ { } } } -impl From> for CResult_PaymentPurposeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DescriptionCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentPurposeDecodeErrorZPtr { result } + CResult_DescriptionCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentPurposeDecodeErrorZPtr { err } + CResult_DescriptionCreationErrorZPtr { err } }; Self { contents, @@ -20914,59 +26003,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentPurposeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentPurposeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentPurposeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentPurposeDecodeErrorZ_clone(orig: &CResult_PaymentPurposeDecodeErrorZ) -> CResult_PaymentPurposeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_ClaimedHTLCDecodeErrorZ -pub union CResult_ClaimedHTLCDecodeErrorZPtr { +/// The contents of CResult_PrivateRouteCreationErrorZ +pub union CResult_PrivateRouteCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::ClaimedHTLC, + pub result: *mut crate::lightning_invoice::PrivateRoute, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning_invoice::CreationError, } #[repr(C)] -/// A CResult_ClaimedHTLCDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::ClaimedHTLC on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_ClaimedHTLCDecodeErrorZ { - /// The contents of this CResult_ClaimedHTLCDecodeErrorZ, accessible via either +pub struct CResult_PrivateRouteCreationErrorZ { + /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_ClaimedHTLCDecodeErrorZPtr, - /// Whether this CResult_ClaimedHTLCDecodeErrorZ represents a success state. + pub contents: CResult_PrivateRouteCreationErrorZPtr, + /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the success state. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_ok(o: crate::lightning::events::ClaimedHTLC) -> CResult_ClaimedHTLCDecodeErrorZ { - CResult_ClaimedHTLCDecodeErrorZ { - contents: CResult_ClaimedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ in the error state. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ClaimedHTLCDecodeErrorZ { - CResult_ClaimedHTLCDecodeErrorZ { - contents: CResult_ClaimedHTLCDecodeErrorZPtr { +/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { + CResult_PrivateRouteCreationErrorZ { + contents: CResult_PrivateRouteCreationErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -20974,13 +26063,13 @@ pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_is_ok(o: &CResult_ClaimedHTLCDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_ClaimedHTLCDecodeErrorZ. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_free(_res: CResult_ClaimedHTLCDecodeErrorZ) { } -impl Drop for CResult_ClaimedHTLCDecodeErrorZ { +/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } +impl Drop for CResult_PrivateRouteCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -20993,16 +26082,16 @@ impl Drop for CResult_ClaimedHTLCDecodeErrorZ { } } } -impl From> for CResult_ClaimedHTLCDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PrivateRouteCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_ClaimedHTLCDecodeErrorZPtr { result } + CResult_PrivateRouteCreationErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_ClaimedHTLCDecodeErrorZPtr { err } + CResult_PrivateRouteCreationErrorZPtr { err } }; Self { contents, @@ -21010,96 +26099,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ClaimedHTLCDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ClaimedHTLCDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_ClaimedHTLCDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_ClaimedHTLCDecodeErrorZ_clone(orig: &CResult_ClaimedHTLCDecodeErrorZ) -> CResult_ClaimedHTLCDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PathFailure or not -pub enum COption_PathFailureZ { - /// When we're in this state, this COption_PathFailureZ contains a crate::lightning::events::PathFailure - Some(crate::lightning::events::PathFailure), - /// When we're in this state, this COption_PathFailureZ contains nothing - None -} -impl COption_PathFailureZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PathFailure { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing a crate::lightning::events::PathFailure -pub extern "C" fn COption_PathFailureZ_some(o: crate::lightning::events::PathFailure) -> COption_PathFailureZ { - COption_PathFailureZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PathFailureZ containing nothing -pub extern "C" fn COption_PathFailureZ_none() -> COption_PathFailureZ { - COption_PathFailureZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PathFailure, if we are in the Some state -pub extern "C" fn COption_PathFailureZ_free(_res: COption_PathFailureZ) { } -#[no_mangle] -/// Creates a new COption_PathFailureZ which has the same data as `orig` +/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PathFailureZ_clone(orig: &COption_PathFailureZ) -> COption_PathFailureZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_PathFailureZDecodeErrorZ -pub union CResult_COption_PathFailureZDecodeErrorZPtr { +/// The contents of CResult_OutPointDecodeErrorZ +pub union CResult_OutPointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_PathFailureZ, + pub result: *mut crate::lightning::chain::transaction::OutPoint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_PathFailureZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_PathFailureZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_PathFailureZDecodeErrorZ { - /// The contents of this CResult_COption_PathFailureZDecodeErrorZ, accessible via either +pub struct CResult_OutPointDecodeErrorZ { + /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_PathFailureZDecodeErrorZPtr, - /// Whether this CResult_COption_PathFailureZDecodeErrorZ represents a success state. + pub contents: CResult_OutPointDecodeErrorZPtr, + /// Whether this CResult_OutPointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_ok(o: crate::c_types::derived::COption_PathFailureZ) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_PathFailureZDecodeErrorZ { - CResult_COption_PathFailureZDecodeErrorZ { - contents: CResult_COption_PathFailureZDecodeErrorZPtr { +/// Creates a new CResult_OutPointDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { + CResult_OutPointDecodeErrorZ { + contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21107,13 +26159,13 @@ pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_is_ok(o: &CResult_COption_PathFailureZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_PathFailureZDecodeErrorZ. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_free(_res: CResult_COption_PathFailureZDecodeErrorZ) { } -impl Drop for CResult_COption_PathFailureZDecodeErrorZ { +/// Frees any resources used by the CResult_OutPointDecodeErrorZ. +pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } +impl Drop for CResult_OutPointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21126,16 +26178,16 @@ impl Drop for CResult_COption_PathFailureZDecodeErrorZ { } } } -impl From> for CResult_COption_PathFailureZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutPointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_PathFailureZDecodeErrorZPtr { result } + CResult_OutPointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_PathFailureZDecodeErrorZPtr { err } + CResult_OutPointDecodeErrorZPtr { err } }; Self { contents, @@ -21143,96 +26195,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_PathFailureZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_PathFailureZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_PathFailureZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_PathFailureZDecodeErrorZ_clone(orig: &CResult_COption_PathFailureZDecodeErrorZ) -> CResult_COption_PathFailureZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::ClosureReason or not -pub enum COption_ClosureReasonZ { - /// When we're in this state, this COption_ClosureReasonZ contains a crate::lightning::events::ClosureReason - Some(crate::lightning::events::ClosureReason), - /// When we're in this state, this COption_ClosureReasonZ contains nothing - None -} -impl COption_ClosureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::ClosureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing a crate::lightning::events::ClosureReason -pub extern "C" fn COption_ClosureReasonZ_some(o: crate::lightning::events::ClosureReason) -> COption_ClosureReasonZ { - COption_ClosureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_ClosureReasonZ containing nothing -pub extern "C" fn COption_ClosureReasonZ_none() -> COption_ClosureReasonZ { - COption_ClosureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::ClosureReason, if we are in the Some state -pub extern "C" fn COption_ClosureReasonZ_free(_res: COption_ClosureReasonZ) { } -#[no_mangle] -/// Creates a new COption_ClosureReasonZ which has the same data as `orig` +/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_ClosureReasonZ_clone(orig: &COption_ClosureReasonZ) -> COption_ClosureReasonZ { Clone::clone(&orig) } +pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_ClosureReasonZDecodeErrorZ -pub union CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// The contents of CResult_BigSizeDecodeErrorZ +pub union CResult_BigSizeDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_ClosureReasonZ, + pub result: *mut crate::lightning::util::ser::BigSize, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_ClosureReasonZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_ClosureReasonZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BigSizeDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::BigSize on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_ClosureReasonZDecodeErrorZ { - /// The contents of this CResult_COption_ClosureReasonZDecodeErrorZ, accessible via either +pub struct CResult_BigSizeDecodeErrorZ { + /// The contents of this CResult_BigSizeDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_ClosureReasonZDecodeErrorZPtr, - /// Whether this CResult_COption_ClosureReasonZDecodeErrorZ represents a success state. + pub contents: CResult_BigSizeDecodeErrorZPtr, + /// Whether this CResult_BigSizeDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_ok(o: crate::c_types::derived::COption_ClosureReasonZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the success state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_ok(o: crate::lightning::util::ser::BigSize) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_ClosureReasonZDecodeErrorZ { - CResult_COption_ClosureReasonZDecodeErrorZ { - contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { +/// Creates a new CResult_BigSizeDecodeErrorZ in the error state. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BigSizeDecodeErrorZ { + CResult_BigSizeDecodeErrorZ { + contents: CResult_BigSizeDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21240,13 +26255,13 @@ pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o: &CResult_COption_ClosureReasonZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_ClosureReasonZDecodeErrorZ. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_free(_res: CResult_COption_ClosureReasonZDecodeErrorZ) { } -impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { +/// Frees any resources used by the CResult_BigSizeDecodeErrorZ. +pub extern "C" fn CResult_BigSizeDecodeErrorZ_free(_res: CResult_BigSizeDecodeErrorZ) { } +impl Drop for CResult_BigSizeDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21259,113 +26274,76 @@ impl Drop for CResult_COption_ClosureReasonZDecodeErrorZ { } } } -impl From> for CResult_COption_ClosureReasonZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BigSizeDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_ClosureReasonZDecodeErrorZPtr { result } + CResult_BigSizeDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_ClosureReasonZDecodeErrorZPtr { err } + CResult_BigSizeDecodeErrorZPtr { err } }; Self { - contents, - result_ok: o.result_ok, - } - } -} -impl Clone for CResult_COption_ClosureReasonZDecodeErrorZ { - fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_COption_ClosureReasonZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_COption_ClosureReasonZDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig: &CResult_COption_ClosureReasonZDecodeErrorZ) -> CResult_COption_ClosureReasonZDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::HTLCDestination or not -pub enum COption_HTLCDestinationZ { - /// When we're in this state, this COption_HTLCDestinationZ contains a crate::lightning::events::HTLCDestination - Some(crate::lightning::events::HTLCDestination), - /// When we're in this state, this COption_HTLCDestinationZ contains nothing - None -} -impl COption_HTLCDestinationZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::HTLCDestination { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing a crate::lightning::events::HTLCDestination -pub extern "C" fn COption_HTLCDestinationZ_some(o: crate::lightning::events::HTLCDestination) -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::Some(o) + contents, + result_ok: o.result_ok, + } + } } -#[no_mangle] -/// Constructs a new COption_HTLCDestinationZ containing nothing -pub extern "C" fn COption_HTLCDestinationZ_none() -> COption_HTLCDestinationZ { - COption_HTLCDestinationZ::None +impl Clone for CResult_BigSizeDecodeErrorZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_BigSizeDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_BigSizeDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } #[no_mangle] -/// Frees any resources associated with the crate::lightning::events::HTLCDestination, if we are in the Some state -pub extern "C" fn COption_HTLCDestinationZ_free(_res: COption_HTLCDestinationZ) { } -#[no_mangle] -/// Creates a new COption_HTLCDestinationZ which has the same data as `orig` +/// Creates a new CResult_BigSizeDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_HTLCDestinationZ_clone(orig: &COption_HTLCDestinationZ) -> COption_HTLCDestinationZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_HTLCDestinationZDecodeErrorZ -pub union CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// The contents of CResult_UntrustedStringDecodeErrorZ +pub union CResult_UntrustedStringDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_HTLCDestinationZ, + pub result: *mut crate::lightning_types::string::UntrustedString, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_COption_HTLCDestinationZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_HTLCDestinationZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_types::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_HTLCDestinationZDecodeErrorZ { - /// The contents of this CResult_COption_HTLCDestinationZDecodeErrorZ, accessible via either +pub struct CResult_UntrustedStringDecodeErrorZ { + /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr, - /// Whether this CResult_COption_HTLCDestinationZDecodeErrorZ represents a success state. + pub contents: CResult_UntrustedStringDecodeErrorZPtr, + /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o: crate::c_types::derived::COption_HTLCDestinationZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning_types::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_HTLCDestinationZDecodeErrorZ { - CResult_COption_HTLCDestinationZDecodeErrorZ { - contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { +/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { + CResult_UntrustedStringDecodeErrorZ { + contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21373,13 +26351,13 @@ pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_err(e: crate::lig } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_HTLCDestinationZDecodeErrorZ. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res: CResult_COption_HTLCDestinationZDecodeErrorZ) { } -impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { +/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } +impl Drop for CResult_UntrustedStringDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21392,16 +26370,16 @@ impl Drop for CResult_COption_HTLCDestinationZDecodeErrorZ { } } } -impl From> for CResult_COption_HTLCDestinationZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UntrustedStringDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_HTLCDestinationZDecodeErrorZPtr { result } + CResult_UntrustedStringDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_HTLCDestinationZDecodeErrorZPtr { err } + CResult_UntrustedStringDecodeErrorZPtr { err } }; Self { contents, @@ -21409,59 +26387,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_HTLCDestinationZDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_COption_HTLCDestinationZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig: &CResult_COption_HTLCDestinationZDecodeErrorZ) -> CResult_COption_HTLCDestinationZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentFailureReasonDecodeErrorZ -pub union CResult_PaymentFailureReasonDecodeErrorZPtr { +/// The contents of CResult_HostnameDecodeErrorZ +pub union CResult_HostnameDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::events::PaymentFailureReason, + pub result: *mut crate::lightning::util::ser::Hostname, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentFailureReasonDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::events::PaymentFailureReason on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HostnameDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::Hostname on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentFailureReasonDecodeErrorZ { - /// The contents of this CResult_PaymentFailureReasonDecodeErrorZ, accessible via either +pub struct CResult_HostnameDecodeErrorZ { + /// The contents of this CResult_HostnameDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentFailureReasonDecodeErrorZPtr, - /// Whether this CResult_PaymentFailureReasonDecodeErrorZ represents a success state. + pub contents: CResult_HostnameDecodeErrorZPtr, + /// Whether this CResult_HostnameDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_ok(o: crate::lightning::events::PaymentFailureReason) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the success state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_ok(o: crate::lightning::util::ser::Hostname) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentFailureReasonDecodeErrorZ { - CResult_PaymentFailureReasonDecodeErrorZ { - contents: CResult_PaymentFailureReasonDecodeErrorZPtr { +/// Creates a new CResult_HostnameDecodeErrorZ in the error state. +pub extern "C" fn CResult_HostnameDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HostnameDecodeErrorZ { + CResult_HostnameDecodeErrorZ { + contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21469,13 +26447,13 @@ pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_err(e: crate::lightni } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o: &CResult_PaymentFailureReasonDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HostnameDecodeErrorZ_is_ok(o: &CResult_HostnameDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentFailureReasonDecodeErrorZ. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_free(_res: CResult_PaymentFailureReasonDecodeErrorZ) { } -impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { +/// Frees any resources used by the CResult_HostnameDecodeErrorZ. +pub extern "C" fn CResult_HostnameDecodeErrorZ_free(_res: CResult_HostnameDecodeErrorZ) { } +impl Drop for CResult_HostnameDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21488,16 +26466,16 @@ impl Drop for CResult_PaymentFailureReasonDecodeErrorZ { } } } -impl From> for CResult_PaymentFailureReasonDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HostnameDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentFailureReasonDecodeErrorZPtr { result } + CResult_HostnameDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentFailureReasonDecodeErrorZPtr { err } + CResult_HostnameDecodeErrorZPtr { err } }; Self { contents, @@ -21505,252 +26483,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HostnameDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentFailureReasonDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_PaymentFailureReasonDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentFailureReasonDecodeErrorZ_clone(orig: &CResult_PaymentFailureReasonDecodeErrorZ) -> CResult_PaymentFailureReasonDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::c_types::U128 or not -pub enum COption_U128Z { - /// When we're in this state, this COption_U128Z contains a crate::c_types::U128 - Some(crate::c_types::U128), - /// When we're in this state, this COption_U128Z contains nothing - None -} -impl COption_U128Z { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::c_types::U128 { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_U128Z containing a crate::c_types::U128 -pub extern "C" fn COption_U128Z_some(o: crate::c_types::U128) -> COption_U128Z { - COption_U128Z::Some(o) -} -#[no_mangle] -/// Constructs a new COption_U128Z containing nothing -pub extern "C" fn COption_U128Z_none() -> COption_U128Z { - COption_U128Z::None -} -#[no_mangle] -/// Frees any resources associated with the crate::c_types::U128, if we are in the Some state -pub extern "C" fn COption_U128Z_free(_res: COption_U128Z) { } -#[no_mangle] -/// Creates a new COption_U128Z which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_U128Z_clone(orig: &COption_U128Z) -> COption_U128Z { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::events::ClaimedHTLCs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ClaimedHTLCZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::events::ClaimedHTLC, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ClaimedHTLCZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::events::ClaimedHTLC] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ClaimedHTLCZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ClaimedHTLCZ_free(_res: CVec_ClaimedHTLCZ) { } -impl Drop for CVec_ClaimedHTLCZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ClaimedHTLCZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::PaymentFailureReason or not -pub enum COption_PaymentFailureReasonZ { - /// When we're in this state, this COption_PaymentFailureReasonZ contains a crate::lightning::events::PaymentFailureReason - Some(crate::lightning::events::PaymentFailureReason), - /// When we're in this state, this COption_PaymentFailureReasonZ contains nothing - None -} -impl COption_PaymentFailureReasonZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::PaymentFailureReason { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing a crate::lightning::events::PaymentFailureReason -pub extern "C" fn COption_PaymentFailureReasonZ_some(o: crate::lightning::events::PaymentFailureReason) -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_PaymentFailureReasonZ containing nothing -pub extern "C" fn COption_PaymentFailureReasonZ_none() -> COption_PaymentFailureReasonZ { - COption_PaymentFailureReasonZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::PaymentFailureReason, if we are in the Some state -pub extern "C" fn COption_PaymentFailureReasonZ_free(_res: COption_PaymentFailureReasonZ) { } -#[no_mangle] -/// Creates a new COption_PaymentFailureReasonZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_PaymentFailureReasonZ_clone(orig: &COption_PaymentFailureReasonZ) -> COption_PaymentFailureReasonZ { Clone::clone(&orig) } -#[repr(C)] -#[derive(Clone)] -/// An enum which can either contain a crate::lightning::events::Event or not -pub enum COption_EventZ { - /// When we're in this state, this COption_EventZ contains a crate::lightning::events::Event - Some(crate::lightning::events::Event), - /// When we're in this state, this COption_EventZ contains nothing - None -} -impl COption_EventZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::events::Event { - if let Self::Some(v) = self { v } else { unreachable!() } + } } + } } } #[no_mangle] -/// Constructs a new COption_EventZ containing a crate::lightning::events::Event -pub extern "C" fn COption_EventZ_some(o: crate::lightning::events::Event) -> COption_EventZ { - COption_EventZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_EventZ containing nothing -pub extern "C" fn COption_EventZ_none() -> COption_EventZ { - COption_EventZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::events::Event, if we are in the Some state -pub extern "C" fn COption_EventZ_free(_res: COption_EventZ) { } -#[no_mangle] -/// Creates a new COption_EventZ which has the same data as `orig` +/// Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn COption_EventZ_clone(orig: &COption_EventZ) -> COption_EventZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_COption_EventZDecodeErrorZ -pub union CResult_COption_EventZDecodeErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedNoneZ +pub union CResult_TransactionU16LenLimitedNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::COption_EventZ, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_COption_EventZDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::COption_EventZ on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_COption_EventZDecodeErrorZ { - /// The contents of this CResult_COption_EventZDecodeErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedNoneZ { + /// The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_COption_EventZDecodeErrorZPtr, - /// Whether this CResult_COption_EventZDecodeErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedNoneZPtr, + /// Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the success state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_ok(o: crate::c_types::derived::COption_EventZ) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ in the error state. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_COption_EventZDecodeErrorZ { - CResult_COption_EventZDecodeErrorZ { - contents: CResult_COption_EventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_err() -> CResult_TransactionU16LenLimitedNoneZ { + CResult_TransactionU16LenLimitedNoneZ { + contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_is_ok(o: &CResult_COption_EventZDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_is_ok(o: &CResult_TransactionU16LenLimitedNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_COption_EventZDecodeErrorZ. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_free(_res: CResult_COption_EventZDecodeErrorZ) { } -impl Drop for CResult_COption_EventZDecodeErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_free(_res: CResult_TransactionU16LenLimitedNoneZ) { } +impl Drop for CResult_TransactionU16LenLimitedNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_COption_EventZDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_COption_EventZDecodeErrorZPtr { result } + CResult_TransactionU16LenLimitedNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_COption_EventZDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_TransactionU16LenLimitedNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -21758,59 +26575,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_COption_EventZDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_COption_EventZDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_COption_EventZDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_COption_EventZDecodeErrorZ_clone(orig: &CResult_COption_EventZDecodeErrorZ) -> CResult_COption_EventZDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SiPrefixBolt11ParseErrorZ -pub union CResult_SiPrefixBolt11ParseErrorZPtr { +/// The contents of CResult_TransactionU16LenLimitedDecodeErrorZ +pub union CResult_TransactionU16LenLimitedDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SiPrefix, + pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::Bolt11ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SiPrefixBolt11ParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SiPrefix on success and a crate::lightning_invoice::Bolt11ParseError on failure. +/// A CResult_TransactionU16LenLimitedDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SiPrefixBolt11ParseErrorZ { - /// The contents of this CResult_SiPrefixBolt11ParseErrorZ, accessible via either +pub struct CResult_TransactionU16LenLimitedDecodeErrorZ { + /// The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SiPrefixBolt11ParseErrorZPtr, - /// Whether this CResult_SiPrefixBolt11ParseErrorZ represents a success state. + pub contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr, + /// Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the success state. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SiPrefix) -> CResult_SiPrefixBolt11ParseErrorZ { - CResult_SiPrefixBolt11ParseErrorZ { - contents: CResult_SiPrefixBolt11ParseErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the success state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SiPrefixBolt11ParseErrorZ in the error state. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SiPrefixBolt11ParseErrorZ { - CResult_SiPrefixBolt11ParseErrorZ { - contents: CResult_SiPrefixBolt11ParseErrorZPtr { +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the error state. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TransactionU16LenLimitedDecodeErrorZ { + CResult_TransactionU16LenLimitedDecodeErrorZ { + contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21818,13 +26635,13 @@ pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_err(e: crate::lightning_invo } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_is_ok(o: &CResult_SiPrefixBolt11ParseErrorZ) -> bool { +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SiPrefixBolt11ParseErrorZ. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_free(_res: CResult_SiPrefixBolt11ParseErrorZ) { } -impl Drop for CResult_SiPrefixBolt11ParseErrorZ { +/// Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res: CResult_TransactionU16LenLimitedDecodeErrorZ) { } +impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21837,16 +26654,16 @@ impl Drop for CResult_SiPrefixBolt11ParseErrorZ { } } } -impl From> for CResult_SiPrefixBolt11ParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TransactionU16LenLimitedDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SiPrefixBolt11ParseErrorZPtr { result } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SiPrefixBolt11ParseErrorZPtr { err } + CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } }; Self { contents, @@ -21854,59 +26671,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SiPrefixBolt11ParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SiPrefixBolt11ParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SiPrefixBolt11ParseErrorZ which has the same data as `orig` +/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SiPrefixBolt11ParseErrorZ_clone(orig: &CResult_SiPrefixBolt11ParseErrorZ) -> CResult_SiPrefixBolt11ParseErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceParseOrSemanticErrorZ -pub union CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// The contents of CResult_ChannelIdDecodeErrorZ +pub union CResult_ChannelIdDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Bolt11Invoice, + pub result: *mut crate::lightning::ln::types::ChannelId, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::ParseOrSemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_Bolt11InvoiceParseOrSemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::ParseOrSemanticError on failure. +/// A CResult_ChannelIdDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::types::ChannelId on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_Bolt11InvoiceParseOrSemanticErrorZ { - /// The contents of this CResult_Bolt11InvoiceParseOrSemanticErrorZ, accessible via either +pub struct CResult_ChannelIdDecodeErrorZ { + /// The contents of this CResult_ChannelIdDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr, - /// Whether this CResult_Bolt11InvoiceParseOrSemanticErrorZ represents a success state. + pub contents: CResult_ChannelIdDecodeErrorZPtr, + /// Whether this CResult_ChannelIdDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { - CResult_Bolt11InvoiceParseOrSemanticErrorZ { - contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_ChannelIdDecodeErrorZ in the success state. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_ok(o: crate::lightning::ln::types::ChannelId) -> CResult_ChannelIdDecodeErrorZ { + CResult_ChannelIdDecodeErrorZ { + contents: CResult_ChannelIdDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::lightning_invoice::ParseOrSemanticError) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { - CResult_Bolt11InvoiceParseOrSemanticErrorZ { - contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { +/// Creates a new CResult_ChannelIdDecodeErrorZ in the error state. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ChannelIdDecodeErrorZ { + CResult_ChannelIdDecodeErrorZ { + contents: CResult_ChannelIdDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -21914,13 +26731,13 @@ pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e: crate::light } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> bool { +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_is_ok(o: &CResult_ChannelIdDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_Bolt11InvoiceParseOrSemanticErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res: CResult_Bolt11InvoiceParseOrSemanticErrorZ) { } -impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { +/// Frees any resources used by the CResult_ChannelIdDecodeErrorZ. +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_free(_res: CResult_ChannelIdDecodeErrorZ) { } +impl Drop for CResult_ChannelIdDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -21933,16 +26750,16 @@ impl Drop for CResult_Bolt11InvoiceParseOrSemanticErrorZ { } } } -impl From> for CResult_Bolt11InvoiceParseOrSemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ChannelIdDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { result } + CResult_ChannelIdDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { err } + CResult_ChannelIdDecodeErrorZPtr { err } }; Self { contents, @@ -21950,59 +26767,101 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ChannelIdDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_Bolt11InvoiceParseOrSemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_ChannelIdDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceParseOrSemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_ChannelIdDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceParseOrSemanticErrorZ) -> CResult_Bolt11InvoiceParseOrSemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ChannelIdDecodeErrorZ_clone(orig: &CResult_ChannelIdDecodeErrorZ) -> CResult_ChannelIdDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ -pub union CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple__u832u16Z { + /// The element at position 0 + pub a: crate::c_types::ThirtyTwoBytes, + /// The element at position 1 + pub b: u16, +} +impl From<(crate::c_types::ThirtyTwoBytes, u16)> for C2Tuple__u832u16Z { + fn from (tup: (crate::c_types::ThirtyTwoBytes, u16)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple__u832u16Z { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u16) { + (self.a, self.b) + } +} +impl Clone for C2Tuple__u832u16Z { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple__u832u16Z_clone(orig: &C2Tuple__u832u16Z) -> C2Tuple__u832u16Z { Clone::clone(&orig) } +/// Creates a new C2Tuple__u832u16Z from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple__u832u16Z_new(a: crate::c_types::ThirtyTwoBytes, b: u16) -> C2Tuple__u832u16Z { + C2Tuple__u832u16Z { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple__u832u16Z. +pub extern "C" fn C2Tuple__u832u16Z_free(_res: C2Tuple__u832u16Z) { } +#[repr(C)] +/// The contents of CResult_BlindedPayInfoDecodeErrorZ +pub union CResult_BlindedPayInfoDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::SignedRawBolt11Invoice, + pub result: *mut crate::lightning::blinded_path::payment::BlindedPayInfo, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::Bolt11ParseError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::SignedRawBolt11Invoice on success and a crate::lightning_invoice::Bolt11ParseError on failure. +/// A CResult_BlindedPayInfoDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::BlindedPayInfo on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - /// The contents of this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ, accessible via either +pub struct CResult_BlindedPayInfoDecodeErrorZ { + /// The contents of this CResult_BlindedPayInfoDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr, - /// Whether this CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ represents a success state. + pub contents: CResult_BlindedPayInfoDecodeErrorZPtr, + /// Whether this CResult_BlindedPayInfoDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the success state. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o: crate::lightning_invoice::SignedRawBolt11Invoice) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::BlindedPayInfo) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ in the error state. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate::lightning_invoice::Bolt11ParseError) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPayInfoDecodeErrorZ { + CResult_BlindedPayInfoDecodeErrorZ { + contents: CResult_BlindedPayInfoDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22010,13 +26869,13 @@ pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e: crate:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_is_ok(o: &CResult_BlindedPayInfoDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) { } -impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { +/// Frees any resources used by the CResult_BlindedPayInfoDecodeErrorZ. +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_free(_res: CResult_BlindedPayInfoDecodeErrorZ) { } +impl Drop for CResult_BlindedPayInfoDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22029,16 +26888,16 @@ impl Drop for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { } } } -impl From> for CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedPayInfoDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { result } + CResult_BlindedPayInfoDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { err } + CResult_BlindedPayInfoDecodeErrorZPtr { err } }; Self { contents, @@ -22046,141 +26905,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_SignedRawBolt11InvoiceBolt11ParseErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedPayInfoDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig: &CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ) -> CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { - /// The element at position 0 - pub a: crate::lightning_invoice::RawBolt11Invoice, - /// The element at position 1 - pub b: crate::c_types::ThirtyTwoBytes, - /// The element at position 2 - pub c: crate::lightning_invoice::Bolt11InvoiceSignature, -} -impl From<(crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)> for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { - fn from (tup: (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning_invoice::RawBolt11Invoice, crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::Bolt11InvoiceSignature) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_BlindedPayInfoDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig: &C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a: crate::lightning_invoice::RawBolt11Invoice, b: crate::c_types::ThirtyTwoBytes, c: crate::lightning_invoice::Bolt11InvoiceSignature) -> C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { - C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ. -pub extern "C" fn C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res: C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ) { } +pub extern "C" fn CResult_BlindedPayInfoDecodeErrorZ_clone(orig: &CResult_BlindedPayInfoDecodeErrorZ) -> CResult_BlindedPayInfoDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PayeePubKeySecp256k1ErrorZ -pub union CResult_PayeePubKeySecp256k1ErrorZPtr { +/// The contents of CResult_BlindedPaymentPathNoneZ +pub union CResult_BlindedPaymentPathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PayeePubKey, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub result: *mut crate::lightning::blinded_path::payment::BlindedPaymentPath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_PayeePubKeySecp256k1ErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PayeePubKey on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_BlindedPaymentPathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::BlindedPaymentPath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PayeePubKeySecp256k1ErrorZ { - /// The contents of this CResult_PayeePubKeySecp256k1ErrorZ, accessible via either +pub struct CResult_BlindedPaymentPathNoneZ { + /// The contents of this CResult_BlindedPaymentPathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PayeePubKeySecp256k1ErrorZPtr, - /// Whether this CResult_PayeePubKeySecp256k1ErrorZ represents a success state. + pub contents: CResult_BlindedPaymentPathNoneZPtr, + /// Whether this CResult_BlindedPaymentPathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the success state. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_ok(o: crate::lightning_invoice::PayeePubKey) -> CResult_PayeePubKeySecp256k1ErrorZ { - CResult_PayeePubKeySecp256k1ErrorZ { - contents: CResult_PayeePubKeySecp256k1ErrorZPtr { +/// Creates a new CResult_BlindedPaymentPathNoneZ in the success state. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_ok(o: crate::lightning::blinded_path::payment::BlindedPaymentPath) -> CResult_BlindedPaymentPathNoneZ { + CResult_BlindedPaymentPathNoneZ { + contents: CResult_BlindedPaymentPathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ in the error state. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_PayeePubKeySecp256k1ErrorZ { - CResult_PayeePubKeySecp256k1ErrorZ { - contents: CResult_PayeePubKeySecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_BlindedPaymentPathNoneZ in the error state. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_err() -> CResult_BlindedPaymentPathNoneZ { + CResult_BlindedPaymentPathNoneZ { + contents: CResult_BlindedPaymentPathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_is_ok(o: &CResult_PayeePubKeySecp256k1ErrorZ) -> bool { +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_is_ok(o: &CResult_BlindedPaymentPathNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PayeePubKeySecp256k1ErrorZ. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_free(_res: CResult_PayeePubKeySecp256k1ErrorZ) { } -impl Drop for CResult_PayeePubKeySecp256k1ErrorZ { +/// Frees any resources used by the CResult_BlindedPaymentPathNoneZ. +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_free(_res: CResult_BlindedPaymentPathNoneZ) { } +impl Drop for CResult_BlindedPaymentPathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_PayeePubKeySecp256k1ErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedPaymentPathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PayeePubKeySecp256k1ErrorZPtr { result } + CResult_BlindedPaymentPathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PayeePubKeySecp256k1ErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedPaymentPathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -22188,47 +26997,47 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedPaymentPathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PayeePubKeySecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedPaymentPathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_PayeePubKeySecp256k1ErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedPaymentPathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PayeePubKeySecp256k1ErrorZ_clone(orig: &CResult_PayeePubKeySecp256k1ErrorZ) -> CResult_PayeePubKeySecp256k1ErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedPaymentPathNoneZ_clone(orig: &CResult_BlindedPaymentPathNoneZ) -> CResult_BlindedPaymentPathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// A dynamically-allocated array of crate::lightning_invoice::PrivateRoutes of arbitrary size. +/// A dynamically-allocated array of crate::lightning::blinded_path::payment::PaymentForwardNodes of arbitrary size. /// This corresponds to std::vector in C++ -pub struct CVec_PrivateRouteZ { +pub struct CVec_PaymentForwardNodeZ { /// The elements in the array. /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning_invoice::PrivateRoute, + pub data: *mut crate::lightning::blinded_path::payment::PaymentForwardNode, /// The number of elements pointed to by `data`. pub datalen: usize } -impl CVec_PrivateRouteZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { +impl CVec_PaymentForwardNodeZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { if self.datalen == 0 { return Vec::new(); } let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); self.data = core::ptr::null_mut(); self.datalen = 0; ret } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] { + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::payment::PaymentForwardNode] { unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl From> for CVec_PrivateRouteZ { - fn from(v: Vec) -> Self { +impl From> for CVec_PaymentForwardNodeZ { + fn from(v: Vec) -> Self { let datalen = v.len(); let data = Box::into_raw(v.into_boxed_slice()); Self { datalen, data: unsafe { (*data).as_mut_ptr() } } @@ -22236,14 +27045,14 @@ impl From> for CVec_PrivateRouteZ { } #[no_mangle] /// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_PrivateRouteZ_free(_res: CVec_PrivateRouteZ) { } -impl Drop for CVec_PrivateRouteZ { +pub extern "C" fn CVec_PaymentForwardNodeZ_free(_res: CVec_PaymentForwardNodeZ) { } +impl Drop for CVec_PaymentForwardNodeZ { fn drop(&mut self) { if self.datalen == 0 { return; } let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl Clone for CVec_PrivateRouteZ { +impl Clone for CVec_PaymentForwardNodeZ { fn clone(&self) -> Self { let mut res = Vec::new(); if self.datalen == 0 { return Self::from(res); } @@ -22252,41 +27061,41 @@ impl Clone for CVec_PrivateRouteZ { } } #[repr(C)] -/// The contents of CResult_PositiveTimestampCreationErrorZ -pub union CResult_PositiveTimestampCreationErrorZPtr { +/// The contents of CResult_PaymentRelayDecodeErrorZ +pub union CResult_PaymentRelayDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PositiveTimestamp, + pub result: *mut crate::lightning::blinded_path::payment::PaymentRelay, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PositiveTimestampCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PositiveTimestamp on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_PaymentRelayDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentRelay on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PositiveTimestampCreationErrorZ { - /// The contents of this CResult_PositiveTimestampCreationErrorZ, accessible via either +pub struct CResult_PaymentRelayDecodeErrorZ { + /// The contents of this CResult_PaymentRelayDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PositiveTimestampCreationErrorZPtr, - /// Whether this CResult_PositiveTimestampCreationErrorZ represents a success state. + pub contents: CResult_PaymentRelayDecodeErrorZPtr, + /// Whether this CResult_PaymentRelayDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the success state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_ok(o: crate::lightning_invoice::PositiveTimestamp) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentRelay) -> CResult_PaymentRelayDecodeErrorZ { + CResult_PaymentRelayDecodeErrorZ { + contents: CResult_PaymentRelayDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ in the error state. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PositiveTimestampCreationErrorZ { - CResult_PositiveTimestampCreationErrorZ { - contents: CResult_PositiveTimestampCreationErrorZPtr { +/// Creates a new CResult_PaymentRelayDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentRelayDecodeErrorZ { + CResult_PaymentRelayDecodeErrorZ { + contents: CResult_PaymentRelayDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22294,13 +27103,13 @@ pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_err(e: crate::lightnin } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_is_ok(o: &CResult_PositiveTimestampCreationErrorZ) -> bool { +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_is_ok(o: &CResult_PaymentRelayDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PositiveTimestampCreationErrorZ. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_free(_res: CResult_PositiveTimestampCreationErrorZ) { } -impl Drop for CResult_PositiveTimestampCreationErrorZ { +/// Frees any resources used by the CResult_PaymentRelayDecodeErrorZ. +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_free(_res: CResult_PaymentRelayDecodeErrorZ) { } +impl Drop for CResult_PaymentRelayDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22313,16 +27122,16 @@ impl Drop for CResult_PositiveTimestampCreationErrorZ { } } } -impl From> for CResult_PositiveTimestampCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentRelayDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PositiveTimestampCreationErrorZPtr { result } + CResult_PaymentRelayDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PositiveTimestampCreationErrorZPtr { err } + CResult_PaymentRelayDecodeErrorZPtr { err } }; Self { contents, @@ -22330,58 +27139,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PositiveTimestampCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentRelayDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PositiveTimestampCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentRelayDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PositiveTimestampCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentRelayDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PositiveTimestampCreationErrorZ_clone(orig: &CResult_PositiveTimestampCreationErrorZ) -> CResult_PositiveTimestampCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_clone(orig: &CResult_PaymentRelayDecodeErrorZ) -> CResult_PaymentRelayDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_NoneBolt11SemanticErrorZ -pub union CResult_NoneBolt11SemanticErrorZPtr { - /// Note that this value is always NULL, as there are no contents in the OK variant - pub result: *mut core::ffi::c_void, +/// The contents of CResult_PaymentConstraintsDecodeErrorZ +pub union CResult_PaymentConstraintsDecodeErrorZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::lightning::blinded_path::payment::PaymentConstraints, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::Bolt11SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_NoneBolt11SemanticErrorZ represents the result of a fallible operation, -/// containing a () on success and a crate::lightning_invoice::Bolt11SemanticError on failure. +/// A CResult_PaymentConstraintsDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentConstraints on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_NoneBolt11SemanticErrorZ { - /// The contents of this CResult_NoneBolt11SemanticErrorZ, accessible via either +pub struct CResult_PaymentConstraintsDecodeErrorZ { + /// The contents of this CResult_PaymentConstraintsDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_NoneBolt11SemanticErrorZPtr, - /// Whether this CResult_NoneBolt11SemanticErrorZ represents a success state. + pub contents: CResult_PaymentConstraintsDecodeErrorZPtr, + /// Whether this CResult_PaymentConstraintsDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_NoneBolt11SemanticErrorZ in the success state. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_ok() -> CResult_NoneBolt11SemanticErrorZ { - CResult_NoneBolt11SemanticErrorZ { - contents: CResult_NoneBolt11SemanticErrorZPtr { - result: core::ptr::null_mut(), +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentConstraints) -> CResult_PaymentConstraintsDecodeErrorZ { + CResult_PaymentConstraintsDecodeErrorZ { + contents: CResult_PaymentConstraintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_NoneBolt11SemanticErrorZ in the error state. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_NoneBolt11SemanticErrorZ { - CResult_NoneBolt11SemanticErrorZ { - contents: CResult_NoneBolt11SemanticErrorZPtr { +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentConstraintsDecodeErrorZ { + CResult_PaymentConstraintsDecodeErrorZ { + contents: CResult_PaymentConstraintsDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22389,15 +27199,18 @@ pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_err(e: crate::lightning_invoi } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_is_ok(o: &CResult_NoneBolt11SemanticErrorZ) -> bool { +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_is_ok(o: &CResult_PaymentConstraintsDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_NoneBolt11SemanticErrorZ. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_free(_res: CResult_NoneBolt11SemanticErrorZ) { } -impl Drop for CResult_NoneBolt11SemanticErrorZ { +/// Frees any resources used by the CResult_PaymentConstraintsDecodeErrorZ. +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_free(_res: CResult_PaymentConstraintsDecodeErrorZ) { } +impl Drop for CResult_PaymentConstraintsDecodeErrorZ { fn drop(&mut self) { if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -22405,16 +27218,16 @@ impl Drop for CResult_NoneBolt11SemanticErrorZ { } } } -impl From> for CResult_NoneBolt11SemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::Bolt11SemanticError>) -> Self { +impl From> for CResult_PaymentConstraintsDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { - let _ = unsafe { Box::from_raw(o.contents.result) }; - o.contents.result = core::ptr::null_mut(); - CResult_NoneBolt11SemanticErrorZPtr { result: core::ptr::null_mut() } + let result = unsafe { o.contents.result }; + unsafe { o.contents.result = core::ptr::null_mut() }; + CResult_PaymentConstraintsDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_NoneBolt11SemanticErrorZPtr { err } + CResult_PaymentConstraintsDecodeErrorZPtr { err } }; Self { contents, @@ -22422,59 +27235,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_NoneBolt11SemanticErrorZPtr { - result: core::ptr::null_mut() + Self { result_ok: true, contents: CResult_PaymentConstraintsDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_NoneBolt11SemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentConstraintsDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_NoneBolt11SemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentConstraintsDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_NoneBolt11SemanticErrorZ_clone(orig: &CResult_NoneBolt11SemanticErrorZ) -> CResult_NoneBolt11SemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_clone(orig: &CResult_PaymentConstraintsDecodeErrorZ) -> CResult_PaymentConstraintsDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_Bolt11InvoiceBolt11SemanticErrorZ -pub union CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +/// The contents of CResult_PaymentContextDecodeErrorZ +pub union CResult_PaymentContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Bolt11Invoice, + pub result: *mut crate::lightning::blinded_path::payment::PaymentContext, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::Bolt11SemanticError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_Bolt11InvoiceBolt11SemanticErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::Bolt11SemanticError on failure. +/// A CResult_PaymentContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::PaymentContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_Bolt11InvoiceBolt11SemanticErrorZ { - /// The contents of this CResult_Bolt11InvoiceBolt11SemanticErrorZ, accessible via either +pub struct CResult_PaymentContextDecodeErrorZ { + /// The contents of this CResult_PaymentContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr, - /// Whether this CResult_Bolt11InvoiceBolt11SemanticErrorZ represents a success state. + pub contents: CResult_PaymentContextDecodeErrorZPtr, + /// Whether this CResult_PaymentContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the success state. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { - CResult_Bolt11InvoiceBolt11SemanticErrorZ { - contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +/// Creates a new CResult_PaymentContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentContext) -> CResult_PaymentContextDecodeErrorZ { + CResult_PaymentContextDecodeErrorZ { + contents: CResult_PaymentContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ in the error state. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightning_invoice::Bolt11SemanticError) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { - CResult_Bolt11InvoiceBolt11SemanticErrorZ { - contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { +/// Creates a new CResult_PaymentContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentContextDecodeErrorZ { + CResult_PaymentContextDecodeErrorZ { + contents: CResult_PaymentContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22482,13 +27295,13 @@ pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e: crate::lightn } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> bool { +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_is_ok(o: &CResult_PaymentContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_Bolt11InvoiceBolt11SemanticErrorZ. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res: CResult_Bolt11InvoiceBolt11SemanticErrorZ) { } -impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { +/// Frees any resources used by the CResult_PaymentContextDecodeErrorZ. +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_free(_res: CResult_PaymentContextDecodeErrorZ) { } +impl Drop for CResult_PaymentContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22501,16 +27314,16 @@ impl Drop for CResult_Bolt11InvoiceBolt11SemanticErrorZ { } } } -impl From> for CResult_Bolt11InvoiceBolt11SemanticErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PaymentContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { result } + CResult_PaymentContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { err } + CResult_PaymentContextDecodeErrorZPtr { err } }; Self { contents, @@ -22518,59 +27331,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PaymentContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_Bolt11InvoiceBolt11SemanticErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PaymentContextDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_Bolt11InvoiceBolt11SemanticErrorZ which has the same data as `orig` +/// Creates a new CResult_PaymentContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig: &CResult_Bolt11InvoiceBolt11SemanticErrorZ) -> CResult_Bolt11InvoiceBolt11SemanticErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PaymentContextDecodeErrorZ_clone(orig: &CResult_PaymentContextDecodeErrorZ) -> CResult_PaymentContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DescriptionCreationErrorZ -pub union CResult_DescriptionCreationErrorZPtr { +/// The contents of CResult_UnknownPaymentContextDecodeErrorZ +pub union CResult_UnknownPaymentContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::Description, + pub result: *mut crate::lightning::blinded_path::payment::UnknownPaymentContext, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_DescriptionCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::Description on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_UnknownPaymentContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::UnknownPaymentContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DescriptionCreationErrorZ { - /// The contents of this CResult_DescriptionCreationErrorZ, accessible via either +pub struct CResult_UnknownPaymentContextDecodeErrorZ { + /// The contents of this CResult_UnknownPaymentContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DescriptionCreationErrorZPtr, - /// Whether this CResult_DescriptionCreationErrorZ represents a success state. + pub contents: CResult_UnknownPaymentContextDecodeErrorZPtr, + /// Whether this CResult_UnknownPaymentContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the success state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_ok(o: crate::lightning_invoice::Description) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::UnknownPaymentContext) -> CResult_UnknownPaymentContextDecodeErrorZ { + CResult_UnknownPaymentContextDecodeErrorZ { + contents: CResult_UnknownPaymentContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ in the error state. -pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_DescriptionCreationErrorZ { - CResult_DescriptionCreationErrorZ { - contents: CResult_DescriptionCreationErrorZPtr { +/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UnknownPaymentContextDecodeErrorZ { + CResult_UnknownPaymentContextDecodeErrorZ { + contents: CResult_UnknownPaymentContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22578,13 +27391,13 @@ pub extern "C" fn CResult_DescriptionCreationErrorZ_err(e: crate::lightning_invo } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DescriptionCreationErrorZ_is_ok(o: &CResult_DescriptionCreationErrorZ) -> bool { +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_is_ok(o: &CResult_UnknownPaymentContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DescriptionCreationErrorZ. -pub extern "C" fn CResult_DescriptionCreationErrorZ_free(_res: CResult_DescriptionCreationErrorZ) { } -impl Drop for CResult_DescriptionCreationErrorZ { +/// Frees any resources used by the CResult_UnknownPaymentContextDecodeErrorZ. +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_free(_res: CResult_UnknownPaymentContextDecodeErrorZ) { } +impl Drop for CResult_UnknownPaymentContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22597,16 +27410,16 @@ impl Drop for CResult_DescriptionCreationErrorZ { } } } -impl From> for CResult_DescriptionCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_UnknownPaymentContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DescriptionCreationErrorZPtr { result } + CResult_UnknownPaymentContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DescriptionCreationErrorZPtr { err } + CResult_UnknownPaymentContextDecodeErrorZPtr { err } }; Self { contents, @@ -22614,59 +27427,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DescriptionCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DescriptionCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_UnknownPaymentContextDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DescriptionCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_UnknownPaymentContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DescriptionCreationErrorZ_clone(orig: &CResult_DescriptionCreationErrorZ) -> CResult_DescriptionCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_UnknownPaymentContextDecodeErrorZ_clone(orig: &CResult_UnknownPaymentContextDecodeErrorZ) -> CResult_UnknownPaymentContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PrivateRouteCreationErrorZ -pub union CResult_PrivateRouteCreationErrorZPtr { +/// The contents of CResult_Bolt12OfferContextDecodeErrorZ +pub union CResult_Bolt12OfferContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning_invoice::PrivateRoute, + pub result: *mut crate::lightning::blinded_path::payment::Bolt12OfferContext, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning_invoice::CreationError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PrivateRouteCreationErrorZ represents the result of a fallible operation, -/// containing a crate::lightning_invoice::PrivateRoute on success and a crate::lightning_invoice::CreationError on failure. +/// A CResult_Bolt12OfferContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::Bolt12OfferContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PrivateRouteCreationErrorZ { - /// The contents of this CResult_PrivateRouteCreationErrorZ, accessible via either +pub struct CResult_Bolt12OfferContextDecodeErrorZ { + /// The contents of this CResult_Bolt12OfferContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PrivateRouteCreationErrorZPtr, - /// Whether this CResult_PrivateRouteCreationErrorZ represents a success state. + pub contents: CResult_Bolt12OfferContextDecodeErrorZPtr, + /// Whether this CResult_Bolt12OfferContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the success state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_ok(o: crate::lightning_invoice::PrivateRoute) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12OfferContext) -> CResult_Bolt12OfferContextDecodeErrorZ { + CResult_Bolt12OfferContextDecodeErrorZ { + contents: CResult_Bolt12OfferContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ in the error state. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_invoice::CreationError) -> CResult_PrivateRouteCreationErrorZ { - CResult_PrivateRouteCreationErrorZ { - contents: CResult_PrivateRouteCreationErrorZPtr { +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12OfferContextDecodeErrorZ { + CResult_Bolt12OfferContextDecodeErrorZ { + contents: CResult_Bolt12OfferContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22674,13 +27487,13 @@ pub extern "C" fn CResult_PrivateRouteCreationErrorZ_err(e: crate::lightning_inv } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_is_ok(o: &CResult_PrivateRouteCreationErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_is_ok(o: &CResult_Bolt12OfferContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PrivateRouteCreationErrorZ. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_free(_res: CResult_PrivateRouteCreationErrorZ) { } -impl Drop for CResult_PrivateRouteCreationErrorZ { +/// Frees any resources used by the CResult_Bolt12OfferContextDecodeErrorZ. +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_free(_res: CResult_Bolt12OfferContextDecodeErrorZ) { } +impl Drop for CResult_Bolt12OfferContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22693,16 +27506,16 @@ impl Drop for CResult_PrivateRouteCreationErrorZ { } } } -impl From> for CResult_PrivateRouteCreationErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12OfferContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PrivateRouteCreationErrorZPtr { result } + CResult_Bolt12OfferContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PrivateRouteCreationErrorZPtr { err } + CResult_Bolt12OfferContextDecodeErrorZPtr { err } }; Self { contents, @@ -22710,59 +27523,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PrivateRouteCreationErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PrivateRouteCreationErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_Bolt12OfferContextDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PrivateRouteCreationErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12OfferContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PrivateRouteCreationErrorZ_clone(orig: &CResult_PrivateRouteCreationErrorZ) -> CResult_PrivateRouteCreationErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12OfferContextDecodeErrorZ_clone(orig: &CResult_Bolt12OfferContextDecodeErrorZ) -> CResult_Bolt12OfferContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_OutPointDecodeErrorZ -pub union CResult_OutPointDecodeErrorZPtr { +/// The contents of CResult_Bolt12RefundContextDecodeErrorZ +pub union CResult_Bolt12RefundContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::transaction::OutPoint, + pub result: *mut crate::lightning::blinded_path::payment::Bolt12RefundContext, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_OutPointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::transaction::OutPoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_Bolt12RefundContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::payment::Bolt12RefundContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_OutPointDecodeErrorZ { - /// The contents of this CResult_OutPointDecodeErrorZ, accessible via either +pub struct CResult_Bolt12RefundContextDecodeErrorZ { + /// The contents of this CResult_Bolt12RefundContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_OutPointDecodeErrorZPtr, - /// Whether this CResult_OutPointDecodeErrorZ represents a success state. + pub contents: CResult_Bolt12RefundContextDecodeErrorZPtr, + /// Whether this CResult_Bolt12RefundContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the success state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_ok(o: crate::lightning::chain::transaction::OutPoint) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::Bolt12RefundContext) -> CResult_Bolt12RefundContextDecodeErrorZ { + CResult_Bolt12RefundContextDecodeErrorZ { + contents: CResult_Bolt12RefundContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ in the error state. -pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutPointDecodeErrorZ { - CResult_OutPointDecodeErrorZ { - contents: CResult_OutPointDecodeErrorZPtr { +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_Bolt12RefundContextDecodeErrorZ { + CResult_Bolt12RefundContextDecodeErrorZ { + contents: CResult_Bolt12RefundContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22770,13 +27583,13 @@ pub extern "C" fn CResult_OutPointDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_OutPointDecodeErrorZ_is_ok(o: &CResult_OutPointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_is_ok(o: &CResult_Bolt12RefundContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_OutPointDecodeErrorZ. -pub extern "C" fn CResult_OutPointDecodeErrorZ_free(_res: CResult_OutPointDecodeErrorZ) { } -impl Drop for CResult_OutPointDecodeErrorZ { +/// Frees any resources used by the CResult_Bolt12RefundContextDecodeErrorZ. +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_free(_res: CResult_Bolt12RefundContextDecodeErrorZ) { } +impl Drop for CResult_Bolt12RefundContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22789,16 +27602,16 @@ impl Drop for CResult_OutPointDecodeErrorZ { } } } -impl From> for CResult_OutPointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt12RefundContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_OutPointDecodeErrorZPtr { result } + CResult_Bolt12RefundContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_OutPointDecodeErrorZPtr { err } + CResult_Bolt12RefundContextDecodeErrorZPtr { err } }; Self { contents, @@ -22806,59 +27619,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_OutPointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_OutPointDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_Bolt12RefundContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_OutPointDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_Bolt12RefundContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_OutPointDecodeErrorZ_clone(orig: &CResult_OutPointDecodeErrorZ) -> CResult_OutPointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt12RefundContextDecodeErrorZ_clone(orig: &CResult_Bolt12RefundContextDecodeErrorZ) -> CResult_Bolt12RefundContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BigSizeDecodeErrorZ -pub union CResult_BigSizeDecodeErrorZPtr { +/// The contents of CResult_TxOutUtxoLookupErrorZ +pub union CResult_TxOutUtxoLookupErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::ser::BigSize, + pub result: *mut crate::c_types::TxOut, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, } #[repr(C)] -/// A CResult_BigSizeDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::ser::BigSize on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BigSizeDecodeErrorZ { - /// The contents of this CResult_BigSizeDecodeErrorZ, accessible via either +pub struct CResult_TxOutUtxoLookupErrorZ { + /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BigSizeDecodeErrorZPtr, - /// Whether this CResult_BigSizeDecodeErrorZ represents a success state. + pub contents: CResult_TxOutUtxoLookupErrorZPtr, + /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BigSizeDecodeErrorZ in the success state. -pub extern "C" fn CResult_BigSizeDecodeErrorZ_ok(o: crate::lightning::util::ser::BigSize) -> CResult_BigSizeDecodeErrorZ { - CResult_BigSizeDecodeErrorZ { - contents: CResult_BigSizeDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BigSizeDecodeErrorZ in the error state. -pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BigSizeDecodeErrorZ { - CResult_BigSizeDecodeErrorZ { - contents: CResult_BigSizeDecodeErrorZPtr { +/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { + CResult_TxOutUtxoLookupErrorZ { + contents: CResult_TxOutUtxoLookupErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22866,13 +27679,13 @@ pub extern "C" fn CResult_BigSizeDecodeErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BigSizeDecodeErrorZ_is_ok(o: &CResult_BigSizeDecodeErrorZ) -> bool { +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BigSizeDecodeErrorZ. -pub extern "C" fn CResult_BigSizeDecodeErrorZ_free(_res: CResult_BigSizeDecodeErrorZ) { } -impl Drop for CResult_BigSizeDecodeErrorZ { +/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } +impl Drop for CResult_TxOutUtxoLookupErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22885,16 +27698,16 @@ impl Drop for CResult_BigSizeDecodeErrorZ { } } } -impl From> for CResult_BigSizeDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TxOutUtxoLookupErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BigSizeDecodeErrorZPtr { result } + CResult_TxOutUtxoLookupErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BigSizeDecodeErrorZPtr { err } + CResult_TxOutUtxoLookupErrorZPtr { err } }; Self { contents, @@ -22902,59 +27715,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BigSizeDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BigSizeDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BigSizeDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BigSizeDecodeErrorZ_clone(orig: &CResult_BigSizeDecodeErrorZ) -> CResult_BigSizeDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HostnameDecodeErrorZ -pub union CResult_HostnameDecodeErrorZPtr { +/// The contents of CResult_ResponderDecodeErrorZ +pub union CResult_ResponderDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::ser::Hostname, + pub result: *mut crate::lightning::onion_message::messenger::Responder, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_HostnameDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::ser::Hostname on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_ResponderDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::Responder on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HostnameDecodeErrorZ { - /// The contents of this CResult_HostnameDecodeErrorZ, accessible via either +pub struct CResult_ResponderDecodeErrorZ { + /// The contents of this CResult_ResponderDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HostnameDecodeErrorZPtr, - /// Whether this CResult_HostnameDecodeErrorZ represents a success state. + pub contents: CResult_ResponderDecodeErrorZPtr, + /// Whether this CResult_ResponderDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HostnameDecodeErrorZ in the success state. -pub extern "C" fn CResult_HostnameDecodeErrorZ_ok(o: crate::lightning::util::ser::Hostname) -> CResult_HostnameDecodeErrorZ { - CResult_HostnameDecodeErrorZ { - contents: CResult_HostnameDecodeErrorZPtr { +/// Creates a new CResult_ResponderDecodeErrorZ in the success state. +pub extern "C" fn CResult_ResponderDecodeErrorZ_ok(o: crate::lightning::onion_message::messenger::Responder) -> CResult_ResponderDecodeErrorZ { + CResult_ResponderDecodeErrorZ { + contents: CResult_ResponderDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } -#[no_mangle] -/// Creates a new CResult_HostnameDecodeErrorZ in the error state. -pub extern "C" fn CResult_HostnameDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HostnameDecodeErrorZ { - CResult_HostnameDecodeErrorZ { - contents: CResult_HostnameDecodeErrorZPtr { +#[no_mangle] +/// Creates a new CResult_ResponderDecodeErrorZ in the error state. +pub extern "C" fn CResult_ResponderDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_ResponderDecodeErrorZ { + CResult_ResponderDecodeErrorZ { + contents: CResult_ResponderDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -22962,13 +27775,13 @@ pub extern "C" fn CResult_HostnameDecodeErrorZ_err(e: crate::lightning::ln::msgs } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HostnameDecodeErrorZ_is_ok(o: &CResult_HostnameDecodeErrorZ) -> bool { +pub extern "C" fn CResult_ResponderDecodeErrorZ_is_ok(o: &CResult_ResponderDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HostnameDecodeErrorZ. -pub extern "C" fn CResult_HostnameDecodeErrorZ_free(_res: CResult_HostnameDecodeErrorZ) { } -impl Drop for CResult_HostnameDecodeErrorZ { +/// Frees any resources used by the CResult_ResponderDecodeErrorZ. +pub extern "C" fn CResult_ResponderDecodeErrorZ_free(_res: CResult_ResponderDecodeErrorZ) { } +impl Drop for CResult_ResponderDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -22981,16 +27794,16 @@ impl Drop for CResult_HostnameDecodeErrorZ { } } } -impl From> for CResult_HostnameDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_ResponderDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HostnameDecodeErrorZPtr { result } + CResult_ResponderDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HostnameDecodeErrorZPtr { err } + CResult_ResponderDecodeErrorZPtr { err } }; Self { contents, @@ -22998,91 +27811,178 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HostnameDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_ResponderDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HostnameDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_ResponderDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HostnameDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_ResponderDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HostnameDecodeErrorZ_clone(orig: &CResult_HostnameDecodeErrorZ) -> CResult_HostnameDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_ResponderDecodeErrorZ_clone(orig: &CResult_ResponderDecodeErrorZ) -> CResult_ResponderDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionU16LenLimitedNoneZ -pub union CResult_TransactionU16LenLimitedNoneZPtr { +#[derive(Clone)] +/// An enum which can either contain a crate::lightning::blinded_path::message::MessageContext or not +pub enum COption_MessageContextZ { + /// When we're in this state, this COption_MessageContextZ contains a crate::lightning::blinded_path::message::MessageContext + Some(crate::lightning::blinded_path::message::MessageContext), + /// When we're in this state, this COption_MessageContextZ contains nothing + None +} +impl COption_MessageContextZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::blinded_path::message::MessageContext { + if let Self::Some(v) = self { v } else { unreachable!() } + } +} +#[no_mangle] +/// Constructs a new COption_MessageContextZ containing a crate::lightning::blinded_path::message::MessageContext +pub extern "C" fn COption_MessageContextZ_some(o: crate::lightning::blinded_path::message::MessageContext) -> COption_MessageContextZ { + COption_MessageContextZ::Some(o) +} +#[no_mangle] +/// Constructs a new COption_MessageContextZ containing nothing +pub extern "C" fn COption_MessageContextZ_none() -> COption_MessageContextZ { + COption_MessageContextZ::None +} +#[no_mangle] +/// Frees any resources associated with the crate::lightning::blinded_path::message::MessageContext, if we are in the Some state +pub extern "C" fn COption_MessageContextZ_free(_res: COption_MessageContextZ) { } +#[no_mangle] +/// Creates a new COption_MessageContextZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn COption_MessageContextZ_clone(orig: &COption_MessageContextZ) -> COption_MessageContextZ { Clone::clone(&orig) } +#[repr(C)] +/// A tuple of 3 elements. See the individual fields for the types contained. +pub struct C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + /// The element at position 0 + pub a: crate::c_types::PublicKey, + /// The element at position 1 + pub b: crate::lightning::ln::msgs::OnionMessage, + /// The element at position 2 + pub c: crate::c_types::derived::COption_CVec_SocketAddressZZ, +} +impl From<(crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)> for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)) -> Self { + Self { + a: tup.0, + b: tup.1, + c: tup.2, + } + } +} +impl C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ) { + (self.a, self.b, self.c) + } +} +impl Clone for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + c: Clone::clone(&self.c), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(orig: &C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { Clone::clone(&orig) } +/// Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::msgs::OnionMessage, c: crate::c_types::derived::COption_CVec_SocketAddressZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { + C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { a, b, c, } +} + +#[no_mangle] +/// Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. +pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(_res: C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) { } +#[repr(C)] +/// The contents of CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ +pub union CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[repr(C)] -/// A CResult_TransactionU16LenLimitedNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a () on failure. +/// A CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ on success and a crate::lightning::onion_message::messenger::SendError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TransactionU16LenLimitedNoneZ { - /// The contents of this CResult_TransactionU16LenLimitedNoneZ, accessible via either +pub struct CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + /// The contents of this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionU16LenLimitedNoneZPtr, - /// Whether this CResult_TransactionU16LenLimitedNoneZ represents a success state. + pub contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr, + /// Whether this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the success state. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedNoneZ { - CResult_TransactionU16LenLimitedNoneZ { - contents: CResult_TransactionU16LenLimitedNoneZPtr { +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(o: crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedNoneZ in the error state. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_err() -> CResult_TransactionU16LenLimitedNoneZ { - CResult_TransactionU16LenLimitedNoneZ { - contents: CResult_TransactionU16LenLimitedNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the error state. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_is_ok(o: &CResult_TransactionU16LenLimitedNoneZ) -> bool { +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_is_ok(o: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionU16LenLimitedNoneZ. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_free(_res: CResult_TransactionU16LenLimitedNoneZ) { } -impl Drop for CResult_TransactionU16LenLimitedNoneZ { +/// Frees any resources used by the CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ. +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_free(_res: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) { } +impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_TransactionU16LenLimitedNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TransactionU16LenLimitedNoneZPtr { result } + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_TransactionU16LenLimitedNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { err } }; Self { contents, @@ -23090,95 +27990,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionU16LenLimitedNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionU16LenLimitedNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedNoneZ which has the same data as `orig` +/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionU16LenLimitedNoneZ_clone(orig: &CResult_TransactionU16LenLimitedNoneZ) -> CResult_TransactionU16LenLimitedNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_clone(orig: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TransactionU16LenLimitedDecodeErrorZ -pub union CResult_TransactionU16LenLimitedDecodeErrorZPtr { +/// The contents of CResult_PeeledOnionNoneZ +pub union CResult_PeeledOnionNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::ser::TransactionU16LenLimited, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::onion_message::messenger::PeeledOnion, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_TransactionU16LenLimitedDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::ser::TransactionU16LenLimited on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_PeeledOnionNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::PeeledOnion on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TransactionU16LenLimitedDecodeErrorZ { - /// The contents of this CResult_TransactionU16LenLimitedDecodeErrorZ, accessible via either +pub struct CResult_PeeledOnionNoneZ { + /// The contents of this CResult_PeeledOnionNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr, - /// Whether this CResult_TransactionU16LenLimitedDecodeErrorZ represents a success state. + pub contents: CResult_PeeledOnionNoneZPtr, + /// Whether this CResult_PeeledOnionNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the success state. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o: crate::lightning::util::ser::TransactionU16LenLimited) -> CResult_TransactionU16LenLimitedDecodeErrorZ { - CResult_TransactionU16LenLimitedDecodeErrorZ { - contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { +/// Creates a new CResult_PeeledOnionNoneZ in the success state. +pub extern "C" fn CResult_PeeledOnionNoneZ_ok(o: crate::lightning::onion_message::messenger::PeeledOnion) -> CResult_PeeledOnionNoneZ { + CResult_PeeledOnionNoneZ { + contents: CResult_PeeledOnionNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ in the error state. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TransactionU16LenLimitedDecodeErrorZ { - CResult_TransactionU16LenLimitedDecodeErrorZ { - contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_PeeledOnionNoneZ in the error state. +pub extern "C" fn CResult_PeeledOnionNoneZ_err() -> CResult_PeeledOnionNoneZ { + CResult_PeeledOnionNoneZ { + contents: CResult_PeeledOnionNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> bool { +pub extern "C" fn CResult_PeeledOnionNoneZ_is_ok(o: &CResult_PeeledOnionNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TransactionU16LenLimitedDecodeErrorZ. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res: CResult_TransactionU16LenLimitedDecodeErrorZ) { } -impl Drop for CResult_TransactionU16LenLimitedDecodeErrorZ { +/// Frees any resources used by the CResult_PeeledOnionNoneZ. +pub extern "C" fn CResult_PeeledOnionNoneZ_free(_res: CResult_PeeledOnionNoneZ) { } +impl Drop for CResult_PeeledOnionNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_TransactionU16LenLimitedDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_PeeledOnionNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TransactionU16LenLimitedDecodeErrorZPtr { result } + CResult_PeeledOnionNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TransactionU16LenLimitedDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_PeeledOnionNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -23186,59 +28082,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_PeeledOnionNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TransactionU16LenLimitedDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_PeeledOnionNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_TransactionU16LenLimitedDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_PeeledOnionNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig: &CResult_TransactionU16LenLimitedDecodeErrorZ) -> CResult_TransactionU16LenLimitedDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_PeeledOnionNoneZ_clone(orig: &CResult_PeeledOnionNoneZ) -> CResult_PeeledOnionNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_UntrustedStringDecodeErrorZ -pub union CResult_UntrustedStringDecodeErrorZPtr { +/// The contents of CResult_SendSuccessSendErrorZ +pub union CResult_SendSuccessSendErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::util::string::UntrustedString, + pub result: *mut crate::lightning::onion_message::messenger::SendSuccess, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[repr(C)] -/// A CResult_UntrustedStringDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::util::string::UntrustedString on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_SendSuccessSendErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::onion_message::messenger::SendSuccess on success and a crate::lightning::onion_message::messenger::SendError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_UntrustedStringDecodeErrorZ { - /// The contents of this CResult_UntrustedStringDecodeErrorZ, accessible via either +pub struct CResult_SendSuccessSendErrorZ { + /// The contents of this CResult_SendSuccessSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_UntrustedStringDecodeErrorZPtr, - /// Whether this CResult_UntrustedStringDecodeErrorZ represents a success state. + pub contents: CResult_SendSuccessSendErrorZPtr, + /// Whether this CResult_SendSuccessSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the success state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_ok(o: crate::lightning::util::string::UntrustedString) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { +/// Creates a new CResult_SendSuccessSendErrorZ in the success state. +pub extern "C" fn CResult_SendSuccessSendErrorZ_ok(o: crate::lightning::onion_message::messenger::SendSuccess) -> CResult_SendSuccessSendErrorZ { + CResult_SendSuccessSendErrorZ { + contents: CResult_SendSuccessSendErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ in the error state. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_UntrustedStringDecodeErrorZ { - CResult_UntrustedStringDecodeErrorZ { - contents: CResult_UntrustedStringDecodeErrorZPtr { +/// Creates a new CResult_SendSuccessSendErrorZ in the error state. +pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_SendSuccessSendErrorZ { + CResult_SendSuccessSendErrorZ { + contents: CResult_SendSuccessSendErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23246,13 +28142,13 @@ pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_err(e: crate::lightning::l } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_is_ok(o: &CResult_UntrustedStringDecodeErrorZ) -> bool { +pub extern "C" fn CResult_SendSuccessSendErrorZ_is_ok(o: &CResult_SendSuccessSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_UntrustedStringDecodeErrorZ. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_free(_res: CResult_UntrustedStringDecodeErrorZ) { } -impl Drop for CResult_UntrustedStringDecodeErrorZ { +/// Frees any resources used by the CResult_SendSuccessSendErrorZ. +pub extern "C" fn CResult_SendSuccessSendErrorZ_free(_res: CResult_SendSuccessSendErrorZ) { } +impl Drop for CResult_SendSuccessSendErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23265,16 +28161,16 @@ impl Drop for CResult_UntrustedStringDecodeErrorZ { } } } -impl From> for CResult_UntrustedStringDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SendSuccessSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_UntrustedStringDecodeErrorZPtr { result } + CResult_SendSuccessSendErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_UntrustedStringDecodeErrorZPtr { err } + CResult_SendSuccessSendErrorZPtr { err } }; Self { contents, @@ -23282,101 +28178,58 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_UntrustedStringDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SendSuccessSendErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_UntrustedStringDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_SendSuccessSendErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_UntrustedStringDecodeErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_UntrustedStringDecodeErrorZ_clone(orig: &CResult_UntrustedStringDecodeErrorZ) -> CResult_UntrustedStringDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple__u832u16Z { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: u16, -} -impl From<(crate::c_types::ThirtyTwoBytes, u16)> for C2Tuple__u832u16Z { - fn from (tup: (crate::c_types::ThirtyTwoBytes, u16)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple__u832u16Z { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, u16) { - (self.a, self.b) - } -} -impl Clone for C2Tuple__u832u16Z { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_SendSuccessSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple__u832u16Z_clone(orig: &C2Tuple__u832u16Z) -> C2Tuple__u832u16Z { Clone::clone(&orig) } -/// Creates a new C2Tuple__u832u16Z from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple__u832u16Z_new(a: crate::c_types::ThirtyTwoBytes, b: u16) -> C2Tuple__u832u16Z { - C2Tuple__u832u16Z { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple__u832u16Z. -pub extern "C" fn C2Tuple__u832u16Z_free(_res: C2Tuple__u832u16Z) { } +pub extern "C" fn CResult_SendSuccessSendErrorZ_clone(orig: &CResult_SendSuccessSendErrorZ) -> CResult_SendSuccessSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentRelayDecodeErrorZ -pub union CResult_PaymentRelayDecodeErrorZPtr { - /// A pointer to the contents in the success state. - /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::payment::PaymentRelay, +/// The contents of CResult_NoneSendErrorZ +pub union CResult_NoneSendErrorZPtr { + /// Note that this value is always NULL, as there are no contents in the OK variant + pub result: *mut core::ffi::c_void, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub err: *mut crate::lightning::onion_message::messenger::SendError, } #[repr(C)] -/// A CResult_PaymentRelayDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::PaymentRelay on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_NoneSendErrorZ represents the result of a fallible operation, +/// containing a () on success and a crate::lightning::onion_message::messenger::SendError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentRelayDecodeErrorZ { - /// The contents of this CResult_PaymentRelayDecodeErrorZ, accessible via either +pub struct CResult_NoneSendErrorZ { + /// The contents of this CResult_NoneSendErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentRelayDecodeErrorZPtr, - /// Whether this CResult_PaymentRelayDecodeErrorZ represents a success state. + pub contents: CResult_NoneSendErrorZPtr, + /// Whether this CResult_NoneSendErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentRelay) -> CResult_PaymentRelayDecodeErrorZ { - CResult_PaymentRelayDecodeErrorZ { - contents: CResult_PaymentRelayDecodeErrorZPtr { - result: Box::into_raw(Box::new(o)), +/// Creates a new CResult_NoneSendErrorZ in the success state. +pub extern "C" fn CResult_NoneSendErrorZ_ok() -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { + result: core::ptr::null_mut(), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentRelayDecodeErrorZ { - CResult_PaymentRelayDecodeErrorZ { - contents: CResult_PaymentRelayDecodeErrorZPtr { +/// Creates a new CResult_NoneSendErrorZ in the error state. +pub extern "C" fn CResult_NoneSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_NoneSendErrorZ { + CResult_NoneSendErrorZ { + contents: CResult_NoneSendErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23384,18 +28237,15 @@ pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_is_ok(o: &CResult_PaymentRelayDecodeErrorZ) -> bool { +pub extern "C" fn CResult_NoneSendErrorZ_is_ok(o: &CResult_NoneSendErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentRelayDecodeErrorZ. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_free(_res: CResult_PaymentRelayDecodeErrorZ) { } -impl Drop for CResult_PaymentRelayDecodeErrorZ { +/// Frees any resources used by the CResult_NoneSendErrorZ. +pub extern "C" fn CResult_NoneSendErrorZ_free(_res: CResult_NoneSendErrorZ) { } +impl Drop for CResult_NoneSendErrorZ { fn drop(&mut self) { if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } } else { if unsafe { !(self.contents.err as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.err) }; @@ -23403,16 +28253,16 @@ impl Drop for CResult_PaymentRelayDecodeErrorZ { } } } -impl From> for CResult_PaymentRelayDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_NoneSendErrorZ { + fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::onion_message::messenger::SendError>) -> Self { let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentRelayDecodeErrorZPtr { result } + let _ = unsafe { Box::from_raw(o.contents.result) }; + o.contents.result = core::ptr::null_mut(); + CResult_NoneSendErrorZPtr { result: core::ptr::null_mut() } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentRelayDecodeErrorZPtr { err } + CResult_NoneSendErrorZPtr { err } }; Self { contents, @@ -23420,59 +28270,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentRelayDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_NoneSendErrorZPtr { + result: core::ptr::null_mut() } } } else { - Self { result_ok: false, contents: CResult_PaymentRelayDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_NoneSendErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentRelayDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_NoneSendErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentRelayDecodeErrorZ_clone(orig: &CResult_PaymentRelayDecodeErrorZ) -> CResult_PaymentRelayDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_NoneSendErrorZ_clone(orig: &CResult_NoneSendErrorZ) -> CResult_NoneSendErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_PaymentConstraintsDecodeErrorZ -pub union CResult_PaymentConstraintsDecodeErrorZPtr { +/// The contents of CResult_BlindedHopDecodeErrorZ +pub union CResult_BlindedHopDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::payment::PaymentConstraints, + pub result: *mut crate::lightning::blinded_path::BlindedHop, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_PaymentConstraintsDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::payment::PaymentConstraints on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PaymentConstraintsDecodeErrorZ { - /// The contents of this CResult_PaymentConstraintsDecodeErrorZ, accessible via either +pub struct CResult_BlindedHopDecodeErrorZ { + /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PaymentConstraintsDecodeErrorZPtr, - /// Whether this CResult_PaymentConstraintsDecodeErrorZ represents a success state. + pub contents: CResult_BlindedHopDecodeErrorZPtr, + /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the success state. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_ok(o: crate::lightning::blinded_path::payment::PaymentConstraints) -> CResult_PaymentConstraintsDecodeErrorZ { - CResult_PaymentConstraintsDecodeErrorZ { - contents: CResult_PaymentConstraintsDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ in the error state. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_PaymentConstraintsDecodeErrorZ { - CResult_PaymentConstraintsDecodeErrorZ { - contents: CResult_PaymentConstraintsDecodeErrorZPtr { +/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { + CResult_BlindedHopDecodeErrorZ { + contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23480,13 +28330,13 @@ pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_err(e: crate::lightning } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_is_ok(o: &CResult_PaymentConstraintsDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_PaymentConstraintsDecodeErrorZ. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_free(_res: CResult_PaymentConstraintsDecodeErrorZ) { } -impl Drop for CResult_PaymentConstraintsDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } +impl Drop for CResult_BlindedHopDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23499,16 +28349,16 @@ impl Drop for CResult_PaymentConstraintsDecodeErrorZ { } } } -impl From> for CResult_PaymentConstraintsDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedHopDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PaymentConstraintsDecodeErrorZPtr { result } + CResult_BlindedHopDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_PaymentConstraintsDecodeErrorZPtr { err } + CResult_BlindedHopDecodeErrorZPtr { err } }; Self { contents, @@ -23516,137 +28366,141 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_PaymentConstraintsDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_PaymentConstraintsDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_PaymentConstraintsDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_PaymentConstraintsDecodeErrorZ_clone(orig: &CResult_PaymentConstraintsDecodeErrorZ) -> CResult_PaymentConstraintsDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - /// The element at position 0 - pub a: crate::c_types::ThirtyTwoBytes, - /// The element at position 1 - pub b: crate::lightning::ln::outbound_payment::RecipientOnionFields, - /// The element at position 2 - pub c: crate::lightning::routing::router::RouteParameters, +/// A dynamically-allocated array of crate::lightning::ln::channelmanager::PhantomRouteHintss of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_PhantomRouteHintsZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::ln::channelmanager::PhantomRouteHints, + /// The number of elements pointed to by `data`. + pub datalen: usize } -impl From<(crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)> for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - fn from (tup: (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } +impl CVec_PhantomRouteHintsZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret } -} -impl C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::ThirtyTwoBytes, crate::lightning::ln::outbound_payment::RecipientOnionFields, crate::lightning::routing::router::RouteParameters) { - (self.a, self.b, self.c) + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::PhantomRouteHints] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } } } -impl Clone for C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } +impl From> for CVec_PhantomRouteHintsZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_clone(orig: &C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_new(a: crate::c_types::ThirtyTwoBytes, b: crate::lightning::ln::outbound_payment::RecipientOnionFields, c: crate::lightning::routing::router::RouteParameters) -> C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { - C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ { a, b, c, } +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_PhantomRouteHintsZ_free(_res: CVec_PhantomRouteHintsZ) { } +impl Drop for CVec_PhantomRouteHintsZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_PhantomRouteHintsZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } } - -#[no_mangle] -/// Frees any resources used by the C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ. -pub extern "C" fn C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ_free(_res: C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) { } #[repr(C)] -/// The contents of CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ -pub union CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { +/// The contents of CResult_Bolt11InvoiceSignOrCreationErrorZ +pub union CResult_Bolt11InvoiceSignOrCreationErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning_invoice::Bolt11Invoice, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning_invoice::SignOrCreationError, } #[repr(C)] -/// A CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ on success and a () on failure. +/// A CResult_Bolt11InvoiceSignOrCreationErrorZ represents the result of a fallible operation, +/// containing a crate::lightning_invoice::Bolt11Invoice on success and a crate::lightning_invoice::SignOrCreationError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - /// The contents of this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ, accessible via either +pub struct CResult_Bolt11InvoiceSignOrCreationErrorZ { + /// The contents of this CResult_Bolt11InvoiceSignOrCreationErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr, - /// Whether this CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ represents a success state. + pub contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr, + /// Whether this CResult_Bolt11InvoiceSignOrCreationErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the success state. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_ok(o: crate::c_types::derived::C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the success state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o: crate::lightning_invoice::Bolt11Invoice) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ in the error state. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_err() -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ in the error state. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e: crate::lightning_invoice::SignOrCreationError) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { + CResult_Bolt11InvoiceSignOrCreationErrorZ { + contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_is_ok(o: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> bool { +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_free(_res: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) { } -impl Drop for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { +/// Frees any resources used by the CResult_Bolt11InvoiceSignOrCreationErrorZ. +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res: CResult_Bolt11InvoiceSignOrCreationErrorZ) { } +impl Drop for CResult_Bolt11InvoiceSignOrCreationErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_Bolt11InvoiceSignOrCreationErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { result } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_Bolt11InvoiceSignOrCreationErrorZPtr { err } }; Self { contents, @@ -23654,59 +28508,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_Bolt11InvoiceSignOrCreationErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ which has the same data as `orig` +/// Creates a new CResult_Bolt11InvoiceSignOrCreationErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_clone(orig: &CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ) -> CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { Clone::clone(&orig) } +pub extern "C" fn CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig: &CResult_Bolt11InvoiceSignOrCreationErrorZ) -> CResult_Bolt11InvoiceSignOrCreationErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_StrSecp256k1ErrorZ -pub union CResult_StrSecp256k1ErrorZPtr { +/// The contents of CResult_InvoiceErrorDecodeErrorZ +pub union CResult_InvoiceErrorDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::Str, + pub result: *mut crate::lightning::offers::invoice_error::InvoiceError, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::c_types::Secp256k1Error, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_StrSecp256k1ErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::Str on success and a crate::c_types::Secp256k1Error on failure. +/// A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_StrSecp256k1ErrorZ { - /// The contents of this CResult_StrSecp256k1ErrorZ, accessible via either +pub struct CResult_InvoiceErrorDecodeErrorZ { + /// The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_StrSecp256k1ErrorZPtr, - /// Whether this CResult_StrSecp256k1ErrorZ represents a success state. + pub contents: CResult_InvoiceErrorDecodeErrorZPtr, + /// Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ in the success state. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_ok(o: crate::c_types::Str) -> CResult_StrSecp256k1ErrorZ { - CResult_StrSecp256k1ErrorZ { - contents: CResult_StrSecp256k1ErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_ok(o: crate::lightning::offers::invoice_error::InvoiceError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ in the error state. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Error) -> CResult_StrSecp256k1ErrorZ { - CResult_StrSecp256k1ErrorZ { - contents: CResult_StrSecp256k1ErrorZPtr { +/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceErrorDecodeErrorZ { + CResult_InvoiceErrorDecodeErrorZ { + contents: CResult_InvoiceErrorDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23714,13 +28568,13 @@ pub extern "C" fn CResult_StrSecp256k1ErrorZ_err(e: crate::c_types::Secp256k1Err } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_StrSecp256k1ErrorZ_is_ok(o: &CResult_StrSecp256k1ErrorZ) -> bool { +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_is_ok(o: &CResult_InvoiceErrorDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_StrSecp256k1ErrorZ. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_free(_res: CResult_StrSecp256k1ErrorZ) { } -impl Drop for CResult_StrSecp256k1ErrorZ { +/// Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_free(_res: CResult_InvoiceErrorDecodeErrorZ) { } +impl Drop for CResult_InvoiceErrorDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23733,16 +28587,16 @@ impl Drop for CResult_StrSecp256k1ErrorZ { } } } -impl From> for CResult_StrSecp256k1ErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InvoiceErrorDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_StrSecp256k1ErrorZPtr { result } + CResult_InvoiceErrorDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_StrSecp256k1ErrorZPtr { err } + CResult_InvoiceErrorDecodeErrorZPtr { err } }; Self { contents, @@ -23750,59 +28604,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_StrSecp256k1ErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InvoiceErrorDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_StrSecp256k1ErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_InvoiceErrorDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_StrSecp256k1ErrorZ which has the same data as `orig` +/// Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_StrSecp256k1ErrorZ_clone(orig: &CResult_StrSecp256k1ErrorZ) -> CResult_StrSecp256k1ErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_TxOutUtxoLookupErrorZ -pub union CResult_TxOutUtxoLookupErrorZPtr { +/// The contents of CResult_TrackedSpendableOutputDecodeErrorZ +pub union CResult_TrackedSpendableOutputDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::TxOut, + pub result: *mut crate::lightning::util::sweep::TrackedSpendableOutput, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::routing::utxo::UtxoLookupError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_TxOutUtxoLookupErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::TxOut on success and a crate::lightning::routing::utxo::UtxoLookupError on failure. +/// A CResult_TrackedSpendableOutputDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::TrackedSpendableOutput on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_TxOutUtxoLookupErrorZ { - /// The contents of this CResult_TxOutUtxoLookupErrorZ, accessible via either +pub struct CResult_TrackedSpendableOutputDecodeErrorZ { + /// The contents of this CResult_TrackedSpendableOutputDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_TxOutUtxoLookupErrorZPtr, - /// Whether this CResult_TxOutUtxoLookupErrorZ represents a success state. + pub contents: CResult_TrackedSpendableOutputDecodeErrorZPtr, + /// Whether this CResult_TrackedSpendableOutputDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the success state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_ok(o: crate::c_types::TxOut) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the success state. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_ok(o: crate::lightning::util::sweep::TrackedSpendableOutput) -> CResult_TrackedSpendableOutputDecodeErrorZ { + CResult_TrackedSpendableOutputDecodeErrorZ { + contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ in the error state. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing::utxo::UtxoLookupError) -> CResult_TxOutUtxoLookupErrorZ { - CResult_TxOutUtxoLookupErrorZ { - contents: CResult_TxOutUtxoLookupErrorZPtr { +/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ in the error state. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_TrackedSpendableOutputDecodeErrorZ { + CResult_TrackedSpendableOutputDecodeErrorZ { + contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23810,13 +28664,13 @@ pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_err(e: crate::lightning::routing } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_is_ok(o: &CResult_TxOutUtxoLookupErrorZ) -> bool { +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_is_ok(o: &CResult_TrackedSpendableOutputDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_TxOutUtxoLookupErrorZ. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_free(_res: CResult_TxOutUtxoLookupErrorZ) { } -impl Drop for CResult_TxOutUtxoLookupErrorZ { +/// Frees any resources used by the CResult_TrackedSpendableOutputDecodeErrorZ. +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_free(_res: CResult_TrackedSpendableOutputDecodeErrorZ) { } +impl Drop for CResult_TrackedSpendableOutputDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23829,16 +28683,16 @@ impl Drop for CResult_TxOutUtxoLookupErrorZ { } } } -impl From> for CResult_TxOutUtxoLookupErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_TrackedSpendableOutputDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_TxOutUtxoLookupErrorZPtr { result } + CResult_TrackedSpendableOutputDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_TxOutUtxoLookupErrorZPtr { err } + CResult_TrackedSpendableOutputDecodeErrorZPtr { err } }; Self { contents, @@ -23846,105 +28700,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_TxOutUtxoLookupErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_TxOutUtxoLookupErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_TrackedSpendableOutputDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_TxOutUtxoLookupErrorZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_TxOutUtxoLookupErrorZ_clone(orig: &CResult_TxOutUtxoLookupErrorZ) -> CResult_TxOutUtxoLookupErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// A tuple of 3 elements. See the individual fields for the types contained. -pub struct C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - /// The element at position 0 - pub a: crate::c_types::PublicKey, - /// The element at position 1 - pub b: crate::lightning::ln::msgs::OnionMessage, - /// The element at position 2 - pub c: crate::c_types::derived::COption_CVec_SocketAddressZZ, -} -impl From<(crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)> for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - fn from (tup: (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - c: tup.2, - } - } -} -impl C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::c_types::PublicKey, crate::lightning::ln::msgs::OnionMessage, crate::c_types::derived::COption_CVec_SocketAddressZZ) { - (self.a, self.b, self.c) - } -} -impl Clone for C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), - c: Clone::clone(&self.c), - } - } -} -#[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_TrackedSpendableOutputDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_clone(orig: &C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { Clone::clone(&orig) } -/// Creates a new C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_new(a: crate::c_types::PublicKey, b: crate::lightning::ln::msgs::OnionMessage, c: crate::c_types::derived::COption_CVec_SocketAddressZZ) -> C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { - C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ { a, b, c, } -} - -#[no_mangle] -/// Frees any resources used by the C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ. -pub extern "C" fn C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ_free(_res: C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) { } +pub extern "C" fn CResult_TrackedSpendableOutputDecodeErrorZ_clone(orig: &CResult_TrackedSpendableOutputDecodeErrorZ) -> CResult_TrackedSpendableOutputDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ -pub union CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// The contents of CResult_OutputSpendStatusDecodeErrorZ +pub union CResult_OutputSpendStatusDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ, + pub result: *mut crate::lightning::util::sweep::OutputSpendStatus, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ on success and a crate::lightning::onion_message::messenger::SendError on failure. +/// A CResult_OutputSpendStatusDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::OutputSpendStatus on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - /// The contents of this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ, accessible via either +pub struct CResult_OutputSpendStatusDecodeErrorZ { + /// The contents of this CResult_OutputSpendStatusDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr, - /// Whether this CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ represents a success state. + pub contents: CResult_OutputSpendStatusDecodeErrorZPtr, + /// Whether this CResult_OutputSpendStatusDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the success state. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_ok(o: crate::c_types::derived::C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSpendStatus) -> CResult_OutputSpendStatusDecodeErrorZ { + CResult_OutputSpendStatusDecodeErrorZ { + contents: CResult_OutputSpendStatusDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ in the error state. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - contents: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSpendStatusDecodeErrorZ { + CResult_OutputSpendStatusDecodeErrorZ { + contents: CResult_OutputSpendStatusDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -23952,13 +28760,13 @@ pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddres } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_is_ok(o: &CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) -> bool { +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_is_ok(o: &CResult_OutputSpendStatusDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ. -pub extern "C" fn CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ_free(_res: CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ) { } -impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { +/// Frees any resources used by the CResult_OutputSpendStatusDecodeErrorZ. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_free(_res: CResult_OutputSpendStatusDecodeErrorZ) { } +impl Drop for CResult_OutputSpendStatusDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -23971,16 +28779,16 @@ impl Drop for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ } } } -impl From> for CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutputSpendStatusDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { result } + CResult_OutputSpendStatusDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZPtr { err } + CResult_OutputSpendStatusDecodeErrorZPtr { err } }; Self { contents, @@ -23988,117 +28796,137 @@ impl From Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_OutputSpendStatusDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OutputSpendStatusDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } } +#[no_mangle] +/// Creates a new CResult_OutputSpendStatusDecodeErrorZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_OutputSpendStatusDecodeErrorZ_clone(orig: &CResult_OutputSpendStatusDecodeErrorZ) -> CResult_OutputSpendStatusDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// A CResult_PeeledOnionNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::messenger::PeeledOnion on success and a () on failure. -/// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_PeeledOnionNoneZ { - /// The contents of this CResult_PeeledOnionNoneZ, accessible via either - /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_PeeledOnionNoneZPtr, - /// Whether this CResult_PeeledOnionNoneZ represents a success state. - pub result_ok: bool, +/// An enum which can either contain a crate::lightning::chain::Filter or not +pub enum COption_FilterZ { + /// When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter + Some(crate::lightning::chain::Filter), + /// When we're in this state, this COption_FilterZ contains nothing + None +} +impl COption_FilterZ { + #[allow(unused)] pub(crate) fn is_some(&self) -> bool { + if let Self::None = self { false } else { true } + } + #[allow(unused)] pub(crate) fn is_none(&self) -> bool { + !self.is_some() + } + #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::Filter { + if let Self::Some(v) = self { v } else { unreachable!() } + } } #[no_mangle] -/// Creates a new CResult_PeeledOnionNoneZ in the success state. -pub extern "C" fn CResult_PeeledOnionNoneZ_ok(o: crate::lightning::onion_message::messenger::PeeledOnion) -> CResult_PeeledOnionNoneZ { - CResult_PeeledOnionNoneZ { - contents: CResult_PeeledOnionNoneZPtr { - result: Box::into_raw(Box::new(o)), - }, - result_ok: true, - } +/// Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter +pub extern "C" fn COption_FilterZ_some(o: crate::lightning::chain::Filter) -> COption_FilterZ { + COption_FilterZ::Some(o) } #[no_mangle] -/// Creates a new CResult_PeeledOnionNoneZ in the error state. -pub extern "C" fn CResult_PeeledOnionNoneZ_err() -> CResult_PeeledOnionNoneZ { - CResult_PeeledOnionNoneZ { - contents: CResult_PeeledOnionNoneZPtr { - err: core::ptr::null_mut(), - }, - result_ok: false, - } +/// Constructs a new COption_FilterZ containing nothing +pub extern "C" fn COption_FilterZ_none() -> COption_FilterZ { + COption_FilterZ::None } -/// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_PeeledOnionNoneZ_is_ok(o: &CResult_PeeledOnionNoneZ) -> bool { - o.result_ok +/// Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state +pub extern "C" fn COption_FilterZ_free(_res: COption_FilterZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::lightning::util::sweep::TrackedSpendableOutputs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_TrackedSpendableOutputZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::lightning::util::sweep::TrackedSpendableOutput, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_TrackedSpendableOutputZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::sweep::TrackedSpendableOutput] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_TrackedSpendableOutputZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } } #[no_mangle] -/// Frees any resources used by the CResult_PeeledOnionNoneZ. -pub extern "C" fn CResult_PeeledOnionNoneZ_free(_res: CResult_PeeledOnionNoneZ) { } -impl Drop for CResult_PeeledOnionNoneZ { +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_TrackedSpendableOutputZ_free(_res: CVec_TrackedSpendableOutputZ) { } +impl Drop for CVec_TrackedSpendableOutputZ { fn drop(&mut self) { - if self.result_ok { - if unsafe { !(self.contents.result as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.result) }; - } - } else { - } + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; } } -impl From> for CResult_PeeledOnionNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { - let contents = if o.result_ok { - let result = unsafe { o.contents.result }; - unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_PeeledOnionNoneZPtr { result } - } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_PeeledOnionNoneZPtr { err: core::ptr::null_mut() } - }; - Self { - contents, - result_ok: o.result_ok, - } +impl Clone for CVec_TrackedSpendableOutputZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) } } #[repr(C)] -/// The contents of CResult_SendSuccessSendErrorZ -pub union CResult_SendSuccessSendErrorZPtr { +/// The contents of CResult_OutputSweeperDecodeErrorZ +pub union CResult_OutputSweeperDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::onion_message::messenger::SendSuccess, + pub result: *mut crate::lightning::util::sweep::OutputSweeper, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::onion_message::messenger::SendError, + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_SendSuccessSendErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::onion_message::messenger::SendSuccess on success and a crate::lightning::onion_message::messenger::SendError on failure. +/// A CResult_OutputSweeperDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::util::sweep::OutputSweeper on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_SendSuccessSendErrorZ { - /// The contents of this CResult_SendSuccessSendErrorZ, accessible via either +pub struct CResult_OutputSweeperDecodeErrorZ { + /// The contents of this CResult_OutputSweeperDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_SendSuccessSendErrorZPtr, - /// Whether this CResult_SendSuccessSendErrorZ represents a success state. + pub contents: CResult_OutputSweeperDecodeErrorZPtr, + /// Whether this CResult_OutputSweeperDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_SendSuccessSendErrorZ in the success state. -pub extern "C" fn CResult_SendSuccessSendErrorZ_ok(o: crate::lightning::onion_message::messenger::SendSuccess) -> CResult_SendSuccessSendErrorZ { - CResult_SendSuccessSendErrorZ { - contents: CResult_SendSuccessSendErrorZPtr { +/// Creates a new CResult_OutputSweeperDecodeErrorZ in the success state. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_ok(o: crate::lightning::util::sweep::OutputSweeper) -> CResult_OutputSweeperDecodeErrorZ { + CResult_OutputSweeperDecodeErrorZ { + contents: CResult_OutputSweeperDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_SendSuccessSendErrorZ in the error state. -pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_message::messenger::SendError) -> CResult_SendSuccessSendErrorZ { - CResult_SendSuccessSendErrorZ { - contents: CResult_SendSuccessSendErrorZPtr { +/// Creates a new CResult_OutputSweeperDecodeErrorZ in the error state. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OutputSweeperDecodeErrorZ { + CResult_OutputSweeperDecodeErrorZ { + contents: CResult_OutputSweeperDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24106,13 +28934,13 @@ pub extern "C" fn CResult_SendSuccessSendErrorZ_err(e: crate::lightning::onion_m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_SendSuccessSendErrorZ_is_ok(o: &CResult_SendSuccessSendErrorZ) -> bool { +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_is_ok(o: &CResult_OutputSweeperDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_SendSuccessSendErrorZ. -pub extern "C" fn CResult_SendSuccessSendErrorZ_free(_res: CResult_SendSuccessSendErrorZ) { } -impl Drop for CResult_SendSuccessSendErrorZ { +/// Frees any resources used by the CResult_OutputSweeperDecodeErrorZ. +pub extern "C" fn CResult_OutputSweeperDecodeErrorZ_free(_res: CResult_OutputSweeperDecodeErrorZ) { } +impl Drop for CResult_OutputSweeperDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24125,16 +28953,16 @@ impl Drop for CResult_SendSuccessSendErrorZ { } } } -impl From> for CResult_SendSuccessSendErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OutputSweeperDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_SendSuccessSendErrorZPtr { result } + CResult_OutputSweeperDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_SendSuccessSendErrorZPtr { err } + CResult_OutputSweeperDecodeErrorZPtr { err } }; Self { contents, @@ -24143,73 +28971,107 @@ impl From for C2Tuple_BestBlockOutputSweeperZ { + fn from (tup: (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_BestBlockOutputSweeperZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::BestBlock, crate::lightning::util::sweep::OutputSweeper) { + (self.a, self.b) + } +} +/// Creates a new C2Tuple_BestBlockOutputSweeperZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_new(a: crate::lightning::chain::BestBlock, b: crate::lightning::util::sweep::OutputSweeper) -> C2Tuple_BestBlockOutputSweeperZ { + C2Tuple_BestBlockOutputSweeperZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_BestBlockOutputSweeperZ. +pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_free(_res: C2Tuple_BestBlockOutputSweeperZ) { } +#[repr(C)] +/// The contents of CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ +pub union CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedPathNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a () on failure. +/// A CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathNoneZ { - /// The contents of this CResult_BlindedPathNoneZ, accessible via either +pub struct CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + /// The contents of this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathNoneZPtr, - /// Whether this CResult_BlindedPathNoneZ represents a success state. + pub contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr, + /// Whether this CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the success state. -pub extern "C" fn CResult_BlindedPathNoneZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { +/// Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the success state. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_ok(o: crate::c_types::derived::C2Tuple_BestBlockOutputSweeperZ) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ in the error state. -pub extern "C" fn CResult_BlindedPathNoneZ_err() -> CResult_BlindedPathNoneZ { - CResult_BlindedPathNoneZ { - contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ in the error state. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + contents: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathNoneZ_is_ok(o: &CResult_BlindedPathNoneZ) -> bool { +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_is_ok(o: &CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathNoneZ. -pub extern "C" fn CResult_BlindedPathNoneZ_free(_res: CResult_BlindedPathNoneZ) { } -impl Drop for CResult_BlindedPathNoneZ { +/// Frees any resources used by the CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ. +pub extern "C" fn CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ_free(_res: CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ) { } +impl Drop for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_BlindedPathNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathNoneZPtr { result } + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_BlindedPathNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZPtr { err } }; Self { contents, @@ -24217,91 +29079,78 @@ impl From Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_BlindedPathNoneZPtr { - err: core::ptr::null_mut() - } } - } - } -} -#[no_mangle] -/// Creates a new CResult_BlindedPathNoneZ which has the same data as `orig` -/// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathNoneZ_clone(orig: &CResult_BlindedPathNoneZ) -> CResult_BlindedPathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ -pub union CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +/// The contents of CResult_DelayedPaymentBasepointDecodeErrorZ +pub union CResult_DelayedPaymentBasepointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentBasepoint, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents the result of a fallible operation, -/// containing a crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ on success and a () on failure. +/// A CResult_DelayedPaymentBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::DelayedPaymentBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - /// The contents of this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ, accessible via either +pub struct CResult_DelayedPaymentBasepointDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr, - /// Whether this CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ represents a success state. + pub contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the success state. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(o: crate::c_types::derived::C2Tuple_BlindedPayInfoBlindedPathZ) -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentBasepoint) -> CResult_DelayedPaymentBasepointDecodeErrorZ { + CResult_DelayedPaymentBasepointDecodeErrorZ { + contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ in the error state. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err() -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentBasepointDecodeErrorZ { + CResult_DelayedPaymentBasepointDecodeErrorZ { + contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(o: &CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(_res: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) { } -impl Drop for CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { +/// Frees any resources used by the CResult_DelayedPaymentBasepointDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_free(_res: CResult_DelayedPaymentBasepointDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentBasepointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { result } + CResult_DelayedPaymentBasepointDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_DelayedPaymentBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -24309,105 +29158,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZPtr { - err: core::ptr::null_mut() + Self { result_ok: false, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(orig: &CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ) -> CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { Clone::clone(&orig) } -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::blinded_path::payment::ForwardNodes of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_ForwardNodeZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::blinded_path::payment::ForwardNode, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_ForwardNodeZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::blinded_path::payment::ForwardNode] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_ForwardNodeZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_ForwardNodeZ_free(_res: CVec_ForwardNodeZ) { } -impl Drop for CVec_ForwardNodeZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_ForwardNodeZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_clone(orig: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> CResult_DelayedPaymentBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedPathDecodeErrorZ -pub union CResult_BlindedPathDecodeErrorZPtr { +/// The contents of CResult_DelayedPaymentKeyDecodeErrorZ +pub union CResult_DelayedPaymentKeyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedPath, + pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedPathDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedPath on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_DelayedPaymentKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::DelayedPaymentKey on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedPathDecodeErrorZ { - /// The contents of this CResult_BlindedPathDecodeErrorZ, accessible via either +pub struct CResult_DelayedPaymentKeyDecodeErrorZ { + /// The contents of this CResult_DelayedPaymentKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedPathDecodeErrorZPtr, - /// Whether this CResult_BlindedPathDecodeErrorZ represents a success state. + pub contents: CResult_DelayedPaymentKeyDecodeErrorZPtr, + /// Whether this CResult_DelayedPaymentKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedPath) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentKey) -> CResult_DelayedPaymentKeyDecodeErrorZ { + CResult_DelayedPaymentKeyDecodeErrorZ { + contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedPathDecodeErrorZ { - CResult_BlindedPathDecodeErrorZ { - contents: CResult_BlindedPathDecodeErrorZPtr { +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentKeyDecodeErrorZ { + CResult_DelayedPaymentKeyDecodeErrorZ { + contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24415,13 +29218,13 @@ pub extern "C" fn CResult_BlindedPathDecodeErrorZ_err(e: crate::lightning::ln::m } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_is_ok(o: &CResult_BlindedPathDecodeErrorZ) -> bool { +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedPathDecodeErrorZ. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_free(_res: CResult_BlindedPathDecodeErrorZ) { } -impl Drop for CResult_BlindedPathDecodeErrorZ { +/// Frees any resources used by the CResult_DelayedPaymentKeyDecodeErrorZ. +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_free(_res: CResult_DelayedPaymentKeyDecodeErrorZ) { } +impl Drop for CResult_DelayedPaymentKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24434,16 +29237,16 @@ impl Drop for CResult_BlindedPathDecodeErrorZ { } } } -impl From> for CResult_BlindedPathDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_DelayedPaymentKeyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedPathDecodeErrorZPtr { result } + CResult_DelayedPaymentKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedPathDecodeErrorZPtr { err } + CResult_DelayedPaymentKeyDecodeErrorZPtr { err } }; Self { contents, @@ -24451,59 +29254,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedPathDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedPathDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedPathDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedPathDecodeErrorZ_clone(orig: &CResult_BlindedPathDecodeErrorZ) -> CResult_BlindedPathDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_clone(orig: &CResult_DelayedPaymentKeyDecodeErrorZ) -> CResult_DelayedPaymentKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_BlindedHopDecodeErrorZ -pub union CResult_BlindedHopDecodeErrorZPtr { +/// The contents of CResult_HtlcBasepointDecodeErrorZ +pub union CResult_HtlcBasepointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::blinded_path::BlindedHop, + pub result: *mut crate::lightning::ln::channel_keys::HtlcBasepoint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_BlindedHopDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::blinded_path::BlindedHop on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HtlcBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::HtlcBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_BlindedHopDecodeErrorZ { - /// The contents of this CResult_BlindedHopDecodeErrorZ, accessible via either +pub struct CResult_HtlcBasepointDecodeErrorZ { + /// The contents of this CResult_HtlcBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_BlindedHopDecodeErrorZPtr, - /// Whether this CResult_BlindedHopDecodeErrorZ represents a success state. + pub contents: CResult_HtlcBasepointDecodeErrorZPtr, + /// Whether this CResult_HtlcBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the success state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_ok(o: crate::lightning::blinded_path::BlindedHop) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcBasepoint) -> CResult_HtlcBasepointDecodeErrorZ { + CResult_HtlcBasepointDecodeErrorZ { + contents: CResult_HtlcBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ in the error state. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedHopDecodeErrorZ { - CResult_BlindedHopDecodeErrorZ { - contents: CResult_BlindedHopDecodeErrorZPtr { +/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcBasepointDecodeErrorZ { + CResult_HtlcBasepointDecodeErrorZ { + contents: CResult_HtlcBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24511,13 +29314,13 @@ pub extern "C" fn CResult_BlindedHopDecodeErrorZ_err(e: crate::lightning::ln::ms } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_is_ok(o: &CResult_BlindedHopDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_is_ok(o: &CResult_HtlcBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_BlindedHopDecodeErrorZ. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_free(_res: CResult_BlindedHopDecodeErrorZ) { } -impl Drop for CResult_BlindedHopDecodeErrorZ { +/// Frees any resources used by the CResult_HtlcBasepointDecodeErrorZ. +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_free(_res: CResult_HtlcBasepointDecodeErrorZ) { } +impl Drop for CResult_HtlcBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24530,16 +29333,16 @@ impl Drop for CResult_BlindedHopDecodeErrorZ { } } } -impl From> for CResult_BlindedHopDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HtlcBasepointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_BlindedHopDecodeErrorZPtr { result } + CResult_HtlcBasepointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_BlindedHopDecodeErrorZPtr { err } + CResult_HtlcBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -24547,59 +29350,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_BlindedHopDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HtlcBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_BlindedHopDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HtlcBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HtlcBasepointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_BlindedHopDecodeErrorZ_clone(orig: &CResult_BlindedHopDecodeErrorZ) -> CResult_BlindedHopDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_clone(orig: &CResult_HtlcBasepointDecodeErrorZ) -> CResult_HtlcBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_InvoiceErrorDecodeErrorZ -pub union CResult_InvoiceErrorDecodeErrorZPtr { +/// The contents of CResult_HtlcKeyDecodeErrorZ +pub union CResult_HtlcKeyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::offers::invoice_error::InvoiceError, + pub result: *mut crate::lightning::ln::channel_keys::HtlcKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_InvoiceErrorDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::offers::invoice_error::InvoiceError on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_HtlcKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::HtlcKey on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_InvoiceErrorDecodeErrorZ { - /// The contents of this CResult_InvoiceErrorDecodeErrorZ, accessible via either +pub struct CResult_HtlcKeyDecodeErrorZ { + /// The contents of this CResult_HtlcKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_InvoiceErrorDecodeErrorZPtr, - /// Whether this CResult_InvoiceErrorDecodeErrorZ represents a success state. + pub contents: CResult_HtlcKeyDecodeErrorZPtr, + /// Whether this CResult_HtlcKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the success state. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_ok(o: crate::lightning::offers::invoice_error::InvoiceError) -> CResult_InvoiceErrorDecodeErrorZ { - CResult_InvoiceErrorDecodeErrorZ { - contents: CResult_InvoiceErrorDecodeErrorZPtr { +/// Creates a new CResult_HtlcKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcKey) -> CResult_HtlcKeyDecodeErrorZ { + CResult_HtlcKeyDecodeErrorZ { + contents: CResult_HtlcKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_InvoiceErrorDecodeErrorZ in the error state. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_InvoiceErrorDecodeErrorZ { - CResult_InvoiceErrorDecodeErrorZ { - contents: CResult_InvoiceErrorDecodeErrorZPtr { +/// Creates a new CResult_HtlcKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcKeyDecodeErrorZ { + CResult_HtlcKeyDecodeErrorZ { + contents: CResult_HtlcKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24607,13 +29410,13 @@ pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_err(e: crate::lightning::ln:: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_is_ok(o: &CResult_InvoiceErrorDecodeErrorZ) -> bool { +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_is_ok(o: &CResult_HtlcKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_InvoiceErrorDecodeErrorZ. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_free(_res: CResult_InvoiceErrorDecodeErrorZ) { } -impl Drop for CResult_InvoiceErrorDecodeErrorZ { +/// Frees any resources used by the CResult_HtlcKeyDecodeErrorZ. +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_free(_res: CResult_HtlcKeyDecodeErrorZ) { } +impl Drop for CResult_HtlcKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24626,16 +29429,16 @@ impl Drop for CResult_InvoiceErrorDecodeErrorZ { } } } -impl From> for CResult_InvoiceErrorDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_HtlcKeyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_InvoiceErrorDecodeErrorZPtr { result } + CResult_HtlcKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_InvoiceErrorDecodeErrorZPtr { err } + CResult_HtlcKeyDecodeErrorZPtr { err } }; Self { contents, @@ -24643,59 +29446,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InvoiceErrorDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_HtlcKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InvoiceErrorDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_HtlcKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_InvoiceErrorDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_HtlcKeyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_InvoiceErrorDecodeErrorZ_clone(orig: &CResult_InvoiceErrorDecodeErrorZ) -> CResult_InvoiceErrorDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_clone(orig: &CResult_HtlcKeyDecodeErrorZ) -> CResult_HtlcKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentBasepointDecodeErrorZ -pub union CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// The contents of CResult_RevocationBasepointDecodeErrorZ +pub union CResult_RevocationBasepointDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentBasepoint, + pub result: *mut crate::lightning::ln::channel_keys::RevocationBasepoint, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_DelayedPaymentBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::DelayedPaymentBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RevocationBasepointDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::RevocationBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DelayedPaymentBasepointDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentBasepointDecodeErrorZ, accessible via either +pub struct CResult_RevocationBasepointDecodeErrorZ { + /// The contents of this CResult_RevocationBasepointDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentBasepointDecodeErrorZ represents a success state. + pub contents: CResult_RevocationBasepointDecodeErrorZPtr, + /// Whether this CResult_RevocationBasepointDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentBasepoint) -> CResult_DelayedPaymentBasepointDecodeErrorZ { - CResult_DelayedPaymentBasepointDecodeErrorZ { - contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationBasepoint) -> CResult_RevocationBasepointDecodeErrorZ { + CResult_RevocationBasepointDecodeErrorZ { + contents: CResult_RevocationBasepointDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentBasepointDecodeErrorZ { - CResult_DelayedPaymentBasepointDecodeErrorZ { - contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { +/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationBasepointDecodeErrorZ { + CResult_RevocationBasepointDecodeErrorZ { + contents: CResult_RevocationBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24703,13 +29506,13 @@ pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_err(e: crate::ligh } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_is_ok(o: &CResult_RevocationBasepointDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentBasepointDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_free(_res: CResult_DelayedPaymentBasepointDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { +/// Frees any resources used by the CResult_RevocationBasepointDecodeErrorZ. +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_free(_res: CResult_RevocationBasepointDecodeErrorZ) { } +impl Drop for CResult_RevocationBasepointDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24722,16 +29525,16 @@ impl Drop for CResult_DelayedPaymentBasepointDecodeErrorZ { } } } -impl From> for CResult_DelayedPaymentBasepointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevocationBasepointDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DelayedPaymentBasepointDecodeErrorZPtr { result } + CResult_RevocationBasepointDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentBasepointDecodeErrorZPtr { err } + CResult_RevocationBasepointDecodeErrorZPtr { err } }; Self { contents, @@ -24739,59 +29542,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RevocationBasepointDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DelayedPaymentBasepointDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RevocationBasepointDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentBasepointDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RevocationBasepointDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentBasepointDecodeErrorZ_clone(orig: &CResult_DelayedPaymentBasepointDecodeErrorZ) -> CResult_DelayedPaymentBasepointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_clone(orig: &CResult_RevocationBasepointDecodeErrorZ) -> CResult_RevocationBasepointDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_DelayedPaymentKeyDecodeErrorZ -pub union CResult_DelayedPaymentKeyDecodeErrorZPtr { +/// The contents of CResult_RevocationKeyDecodeErrorZ +pub union CResult_RevocationKeyDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::DelayedPaymentKey, + pub result: *mut crate::lightning::ln::channel_keys::RevocationKey, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_DelayedPaymentKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::DelayedPaymentKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_RevocationKeyDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::ln::channel_keys::RevocationKey on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_DelayedPaymentKeyDecodeErrorZ { - /// The contents of this CResult_DelayedPaymentKeyDecodeErrorZ, accessible via either +pub struct CResult_RevocationKeyDecodeErrorZ { + /// The contents of this CResult_RevocationKeyDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_DelayedPaymentKeyDecodeErrorZPtr, - /// Whether this CResult_DelayedPaymentKeyDecodeErrorZ represents a success state. + pub contents: CResult_RevocationKeyDecodeErrorZPtr, + /// Whether this CResult_RevocationKeyDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::DelayedPaymentKey) -> CResult_DelayedPaymentKeyDecodeErrorZ { - CResult_DelayedPaymentKeyDecodeErrorZ { - contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { +/// Creates a new CResult_RevocationKeyDecodeErrorZ in the success state. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationKey) -> CResult_RevocationKeyDecodeErrorZ { + CResult_RevocationKeyDecodeErrorZ { + contents: CResult_RevocationKeyDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_DelayedPaymentKeyDecodeErrorZ { - CResult_DelayedPaymentKeyDecodeErrorZ { - contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { +/// Creates a new CResult_RevocationKeyDecodeErrorZ in the error state. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationKeyDecodeErrorZ { + CResult_RevocationKeyDecodeErrorZ { + contents: CResult_RevocationKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24799,13 +29602,13 @@ pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_err(e: crate::lightning: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_is_ok(o: &CResult_DelayedPaymentKeyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_is_ok(o: &CResult_RevocationKeyDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_DelayedPaymentKeyDecodeErrorZ. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_free(_res: CResult_DelayedPaymentKeyDecodeErrorZ) { } -impl Drop for CResult_DelayedPaymentKeyDecodeErrorZ { +/// Frees any resources used by the CResult_RevocationKeyDecodeErrorZ. +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_free(_res: CResult_RevocationKeyDecodeErrorZ) { } +impl Drop for CResult_RevocationKeyDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -24818,16 +29621,16 @@ impl Drop for CResult_DelayedPaymentKeyDecodeErrorZ { } } } -impl From> for CResult_DelayedPaymentKeyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_RevocationKeyDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_DelayedPaymentKeyDecodeErrorZPtr { result } + CResult_RevocationKeyDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_DelayedPaymentKeyDecodeErrorZPtr { err } + CResult_RevocationKeyDecodeErrorZPtr { err } }; Self { contents, @@ -24835,95 +29638,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_RevocationKeyDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_DelayedPaymentKeyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_RevocationKeyDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_DelayedPaymentKeyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_RevocationKeyDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_DelayedPaymentKeyDecodeErrorZ_clone(orig: &CResult_DelayedPaymentKeyDecodeErrorZ) -> CResult_DelayedPaymentKeyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_clone(orig: &CResult_RevocationKeyDecodeErrorZ) -> CResult_RevocationKeyDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_HtlcBasepointDecodeErrorZ -pub union CResult_HtlcBasepointDecodeErrorZPtr { +/// The contents of CResult_LockedChannelMonitorNoneZ +pub union CResult_LockedChannelMonitorNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::HtlcBasepoint, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::chain::chainmonitor::LockedChannelMonitor, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_HtlcBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::HtlcBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HtlcBasepointDecodeErrorZ { - /// The contents of this CResult_HtlcBasepointDecodeErrorZ, accessible via either +pub struct CResult_LockedChannelMonitorNoneZ { + /// The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HtlcBasepointDecodeErrorZPtr, - /// Whether this CResult_HtlcBasepointDecodeErrorZ represents a success state. + pub contents: CResult_LockedChannelMonitorNoneZPtr, + /// Whether this CResult_LockedChannelMonitorNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcBasepoint) -> CResult_HtlcBasepointDecodeErrorZ { - CResult_HtlcBasepointDecodeErrorZ { - contents: CResult_HtlcBasepointDecodeErrorZPtr { +/// Creates a new CResult_LockedChannelMonitorNoneZ in the success state. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_ok(o: crate::lightning::chain::chainmonitor::LockedChannelMonitor) -> CResult_LockedChannelMonitorNoneZ { + CResult_LockedChannelMonitorNoneZ { + contents: CResult_LockedChannelMonitorNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HtlcBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcBasepointDecodeErrorZ { - CResult_HtlcBasepointDecodeErrorZ { - contents: CResult_HtlcBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_LockedChannelMonitorNoneZ in the error state. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_err() -> CResult_LockedChannelMonitorNoneZ { + CResult_LockedChannelMonitorNoneZ { + contents: CResult_LockedChannelMonitorNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_is_ok(o: &CResult_HtlcBasepointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_is_ok(o: &CResult_LockedChannelMonitorNoneZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HtlcBasepointDecodeErrorZ. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_free(_res: CResult_HtlcBasepointDecodeErrorZ) { } -impl Drop for CResult_HtlcBasepointDecodeErrorZ { +/// Frees any resources used by the CResult_LockedChannelMonitorNoneZ. +pub extern "C" fn CResult_LockedChannelMonitorNoneZ_free(_res: CResult_LockedChannelMonitorNoneZ) { } +impl Drop for CResult_LockedChannelMonitorNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_HtlcBasepointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_LockedChannelMonitorNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HtlcBasepointDecodeErrorZPtr { result } + CResult_LockedChannelMonitorNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HtlcBasepointDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_LockedChannelMonitorNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -24931,59 +29730,218 @@ impl From for C2Tuple_OutPointChannelIdZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OutPointChannelIdZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::types::ChannelId) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OutPointChannelIdZ { fn clone(&self) -> Self { - if self.result_ok { - Self { result_ok: true, contents: CResult_HtlcBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) - } } - } else { - Self { result_ok: false, contents: CResult_HtlcBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) - } } + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), } } } #[no_mangle] -/// Creates a new CResult_HtlcBasepointDecodeErrorZ which has the same data as `orig` +/// Creates a new tuple which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HtlcBasepointDecodeErrorZ_clone(orig: &CResult_HtlcBasepointDecodeErrorZ) -> CResult_HtlcBasepointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn C2Tuple_OutPointChannelIdZ_clone(orig: &C2Tuple_OutPointChannelIdZ) -> C2Tuple_OutPointChannelIdZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointChannelIdZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointChannelIdZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::lightning::ln::types::ChannelId) -> C2Tuple_OutPointChannelIdZ { + C2Tuple_OutPointChannelIdZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointChannelIdZ. +pub extern "C" fn C2Tuple_OutPointChannelIdZ_free(_res: C2Tuple_OutPointChannelIdZ) { } #[repr(C)] -/// The contents of CResult_HtlcKeyDecodeErrorZ -pub union CResult_HtlcKeyDecodeErrorZPtr { +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointChannelIdZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_OutPointChannelIdZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_OutPointChannelIdZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_OutPointChannelIdZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OutPointChannelIdZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_OutPointChannelIdZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_OutPointChannelIdZZ_free(_res: CVec_C2Tuple_OutPointChannelIdZZ) { } +impl Drop for CVec_C2Tuple_OutPointChannelIdZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_OutPointChannelIdZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// A tuple of 2 elements. See the individual fields for the types contained. +pub struct C2Tuple_OutPointCVec_u64ZZ { + /// The element at position 0 + pub a: crate::lightning::chain::transaction::OutPoint, + /// The element at position 1 + pub b: crate::c_types::derived::CVec_u64Z, +} +impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z)> for C2Tuple_OutPointCVec_u64ZZ { + fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z)) -> Self { + Self { + a: tup.0, + b: tup.1, + } + } +} +impl C2Tuple_OutPointCVec_u64ZZ { + #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_u64Z) { + (self.a, self.b) + } +} +impl Clone for C2Tuple_OutPointCVec_u64ZZ { + fn clone(&self) -> Self { + Self { + a: Clone::clone(&self.a), + b: Clone::clone(&self.b), + } + } +} +#[no_mangle] +/// Creates a new tuple which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn C2Tuple_OutPointCVec_u64ZZ_clone(orig: &C2Tuple_OutPointCVec_u64ZZ) -> C2Tuple_OutPointCVec_u64ZZ { Clone::clone(&orig) } +/// Creates a new C2Tuple_OutPointCVec_u64ZZ from the contained elements. +#[no_mangle] +pub extern "C" fn C2Tuple_OutPointCVec_u64ZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_u64Z) -> C2Tuple_OutPointCVec_u64ZZ { + C2Tuple_OutPointCVec_u64ZZ { a, b, } +} + +#[no_mangle] +/// Frees any resources used by the C2Tuple_OutPointCVec_u64ZZ. +pub extern "C" fn C2Tuple_OutPointCVec_u64ZZ_free(_res: C2Tuple_OutPointCVec_u64ZZ) { } +#[repr(C)] +/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZs of arbitrary size. +/// This corresponds to std::vector in C++ +pub struct CVec_C2Tuple_OutPointCVec_u64ZZZ { + /// The elements in the array. + /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). + pub data: *mut crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZ, + /// The number of elements pointed to by `data`. + pub datalen: usize +} +impl CVec_C2Tuple_OutPointCVec_u64ZZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = core::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OutPointCVec_u64ZZ] { + unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_C2Tuple_OutPointCVec_u64ZZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +/// Frees the buffer pointed to by `data` if `datalen` is non-0. +pub extern "C" fn CVec_C2Tuple_OutPointCVec_u64ZZZ_free(_res: CVec_C2Tuple_OutPointCVec_u64ZZZ) { } +impl Drop for CVec_C2Tuple_OutPointCVec_u64ZZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_C2Tuple_OutPointCVec_u64ZZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +/// The contents of CResult_BlindedMessagePathDecodeErrorZ +pub union CResult_BlindedMessagePathDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::HtlcKey, + pub result: *mut crate::lightning::blinded_path::message::BlindedMessagePath, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_HtlcKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::HtlcKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedMessagePathDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_HtlcKeyDecodeErrorZ { - /// The contents of this CResult_HtlcKeyDecodeErrorZ, accessible via either +pub struct CResult_BlindedMessagePathDecodeErrorZ { + /// The contents of this CResult_BlindedMessagePathDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_HtlcKeyDecodeErrorZPtr, - /// Whether this CResult_HtlcKeyDecodeErrorZ represents a success state. + pub contents: CResult_BlindedMessagePathDecodeErrorZPtr, + /// Whether this CResult_BlindedMessagePathDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::HtlcKey) -> CResult_HtlcKeyDecodeErrorZ { - CResult_HtlcKeyDecodeErrorZ { - contents: CResult_HtlcKeyDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ in the success state. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::BlindedMessagePath) -> CResult_BlindedMessagePathDecodeErrorZ { + CResult_BlindedMessagePathDecodeErrorZ { + contents: CResult_BlindedMessagePathDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_HtlcKeyDecodeErrorZ { - CResult_HtlcKeyDecodeErrorZ { - contents: CResult_HtlcKeyDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ in the error state. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_BlindedMessagePathDecodeErrorZ { + CResult_BlindedMessagePathDecodeErrorZ { + contents: CResult_BlindedMessagePathDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -24991,13 +29949,13 @@ pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_is_ok(o: &CResult_HtlcKeyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_is_ok(o: &CResult_BlindedMessagePathDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_HtlcKeyDecodeErrorZ. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_free(_res: CResult_HtlcKeyDecodeErrorZ) { } -impl Drop for CResult_HtlcKeyDecodeErrorZ { +/// Frees any resources used by the CResult_BlindedMessagePathDecodeErrorZ. +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_free(_res: CResult_BlindedMessagePathDecodeErrorZ) { } +impl Drop for CResult_BlindedMessagePathDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25010,16 +29968,16 @@ impl Drop for CResult_HtlcKeyDecodeErrorZ { } } } -impl From> for CResult_HtlcKeyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedMessagePathDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_HtlcKeyDecodeErrorZPtr { result } + CResult_BlindedMessagePathDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_HtlcKeyDecodeErrorZPtr { err } + CResult_BlindedMessagePathDecodeErrorZPtr { err } }; Self { contents, @@ -25027,95 +29985,91 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_HtlcKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedMessagePathDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_HtlcKeyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_BlindedMessagePathDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_HtlcKeyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedMessagePathDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_HtlcKeyDecodeErrorZ_clone(orig: &CResult_HtlcKeyDecodeErrorZ) -> CResult_HtlcKeyDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedMessagePathDecodeErrorZ_clone(orig: &CResult_BlindedMessagePathDecodeErrorZ) -> CResult_BlindedMessagePathDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevocationBasepointDecodeErrorZ -pub union CResult_RevocationBasepointDecodeErrorZPtr { +/// The contents of CResult_BlindedMessagePathNoneZ +pub union CResult_BlindedMessagePathNoneZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::RevocationBasepoint, - /// A pointer to the contents in the error state. - /// Reading from this pointer when `result_ok` is set is undefined. - pub err: *mut crate::lightning::ln::msgs::DecodeError, + pub result: *mut crate::lightning::blinded_path::message::BlindedMessagePath, + /// Note that this value is always NULL, as there are no contents in the Err variant + pub err: *mut core::ffi::c_void, } #[repr(C)] -/// A CResult_RevocationBasepointDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::RevocationBasepoint on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_BlindedMessagePathNoneZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::BlindedMessagePath on success and a () on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevocationBasepointDecodeErrorZ { - /// The contents of this CResult_RevocationBasepointDecodeErrorZ, accessible via either +pub struct CResult_BlindedMessagePathNoneZ { + /// The contents of this CResult_BlindedMessagePathNoneZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevocationBasepointDecodeErrorZPtr, - /// Whether this CResult_RevocationBasepointDecodeErrorZ represents a success state. + pub contents: CResult_BlindedMessagePathNoneZPtr, + /// Whether this CResult_BlindedMessagePathNoneZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationBasepoint) -> CResult_RevocationBasepointDecodeErrorZ { - CResult_RevocationBasepointDecodeErrorZ { - contents: CResult_RevocationBasepointDecodeErrorZPtr { +/// Creates a new CResult_BlindedMessagePathNoneZ in the success state. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_ok(o: crate::lightning::blinded_path::message::BlindedMessagePath) -> CResult_BlindedMessagePathNoneZ { + CResult_BlindedMessagePathNoneZ { + contents: CResult_BlindedMessagePathNoneZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationBasepointDecodeErrorZ { - CResult_RevocationBasepointDecodeErrorZ { - contents: CResult_RevocationBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(e)), +/// Creates a new CResult_BlindedMessagePathNoneZ in the error state. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_err() -> CResult_BlindedMessagePathNoneZ { + CResult_BlindedMessagePathNoneZ { + contents: CResult_BlindedMessagePathNoneZPtr { + err: core::ptr::null_mut(), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_is_ok(o: &CResult_RevocationBasepointDecodeErrorZ) -> bool { +pub extern "C" fn CResult_BlindedMessagePathNoneZ_is_ok(o: &CResult_BlindedMessagePathNoneZ) -> bool { o.result_ok -} -#[no_mangle] -/// Frees any resources used by the CResult_RevocationBasepointDecodeErrorZ. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_free(_res: CResult_RevocationBasepointDecodeErrorZ) { } -impl Drop for CResult_RevocationBasepointDecodeErrorZ { +} +#[no_mangle] +/// Frees any resources used by the CResult_BlindedMessagePathNoneZ. +pub extern "C" fn CResult_BlindedMessagePathNoneZ_free(_res: CResult_BlindedMessagePathNoneZ) { } +impl Drop for CResult_BlindedMessagePathNoneZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { - if unsafe { !(self.contents.err as *mut ()).is_null() } { - let _ = unsafe { Box::from_raw(self.contents.err) }; - } } } } -impl From> for CResult_RevocationBasepointDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_BlindedMessagePathNoneZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RevocationBasepointDecodeErrorZPtr { result } + CResult_BlindedMessagePathNoneZPtr { result } } else { - let err = unsafe { o.contents.err }; - unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevocationBasepointDecodeErrorZPtr { err } + let _ = unsafe { Box::from_raw(o.contents.err) }; + o.contents.err = core::ptr::null_mut(); + CResult_BlindedMessagePathNoneZPtr { err: core::ptr::null_mut() } }; Self { contents, @@ -25123,59 +30077,59 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevocationBasepointDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_BlindedMessagePathNoneZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevocationBasepointDecodeErrorZPtr { - err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + Self { result_ok: false, contents: CResult_BlindedMessagePathNoneZPtr { + err: core::ptr::null_mut() } } } } } #[no_mangle] -/// Creates a new CResult_RevocationBasepointDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_BlindedMessagePathNoneZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevocationBasepointDecodeErrorZ_clone(orig: &CResult_RevocationBasepointDecodeErrorZ) -> CResult_RevocationBasepointDecodeErrorZ { Clone::clone(&orig) } +pub extern "C" fn CResult_BlindedMessagePathNoneZ_clone(orig: &CResult_BlindedMessagePathNoneZ) -> CResult_BlindedMessagePathNoneZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_RevocationKeyDecodeErrorZ -pub union CResult_RevocationKeyDecodeErrorZPtr { +/// The contents of CResult_MessageContextDecodeErrorZ +pub union CResult_MessageContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::ln::channel_keys::RevocationKey, + pub result: *mut crate::lightning::blinded_path::message::MessageContext, /// A pointer to the contents in the error state. /// Reading from this pointer when `result_ok` is set is undefined. pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_RevocationKeyDecodeErrorZ represents the result of a fallible operation, -/// containing a crate::lightning::ln::channel_keys::RevocationKey on success and a crate::lightning::ln::msgs::DecodeError on failure. +/// A CResult_MessageContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::MessageContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_RevocationKeyDecodeErrorZ { - /// The contents of this CResult_RevocationKeyDecodeErrorZ, accessible via either +pub struct CResult_MessageContextDecodeErrorZ { + /// The contents of this CResult_MessageContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_RevocationKeyDecodeErrorZPtr, - /// Whether this CResult_RevocationKeyDecodeErrorZ represents a success state. + pub contents: CResult_MessageContextDecodeErrorZPtr, + /// Whether this CResult_MessageContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ in the success state. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_ok(o: crate::lightning::ln::channel_keys::RevocationKey) -> CResult_RevocationKeyDecodeErrorZ { - CResult_RevocationKeyDecodeErrorZ { - contents: CResult_RevocationKeyDecodeErrorZPtr { +/// Creates a new CResult_MessageContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::MessageContext) -> CResult_MessageContextDecodeErrorZ { + CResult_MessageContextDecodeErrorZ { + contents: CResult_MessageContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ in the error state. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_RevocationKeyDecodeErrorZ { - CResult_RevocationKeyDecodeErrorZ { - contents: CResult_RevocationKeyDecodeErrorZPtr { +/// Creates a new CResult_MessageContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_MessageContextDecodeErrorZ { + CResult_MessageContextDecodeErrorZ { + contents: CResult_MessageContextDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, @@ -25183,13 +30137,13 @@ pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_err(e: crate::lightning::ln: } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_is_ok(o: &CResult_RevocationKeyDecodeErrorZ) -> bool { +pub extern "C" fn CResult_MessageContextDecodeErrorZ_is_ok(o: &CResult_MessageContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_RevocationKeyDecodeErrorZ. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_free(_res: CResult_RevocationKeyDecodeErrorZ) { } -impl Drop for CResult_RevocationKeyDecodeErrorZ { +/// Frees any resources used by the CResult_MessageContextDecodeErrorZ. +pub extern "C" fn CResult_MessageContextDecodeErrorZ_free(_res: CResult_MessageContextDecodeErrorZ) { } +impl Drop for CResult_MessageContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -25202,16 +30156,16 @@ impl Drop for CResult_RevocationKeyDecodeErrorZ { } } } -impl From> for CResult_RevocationKeyDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_MessageContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_RevocationKeyDecodeErrorZPtr { result } + CResult_MessageContextDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = core::ptr::null_mut(); } - CResult_RevocationKeyDecodeErrorZPtr { err } + CResult_MessageContextDecodeErrorZPtr { err } }; Self { contents, @@ -25219,123 +30173,95 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_RevocationKeyDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_MessageContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_RevocationKeyDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_MessageContextDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -/// Creates a new CResult_RevocationKeyDecodeErrorZ which has the same data as `orig` +/// Creates a new CResult_MessageContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn CResult_RevocationKeyDecodeErrorZ_clone(orig: &CResult_RevocationKeyDecodeErrorZ) -> CResult_RevocationKeyDecodeErrorZ { Clone::clone(&orig) } -#[repr(C)] -/// An enum which can either contain a crate::lightning::chain::Filter or not -pub enum COption_FilterZ { - /// When we're in this state, this COption_FilterZ contains a crate::lightning::chain::Filter - Some(crate::lightning::chain::Filter), - /// When we're in this state, this COption_FilterZ contains nothing - None -} -impl COption_FilterZ { - #[allow(unused)] pub(crate) fn is_some(&self) -> bool { - if let Self::None = self { false } else { true } - } - #[allow(unused)] pub(crate) fn is_none(&self) -> bool { - !self.is_some() - } - #[allow(unused)] pub(crate) fn take(mut self) -> crate::lightning::chain::Filter { - if let Self::Some(v) = self { v } else { unreachable!() } - } -} -#[no_mangle] -/// Constructs a new COption_FilterZ containing a crate::lightning::chain::Filter -pub extern "C" fn COption_FilterZ_some(o: crate::lightning::chain::Filter) -> COption_FilterZ { - COption_FilterZ::Some(o) -} -#[no_mangle] -/// Constructs a new COption_FilterZ containing nothing -pub extern "C" fn COption_FilterZ_none() -> COption_FilterZ { - COption_FilterZ::None -} -#[no_mangle] -/// Frees any resources associated with the crate::lightning::chain::Filter, if we are in the Some state -pub extern "C" fn COption_FilterZ_free(_res: COption_FilterZ) { } +pub extern "C" fn CResult_MessageContextDecodeErrorZ_clone(orig: &CResult_MessageContextDecodeErrorZ) -> CResult_MessageContextDecodeErrorZ { Clone::clone(&orig) } #[repr(C)] -/// The contents of CResult_LockedChannelMonitorNoneZ -pub union CResult_LockedChannelMonitorNoneZPtr { +/// The contents of CResult_OffersContextDecodeErrorZ +pub union CResult_OffersContextDecodeErrorZPtr { /// A pointer to the contents in the success state. /// Reading from this pointer when `result_ok` is not set is undefined. - pub result: *mut crate::lightning::chain::chainmonitor::LockedChannelMonitor, - /// Note that this value is always NULL, as there are no contents in the Err variant - pub err: *mut core::ffi::c_void, + pub result: *mut crate::lightning::blinded_path::message::OffersContext, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::msgs::DecodeError, } #[repr(C)] -/// A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation, -/// containing a crate::lightning::chain::chainmonitor::LockedChannelMonitor on success and a () on failure. +/// A CResult_OffersContextDecodeErrorZ represents the result of a fallible operation, +/// containing a crate::lightning::blinded_path::message::OffersContext on success and a crate::lightning::ln::msgs::DecodeError on failure. /// `result_ok` indicates the overall state, and the contents are provided via `contents`. -pub struct CResult_LockedChannelMonitorNoneZ { - /// The contents of this CResult_LockedChannelMonitorNoneZ, accessible via either +pub struct CResult_OffersContextDecodeErrorZ { + /// The contents of this CResult_OffersContextDecodeErrorZ, accessible via either /// `err` or `result` depending on the state of `result_ok`. - pub contents: CResult_LockedChannelMonitorNoneZPtr, - /// Whether this CResult_LockedChannelMonitorNoneZ represents a success state. + pub contents: CResult_OffersContextDecodeErrorZPtr, + /// Whether this CResult_OffersContextDecodeErrorZ represents a success state. pub result_ok: bool, } #[no_mangle] -/// Creates a new CResult_LockedChannelMonitorNoneZ in the success state. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_ok(o: crate::lightning::chain::chainmonitor::LockedChannelMonitor) -> CResult_LockedChannelMonitorNoneZ { - CResult_LockedChannelMonitorNoneZ { - contents: CResult_LockedChannelMonitorNoneZPtr { +/// Creates a new CResult_OffersContextDecodeErrorZ in the success state. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_ok(o: crate::lightning::blinded_path::message::OffersContext) -> CResult_OffersContextDecodeErrorZ { + CResult_OffersContextDecodeErrorZ { + contents: CResult_OffersContextDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -/// Creates a new CResult_LockedChannelMonitorNoneZ in the error state. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_err() -> CResult_LockedChannelMonitorNoneZ { - CResult_LockedChannelMonitorNoneZ { - contents: CResult_LockedChannelMonitorNoneZPtr { - err: core::ptr::null_mut(), +/// Creates a new CResult_OffersContextDecodeErrorZ in the error state. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_err(e: crate::lightning::ln::msgs::DecodeError) -> CResult_OffersContextDecodeErrorZ { + CResult_OffersContextDecodeErrorZ { + contents: CResult_OffersContextDecodeErrorZPtr { + err: Box::into_raw(Box::new(e)), }, result_ok: false, } } /// Checks if the given object is currently in the success state #[no_mangle] -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_is_ok(o: &CResult_LockedChannelMonitorNoneZ) -> bool { +pub extern "C" fn CResult_OffersContextDecodeErrorZ_is_ok(o: &CResult_OffersContextDecodeErrorZ) -> bool { o.result_ok } #[no_mangle] -/// Frees any resources used by the CResult_LockedChannelMonitorNoneZ. -pub extern "C" fn CResult_LockedChannelMonitorNoneZ_free(_res: CResult_LockedChannelMonitorNoneZ) { } -impl Drop for CResult_LockedChannelMonitorNoneZ { +/// Frees any resources used by the CResult_OffersContextDecodeErrorZ. +pub extern "C" fn CResult_OffersContextDecodeErrorZ_free(_res: CResult_OffersContextDecodeErrorZ) { } +impl Drop for CResult_OffersContextDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { let _ = unsafe { Box::from_raw(self.contents.result) }; } } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } } } } -impl From> for CResult_LockedChannelMonitorNoneZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_OffersContextDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = core::ptr::null_mut() }; - CResult_LockedChannelMonitorNoneZPtr { result } + CResult_OffersContextDecodeErrorZPtr { result } } else { - let _ = unsafe { Box::from_raw(o.contents.err) }; - o.contents.err = core::ptr::null_mut(); - CResult_LockedChannelMonitorNoneZPtr { err: core::ptr::null_mut() } + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = core::ptr::null_mut(); } + CResult_OffersContextDecodeErrorZPtr { err } }; Self { contents, @@ -25343,183 +30269,20 @@ impl From Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::transaction::OutPoint] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_OutPointZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_OutPointZ_free(_res: CVec_OutPointZ) { } -impl Drop for CVec_OutPointZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_OutPointZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A dynamically-allocated array of crate::lightning::chain::chainmonitor::MonitorUpdateIds of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_MonitorUpdateIdZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::lightning::chain::chainmonitor::MonitorUpdateId, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_MonitorUpdateIdZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::chainmonitor::MonitorUpdateId] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_MonitorUpdateIdZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_MonitorUpdateIdZ_free(_res: CVec_MonitorUpdateIdZ) { } -impl Drop for CVec_MonitorUpdateIdZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_MonitorUpdateIdZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} -#[repr(C)] -/// A tuple of 2 elements. See the individual fields for the types contained. -pub struct C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - /// The element at position 0 - pub a: crate::lightning::chain::transaction::OutPoint, - /// The element at position 1 - pub b: crate::c_types::derived::CVec_MonitorUpdateIdZ, -} -impl From<(crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ)> for C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - fn from (tup: (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ)) -> Self { - Self { - a: tup.0, - b: tup.1, - } - } -} -impl C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - #[allow(unused)] pub(crate) fn to_rust(mut self) -> (crate::lightning::chain::transaction::OutPoint, crate::c_types::derived::CVec_MonitorUpdateIdZ) { - (self.a, self.b) - } -} -impl Clone for C2Tuple_OutPointCVec_MonitorUpdateIdZZ { +impl Clone for CResult_OffersContextDecodeErrorZ { fn clone(&self) -> Self { - Self { - a: Clone::clone(&self.a), - b: Clone::clone(&self.b), + if self.result_ok { + Self { result_ok: true, contents: CResult_OffersContextDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_OffersContextDecodeErrorZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } } } } #[no_mangle] -/// Creates a new tuple which has the same data as `orig` +/// Creates a new CResult_OffersContextDecodeErrorZ which has the same data as `orig` /// but with all dynamically-allocated buffers duplicated in new buffers. -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig: &C2Tuple_OutPointCVec_MonitorUpdateIdZZ) -> C2Tuple_OutPointCVec_MonitorUpdateIdZZ { Clone::clone(&orig) } -/// Creates a new C2Tuple_OutPointCVec_MonitorUpdateIdZZ from the contained elements. -#[no_mangle] -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a: crate::lightning::chain::transaction::OutPoint, b: crate::c_types::derived::CVec_MonitorUpdateIdZ) -> C2Tuple_OutPointCVec_MonitorUpdateIdZZ { - C2Tuple_OutPointCVec_MonitorUpdateIdZZ { a, b, } -} - -#[no_mangle] -/// Frees any resources used by the C2Tuple_OutPointCVec_MonitorUpdateIdZZ. -pub extern "C" fn C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res: C2Tuple_OutPointCVec_MonitorUpdateIdZZ) { } -#[repr(C)] -/// A dynamically-allocated array of crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZs of arbitrary size. -/// This corresponds to std::vector in C++ -pub struct CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - /// The elements in the array. - /// If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). - pub data: *mut crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZ, - /// The number of elements pointed to by `data`. - pub datalen: usize -} -impl CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { - if self.datalen == 0 { return Vec::new(); } - let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); - self.data = core::ptr::null_mut(); - self.datalen = 0; - ret - } - #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_OutPointCVec_MonitorUpdateIdZZ] { - unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) } - } -} -impl From> for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - fn from(v: Vec) -> Self { - let datalen = v.len(); - let data = Box::into_raw(v.into_boxed_slice()); - Self { datalen, data: unsafe { (*data).as_mut_ptr() } } - } -} -#[no_mangle] -/// Frees the buffer pointed to by `data` if `datalen` is non-0. -pub extern "C" fn CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res: CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ) { } -impl Drop for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - fn drop(&mut self) { - if self.datalen == 0 { return; } - let _ = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }; - } -} -impl Clone for CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { - fn clone(&self) -> Self { - let mut res = Vec::new(); - if self.datalen == 0 { return Self::from(res); } - res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }); - Self::from(res) - } -} +pub extern "C" fn CResult_OffersContextDecodeErrorZ_clone(orig: &CResult_OffersContextDecodeErrorZ) -> CResult_OffersContextDecodeErrorZ { Clone::clone(&orig) } diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 3fe5eb6..5fd9857 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -6,7 +6,10 @@ pub mod derived; use bitcoin::Transaction as BitcoinTransaction; use bitcoin::Witness as BitcoinWitness; use bitcoin::address; -use bitcoin::address::WitnessProgram as BitcoinWitnessProgram; +use bitcoin::WitnessProgram as BitcoinWitnessProgram; +use bitcoin::WitnessVersion as BitcoinWitnessVersion; +use bitcoin::key::TweakedPublicKey as BitcoinTweakedPublicKey; +use bitcoin::key::XOnlyPublicKey; use bitcoin::hashes::Hash; use bitcoin::secp256k1::PublicKey as SecpPublicKey; use bitcoin::secp256k1::SecretKey as SecpSecretKey; @@ -16,16 +19,13 @@ use bitcoin::secp256k1::Error as SecpError; use bitcoin::secp256k1::ecdsa::RecoveryId; use bitcoin::secp256k1::ecdsa::RecoverableSignature as SecpRecoverableSignature; use bitcoin::secp256k1::Scalar as SecpScalar; -use bitcoin::bech32; +use bech32; use core::convert::TryInto; // Bindings need at least rustc 1.34 use alloc::borrow::ToOwned; use core::ffi::c_void; -#[cfg(feature = "std")] -pub(crate) use std::io::{self, Cursor, Read}; -#[cfg(feature = "no-std")] -pub(crate) use core2::io::{self, Cursor, Read}; +pub(crate) use bitcoin::io::{self, Cursor, Read}; #[cfg(feature = "no-std")] use alloc::{boxed::Box, vec::Vec, string::String}; @@ -88,12 +88,12 @@ impl Into for U128 { #[repr(C)] pub struct WitnessVersion(u8); -impl From for WitnessVersion { - fn from(o: address::WitnessVersion) -> Self { Self(o.to_num()) } +impl From for WitnessVersion { + fn from(o: BitcoinWitnessVersion) -> Self { Self(o.to_num()) } } -impl Into for WitnessVersion { - fn into(self) -> address::WitnessVersion { - address::WitnessVersion::try_from(self.0).expect("WitnessVersion objects must be in the range 0..=16") +impl Into for WitnessVersion { + fn into(self) -> BitcoinWitnessVersion { + BitcoinWitnessVersion::try_from(self.0).expect("WitnessVersion objects must be in the range 0..=16") } } @@ -114,7 +114,7 @@ impl WitnessProgram { pub(crate) fn into_bitcoin(mut self) -> BitcoinWitnessProgram { BitcoinWitnessProgram::new( self.version.into(), - self.program.into_rust(), + self.program.as_slice(), ).expect("Program length was previously checked") } } @@ -169,6 +169,25 @@ impl PublicKey { pub(crate) fn null() -> Self { Self { compressed_form: [0; 33] } } } +#[derive(Clone)] +#[repr(C)] +/// Represents a tweaked X-only public key as required for BIP 340 (Taproot). +pub struct TweakedPublicKey { + /// The bytes of the public key X coordinate + pub x_coordinate: [u8; 32], +} +impl TweakedPublicKey { + pub(crate) fn from_rust(pk: &BitcoinTweakedPublicKey) -> Self { + Self { + x_coordinate: pk.serialize(), + } + } + pub(crate) fn into_rust(&self) -> BitcoinTweakedPublicKey { + let xonly_key = XOnlyPublicKey::from_slice(&self.x_coordinate).unwrap(); + BitcoinTweakedPublicKey::dangerous_assume_tweaked(xonly_key) + } +} + #[repr(C)] #[derive(Clone)] /// Represents a valid secp256k1 secret key serialized as a 32 byte array. @@ -271,6 +290,9 @@ impl BigEndianScalar { pub extern "C" fn BigEndianScalar_new(big_endian_bytes: ThirtyTwoBytes) -> BigEndianScalar { BigEndianScalar { big_endian_bytes: big_endian_bytes.data } } +#[no_mangle] +/// Creates a new BigEndianScalar which has the same data as `orig` +pub extern "C" fn BigEndianScalar_clone(orig: &BigEndianScalar) -> BigEndianScalar { orig.clone() } #[repr(C)] #[derive(Copy, Clone)] @@ -298,6 +320,8 @@ pub enum Secp256k1Error { InvalidPublicKeySum, /// The only valid parity values are 0 or 1. InvalidParityValue, + /// Invalid Elligator Swift Value + InvalidEllSwift, } impl Secp256k1Error { pub(crate) fn from_rust(err: SecpError) -> Self { @@ -312,6 +336,7 @@ impl Secp256k1Error { SecpError::InvalidTweak => Secp256k1Error::InvalidTweak, SecpError::NotEnoughMemory => Secp256k1Error::NotEnoughMemory, SecpError::InvalidPublicKeySum => Secp256k1Error::InvalidPublicKeySum, + SecpError::InvalidEllSwift => Secp256k1Error::InvalidEllSwift, SecpError::InvalidParityValue(_) => Secp256k1Error::InvalidParityValue, } } @@ -328,6 +353,7 @@ impl Secp256k1Error { Secp256k1Error::InvalidTweak => SecpError::InvalidTweak, Secp256k1Error::NotEnoughMemory => SecpError::NotEnoughMemory, Secp256k1Error::InvalidPublicKeySum => SecpError::InvalidPublicKeySum, + Secp256k1Error::InvalidEllSwift => SecpError::InvalidEllSwift, Secp256k1Error::InvalidParityValue => SecpError::InvalidParityValue(invalid_parity), } } @@ -436,12 +462,15 @@ impl IOError { io::ErrorKind::Interrupted => IOError::Interrupted, io::ErrorKind::Other => IOError::Other, io::ErrorKind::UnexpectedEof => IOError::UnexpectedEof, - _ => IOError::Other, } } - pub(crate) fn from_rust(err: io::Error) -> Self { + pub(crate) fn from_bitcoin(err: io::Error) -> Self { Self::from_rust_kind(err.kind()) } + #[cfg(feature = "std")] + pub(crate) fn from_rust(err: std::io::Error) -> Self { + Self::from_bitcoin(err.into()) + } pub(crate) fn to_rust_kind(&self) -> io::ErrorKind { match self { IOError::NotFound => io::ErrorKind::NotFound, @@ -677,13 +706,13 @@ impl TxOut { pub(crate) fn into_rust(mut self) -> ::bitcoin::blockdata::transaction::TxOut { ::bitcoin::blockdata::transaction::TxOut { script_pubkey: self.script_pubkey.into_rust().into(), - value: self.value, + value: bitcoin::Amount::from_sat(self.value), } } pub(crate) fn from_rust(txout: &::bitcoin::blockdata::transaction::TxOut) -> Self { Self { script_pubkey: derived::CVec_u8Z::from(txout.script_pubkey.clone().into_bytes()), - value: txout.value + value: txout.value.to_sat() } } } @@ -740,7 +769,7 @@ impl u8slice { } pub(crate) fn reader_to_vec(r: &mut R) -> derived::CVec_u8Z { let mut res = Vec::new(); - r.read_to_end(&mut res).unwrap(); + r.read_to_limit(&mut res, u64::MAX).unwrap(); derived::CVec_u8Z::from(res) } @@ -753,6 +782,7 @@ pub struct ThirtyTwoBytes { pub data: [u8; 32], } +#[derive(Clone)] #[repr(C)] /// A 3-byte byte array. pub struct ThreeBytes { /** The three bytes */ pub data: [u8; 3], } @@ -848,6 +878,12 @@ impl Str { pub(crate) fn into_pathbuf(mut self) -> std::path::PathBuf { std::path::PathBuf::from(self.into_string()) } + pub(crate) fn from_rust(s: &str) -> Self { + s.into() + } + pub(crate) fn is_empty(&self) -> bool { + self.len == 0 + } } impl Into for String { fn into(self) -> Str { diff --git a/lightning-c-bindings/src/lib.rs b/lightning-c-bindings/src/lib.rs index 53abe8a..a076598 100644 --- a/lightning-c-bindings/src/lib.rs +++ b/lightning-c-bindings/src/lib.rs @@ -24,6 +24,7 @@ pub mod version; pub mod c_types; pub mod bitcoin; pub mod lightning; +pub mod lightning_types; pub mod lightning_persister; pub mod lightning_background_processor; pub mod lightning_invoice; diff --git a/lightning-c-bindings/src/lightning/blinded_path/message.rs b/lightning-c-bindings/src/lightning/blinded_path/message.rs new file mode 100644 index 0000000..382a728 --- /dev/null +++ b/lightning-c-bindings/src/lightning/blinded_path/message.rs @@ -0,0 +1,870 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Data structures and methods for constructing [`BlindedMessagePath`]s to send a message over. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::blinded_path::message::BlindedMessagePath as nativeBlindedMessagePathImport; +pub(crate) type nativeBlindedMessagePath = nativeBlindedMessagePathImport; + +/// A blinded path to be used for sending or receiving a message, hiding the identity of the +/// recipient. +#[must_use] +#[repr(C)] +pub struct BlindedMessagePath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBlindedMessagePath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for BlindedMessagePath { + type Target = nativeBlindedMessagePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedMessagePath { } +unsafe impl core::marker::Sync for BlindedMessagePath { } +impl Drop for BlindedMessagePath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedMessagePath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedMessagePath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_free(this_obj: BlindedMessagePath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedMessagePath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedMessagePath) }; +} +#[allow(unused)] +impl BlindedMessagePath { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedMessagePath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedMessagePath { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBlindedMessagePath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for BlindedMessagePath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedMessagePath>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedMessagePath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedMessagePath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedMessagePath +pub extern "C" fn BlindedMessagePath_clone(orig: &BlindedMessagePath) -> BlindedMessagePath { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedMessagePath object +pub extern "C" fn BlindedMessagePath_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::BlindedMessagePath }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedMessagePath. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_hash(o: &BlindedMessagePath) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BlindedMessagePaths contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_eq(a: &BlindedMessagePath, b: &BlindedMessagePath) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the BlindedMessagePath object into a byte array which can be read by BlindedMessagePath_read +pub extern "C" fn BlindedMessagePath_write(obj: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedMessagePath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::message::nativeBlindedMessagePath) }) +} +#[no_mangle] +/// Read a BlindedMessagePath from a byte array, created by BlindedMessagePath_write +pub extern "C" fn BlindedMessagePath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedMessagePathDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Create a one-hop blinded path for a message. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_one_hop(mut recipient_node_id: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedMessagePathNoneZ { + let mut ret = lightning::blinded_path::message::BlindedMessagePath::one_hop(recipient_node_id.into_rust(), context.into_native(), entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a path for an onion message, to be forwarded along `node_pks`. The last node +/// pubkey in `node_pks` will be the destination node. +/// +/// Errors if no hops are provided or if `node_pk`(s) are invalid. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_new(mut intermediate_nodes: crate::c_types::derived::CVec_MessageForwardNodeZ, mut recipient_node_id: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedMessagePathNoneZ { + let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning::blinded_path::message::BlindedMessagePath::new(&local_intermediate_nodes[..], recipient_node_id.into_rust(), context.into_native(), entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Attempts to a use a compact representation for the [`IntroductionNode`] by using a directed +/// short channel id from a channel in `network_graph` leading to the introduction node. +/// +/// While this may result in a smaller encoding, there is a trade off in that the path may +/// become invalid if the channel is closed or hasn't been propagated via gossip. Therefore, +/// calling this may not be suitable for long-lived blinded paths. +#[no_mangle] +pub extern "C" fn BlindedMessagePath_use_compact_introduction_node(this_arg: &mut crate::lightning::blinded_path::message::BlindedMessagePath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::message::nativeBlindedMessagePath)) }.use_compact_introduction_node(network_graph.get_native_ref()) +} + +/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., +/// it is found in the network graph). +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref()); + let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// The [`IntroductionNode`] of the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_introduction_node(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::lightning::blinded_path::IntroductionNode { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.introduction_node(); + crate::lightning::blinded_path::IntroductionNode::from_native(ret) +} + +/// Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the message. +/// +/// [`encrypted_payload`]: BlindedHop::encrypted_payload +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_blinding_point(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinding_point(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// The [`BlindedHop`]s within the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_blinded_hops(this_arg: &crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CVec_BlindedHopZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinded_hops(); + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Advance the blinded onion message path by one hop, making the second hop into the new +/// introduction node. +/// +/// Will only modify `self` when returning `Ok`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedMessagePath_advance_path_by_one(this_arg: &mut crate::lightning::blinded_path::message::BlindedMessagePath, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::message::nativeBlindedMessagePath)) }.advance_path_by_one(node_signer, node_id_lookup, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// The next hop to forward an onion message along its path. +/// +/// Note that payment blinded paths always specify their next hop using an explicit node id. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum NextMessageHop { + /// The node id of the next hop. + NodeId( + crate::c_types::PublicKey), + /// The short channel id leading to the next hop. + ShortChannelId( + u64), +} +use lightning::blinded_path::message::NextMessageHop as NextMessageHopImport; +pub(crate) type nativeNextMessageHop = NextMessageHopImport; + +impl NextMessageHop { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeNextMessageHop { + match self { + NextMessageHop::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNextMessageHop::NodeId ( + a_nonref.into_rust(), + ) + }, + NextMessageHop::ShortChannelId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNextMessageHop::ShortChannelId ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeNextMessageHop { + match self { + NextMessageHop::NodeId (mut a, ) => { + nativeNextMessageHop::NodeId ( + a.into_rust(), + ) + }, + NextMessageHop::ShortChannelId (mut a, ) => { + nativeNextMessageHop::ShortChannelId ( + a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &NextMessageHopImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNextMessageHop) }; + match native { + nativeNextMessageHop::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NextMessageHop::NodeId ( + crate::c_types::PublicKey::from_rust(&a_nonref), + ) + }, + nativeNextMessageHop::ShortChannelId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NextMessageHop::ShortChannelId ( + a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeNextMessageHop) -> Self { + match native { + nativeNextMessageHop::NodeId (mut a, ) => { + NextMessageHop::NodeId ( + crate::c_types::PublicKey::from_rust(&a), + ) + }, + nativeNextMessageHop::ShortChannelId (mut a, ) => { + NextMessageHop::ShortChannelId ( + a, + ) + }, + } + } +} +/// Frees any resources used by the NextMessageHop +#[no_mangle] +pub extern "C" fn NextMessageHop_free(this_ptr: NextMessageHop) { } +/// Creates a copy of the NextMessageHop +#[no_mangle] +pub extern "C" fn NextMessageHop_clone(orig: &NextMessageHop) -> NextMessageHop { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NextMessageHop_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NextMessageHop)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NextMessageHop_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut NextMessageHop) }; +} +#[no_mangle] +/// Utility method to constructs a new NodeId-variant NextMessageHop +pub extern "C" fn NextMessageHop_node_id(a: crate::c_types::PublicKey) -> NextMessageHop { + NextMessageHop::NodeId(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ShortChannelId-variant NextMessageHop +pub extern "C" fn NextMessageHop_short_channel_id(a: u64) -> NextMessageHop { + NextMessageHop::ShortChannelId(a, ) +} +/// Get a string which allows debug introspection of a NextMessageHop object +pub extern "C" fn NextMessageHop_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::NextMessageHop }).into()} +/// Generates a non-cryptographic 64-bit hash of the NextMessageHop. +#[no_mangle] +pub extern "C" fn NextMessageHop_hash(o: &NextMessageHop) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two NextMessageHops contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn NextMessageHop_eq(a: &NextMessageHop, b: &NextMessageHop) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning::blinded_path::message::MessageForwardNode as nativeMessageForwardNodeImport; +pub(crate) type nativeMessageForwardNode = nativeMessageForwardNodeImport; + +/// An intermediate node, and possibly a short channel id leading to the next node. +#[must_use] +#[repr(C)] +pub struct MessageForwardNode { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeMessageForwardNode, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for MessageForwardNode { + type Target = nativeMessageForwardNode; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MessageForwardNode { } +unsafe impl core::marker::Sync for MessageForwardNode { } +impl Drop for MessageForwardNode { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeMessageForwardNode>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the MessageForwardNode, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn MessageForwardNode_free(this_obj: MessageForwardNode) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageForwardNode_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMessageForwardNode) }; +} +#[allow(unused)] +impl MessageForwardNode { + pub(crate) fn get_native_ref(&self) -> &'static nativeMessageForwardNode { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMessageForwardNode { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeMessageForwardNode { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// This node's pubkey. +#[no_mangle] +pub extern "C" fn MessageForwardNode_get_node_id(this_ptr: &MessageForwardNode) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// This node's pubkey. +#[no_mangle] +pub extern "C" fn MessageForwardNode_set_node_id(this_ptr: &mut MessageForwardNode, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); +} +/// The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s +/// `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a +/// more compact representation. +#[no_mangle] +pub extern "C" fn MessageForwardNode_get_short_channel_id(this_ptr: &MessageForwardNode) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The channel between `node_id` and the next hop. If set, the constructed [`BlindedHop`]'s +/// `encrypted_payload` will use this instead of the next [`MessageForwardNode::node_id`] for a +/// more compact representation. +#[no_mangle] +pub extern "C" fn MessageForwardNode_set_short_channel_id(this_ptr: &mut MessageForwardNode, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val; +} +/// Constructs a new MessageForwardNode given each field +#[must_use] +#[no_mangle] +pub extern "C" fn MessageForwardNode_new(mut node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z) -> MessageForwardNode { + let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; + MessageForwardNode { inner: ObjOps::heap_alloc(nativeMessageForwardNode { + node_id: node_id_arg.into_rust(), + short_channel_id: local_short_channel_id_arg, + }), is_owned: true } +} +impl Clone for MessageForwardNode { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeMessageForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeMessageForwardNode)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the MessageForwardNode +pub extern "C" fn MessageForwardNode_clone(orig: &MessageForwardNode) -> MessageForwardNode { + orig.clone() +} +/// Get a string which allows debug introspection of a MessageForwardNode object +pub extern "C" fn MessageForwardNode_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::MessageForwardNode }).into()} +/// Generates a non-cryptographic 64-bit hash of the MessageForwardNode. +#[no_mangle] +pub extern "C" fn MessageForwardNode_hash(o: &MessageForwardNode) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two MessageForwardNodes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn MessageForwardNode_eq(a: &MessageForwardNode, b: &MessageForwardNode) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Additional data included by the recipient in a [`BlindedMessagePath`]. +/// +/// This data is encrypted by the recipient and will be given to the corresponding message handler +/// when handling a message sent over the [`BlindedMessagePath`]. The recipient can use this data to +/// authenticate the message or for further processing if needed. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MessageContext { + /// Context specific to an [`OffersMessage`]. + /// + /// [`OffersMessage`]: crate::onion_message::offers::OffersMessage + Offers( + crate::lightning::blinded_path::message::OffersContext), + /// Context specific to a [`CustomOnionMessageHandler::CustomMessage`]. + /// + /// [`CustomOnionMessageHandler::CustomMessage`]: crate::onion_message::messenger::CustomOnionMessageHandler::CustomMessage + Custom( + crate::c_types::derived::CVec_u8Z), +} +use lightning::blinded_path::message::MessageContext as MessageContextImport; +pub(crate) type nativeMessageContext = MessageContextImport; + +impl MessageContext { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMessageContext { + match self { + MessageContext::Offers (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeMessageContext::Offers ( + a_nonref.into_native(), + ) + }, + MessageContext::Custom (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item }); }; + nativeMessageContext::Custom ( + local_a_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMessageContext { + match self { + MessageContext::Offers (mut a, ) => { + nativeMessageContext::Offers ( + a.into_native(), + ) + }, + MessageContext::Custom (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item }); }; + nativeMessageContext::Custom ( + local_a, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &MessageContextImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeMessageContext) }; + match native { + nativeMessageContext::Offers (ref a, ) => { + let mut a_nonref = Clone::clone(a); + MessageContext::Offers ( + crate::lightning::blinded_path::message::OffersContext::native_into(a_nonref), + ) + }, + nativeMessageContext::Custom (ref a, ) => { + let mut a_nonref = Clone::clone(a); + let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { item }); }; + MessageContext::Custom ( + local_a_nonref.into(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMessageContext) -> Self { + match native { + nativeMessageContext::Offers (mut a, ) => { + MessageContext::Offers ( + crate::lightning::blinded_path::message::OffersContext::native_into(a), + ) + }, + nativeMessageContext::Custom (mut a, ) => { + let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { item }); }; + MessageContext::Custom ( + local_a.into(), + ) + }, + } + } +} +/// Frees any resources used by the MessageContext +#[no_mangle] +pub extern "C" fn MessageContext_free(this_ptr: MessageContext) { } +/// Creates a copy of the MessageContext +#[no_mangle] +pub extern "C" fn MessageContext_clone(orig: &MessageContext) -> MessageContext { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const MessageContext)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut MessageContext) }; +} +#[no_mangle] +/// Utility method to constructs a new Offers-variant MessageContext +pub extern "C" fn MessageContext_offers(a: crate::lightning::blinded_path::message::OffersContext) -> MessageContext { + MessageContext::Offers(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Custom-variant MessageContext +pub extern "C" fn MessageContext_custom(a: crate::c_types::derived::CVec_u8Z) -> MessageContext { + MessageContext::Custom(a, ) +} +/// Get a string which allows debug introspection of a MessageContext object +pub extern "C" fn MessageContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::MessageContext }).into()} +/// Contains data specific to an [`OffersMessage`]. +/// +/// [`OffersMessage`]: crate::onion_message::offers::OffersMessage +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum OffersContext { + /// Context used by a [`BlindedMessagePath`] within an [`Offer`]. + /// + /// This variant is intended to be received when handling an [`InvoiceRequest`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + InvoiceRequest { + /// A nonce used for authenticating that an [`InvoiceRequest`] is for a valid [`Offer`] and + /// for deriving the offer's signing keys. + /// + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + /// [`Offer`]: crate::offers::offer::Offer + nonce: crate::lightning::offers::nonce::Nonce, + }, + /// Context used by a [`BlindedMessagePath`] within a [`Refund`] or as a reply path for an + /// [`InvoiceRequest`]. + /// + /// This variant is intended to be received when handling a [`Bolt12Invoice`] or an + /// [`InvoiceError`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + OutboundPayment { + /// Payment ID used when creating a [`Refund`] or [`InvoiceRequest`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + payment_id: crate::c_types::ThirtyTwoBytes, + /// A nonce used for authenticating that a [`Bolt12Invoice`] is for a valid [`Refund`] or + /// [`InvoiceRequest`] and for deriving their signing keys. + /// + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`Refund`]: crate::offers::refund::Refund + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + nonce: crate::lightning::offers::nonce::Nonce, + /// Authentication code for the [`PaymentId`], which should be checked when the context is + /// used with an [`InvoiceError`]. + /// + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + hmac: crate::c_types::ThirtyTwoBytes, + }, + /// Context used by a [`BlindedMessagePath`] as a reply path for a [`Bolt12Invoice`]. + /// + /// This variant is intended to be received when handling an [`InvoiceError`]. + /// + /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + InboundPayment { + /// The same payment hash as [`Bolt12Invoice::payment_hash`]. + /// + /// [`Bolt12Invoice::payment_hash`]: crate::offers::invoice::Bolt12Invoice::payment_hash + payment_hash: crate::c_types::ThirtyTwoBytes, + }, +} +use lightning::blinded_path::message::OffersContext as OffersContextImport; +pub(crate) type nativeOffersContext = OffersContextImport; + +impl OffersContext { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeOffersContext { + match self { + OffersContext::InvoiceRequest {ref nonce, } => { + let mut nonce_nonref = Clone::clone(nonce); + nativeOffersContext::InvoiceRequest { + nonce: *unsafe { Box::from_raw(nonce_nonref.take_inner()) }, + } + }, + OffersContext::OutboundPayment {ref payment_id, ref nonce, ref hmac, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut nonce_nonref = Clone::clone(nonce); + let mut hmac_nonref = Clone::clone(hmac); + let mut local_hmac_nonref = if hmac_nonref.data == [0; 32] { None } else { Some( { hmac_nonref.data }) }; + nativeOffersContext::OutboundPayment { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + nonce: *unsafe { Box::from_raw(nonce_nonref.take_inner()) }, + hmac: local_hmac_nonref, + } + }, + OffersContext::InboundPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + nativeOffersContext::InboundPayment { + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeOffersContext { + match self { + OffersContext::InvoiceRequest {mut nonce, } => { + nativeOffersContext::InvoiceRequest { + nonce: *unsafe { Box::from_raw(nonce.take_inner()) }, + } + }, + OffersContext::OutboundPayment {mut payment_id, mut nonce, mut hmac, } => { + let mut local_hmac = if hmac.data == [0; 32] { None } else { Some( { hmac.data }) }; + nativeOffersContext::OutboundPayment { + payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + nonce: *unsafe { Box::from_raw(nonce.take_inner()) }, + hmac: local_hmac, + } + }, + OffersContext::InboundPayment {mut payment_hash, } => { + nativeOffersContext::InboundPayment { + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &OffersContextImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOffersContext) }; + match native { + nativeOffersContext::InvoiceRequest {ref nonce, } => { + let mut nonce_nonref = Clone::clone(nonce); + OffersContext::InvoiceRequest { + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce_nonref), is_owned: true }, + } + }, + nativeOffersContext::OutboundPayment {ref payment_id, ref nonce, ref hmac, } => { + let mut payment_id_nonref = Clone::clone(payment_id); + let mut nonce_nonref = Clone::clone(nonce); + let mut hmac_nonref = Clone::clone(hmac); + let mut local_hmac_nonref = if hmac_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (hmac_nonref.unwrap()) } } }; + OffersContext::OutboundPayment { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce_nonref), is_owned: true }, + hmac: local_hmac_nonref, + } + }, + nativeOffersContext::InboundPayment {ref payment_hash, } => { + let mut payment_hash_nonref = Clone::clone(payment_hash); + OffersContext::InboundPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeOffersContext) -> Self { + match native { + nativeOffersContext::InvoiceRequest {mut nonce, } => { + OffersContext::InvoiceRequest { + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce), is_owned: true }, + } + }, + nativeOffersContext::OutboundPayment {mut payment_id, mut nonce, mut hmac, } => { + let mut local_hmac = if hmac.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (hmac.unwrap()) } } }; + OffersContext::OutboundPayment { + payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + nonce: crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(nonce), is_owned: true }, + hmac: local_hmac, + } + }, + nativeOffersContext::InboundPayment {mut payment_hash, } => { + OffersContext::InboundPayment { + payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + } + }, + } + } +} +/// Frees any resources used by the OffersContext +#[no_mangle] +pub extern "C" fn OffersContext_free(this_ptr: OffersContext) { } +/// Creates a copy of the OffersContext +#[no_mangle] +pub extern "C" fn OffersContext_clone(orig: &OffersContext) -> OffersContext { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OffersContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const OffersContext)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OffersContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut OffersContext) }; +} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequest-variant OffersContext +pub extern "C" fn OffersContext_invoice_request(nonce: crate::lightning::offers::nonce::Nonce) -> OffersContext { + OffersContext::InvoiceRequest { + nonce, + } +} +#[no_mangle] +/// Utility method to constructs a new OutboundPayment-variant OffersContext +pub extern "C" fn OffersContext_outbound_payment(payment_id: crate::c_types::ThirtyTwoBytes, nonce: crate::lightning::offers::nonce::Nonce, hmac: crate::c_types::ThirtyTwoBytes) -> OffersContext { + OffersContext::OutboundPayment { + payment_id, + nonce, + hmac, + } +} +#[no_mangle] +/// Utility method to constructs a new InboundPayment-variant OffersContext +pub extern "C" fn OffersContext_inbound_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> OffersContext { + OffersContext::InboundPayment { + payment_hash, + } +} +/// Get a string which allows debug introspection of a OffersContext object +pub extern "C" fn OffersContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::message::OffersContext }).into()} +/// Checks if two OffersContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn OffersContext_eq(a: &OffersContext, b: &OffersContext) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the MessageContext object into a byte array which can be read by MessageContext_read +pub extern "C" fn MessageContext_write(obj: &crate::lightning::blinded_path::message::MessageContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn MessageContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + MessageContext_write(unsafe { &*(obj as *const MessageContext) }) +} +#[no_mangle] +/// Read a MessageContext from a byte array, created by MessageContext_write +pub extern "C" fn MessageContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_MessageContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::MessageContext::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the OffersContext object into a byte array which can be read by OffersContext_read +pub extern "C" fn OffersContext_write(obj: &crate::lightning::blinded_path::message::OffersContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn OffersContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + OffersContext_write(unsafe { &*(obj as *const OffersContext) }) +} +#[no_mangle] +/// Read a OffersContext from a byte array, created by OffersContext_write +pub extern "C" fn OffersContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OffersContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::message::OffersContext::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/blinded_path/mod.rs b/lightning-c-bindings/src/lightning/blinded_path/mod.rs index b6e36ea..4c2f1f6 100644 --- a/lightning-c-bindings/src/lightning/blinded_path/mod.rs +++ b/lightning-c-bindings/src/lightning/blinded_path/mod.rs @@ -18,7 +18,8 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod payment; -mod message { +pub mod message; +mod utils { use alloc::str::FromStr; use alloc::string::String; @@ -30,32 +31,318 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -mod utils { +/// The unblinded node in a blinded path. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum IntroductionNode { + /// The node id of the introduction node. + NodeId( + crate::c_types::PublicKey), + /// The short channel id of the channel leading to the introduction node. The [`Direction`] + /// identifies which side of the channel is the introduction node. + DirectedShortChannelId( + crate::lightning::blinded_path::Direction, + u64), +} +use lightning::blinded_path::IntroductionNode as IntroductionNodeImport; +pub(crate) type nativeIntroductionNode = IntroductionNodeImport; -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; +impl IntroductionNode { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeIntroductionNode { + match self { + IntroductionNode::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeIntroductionNode::NodeId ( + a_nonref.into_rust(), + ) + }, + IntroductionNode::DirectedShortChannelId (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + nativeIntroductionNode::DirectedShortChannelId ( + a_nonref.into_native(), + b_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeIntroductionNode { + match self { + IntroductionNode::NodeId (mut a, ) => { + nativeIntroductionNode::NodeId ( + a.into_rust(), + ) + }, + IntroductionNode::DirectedShortChannelId (mut a, mut b, ) => { + nativeIntroductionNode::DirectedShortChannelId ( + a.into_native(), + b, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &IntroductionNodeImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeIntroductionNode) }; + match native { + nativeIntroductionNode::NodeId (ref a, ) => { + let mut a_nonref = Clone::clone(a); + IntroductionNode::NodeId ( + crate::c_types::PublicKey::from_rust(&a_nonref), + ) + }, + nativeIntroductionNode::DirectedShortChannelId (ref a, ref b, ) => { + let mut a_nonref = Clone::clone(a); + let mut b_nonref = Clone::clone(b); + IntroductionNode::DirectedShortChannelId ( + crate::lightning::blinded_path::Direction::native_into(a_nonref), + b_nonref, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeIntroductionNode) -> Self { + match native { + nativeIntroductionNode::NodeId (mut a, ) => { + IntroductionNode::NodeId ( + crate::c_types::PublicKey::from_rust(&a), + ) + }, + nativeIntroductionNode::DirectedShortChannelId (mut a, mut b, ) => { + IntroductionNode::DirectedShortChannelId ( + crate::lightning::blinded_path::Direction::native_into(a), + b, + ) + }, + } + } +} +/// Frees any resources used by the IntroductionNode +#[no_mangle] +pub extern "C" fn IntroductionNode_free(this_ptr: IntroductionNode) { } +/// Creates a copy of the IntroductionNode +#[no_mangle] +pub extern "C" fn IntroductionNode_clone(orig: &IntroductionNode) -> IntroductionNode { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn IntroductionNode_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const IntroductionNode)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn IntroductionNode_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut IntroductionNode) }; +} +#[no_mangle] +/// Utility method to constructs a new NodeId-variant IntroductionNode +pub extern "C" fn IntroductionNode_node_id(a: crate::c_types::PublicKey) -> IntroductionNode { + IntroductionNode::NodeId(a, ) +} +#[no_mangle] +/// Utility method to constructs a new DirectedShortChannelId-variant IntroductionNode +pub extern "C" fn IntroductionNode_directed_short_channel_id(a: crate::lightning::blinded_path::Direction,b: u64) -> IntroductionNode { + IntroductionNode::DirectedShortChannelId(a, b, ) +} +/// Get a string which allows debug introspection of a IntroductionNode object +pub extern "C" fn IntroductionNode_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::IntroductionNode }).into()} +/// Generates a non-cryptographic 64-bit hash of the IntroductionNode. +#[no_mangle] +pub extern "C" fn IntroductionNode_hash(o: &IntroductionNode) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two IntroductionNodes contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn IntroductionNode_eq(a: &IntroductionNode, b: &IntroductionNode) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which +/// nodes is which in the [`ChannelAnnouncement`] message. +/// +/// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message +/// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Direction { + /// The lesser node id when compared lexicographically in ascending order. + NodeOne, + /// The greater node id when compared lexicographically in ascending order. + NodeTwo, +} +use lightning::blinded_path::Direction as DirectionImport; +pub(crate) type nativeDirection = DirectionImport; + +impl Direction { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeDirection { + match self { + Direction::NodeOne => nativeDirection::NodeOne, + Direction::NodeTwo => nativeDirection::NodeTwo, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeDirection { + match self { + Direction::NodeOne => nativeDirection::NodeOne, + Direction::NodeTwo => nativeDirection::NodeTwo, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &DirectionImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeDirection) }; + match native { + nativeDirection::NodeOne => Direction::NodeOne, + nativeDirection::NodeTwo => Direction::NodeTwo, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeDirection) -> Self { + match native { + nativeDirection::NodeOne => Direction::NodeOne, + nativeDirection::NodeTwo => Direction::NodeTwo, + } + } +} +/// Creates a copy of the Direction +#[no_mangle] +pub extern "C" fn Direction_clone(orig: &Direction) -> Direction { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Direction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Direction)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Direction_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Direction) }; +} +#[no_mangle] +/// Utility method to constructs a new NodeOne-variant Direction +pub extern "C" fn Direction_node_one() -> Direction { + Direction::NodeOne} +#[no_mangle] +/// Utility method to constructs a new NodeTwo-variant Direction +pub extern "C" fn Direction_node_two() -> Direction { + Direction::NodeTwo} +/// Get a string which allows debug introspection of a Direction object +pub extern "C" fn Direction_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::Direction }).into()} +/// Generates a non-cryptographic 64-bit hash of the Direction. +#[no_mangle] +pub extern "C" fn Direction_hash(o: &Direction) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two Directions contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Direction_eq(a: &Direction, b: &Direction) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// An interface for looking up the node id of a channel counterparty for the purpose of forwarding +/// an [`OnionMessage`]. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[repr(C)] +pub struct NodeIdLookUp { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns the node id of the forwarding node's channel counterparty with `short_channel_id`. + /// + /// Here, the forwarding node is referring to the node of the [`OnionMessenger`] parameterized + /// by the [`NodeIdLookUp`] and the counterparty to one of that node's peers. + /// + /// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger + /// + /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None + pub next_node_id: extern "C" fn (this_arg: *const c_void, short_channel_id: u64) -> crate::c_types::PublicKey, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for NodeIdLookUp {} +unsafe impl Sync for NodeIdLookUp {} +#[allow(unused)] +pub(crate) fn NodeIdLookUp_clone_fields(orig: &NodeIdLookUp) -> NodeIdLookUp { + NodeIdLookUp { + this_arg: orig.this_arg, + next_node_id: Clone::clone(&orig.next_node_id), + free: Clone::clone(&orig.free), + } +} + +use lightning::blinded_path::NodeIdLookUp as rustNodeIdLookUp; +impl rustNodeIdLookUp for NodeIdLookUp { + fn next_node_id(&self, mut short_channel_id: u64) -> Option { + let mut ret = (self.next_node_id)(self.this_arg, short_channel_id); + let mut local_ret = if ret.is_null() { None } else { Some( { ret.into_rust() }) }; + local_ret + } +} +pub struct NodeIdLookUpRef(NodeIdLookUp); +impl rustNodeIdLookUp for NodeIdLookUpRef { + fn next_node_id(&self, mut short_channel_id: u64) -> Option { + let mut ret = (self.0.next_node_id)(self.0.this_arg, short_channel_id); + let mut local_ret = if ret.is_null() { None } else { Some( { ret.into_rust() }) }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for NodeIdLookUp { + type Target = NodeIdLookUpRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const NodeIdLookUpRef) } + } +} +impl core::ops::DerefMut for NodeIdLookUp { + fn deref_mut(&mut self) -> &mut NodeIdLookUpRef { + unsafe { &mut *(self as *mut _ as *mut NodeIdLookUpRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn NodeIdLookUp_free(this_ptr: NodeIdLookUp) { } +impl Drop for NodeIdLookUp { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } } -use lightning::blinded_path::BlindedPath as nativeBlindedPathImport; -pub(crate) type nativeBlindedPath = nativeBlindedPathImport; +use lightning::blinded_path::EmptyNodeIdLookUp as nativeEmptyNodeIdLookUpImport; +pub(crate) type nativeEmptyNodeIdLookUp = nativeEmptyNodeIdLookUpImport; -/// Onion messages and payments can be sent and received to blinded paths, which serve to hide the -/// identity of the recipient. +/// A [`NodeIdLookUp`] that always returns `None`. #[must_use] #[repr(C)] -pub struct BlindedPath { +pub struct EmptyNodeIdLookUp { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeBlindedPath, + pub inner: *mut nativeEmptyNodeIdLookUp, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -63,139 +350,82 @@ pub struct BlindedPath { pub is_owned: bool, } -impl Drop for BlindedPath { +impl core::ops::Deref for EmptyNodeIdLookUp { + type Target = nativeEmptyNodeIdLookUp; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for EmptyNodeIdLookUp { } +unsafe impl core::marker::Sync for EmptyNodeIdLookUp { } +impl Drop for EmptyNodeIdLookUp { fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedPath>::is_null(self.inner) { + if self.is_owned && !<*mut nativeEmptyNodeIdLookUp>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the BlindedPath, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the EmptyNodeIdLookUp, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn BlindedPath_free(this_obj: BlindedPath) { } +pub extern "C" fn EmptyNodeIdLookUp_free(this_obj: EmptyNodeIdLookUp) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPath_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPath) }; +pub(crate) extern "C" fn EmptyNodeIdLookUp_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeEmptyNodeIdLookUp) }; } #[allow(unused)] -impl BlindedPath { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPath { +impl EmptyNodeIdLookUp { + pub(crate) fn get_native_ref(&self) -> &'static nativeEmptyNodeIdLookUp { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPath { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeEmptyNodeIdLookUp { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPath { + pub(crate) fn take_inner(mut self) -> *mut nativeEmptyNodeIdLookUp { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// To send to a blinded path, the sender first finds a route to the unblinded -/// `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion -/// message or payment's next hop and forward it along. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_get_introduction_node_id(this_ptr: &BlindedPath) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().introduction_node_id; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// To send to a blinded path, the sender first finds a route to the unblinded -/// `introduction_node_id`, which can unblind its [`encrypted_payload`] to find out the onion -/// message or payment's next hop and forward it along. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_set_introduction_node_id(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.introduction_node_id = val.into_rust(); -} -/// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion -/// message or payment. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_get_blinding_point(this_ptr: &BlindedPath) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Used by the introduction node to decrypt its [`encrypted_payload`] to forward the onion -/// message or payment. -/// -/// [`encrypted_payload`]: BlindedHop::encrypted_payload -#[no_mangle] -pub extern "C" fn BlindedPath_set_blinding_point(this_ptr: &mut BlindedPath, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust(); -} -/// The hops composing the blinded path. -#[no_mangle] -pub extern "C" fn BlindedPath_get_blinded_hops(this_ptr: &BlindedPath) -> crate::c_types::derived::CVec_BlindedHopZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_hops; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); }; - local_inner_val.into() -} -/// The hops composing the blinded path. -#[no_mangle] -pub extern "C" fn BlindedPath_set_blinded_hops(this_ptr: &mut BlindedPath, mut val: crate::c_types::derived::CVec_BlindedHopZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_hops = local_val; -} -/// Constructs a new BlindedPath given each field +/// Constructs a new EmptyNodeIdLookUp given each field #[must_use] #[no_mangle] -pub extern "C" fn BlindedPath_new(mut introduction_node_id_arg: crate::c_types::PublicKey, mut blinding_point_arg: crate::c_types::PublicKey, mut blinded_hops_arg: crate::c_types::derived::CVec_BlindedHopZ) -> BlindedPath { - let mut local_blinded_hops_arg = Vec::new(); for mut item in blinded_hops_arg.into_rust().drain(..) { local_blinded_hops_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - BlindedPath { inner: ObjOps::heap_alloc(nativeBlindedPath { - introduction_node_id: introduction_node_id_arg.into_rust(), - blinding_point: blinding_point_arg.into_rust(), - blinded_hops: local_blinded_hops_arg, +pub extern "C" fn EmptyNodeIdLookUp_new() -> EmptyNodeIdLookUp { + EmptyNodeIdLookUp { inner: ObjOps::heap_alloc(nativeEmptyNodeIdLookUp { }), is_owned: true } } -impl Clone for BlindedPath { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedPath>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } +impl From for crate::lightning::blinded_path::NodeIdLookUp { + fn from(obj: nativeEmptyNodeIdLookUp) -> Self { + let rust_obj = crate::lightning::blinded_path::EmptyNodeIdLookUp { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = EmptyNodeIdLookUp_as_NodeIdLookUp(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(EmptyNodeIdLookUp_free_void); + ret } } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPath_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPath)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedPath -pub extern "C" fn BlindedPath_clone(orig: &BlindedPath) -> BlindedPath { - orig.clone() -} -/// Get a string which allows debug introspection of a BlindedPath object -pub extern "C" fn BlindedPath_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::BlindedPath }).into()} -/// Generates a non-cryptographic 64-bit hash of the BlindedPath. +/// Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is #[no_mangle] -pub extern "C" fn BlindedPath_hash(o: &BlindedPath) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) +pub extern "C" fn EmptyNodeIdLookUp_as_NodeIdLookUp(this_arg: &EmptyNodeIdLookUp) -> crate::lightning::blinded_path::NodeIdLookUp { + crate::lightning::blinded_path::NodeIdLookUp { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + next_node_id: EmptyNodeIdLookUp_NodeIdLookUp_next_node_id, + } } -/// Checks if two BlindedPaths contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn BlindedPath_eq(a: &BlindedPath, b: &BlindedPath) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } + +#[must_use] +extern "C" fn EmptyNodeIdLookUp_NodeIdLookUp_next_node_id(this_arg: *const c_void, mut short_channel_id: u64) -> crate::c_types::PublicKey { + let mut ret = ::next_node_id(unsafe { &mut *(this_arg as *mut nativeEmptyNodeIdLookUp) }, short_channel_id); + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } + use lightning::blinded_path::BlindedHop as nativeBlindedHopImport; pub(crate) type nativeBlindedHop = nativeBlindedHopImport; @@ -217,6 +447,12 @@ pub struct BlindedHop { pub is_owned: bool, } +impl core::ops::Deref for BlindedHop { + type Target = nativeBlindedHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedHop { } +unsafe impl core::marker::Sync for BlindedHop { } impl Drop for BlindedHop { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedHop>::is_null(self.inner) { @@ -247,19 +483,22 @@ impl BlindedHop { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The blinded node id of this hop in a [`BlindedPath`]. +/// The blinded node id of this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_get_blinded_node_id(this_ptr: &BlindedHop) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().blinded_node_id; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The blinded node id of this hop in a [`BlindedPath`]. +/// The blinded node id of this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_set_blinded_node_id(this_ptr: &mut BlindedHop, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinded_node_id = val.into_rust(); } -/// The encrypted payload intended for this hop in a [`BlindedPath`]. +/// The encrypted payload intended for this hop in a blinded path. /// /// Returns a copy of the field. #[no_mangle] @@ -268,7 +507,7 @@ pub extern "C" fn BlindedHop_get_encrypted_payload(this_ptr: &BlindedHop) -> cra let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; local_inner_val.into() } -/// The encrypted payload intended for this hop in a [`BlindedPath`]. +/// The encrypted payload intended for this hop in a blinded path. #[no_mangle] pub extern "C" fn BlindedHop_set_encrypted_payload(this_ptr: &mut BlindedHop, mut val: crate::c_types::derived::CVec_u8Z) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; @@ -325,70 +564,6 @@ pub extern "C" fn BlindedHop_eq(a: &BlindedHop, b: &BlindedHop) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Create a one-hop blinded path for a message. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_one_hop_for_message(mut recipient_node_id: crate::c_types::PublicKey, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { - let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_message(recipient_node_id.into_rust(), entropy_source, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blinded path for an onion message, to be forwarded along `node_pks`. The last node -/// pubkey in `node_pks` will be the destination node. -/// -/// Errors if no hops are provided or if `node_pk`(s) are invalid. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_new_for_message(mut node_pks: crate::c_types::derived::CVec_PublicKeyZ, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPathNoneZ { - let mut local_node_pks = Vec::new(); for mut item in node_pks.into_rust().drain(..) { local_node_pks.push( { item.into_rust() }); }; - let mut ret = lightning::blinded_path::BlindedPath::new_for_message(&local_node_pks[..], entropy_source, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a one-hop blinded path for a payment. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_one_hop_for_payment(mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - let mut ret = lightning::blinded_path::BlindedPath::one_hop_for_payment(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, entropy_source, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. -/// -/// Errors if: -/// * a provided node id is invalid -/// * [`BlindedPayInfo`] calculation results in an integer overflow -/// * any unknown features are required in the provided [`ForwardTlvs`] -/// -/// [`ForwardTlvs`]: crate::blinded_path::payment::ForwardTlvs -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedPath_new_for_payment(mut intermediate_nodes: crate::c_types::derived::CVec_ForwardNodeZ, mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut htlc_maximum_msat: u64, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ { - let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut ret = lightning::blinded_path::BlindedPath::new_for_payment(local_intermediate_nodes, payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, htlc_maximum_msat, entropy_source, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -#[no_mangle] -/// Serialize the BlindedPath object into a byte array which can be read by BlindedPath_read -pub extern "C" fn BlindedPath_write(obj: &crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn BlindedPath_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPath) }) -} -#[no_mangle] -/// Read a BlindedPath from a byte array, created by BlindedPath_write -pub extern "C" fn BlindedPath_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPathDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} #[no_mangle] /// Serialize the BlindedHop object into a byte array which can be read by BlindedHop_read pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::BlindedHop) -> crate::c_types::derived::CVec_u8Z { @@ -396,7 +571,7 @@ pub extern "C" fn BlindedHop_write(obj: &crate::lightning::blinded_path::Blinded } #[allow(unused)] pub(crate) extern "C" fn BlindedHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::nativeBlindedHop) }) } #[no_mangle] /// Read a BlindedHop from a byte array, created by BlindedHop_write diff --git a/lightning-c-bindings/src/lightning/blinded_path/payment.rs b/lightning-c-bindings/src/lightning/blinded_path/payment.rs index 83c3d9b..58be01e 100644 --- a/lightning-c-bindings/src/lightning/blinded_path/payment.rs +++ b/lightning-c-bindings/src/lightning/blinded_path/payment.rs @@ -6,9 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//! Data structures and methods for constructing [`BlindedPath`]s to send a payment over. -//! -//! [`BlindedPath`]: crate::blinded_path::BlindedPath +//! Data structures and methods for constructing [`BlindedPaymentPath`]s to send a payment over. use alloc::str::FromStr; use alloc::string::String; @@ -20,18 +18,416 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; -use lightning::blinded_path::payment::ForwardNode as nativeForwardNodeImport; -pub(crate) type nativeForwardNode = nativeForwardNodeImport; +use lightning::blinded_path::payment::BlindedPayInfo as nativeBlindedPayInfoImport; +pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport; + +/// Information needed to route a payment across a [`BlindedPaymentPath`]. +#[must_use] +#[repr(C)] +pub struct BlindedPayInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBlindedPayInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for BlindedPayInfo { + type Target = nativeBlindedPayInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPayInfo { } +unsafe impl core::marker::Sync for BlindedPayInfo { } +impl Drop for BlindedPayInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) }; +} +#[allow(unused)] +impl BlindedPayInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Base fee charged (in millisatoshi) for the entire blinded path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; + *inner_val +} +/// Base fee charged (in millisatoshi) for the entire blinded path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; +} +/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path +/// (i.e., 10,000 is 1%). +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; + *inner_val +} +/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path +/// (i.e., 10,000 is 1%). +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; +} +/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded +/// path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded +/// path. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the +/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as +/// seen by the recipient. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + *inner_val +} +/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the +/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as +/// seen by the recipient. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; +} +/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the +/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as +/// seen by the recipient. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; + *inner_val +} +/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the +/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as +/// seen by the recipient. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; +} +/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an +/// onion payload. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning_types::features::BlindedHopFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().features; + crate::lightning_types::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } +} +/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an +/// onion payload. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning_types::features::BlindedHopFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new BlindedPayInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning_types::features::BlindedHopFeatures) -> BlindedPayInfo { + BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo { + fee_base_msat: fee_base_msat_arg, + fee_proportional_millionths: fee_proportional_millionths_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + htlc_maximum_msat: htlc_maximum_msat_arg, + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for BlindedPayInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedPayInfo +pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedPayInfo object +pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::BlindedPayInfo }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BlindedPayInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read +pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::blinded_path::payment::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBlindedPayInfo) }) +} +#[no_mangle] +/// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write +pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::BlindedPayInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::blinded_path::payment::BlindedPaymentPath as nativeBlindedPaymentPathImport; +pub(crate) type nativeBlindedPaymentPath = nativeBlindedPaymentPathImport; + +/// A blinded path to be used for sending or receiving a payment, hiding the identity of the +/// recipient. +#[must_use] +#[repr(C)] +pub struct BlindedPaymentPath { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBlindedPaymentPath, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for BlindedPaymentPath { + type Target = nativeBlindedPaymentPath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPaymentPath { } +unsafe impl core::marker::Sync for BlindedPaymentPath { } +impl Drop for BlindedPaymentPath { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedPaymentPath>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedPaymentPath, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_free(this_obj: BlindedPaymentPath) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPaymentPath_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPaymentPath) }; +} +#[allow(unused)] +impl BlindedPaymentPath { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPaymentPath { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPaymentPath { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPaymentPath { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The [`BlindedPayInfo`] used to pay this blinded path. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_get_payinfo(this_ptr: &BlindedPaymentPath) -> crate::lightning::blinded_path::payment::BlindedPayInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payinfo; + crate::lightning::blinded_path::payment::BlindedPayInfo { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::BlindedPayInfo<>) as *mut _) }, is_owned: false } +} +/// The [`BlindedPayInfo`] used to pay this blinded path. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_set_payinfo(this_ptr: &mut BlindedPaymentPath, mut val: crate::lightning::blinded_path::payment::BlindedPayInfo) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payinfo = *unsafe { Box::from_raw(val.take_inner()) }; +} +impl Clone for BlindedPaymentPath { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedPaymentPath>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedPaymentPath_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPaymentPath)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedPaymentPath +pub extern "C" fn BlindedPaymentPath_clone(orig: &BlindedPaymentPath) -> BlindedPaymentPath { + orig.clone() +} +/// Get a string which allows debug introspection of a BlindedPaymentPath object +pub extern "C" fn BlindedPaymentPath_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::BlindedPaymentPath }).into()} +/// Generates a non-cryptographic 64-bit hash of the BlindedPaymentPath. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_hash(o: &BlindedPaymentPath) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two BlindedPaymentPaths contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_eq(a: &BlindedPaymentPath, b: &BlindedPaymentPath) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Create a one-hop blinded path for a payment. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_one_hop(mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPaymentPathNoneZ { + let mut ret = lightning::blinded_path::payment::BlindedPaymentPath::one_hop(payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blinded path for a payment, to be forwarded along `intermediate_nodes`. +/// +/// Errors if: +/// * a provided node id is invalid +/// * [`BlindedPayInfo`] calculation results in an integer overflow +/// * any unknown features are required in the provided [`ForwardTlvs`] +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_new(mut intermediate_nodes: crate::c_types::derived::CVec_PaymentForwardNodeZ, mut payee_node_id: crate::c_types::PublicKey, mut payee_tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut htlc_maximum_msat: u64, mut min_final_cltv_expiry_delta: u16, mut entropy_source: crate::lightning::sign::EntropySource) -> crate::c_types::derived::CResult_BlindedPaymentPathNoneZ { + let mut local_intermediate_nodes = Vec::new(); for mut item in intermediate_nodes.into_rust().drain(..) { local_intermediate_nodes.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = lightning::blinded_path::payment::BlindedPaymentPath::new(local_intermediate_nodes, payee_node_id.into_rust(), *unsafe { Box::from_raw(payee_tlvs.take_inner()) }, htlc_maximum_msat, min_final_cltv_expiry_delta, entropy_source, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Returns the introduction [`NodeId`] of the blinded path, if it is publicly reachable (i.e., +/// it is found in the network graph). +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_public_introduction_node_id(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.public_introduction_node_id(network_graph.get_native_ref()); + let mut local_ret = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + local_ret +} + +/// The [`IntroductionNode`] of the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_introduction_node(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::lightning::blinded_path::IntroductionNode { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.introduction_node(); + crate::lightning::blinded_path::IntroductionNode::from_native(ret) +} + +/// Used by the [`IntroductionNode`] to decrypt its [`encrypted_payload`] to forward the payment. +/// +/// [`encrypted_payload`]: BlindedHop::encrypted_payload +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_blinding_point(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinding_point(); + crate::c_types::PublicKey::from_rust(&ret) +} + +/// The [`BlindedHop`]s within the blinded path. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_blinded_hops(this_arg: &crate::lightning::blinded_path::payment::BlindedPaymentPath) -> crate::c_types::derived::CVec_BlindedHopZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.blinded_hops(); + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Advance the blinded onion payment path by one hop, making the second hop into the new +/// introduction node. +/// +/// Will only modify `self` when returning `Ok`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedPaymentPath_advance_path_by_one(this_arg: &mut crate::lightning::blinded_path::payment::BlindedPaymentPath, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::blinded_path::payment::nativeBlindedPaymentPath)) }.advance_path_by_one(node_signer, node_id_lookup, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + + +use lightning::blinded_path::payment::PaymentForwardNode as nativePaymentForwardNodeImport; +pub(crate) type nativePaymentForwardNode = nativePaymentForwardNodeImport; /// An intermediate node, its outbound channel, and relay parameters. #[must_use] #[repr(C)] -pub struct ForwardNode { +pub struct PaymentForwardNode { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeForwardNode, + pub inner: *mut nativePaymentForwardNode, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -39,86 +435,95 @@ pub struct ForwardNode { pub is_owned: bool, } -impl Drop for ForwardNode { +impl core::ops::Deref for PaymentForwardNode { + type Target = nativePaymentForwardNode; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentForwardNode { } +unsafe impl core::marker::Sync for PaymentForwardNode { } +impl Drop for PaymentForwardNode { fn drop(&mut self) { - if self.is_owned && !<*mut nativeForwardNode>::is_null(self.inner) { + if self.is_owned && !<*mut nativePaymentForwardNode>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the ForwardNode, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the PaymentForwardNode, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn ForwardNode_free(this_obj: ForwardNode) { } +pub extern "C" fn PaymentForwardNode_free(this_obj: PaymentForwardNode) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ForwardNode_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeForwardNode) }; +pub(crate) extern "C" fn PaymentForwardNode_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePaymentForwardNode) }; } #[allow(unused)] -impl ForwardNode { - pub(crate) fn get_native_ref(&self) -> &'static nativeForwardNode { +impl PaymentForwardNode { + pub(crate) fn get_native_ref(&self) -> &'static nativePaymentForwardNode { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeForwardNode { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePaymentForwardNode { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeForwardNode { + pub(crate) fn take_inner(mut self) -> *mut nativePaymentForwardNode { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also /// used for [`BlindedPayInfo`] construction. #[no_mangle] -pub extern "C" fn ForwardNode_get_tlvs(this_ptr: &ForwardNode) -> crate::lightning::blinded_path::payment::ForwardTlvs { +pub extern "C" fn PaymentForwardNode_get_tlvs(this_ptr: &PaymentForwardNode) -> crate::lightning::blinded_path::payment::ForwardTlvs { let mut inner_val = &mut this_ptr.get_native_mut_ref().tlvs; crate::lightning::blinded_path::payment::ForwardTlvs { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::blinded_path::payment::ForwardTlvs<>) as *mut _) }, is_owned: false } } /// The TLVs for this node's [`BlindedHop`], where the fee parameters contained within are also /// used for [`BlindedPayInfo`] construction. #[no_mangle] -pub extern "C" fn ForwardNode_set_tlvs(this_ptr: &mut ForwardNode, mut val: crate::lightning::blinded_path::payment::ForwardTlvs) { +pub extern "C" fn PaymentForwardNode_set_tlvs(this_ptr: &mut PaymentForwardNode, mut val: crate::lightning::blinded_path::payment::ForwardTlvs) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.tlvs = *unsafe { Box::from_raw(val.take_inner()) }; } /// This node's pubkey. #[no_mangle] -pub extern "C" fn ForwardNode_get_node_id(this_ptr: &ForwardNode) -> crate::c_types::PublicKey { +pub extern "C" fn PaymentForwardNode_get_node_id(this_ptr: &PaymentForwardNode) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; crate::c_types::PublicKey::from_rust(&inner_val) } /// This node's pubkey. #[no_mangle] -pub extern "C" fn ForwardNode_set_node_id(this_ptr: &mut ForwardNode, mut val: crate::c_types::PublicKey) { +pub extern "C" fn PaymentForwardNode_set_node_id(this_ptr: &mut PaymentForwardNode, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); } /// The maximum value, in msat, that may be accepted by this node. #[no_mangle] -pub extern "C" fn ForwardNode_get_htlc_maximum_msat(this_ptr: &ForwardNode) -> u64 { +pub extern "C" fn PaymentForwardNode_get_htlc_maximum_msat(this_ptr: &PaymentForwardNode) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; *inner_val } /// The maximum value, in msat, that may be accepted by this node. #[no_mangle] -pub extern "C" fn ForwardNode_set_htlc_maximum_msat(this_ptr: &mut ForwardNode, mut val: u64) { +pub extern "C" fn PaymentForwardNode_set_htlc_maximum_msat(this_ptr: &mut PaymentForwardNode, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; } -/// Constructs a new ForwardNode given each field +/// Constructs a new PaymentForwardNode given each field #[must_use] #[no_mangle] -pub extern "C" fn ForwardNode_new(mut tlvs_arg: crate::lightning::blinded_path::payment::ForwardTlvs, mut node_id_arg: crate::c_types::PublicKey, mut htlc_maximum_msat_arg: u64) -> ForwardNode { - ForwardNode { inner: ObjOps::heap_alloc(nativeForwardNode { +pub extern "C" fn PaymentForwardNode_new(mut tlvs_arg: crate::lightning::blinded_path::payment::ForwardTlvs, mut node_id_arg: crate::c_types::PublicKey, mut htlc_maximum_msat_arg: u64) -> PaymentForwardNode { + PaymentForwardNode { inner: ObjOps::heap_alloc(nativePaymentForwardNode { tlvs: *unsafe { Box::from_raw(tlvs_arg.take_inner()) }, node_id: node_id_arg.into_rust(), htlc_maximum_msat: htlc_maximum_msat_arg, }), is_owned: true } } -impl Clone for ForwardNode { +impl Clone for PaymentForwardNode { fn clone(&self) -> Self { Self { - inner: if <*mut nativeForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativePaymentForwardNode>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -126,17 +531,17 @@ impl Clone for ForwardNode { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeForwardNode)).clone() })) as *mut c_void +pub(crate) extern "C" fn PaymentForwardNode_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativePaymentForwardNode)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ForwardNode -pub extern "C" fn ForwardNode_clone(orig: &ForwardNode) -> ForwardNode { +/// Creates a copy of the PaymentForwardNode +pub extern "C" fn PaymentForwardNode_clone(orig: &PaymentForwardNode) -> PaymentForwardNode { orig.clone() } -/// Get a string which allows debug introspection of a ForwardNode object -pub extern "C" fn ForwardNode_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::ForwardNode }).into()} +/// Get a string which allows debug introspection of a PaymentForwardNode object +pub extern "C" fn PaymentForwardNode_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentForwardNode }).into()} use lightning::blinded_path::payment::ForwardTlvs as nativeForwardTlvsImport; pub(crate) type nativeForwardTlvs = nativeForwardTlvsImport; @@ -157,6 +562,12 @@ pub struct ForwardTlvs { pub is_owned: bool, } +impl core::ops::Deref for ForwardTlvs { + type Target = nativeForwardTlvs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ForwardTlvs { } +unsafe impl core::marker::Sync for ForwardTlvs { } impl Drop for ForwardTlvs { fn drop(&mut self) { if self.is_owned && !<*mut nativeForwardTlvs>::is_null(self.inner) { @@ -187,6 +598,9 @@ impl ForwardTlvs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The short channel id this payment should be forwarded out over. #[no_mangle] @@ -226,27 +640,50 @@ pub extern "C" fn ForwardTlvs_set_payment_constraints(this_ptr: &mut ForwardTlvs /// /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload #[no_mangle] -pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning::ln::features::BlindedHopFeatures { +pub extern "C" fn ForwardTlvs_get_features(this_ptr: &ForwardTlvs) -> crate::lightning_types::features::BlindedHopFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } } /// Supported and required features when relaying a payment onion containing this object's /// corresponding [`BlindedHop::encrypted_payload`]. /// /// [`BlindedHop::encrypted_payload`]: crate::blinded_path::BlindedHop::encrypted_payload #[no_mangle] -pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning::ln::features::BlindedHopFeatures) { +pub extern "C" fn ForwardTlvs_set_features(this_ptr: &mut ForwardTlvs, mut val: crate::lightning_types::features::BlindedHopFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the +/// [`BlindedPaymentPath::blinding_point`] of the appended blinded path. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ForwardTlvs_get_next_blinding_override(this_ptr: &ForwardTlvs) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_blinding_override; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } }; + local_inner_val +} +/// Set if this [`BlindedPaymentPath`] is concatenated to another, to indicate the +/// [`BlindedPaymentPath::blinding_point`] of the appended blinded path. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ForwardTlvs_set_next_blinding_override(this_ptr: &mut ForwardTlvs, mut val: crate::c_types::PublicKey) { + let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_blinding_override = local_val; +} /// Constructs a new ForwardTlvs given each field +/// +/// Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ForwardTlvs_new(mut short_channel_id_arg: u64, mut payment_relay_arg: crate::lightning::blinded_path::payment::PaymentRelay, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> ForwardTlvs { +pub extern "C" fn ForwardTlvs_new(mut short_channel_id_arg: u64, mut payment_relay_arg: crate::lightning::blinded_path::payment::PaymentRelay, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut features_arg: crate::lightning_types::features::BlindedHopFeatures, mut next_blinding_override_arg: crate::c_types::PublicKey) -> ForwardTlvs { + let mut local_next_blinding_override_arg = if next_blinding_override_arg.is_null() { None } else { Some( { next_blinding_override_arg.into_rust() }) }; ForwardTlvs { inner: ObjOps::heap_alloc(nativeForwardTlvs { short_channel_id: short_channel_id_arg, payment_relay: *unsafe { Box::from_raw(payment_relay_arg.take_inner()) }, payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) }, features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + next_blinding_override: local_next_blinding_override_arg, }), is_owned: true } } impl Clone for ForwardTlvs { @@ -292,6 +729,12 @@ pub struct ReceiveTlvs { pub is_owned: bool, } +impl core::ops::Deref for ReceiveTlvs { + type Target = nativeReceiveTlvs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReceiveTlvs { } +unsafe impl core::marker::Sync for ReceiveTlvs { } impl Drop for ReceiveTlvs { fn drop(&mut self) { if self.is_owned && !<*mut nativeReceiveTlvs>::is_null(self.inner) { @@ -322,6 +765,9 @@ impl ReceiveTlvs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. #[no_mangle] @@ -332,7 +778,7 @@ pub extern "C" fn ReceiveTlvs_get_payment_secret(this_ptr: &ReceiveTlvs) -> *con /// Used to authenticate the sender of a payment to the receiver and tie MPP HTLCs together. #[no_mangle] pub extern "C" fn ReceiveTlvs_set_payment_secret(this_ptr: &mut ReceiveTlvs, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data); } /// Constraints for the receiver of this payment. #[no_mangle] @@ -345,13 +791,25 @@ pub extern "C" fn ReceiveTlvs_get_payment_constraints(this_ptr: &ReceiveTlvs) -> pub extern "C" fn ReceiveTlvs_set_payment_constraints(this_ptr: &mut ReceiveTlvs, mut val: crate::lightning::blinded_path::payment::PaymentConstraints) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_constraints = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Context for the receiver of this payment. +#[no_mangle] +pub extern "C" fn ReceiveTlvs_get_payment_context(this_ptr: &ReceiveTlvs) -> crate::lightning::blinded_path::payment::PaymentContext { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_context; + crate::lightning::blinded_path::payment::PaymentContext::from_native(inner_val) +} +/// Context for the receiver of this payment. +#[no_mangle] +pub extern "C" fn ReceiveTlvs_set_payment_context(this_ptr: &mut ReceiveTlvs, mut val: crate::lightning::blinded_path::payment::PaymentContext) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_context = val.into_native(); +} /// Constructs a new ReceiveTlvs given each field #[must_use] #[no_mangle] -pub extern "C" fn ReceiveTlvs_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints) -> ReceiveTlvs { +pub extern "C" fn ReceiveTlvs_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut payment_constraints_arg: crate::lightning::blinded_path::payment::PaymentConstraints, mut payment_context_arg: crate::lightning::blinded_path::payment::PaymentContext) -> ReceiveTlvs { ReceiveTlvs { inner: ObjOps::heap_alloc(nativeReceiveTlvs { - payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data), + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data), payment_constraints: *unsafe { Box::from_raw(payment_constraints_arg.take_inner()) }, + payment_context: payment_context_arg.into_native(), }), is_owned: true } } impl Clone for ReceiveTlvs { @@ -398,6 +856,12 @@ pub struct PaymentRelay { pub is_owned: bool, } +impl core::ops::Deref for PaymentRelay { + type Target = nativePaymentRelay; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentRelay { } +unsafe impl core::marker::Sync for PaymentRelay { } impl Drop for PaymentRelay { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentRelay>::is_null(self.inner) { @@ -428,6 +892,9 @@ impl PaymentRelay { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for this [`BlindedHop`]. #[no_mangle] @@ -518,6 +985,12 @@ pub struct PaymentConstraints { pub is_owned: bool, } +impl core::ops::Deref for PaymentConstraints { + type Target = nativePaymentConstraints; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentConstraints { } +unsafe impl core::marker::Sync for PaymentConstraints { } impl Drop for PaymentConstraints { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentConstraints>::is_null(self.inner) { @@ -548,6 +1021,9 @@ impl PaymentConstraints { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The maximum total CLTV that is acceptable when relaying a payment over this [`BlindedHop`]. #[no_mangle] @@ -604,6 +1080,487 @@ pub extern "C" fn PaymentConstraints_clone(orig: &PaymentConstraints) -> Payment /// Get a string which allows debug introspection of a PaymentConstraints object pub extern "C" fn PaymentConstraints_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentConstraints }).into()} +/// The context of an inbound payment, which is included in a [`BlindedPaymentPath`] via +/// [`ReceiveTlvs`] and surfaced in [`PaymentPurpose`]. +/// +/// [`PaymentPurpose`]: crate::events::PaymentPurpose +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum PaymentContext { + /// The payment context was unknown. + Unknown( + crate::lightning::blinded_path::payment::UnknownPaymentContext), + /// The payment was made for an invoice requested from a BOLT 12 [`Offer`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + Bolt12Offer( + crate::lightning::blinded_path::payment::Bolt12OfferContext), + /// The payment was made for an invoice sent for a BOLT 12 [`Refund`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + Bolt12Refund( + crate::lightning::blinded_path::payment::Bolt12RefundContext), +} +use lightning::blinded_path::payment::PaymentContext as PaymentContextImport; +pub(crate) type nativePaymentContext = PaymentContextImport; + +impl PaymentContext { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativePaymentContext { + match self { + PaymentContext::Unknown (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativePaymentContext::Unknown ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + PaymentContext::Bolt12Offer (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativePaymentContext::Bolt12Offer ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + PaymentContext::Bolt12Refund (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativePaymentContext::Bolt12Refund ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativePaymentContext { + match self { + PaymentContext::Unknown (mut a, ) => { + nativePaymentContext::Unknown ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + PaymentContext::Bolt12Offer (mut a, ) => { + nativePaymentContext::Bolt12Offer ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + PaymentContext::Bolt12Refund (mut a, ) => { + nativePaymentContext::Bolt12Refund ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &PaymentContextImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativePaymentContext) }; + match native { + nativePaymentContext::Unknown (ref a, ) => { + let mut a_nonref = Clone::clone(a); + PaymentContext::Unknown ( + crate::lightning::blinded_path::payment::UnknownPaymentContext { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativePaymentContext::Bolt12Offer (ref a, ) => { + let mut a_nonref = Clone::clone(a); + PaymentContext::Bolt12Offer ( + crate::lightning::blinded_path::payment::Bolt12OfferContext { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativePaymentContext::Bolt12Refund (ref a, ) => { + let mut a_nonref = Clone::clone(a); + PaymentContext::Bolt12Refund ( + crate::lightning::blinded_path::payment::Bolt12RefundContext { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativePaymentContext) -> Self { + match native { + nativePaymentContext::Unknown (mut a, ) => { + PaymentContext::Unknown ( + crate::lightning::blinded_path::payment::UnknownPaymentContext { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativePaymentContext::Bolt12Offer (mut a, ) => { + PaymentContext::Bolt12Offer ( + crate::lightning::blinded_path::payment::Bolt12OfferContext { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativePaymentContext::Bolt12Refund (mut a, ) => { + PaymentContext::Bolt12Refund ( + crate::lightning::blinded_path::payment::Bolt12RefundContext { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the PaymentContext +#[no_mangle] +pub extern "C" fn PaymentContext_free(this_ptr: PaymentContext) { } +/// Creates a copy of the PaymentContext +#[no_mangle] +pub extern "C" fn PaymentContext_clone(orig: &PaymentContext) -> PaymentContext { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PaymentContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PaymentContext)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PaymentContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentContext) }; +} +#[no_mangle] +/// Utility method to constructs a new Unknown-variant PaymentContext +pub extern "C" fn PaymentContext_unknown(a: crate::lightning::blinded_path::payment::UnknownPaymentContext) -> PaymentContext { + PaymentContext::Unknown(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Bolt12Offer-variant PaymentContext +pub extern "C" fn PaymentContext_bolt12_offer(a: crate::lightning::blinded_path::payment::Bolt12OfferContext) -> PaymentContext { + PaymentContext::Bolt12Offer(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Bolt12Refund-variant PaymentContext +pub extern "C" fn PaymentContext_bolt12_refund(a: crate::lightning::blinded_path::payment::Bolt12RefundContext) -> PaymentContext { + PaymentContext::Bolt12Refund(a, ) +} +/// Get a string which allows debug introspection of a PaymentContext object +pub extern "C" fn PaymentContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::PaymentContext }).into()} +/// Checks if two PaymentContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn PaymentContext_eq(a: &PaymentContext, b: &PaymentContext) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} + +use lightning::blinded_path::payment::UnknownPaymentContext as nativeUnknownPaymentContextImport; +pub(crate) type nativeUnknownPaymentContext = nativeUnknownPaymentContextImport; + +/// An unknown payment context. +#[must_use] +#[repr(C)] +pub struct UnknownPaymentContext { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeUnknownPaymentContext, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for UnknownPaymentContext { + type Target = nativeUnknownPaymentContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnknownPaymentContext { } +unsafe impl core::marker::Sync for UnknownPaymentContext { } +impl Drop for UnknownPaymentContext { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUnknownPaymentContext>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the UnknownPaymentContext, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UnknownPaymentContext_free(this_obj: UnknownPaymentContext) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnknownPaymentContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUnknownPaymentContext) }; +} +#[allow(unused)] +impl UnknownPaymentContext { + pub(crate) fn get_native_ref(&self) -> &'static nativeUnknownPaymentContext { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUnknownPaymentContext { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeUnknownPaymentContext { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for UnknownPaymentContext { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnknownPaymentContext>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnknownPaymentContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnknownPaymentContext)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UnknownPaymentContext +pub extern "C" fn UnknownPaymentContext_clone(orig: &UnknownPaymentContext) -> UnknownPaymentContext { + orig.clone() +} +/// Get a string which allows debug introspection of a UnknownPaymentContext object +pub extern "C" fn UnknownPaymentContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::UnknownPaymentContext }).into()} +/// Checks if two UnknownPaymentContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn UnknownPaymentContext_eq(a: &UnknownPaymentContext, b: &UnknownPaymentContext) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::blinded_path::payment::Bolt12OfferContext as nativeBolt12OfferContextImport; +pub(crate) type nativeBolt12OfferContext = nativeBolt12OfferContextImport; + +/// The context of a payment made for an invoice requested from a BOLT 12 [`Offer`]. +/// +/// [`Offer`]: crate::offers::offer::Offer +#[must_use] +#[repr(C)] +pub struct Bolt12OfferContext { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12OfferContext, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Bolt12OfferContext { + type Target = nativeBolt12OfferContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12OfferContext { } +unsafe impl core::marker::Sync for Bolt12OfferContext { } +impl Drop for Bolt12OfferContext { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12OfferContext>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12OfferContext, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_free(this_obj: Bolt12OfferContext) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12OfferContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12OfferContext) }; +} +#[allow(unused)] +impl Bolt12OfferContext { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12OfferContext { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12OfferContext { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12OfferContext { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The identifier of the [`Offer`]. +/// +/// [`Offer`]: crate::offers::offer::Offer +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_get_offer_id(this_ptr: &Bolt12OfferContext) -> crate::lightning::offers::offer::OfferId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().offer_id; + crate::lightning::offers::offer::OfferId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::offers::offer::OfferId<>) as *mut _) }, is_owned: false } +} +/// The identifier of the [`Offer`]. +/// +/// [`Offer`]: crate::offers::offer::Offer +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_set_offer_id(this_ptr: &mut Bolt12OfferContext, mut val: crate::lightning::offers::offer::OfferId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_get_invoice_request(this_ptr: &Bolt12OfferContext) -> crate::lightning::offers::invoice_request::InvoiceRequestFields { + let mut inner_val = &mut this_ptr.get_native_mut_ref().invoice_request; + crate::lightning::offers::invoice_request::InvoiceRequestFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::offers::invoice_request::InvoiceRequestFields<>) as *mut _) }, is_owned: false } +} +/// Fields from an [`InvoiceRequest`] sent for a [`Bolt12Invoice`]. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_set_invoice_request(this_ptr: &mut Bolt12OfferContext, mut val: crate::lightning::offers::invoice_request::InvoiceRequestFields) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.invoice_request = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Constructs a new Bolt12OfferContext given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_new(mut offer_id_arg: crate::lightning::offers::offer::OfferId, mut invoice_request_arg: crate::lightning::offers::invoice_request::InvoiceRequestFields) -> Bolt12OfferContext { + Bolt12OfferContext { inner: ObjOps::heap_alloc(nativeBolt12OfferContext { + offer_id: *unsafe { Box::from_raw(offer_id_arg.take_inner()) }, + invoice_request: *unsafe { Box::from_raw(invoice_request_arg.take_inner()) }, + }), is_owned: true } +} +impl Clone for Bolt12OfferContext { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12OfferContext>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12OfferContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12OfferContext)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12OfferContext +pub extern "C" fn Bolt12OfferContext_clone(orig: &Bolt12OfferContext) -> Bolt12OfferContext { + orig.clone() +} +/// Get a string which allows debug introspection of a Bolt12OfferContext object +pub extern "C" fn Bolt12OfferContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::Bolt12OfferContext }).into()} +/// Checks if two Bolt12OfferContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Bolt12OfferContext_eq(a: &Bolt12OfferContext, b: &Bolt12OfferContext) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::blinded_path::payment::Bolt12RefundContext as nativeBolt12RefundContextImport; +pub(crate) type nativeBolt12RefundContext = nativeBolt12RefundContextImport; + +/// The context of a payment made for an invoice sent for a BOLT 12 [`Refund`]. +/// +/// [`Refund`]: crate::offers::refund::Refund +#[must_use] +#[repr(C)] +pub struct Bolt12RefundContext { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12RefundContext, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Bolt12RefundContext { + type Target = nativeBolt12RefundContext; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12RefundContext { } +unsafe impl core::marker::Sync for Bolt12RefundContext { } +impl Drop for Bolt12RefundContext { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12RefundContext>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12RefundContext, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12RefundContext_free(this_obj: Bolt12RefundContext) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12RefundContext_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12RefundContext) }; +} +#[allow(unused)] +impl Bolt12RefundContext { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12RefundContext { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12RefundContext { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12RefundContext { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new Bolt12RefundContext given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12RefundContext_new() -> Bolt12RefundContext { + Bolt12RefundContext { inner: ObjOps::heap_alloc(nativeBolt12RefundContext { + }), is_owned: true } +} +impl Clone for Bolt12RefundContext { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12RefundContext>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12RefundContext_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12RefundContext)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12RefundContext +pub extern "C" fn Bolt12RefundContext_clone(orig: &Bolt12RefundContext) -> Bolt12RefundContext { + orig.clone() +} +/// Get a string which allows debug introspection of a Bolt12RefundContext object +pub extern "C" fn Bolt12RefundContext_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::blinded_path::payment::Bolt12RefundContext }).into()} +/// Checks if two Bolt12RefundContexts contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Bolt12RefundContext_eq(a: &Bolt12RefundContext, b: &Bolt12RefundContext) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} #[no_mangle] /// Serialize the ForwardTlvs object into a byte array which can be read by ForwardTlvs_read pub extern "C" fn ForwardTlvs_write(obj: &crate::lightning::blinded_path::payment::ForwardTlvs) -> crate::c_types::derived::CVec_u8Z { @@ -611,7 +1568,7 @@ pub extern "C" fn ForwardTlvs_write(obj: &crate::lightning::blinded_path::paymen } #[allow(unused)] pub(crate) extern "C" fn ForwardTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeForwardTlvs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeForwardTlvs) }) } #[no_mangle] /// Serialize the ReceiveTlvs object into a byte array which can be read by ReceiveTlvs_read @@ -620,7 +1577,7 @@ pub extern "C" fn ReceiveTlvs_write(obj: &crate::lightning::blinded_path::paymen } #[allow(unused)] pub(crate) extern "C" fn ReceiveTlvs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReceiveTlvs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeReceiveTlvs) }) } #[no_mangle] /// Serialize the PaymentRelay object into a byte array which can be read by PaymentRelay_read @@ -629,7 +1586,7 @@ pub extern "C" fn PaymentRelay_write(obj: &crate::lightning::blinded_path::payme } #[allow(unused)] pub(crate) extern "C" fn PaymentRelay_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentRelay) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativePaymentRelay) }) } #[no_mangle] /// Read a PaymentRelay from a byte array, created by PaymentRelay_write @@ -645,7 +1602,7 @@ pub extern "C" fn PaymentConstraints_write(obj: &crate::lightning::blinded_path: } #[allow(unused)] pub(crate) extern "C" fn PaymentConstraints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentConstraints) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativePaymentConstraints) }) } #[no_mangle] /// Read a PaymentConstraints from a byte array, created by PaymentConstraints_write @@ -654,3 +1611,67 @@ pub extern "C" fn PaymentConstraints_read(ser: crate::c_types::u8slice) -> crate let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::PaymentConstraints { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } +#[no_mangle] +/// Serialize the PaymentContext object into a byte array which can be read by PaymentContext_read +pub extern "C" fn PaymentContext_write(obj: &crate::lightning::blinded_path::payment::PaymentContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn PaymentContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + PaymentContext_write(unsafe { &*(obj as *const PaymentContext) }) +} +#[no_mangle] +/// Read a PaymentContext from a byte array, created by PaymentContext_write +pub extern "C" fn PaymentContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::PaymentContext::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the UnknownPaymentContext object into a byte array which can be read by UnknownPaymentContext_read +pub extern "C" fn UnknownPaymentContext_write(obj: &crate::lightning::blinded_path::payment::UnknownPaymentContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn UnknownPaymentContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeUnknownPaymentContext) }) +} +#[no_mangle] +/// Read a UnknownPaymentContext from a byte array, created by UnknownPaymentContext_write +pub extern "C" fn UnknownPaymentContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UnknownPaymentContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::UnknownPaymentContext { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Bolt12OfferContext object into a byte array which can be read by Bolt12OfferContext_read +pub extern "C" fn Bolt12OfferContext_write(obj: &crate::lightning::blinded_path::payment::Bolt12OfferContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Bolt12OfferContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBolt12OfferContext) }) +} +#[no_mangle] +/// Read a Bolt12OfferContext from a byte array, created by Bolt12OfferContext_write +pub extern "C" fn Bolt12OfferContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12OfferContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::Bolt12OfferContext { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the Bolt12RefundContext object into a byte array which can be read by Bolt12RefundContext_read +pub extern "C" fn Bolt12RefundContext_write(obj: &crate::lightning::blinded_path::payment::Bolt12RefundContext) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Bolt12RefundContext_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::blinded_path::payment::nativeBolt12RefundContext) }) +} +#[no_mangle] +/// Read a Bolt12RefundContext from a byte array, created by Bolt12RefundContext_write +pub extern "C" fn Bolt12RefundContext_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12RefundContextDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::blinded_path::payment::Bolt12RefundContext { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/chain/chaininterface.rs b/lightning-c-bindings/src/lightning/chain/chaininterface.rs index f4779bb..2f86326 100644 --- a/lightning-c-bindings/src/lightning/chain/chaininterface.rs +++ b/lightning-c-bindings/src/lightning/chain/chaininterface.rs @@ -58,23 +58,31 @@ pub(crate) fn BroadcasterInterface_clone_fields(orig: &BroadcasterInterface) -> use lightning::chain::chaininterface::BroadcasterInterface as rustBroadcasterInterface; impl rustBroadcasterInterface for BroadcasterInterface { - fn broadcast_transactions(&self, mut txs: &[&bitcoin::blockdata::transaction::Transaction]) { + fn broadcast_transactions(&self, mut txs: &[&bitcoin::transaction::Transaction]) { let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); }; (self.broadcast_transactions)(self.this_arg, local_txs.into()) } } +pub struct BroadcasterInterfaceRef(BroadcasterInterface); +impl rustBroadcasterInterface for BroadcasterInterfaceRef { + fn broadcast_transactions(&self, mut txs: &[&bitcoin::transaction::Transaction]) { + let mut local_txs = Vec::new(); for item in txs.iter() { local_txs.push( { crate::c_types::Transaction::from_bitcoin((*item)) }); }; + (self.0.broadcast_transactions)(self.0.this_arg, local_txs.into()) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for BroadcasterInterface { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = BroadcasterInterfaceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const BroadcasterInterfaceRef) } } } impl core::ops::DerefMut for BroadcasterInterface { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut BroadcasterInterfaceRef { + unsafe { &mut *(self as *mut _ as *mut BroadcasterInterfaceRef) } } } /// Calls the free function if one is set @@ -93,11 +101,19 @@ impl Drop for BroadcasterInterface { #[must_use] #[repr(C)] pub enum ConfirmationTarget { + /// The most aggressive (i.e. highest) feerate estimate available. + /// + /// This is used to sanity-check our counterparty's feerates and should be as conservative as + /// possible to ensure that we don't confuse a peer using a very conservative estimator for one + /// trying to burn channel balance to dust. + MaximumFeeEstimate, /// We have some funds available on chain which we need to spend prior to some expiry time at - /// which point our counterparty may be able to steal them. Generally we have in the high tens - /// to low hundreds of blocks to get our transaction on-chain, but we shouldn't risk too low a - /// fee - this should be a relatively high priority feerate. - OnChainSweep, + /// which point our counterparty may be able to steal them. + /// + /// Generally we have in the high tens to low hundreds of blocks to get our transaction + /// on-chain (it doesn't have to happen in the next few blocks!), but we shouldn't risk too low + /// a fee - this should be a relatively high priority feerate. + UrgentOnChainSweep, /// This is the lowest feerate we will allow our channel counterparty to have in an anchor /// channel in order to close the channel if a channel party goes away. /// @@ -168,6 +184,21 @@ pub enum ConfirmationTarget { /// /// [`ChannelManager::close_channel_with_feerate_and_script`]: crate::ln::channelmanager::ChannelManager::close_channel_with_feerate_and_script ChannelCloseMinimum, + /// The feerate used to claim on-chain funds when there is no particular urgency to do so. + /// + /// It is used to get commitment transactions without any HTLCs confirmed in [`ChannelMonitor`] + /// and by [`OutputSweeper`] on transactions spending [`SpendableOutputDescriptor`]s after a + /// channel closure. + /// + /// Generally spending these outputs is safe as long as they eventually confirm, so a value + /// (slightly above) the mempool minimum should suffice. However, as this value will influence + /// how long funds will be unavailable after channel closure, [`FeeEstimator`] implementors + /// might want to choose a higher feerate to regain control over funds faster. + /// + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + /// [`OutputSweeper`]: crate::util::sweep::OutputSweeper + /// [`SpendableOutputDescriptor`]: crate::sign::SpendableOutputDescriptor + OutputSpendingFee, } use lightning::chain::chaininterface::ConfirmationTarget as ConfirmationTargetImport; pub(crate) type nativeConfirmationTarget = ConfirmationTargetImport; @@ -176,46 +207,54 @@ impl ConfirmationTarget { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeConfirmationTarget { match self { - ConfirmationTarget::OnChainSweep => nativeConfirmationTarget::OnChainSweep, + ConfirmationTarget::MaximumFeeEstimate => nativeConfirmationTarget::MaximumFeeEstimate, + ConfirmationTarget::UrgentOnChainSweep => nativeConfirmationTarget::UrgentOnChainSweep, ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee, ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, ConfirmationTarget::AnchorChannelFee => nativeConfirmationTarget::AnchorChannelFee, ConfirmationTarget::NonAnchorChannelFee => nativeConfirmationTarget::NonAnchorChannelFee, ConfirmationTarget::ChannelCloseMinimum => nativeConfirmationTarget::ChannelCloseMinimum, + ConfirmationTarget::OutputSpendingFee => nativeConfirmationTarget::OutputSpendingFee, } } #[allow(unused)] pub(crate) fn into_native(self) -> nativeConfirmationTarget { match self { - ConfirmationTarget::OnChainSweep => nativeConfirmationTarget::OnChainSweep, + ConfirmationTarget::MaximumFeeEstimate => nativeConfirmationTarget::MaximumFeeEstimate, + ConfirmationTarget::UrgentOnChainSweep => nativeConfirmationTarget::UrgentOnChainSweep, ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee, ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, ConfirmationTarget::AnchorChannelFee => nativeConfirmationTarget::AnchorChannelFee, ConfirmationTarget::NonAnchorChannelFee => nativeConfirmationTarget::NonAnchorChannelFee, ConfirmationTarget::ChannelCloseMinimum => nativeConfirmationTarget::ChannelCloseMinimum, + ConfirmationTarget::OutputSpendingFee => nativeConfirmationTarget::OutputSpendingFee, } } #[allow(unused)] pub(crate) fn from_native(native: &ConfirmationTargetImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeConfirmationTarget) }; match native { - nativeConfirmationTarget::OnChainSweep => ConfirmationTarget::OnChainSweep, + nativeConfirmationTarget::MaximumFeeEstimate => ConfirmationTarget::MaximumFeeEstimate, + nativeConfirmationTarget::UrgentOnChainSweep => ConfirmationTarget::UrgentOnChainSweep, nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, nativeConfirmationTarget::AnchorChannelFee => ConfirmationTarget::AnchorChannelFee, nativeConfirmationTarget::NonAnchorChannelFee => ConfirmationTarget::NonAnchorChannelFee, nativeConfirmationTarget::ChannelCloseMinimum => ConfirmationTarget::ChannelCloseMinimum, + nativeConfirmationTarget::OutputSpendingFee => ConfirmationTarget::OutputSpendingFee, } } #[allow(unused)] pub(crate) fn native_into(native: nativeConfirmationTarget) -> Self { match native { - nativeConfirmationTarget::OnChainSweep => ConfirmationTarget::OnChainSweep, + nativeConfirmationTarget::MaximumFeeEstimate => ConfirmationTarget::MaximumFeeEstimate, + nativeConfirmationTarget::UrgentOnChainSweep => ConfirmationTarget::UrgentOnChainSweep, nativeConfirmationTarget::MinAllowedAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedAnchorChannelRemoteFee, nativeConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee, nativeConfirmationTarget::AnchorChannelFee => ConfirmationTarget::AnchorChannelFee, nativeConfirmationTarget::NonAnchorChannelFee => ConfirmationTarget::NonAnchorChannelFee, nativeConfirmationTarget::ChannelCloseMinimum => ConfirmationTarget::ChannelCloseMinimum, + nativeConfirmationTarget::OutputSpendingFee => ConfirmationTarget::OutputSpendingFee, } } } @@ -235,9 +274,13 @@ pub(crate) extern "C" fn ConfirmationTarget_free_void(this_ptr: *mut c_void) { let _ = unsafe { Box::from_raw(this_ptr as *mut ConfirmationTarget) }; } #[no_mangle] -/// Utility method to constructs a new OnChainSweep-variant ConfirmationTarget -pub extern "C" fn ConfirmationTarget_on_chain_sweep() -> ConfirmationTarget { - ConfirmationTarget::OnChainSweep} +/// Utility method to constructs a new MaximumFeeEstimate-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_maximum_fee_estimate() -> ConfirmationTarget { + ConfirmationTarget::MaximumFeeEstimate} +#[no_mangle] +/// Utility method to constructs a new UrgentOnChainSweep-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_urgent_on_chain_sweep() -> ConfirmationTarget { + ConfirmationTarget::UrgentOnChainSweep} #[no_mangle] /// Utility method to constructs a new MinAllowedAnchorChannelRemoteFee-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_min_allowed_anchor_channel_remote_fee() -> ConfirmationTarget { @@ -258,6 +301,10 @@ pub extern "C" fn ConfirmationTarget_non_anchor_channel_fee() -> ConfirmationTar /// Utility method to constructs a new ChannelCloseMinimum-variant ConfirmationTarget pub extern "C" fn ConfirmationTarget_channel_close_minimum() -> ConfirmationTarget { ConfirmationTarget::ChannelCloseMinimum} +#[no_mangle] +/// Utility method to constructs a new OutputSpendingFee-variant ConfirmationTarget +pub extern "C" fn ConfirmationTarget_output_spending_fee() -> ConfirmationTarget { + ConfirmationTarget::OutputSpendingFee} /// Get a string which allows debug introspection of a ConfirmationTarget object pub extern "C" fn ConfirmationTarget_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::chaininterface::ConfirmationTarget }).into()} @@ -286,6 +333,10 @@ pub extern "C" fn ConfirmationTarget_eq(a: &ConfirmationTarget, b: &Confirmation /// /// Note that all of the functions implemented here *must* be reentrant-safe (obviously - they're /// called from inside the library in response to chain events, P2P events, or timer events). +/// +/// LDK may generate a substantial number of fee-estimation calls in some cases. You should +/// pre-calculate and cache the fee estimate results to ensure you don't substantially slow HTLC +/// handling. #[repr(C)] pub struct FeeEstimator { /// An opaque pointer which is passed to your function implementations as an argument. @@ -323,17 +374,25 @@ impl rustFeeEstimator for FeeEstimator { } } +pub struct FeeEstimatorRef(FeeEstimator); +impl rustFeeEstimator for FeeEstimatorRef { + fn get_est_sat_per_1000_weight(&self, mut confirmation_target: lightning::chain::chaininterface::ConfirmationTarget) -> u32 { + let mut ret = (self.0.get_est_sat_per_1000_weight)(self.0.this_arg, crate::lightning::chain::chaininterface::ConfirmationTarget::native_into(confirmation_target)); + ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for FeeEstimator { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FeeEstimatorRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FeeEstimatorRef) } } } impl core::ops::DerefMut for FeeEstimator { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FeeEstimatorRef { + unsafe { &mut *(self as *mut _ as *mut FeeEstimatorRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs index 578aa8a..851c182 100644 --- a/lightning-c-bindings/src/lightning/chain/chainmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/chainmonitor.rs @@ -31,110 +31,6 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -mod update_origin { - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} - -use lightning::chain::chainmonitor::MonitorUpdateId as nativeMonitorUpdateIdImport; -pub(crate) type nativeMonitorUpdateId = nativeMonitorUpdateIdImport; - -/// An opaque identifier describing a specific [`Persist`] method call. -#[must_use] -#[repr(C)] -pub struct MonitorUpdateId { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeMonitorUpdateId, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for MonitorUpdateId { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeMonitorUpdateId>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the MonitorUpdateId, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_free(this_obj: MonitorUpdateId) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn MonitorUpdateId_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeMonitorUpdateId) }; -} -#[allow(unused)] -impl MonitorUpdateId { - pub(crate) fn get_native_ref(&self) -> &'static nativeMonitorUpdateId { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeMonitorUpdateId { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeMonitorUpdateId { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Get a string which allows debug introspection of a MonitorUpdateId object -pub extern "C" fn MonitorUpdateId_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::chainmonitor::MonitorUpdateId }).into()} -impl Clone for MonitorUpdateId { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeMonitorUpdateId>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn MonitorUpdateId_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeMonitorUpdateId)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the MonitorUpdateId -pub extern "C" fn MonitorUpdateId_clone(orig: &MonitorUpdateId) -> MonitorUpdateId { - orig.clone() -} -/// Generates a non-cryptographic 64-bit hash of the MonitorUpdateId. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_hash(o: &MonitorUpdateId) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Checks if two MonitorUpdateIds contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn MonitorUpdateId_eq(a: &MonitorUpdateId, b: &MonitorUpdateId) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} /// `Persist` defines behavior for persisting channel monitors: this could mean /// writing once to disk, and/or uploading to one or more backup services. /// @@ -167,7 +63,7 @@ pub extern "C" fn MonitorUpdateId_eq(a: &MonitorUpdateId, b: &MonitorUpdateId) - /// All calls should generally spawn a background task and immediately return /// [`ChannelMonitorUpdateStatus::InProgress`]. Once the update completes, /// [`ChainMonitor::channel_monitor_updated`] should be called with the corresponding -/// [`MonitorUpdateId`]. +/// [`ChannelMonitor::get_latest_update_id`] or [`ChannelMonitorUpdate::update_id`]. /// /// Note that unlike the direct [`chain::Watch`] interface, /// [`ChainMonitor::channel_monitor_updated`] must be called once for *each* update which occurs. @@ -202,15 +98,16 @@ pub struct Persist { /// channel's outpoint (and it is up to you to maintain a correct mapping between the outpoint /// and the stored channel data). Note that you **must** persist every new monitor to disk. /// - /// The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - /// if you return [`ChannelMonitorUpdateStatus::InProgress`]. + /// The [`ChannelMonitor::get_latest_update_id`] uniquely links this call to [`ChainMonitor::channel_monitor_updated`]. + /// For [`Persist::persist_new_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + /// when you return [`ChannelMonitorUpdateStatus::InProgress`]. /// /// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor` /// and [`ChannelMonitorUpdateStatus`] for requirements when returning errors. /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`Writeable::write`]: crate::util::ser::Writeable::write - pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, + pub persist_new_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, /// Update one channel's data. The provided [`ChannelMonitor`] has already applied the given /// update. /// @@ -227,7 +124,9 @@ pub struct Persist { /// If an implementer chooses to persist the updates only, they need to make /// sure that all the updates are applied to the `ChannelMonitors` *before* /// the set of channel monitors is given to the `ChannelManager` - /// deserialization routine. See [`ChannelMonitor::update_monitor`] for + /// deserialization routine. If there are any gaps in the persisted [`ChannelMonitorUpdate`]s, + /// implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them. + /// See [`ChannelMonitor::update_monitor`] for /// applying a monitor update to a monitor. If full `ChannelMonitors` are /// persisted, then there is no need to persist individual updates. /// @@ -236,8 +135,10 @@ pub struct Persist { /// them in batches. The size of each monitor grows `O(number of state updates)` /// whereas updates are small and `O(1)`. /// - /// The `update_id` is used to identify this call to [`ChainMonitor::channel_monitor_updated`], - /// if you return [`ChannelMonitorUpdateStatus::InProgress`]. + /// The [`ChannelMonitorUpdate::update_id`] or [`ChannelMonitor::get_latest_update_id`] uniquely + /// links this call to [`ChainMonitor::channel_monitor_updated`]. + /// For [`Persist::update_persisted_channel`], it is only necessary to call [`ChainMonitor::channel_monitor_updated`] + /// when a [`ChannelMonitorUpdate`] is provided and when you return [`ChannelMonitorUpdateStatus::InProgress`]. /// /// See [`Writeable::write`] on [`ChannelMonitor`] for writing out a `ChannelMonitor`, /// [`Writeable::write`] on [`ChannelMonitorUpdate`] for writing out an update, and @@ -245,8 +146,13 @@ pub struct Persist { /// /// [`Writeable::write`]: crate::util::ser::Writeable::write /// - /// Note that update (or a relevant inner pointer) may be NULL or all-0s to represent None - pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_id: crate::lightning::chain::transaction::OutPoint, update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus, + /// Note that monitor_update (or a relevant inner pointer) may be NULL or all-0s to represent None + pub update_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor_update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus, + /// Prevents the channel monitor from being loaded on startup. + /// + /// Archiving the data in a backup location (rather than deleting it fully) is useful for + /// hedging against data loss in case of unexpected failure. + pub archive_persisted_channel: extern "C" fn (this_arg: *const c_void, channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -259,34 +165,54 @@ pub(crate) fn Persist_clone_fields(orig: &Persist) -> Persist { this_arg: orig.this_arg, persist_new_channel: Clone::clone(&orig.persist_new_channel), update_persisted_channel: Clone::clone(&orig.update_persisted_channel), + archive_persisted_channel: Clone::clone(&orig.archive_persisted_channel), free: Clone::clone(&orig.free), } } use lightning::chain::chainmonitor::Persist as rustPersist; -impl rustPersist for Persist { - fn persist_new_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { - let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); +impl rustPersist for Persist { + fn persist_new_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.persist_new_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); ret.into_native() } - fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> lightning::chain::ChannelMonitorUpdateStatus { - let mut local_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; - let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, local_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true }); + fn update_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor_update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if monitor_update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (monitor_update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; + let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, local_monitor_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); ret.into_native() } + fn archive_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint) { + (self.archive_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }) + } +} + +pub struct PersistRef(Persist); +impl rustPersist for PersistRef { + fn persist_new_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.0.persist_new_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn update_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint, mut monitor_update: Option<&lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut monitor: &lightning::chain::channelmonitor::ChannelMonitor) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if monitor_update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (monitor_update.unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false }; + let mut ret = (self.0.update_persisted_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }, local_monitor_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((monitor as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn archive_persisted_channel(&self, mut channel_funding_outpoint: lightning::chain::transaction::OutPoint) { + (self.0.archive_persisted_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_funding_outpoint), is_owned: true }) + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Persist { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = PersistRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const PersistRef) } } } impl core::ops::DerefMut for Persist { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut PersistRef { + unsafe { &mut *(self as *mut _ as *mut PersistRef) } } } /// Calls the free function if one is set @@ -301,7 +227,7 @@ impl Drop for Persist { } use lightning::chain::chainmonitor::LockedChannelMonitor as nativeLockedChannelMonitorImport; -pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner>; +pub(crate) type nativeLockedChannelMonitor = nativeLockedChannelMonitorImport<'static, crate::lightning::sign::ecdsa::EcdsaChannelSigner, >; /// A read-only reference to a current ChannelMonitor. /// @@ -322,6 +248,12 @@ pub struct LockedChannelMonitor { pub is_owned: bool, } +impl core::ops::Deref for LockedChannelMonitor { + type Target = nativeLockedChannelMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LockedChannelMonitor { } +unsafe impl core::marker::Sync for LockedChannelMonitor { } impl Drop for LockedChannelMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeLockedChannelMonitor>::is_null(self.inner) { @@ -352,10 +284,13 @@ impl LockedChannelMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::chain::chainmonitor::ChainMonitor as nativeChainMonitorImport; -pub(crate) type nativeChainMonitor = nativeChainMonitorImport; +pub(crate) type nativeChainMonitor = nativeChainMonitorImport; /// An implementation of [`chain::Watch`] for monitoring channels. /// @@ -388,6 +323,12 @@ pub struct ChainMonitor { pub is_owned: bool, } +impl core::ops::Deref for ChainMonitor { + type Target = nativeChainMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChainMonitor { } +unsafe impl core::marker::Sync for ChainMonitor { } impl Drop for ChainMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeChainMonitor>::is_null(self.inner) { @@ -418,6 +359,9 @@ impl ChainMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels. /// @@ -438,8 +382,7 @@ pub extern "C" fn ChainMonitor_new(mut chain_source: crate::c_types::derived::CO /// claims which are awaiting confirmation. /// /// Includes the balances from each [`ChannelMonitor`] *except* those included in -/// `ignored_channels`, allowing you to filter out balances from channels which are still open -/// (and whose balance should likely be pulled from the [`ChannelDetails`]). +/// `ignored_channels`. /// /// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for /// inclusion in the return value. @@ -465,24 +408,27 @@ pub extern "C" fn ChainMonitor_get_monitor(this_arg: &crate::lightning::chain::c local_ret } -/// Lists the funding outpoint of each [`ChannelMonitor`] being monitored. +/// Lists the funding outpoint and channel ID of each [`ChannelMonitor`] being monitored. /// /// Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always /// monitoring for on-chain state resolutions. #[must_use] #[no_mangle] -pub extern "C" fn ChainMonitor_list_monitors(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_OutPointZ { +pub extern "C" fn ChainMonitor_list_monitors(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_C2Tuple_OutPointChannelIdZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_monitors(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }); }; local_ret.into() } /// Lists the pending updates for each [`ChannelMonitor`] (by `OutPoint` being monitored). +/// Each `Vec` contains `update_id`s from [`ChannelMonitor::get_latest_update_id`] for updates +/// that have not yet been fully persisted. Note that if a full monitor is persisted all the pending +/// monitor updates must be individually marked completed by calling [`ChainMonitor::channel_monitor_updated`]. #[must_use] #[no_mangle] -pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ { +pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) -> crate::c_types::derived::CVec_C2Tuple_OutPointCVec_u64ZZZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_pending_monitor_updates(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { item }); }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1.into()).into(); local_ret_0 }); }; local_ret.into() } @@ -493,16 +439,23 @@ pub extern "C" fn ChainMonitor_list_pending_monitor_updates(this_arg: &crate::li /// 1) This [`ChainMonitor`] calls [`Persist::update_persisted_channel`] which stores the /// update to disk and begins updating any remote (e.g. watchtower/backup) copies, /// returning [`ChannelMonitorUpdateStatus::InProgress`], -/// 2) once all remote copies are updated, you call this function with the -/// `completed_update_id` that completed, and once all pending updates have completed the -/// channel will be re-enabled. +/// 2) once all remote copies are updated, you call this function with [`ChannelMonitor::get_latest_update_id`] +/// or [`ChannelMonitorUpdate::update_id`] as the `completed_update_id`, and once all pending +/// updates have completed the channel will be re-enabled. +/// +/// It is only necessary to call [`ChainMonitor::channel_monitor_updated`] when you return [`ChannelMonitorUpdateStatus::InProgress`] +/// from [`Persist`] and either: +/// 1. A new [`ChannelMonitor`] was added in [`Persist::persist_new_channel`], or +/// 2. A [`ChannelMonitorUpdate`] was provided as part of [`Persist::update_persisted_channel`]. +/// Note that we don't care about calls to [`Persist::update_persisted_channel`] where no +/// [`ChannelMonitorUpdate`] was provided. /// /// Returns an [`APIError::APIMisuseError`] if `funding_txo` does not match any currently /// registered [`ChannelMonitor`]s. #[must_use] #[no_mangle] -pub extern "C" fn ChainMonitor_channel_monitor_updated(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut completed_update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_monitor_updated(*unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(completed_update_id.take_inner()) }); +pub extern "C" fn ChainMonitor_channel_monitor_updated(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut completed_update_id: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_monitor_updated(*unsafe { Box::from_raw(funding_txo.take_inner()) }, completed_update_id); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -532,6 +485,32 @@ pub extern "C" fn ChainMonitor_rebroadcast_pending_claims(this_arg: &crate::ligh unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.rebroadcast_pending_claims() } +/// Triggers rebroadcasts of pending claims from force-closed channels after a transaction +/// signature generation failure. +/// +/// `monitor_opt` can be used as a filter to only trigger them for a specific channel monitor. +/// +/// Note that monitor_opt (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChainMonitor_signer_unblocked(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor, mut monitor_opt: crate::lightning::chain::transaction::OutPoint) { + let mut local_monitor_opt = if monitor_opt.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(monitor_opt.take_inner()) } }) }; + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signer_unblocked(local_monitor_opt) +} + +/// Archives fully resolved channel monitors by calling [`Persist::archive_persisted_channel`]. +/// +/// This is useful for pruning fully resolved monitors from the monitor set and primary +/// storage so they are not kept in memory and reloaded on restart. +/// +/// Should be called occasionally (once every handful of blocks or on startup). +/// +/// Depending on the implementation of [`Persist::archive_persisted_channel`] the monitor +/// data could be moved to an archive location or removed entirely. +#[no_mangle] +pub extern "C" fn ChainMonitor_archive_fully_resolved_channel_monitors(this_arg: &crate::lightning::chain::chainmonitor::ChainMonitor) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.archive_fully_resolved_channel_monitors() +} + impl From for crate::lightning::chain::Listen { fn from(obj: nativeChainMonitor) -> Self { let rust_obj = crate::lightning::chain::chainmonitor::ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -557,13 +536,13 @@ pub extern "C" fn ChainMonitor_as_Listen(this_arg: &ChainMonitor) -> crate::ligh extern "C" fn ChainMonitor_Listen_filtered_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - >::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) + ::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) } extern "C" fn ChainMonitor_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { - >::block_connected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) + ::block_connected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) } extern "C" fn ChainMonitor_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { - >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) + ::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } impl From for crate::lightning::chain::Confirm { @@ -592,17 +571,17 @@ pub extern "C" fn ChainMonitor_as_Confirm(this_arg: &ChainMonitor) -> crate::lig extern "C" fn ChainMonitor_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - >::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) + ::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) } extern "C" fn ChainMonitor_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) { - >::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) + ::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) } extern "C" fn ChainMonitor_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { - >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) + ::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] extern "C" fn ChainMonitor_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut ret = ::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_2.unwrap().as_ref() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); }; local_ret.into() } @@ -632,19 +611,19 @@ pub extern "C" fn ChainMonitor_as_Watch(this_arg: &ChainMonitor) -> crate::light #[must_use] extern "C" fn ChainMonitor_Watch_watch_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, mut monitor: crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::c_types::derived::CResult_ChannelMonitorUpdateStatusNoneZ { - let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); + let mut ret = >::watch_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, *unsafe { Box::from_raw(monitor.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn ChainMonitor_Watch_update_channel(this_arg: *const c_void, mut funding_txo: crate::lightning::chain::transaction::OutPoint, update: &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, update.get_native_ref()); + let mut ret = >::update_channel(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, *unsafe { Box::from_raw(funding_txo.take_inner()) }, update.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } #[must_use] -extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ { - let mut ret = >::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); }; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(orig_ret_0_2.unwrap())) } }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1.into(), local_orig_ret_0_2).into(); local_ret_0 }); }; +extern "C" fn ChainMonitor_Watch_release_pending_monitor_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ { + let mut ret = >::release_pending_monitor_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2, mut orig_ret_0_3) = item; let mut local_orig_ret_0_2 = Vec::new(); for mut item in orig_ret_0_2.drain(..) { local_orig_ret_0_2.push( { crate::lightning::chain::channelmonitor::MonitorEvent::native_into(item) }); }; let mut local_orig_ret_0_3 = if orig_ret_0_3.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(orig_ret_0_3.unwrap())) } }; let mut local_ret_0 = (crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2.into(), local_orig_ret_0_3).into(); local_ret_0 }); }; local_ret.into() } @@ -670,6 +649,6 @@ pub extern "C" fn ChainMonitor_as_EventsProvider(this_arg: &ChainMonitor) -> cra } extern "C" fn ChainMonitor_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { - >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, handler) + ::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChainMonitor) }, handler) } diff --git a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs index 45e7998..4a51287 100644 --- a/lightning-c-bindings/src/lightning/chain/channelmonitor.rs +++ b/lightning-c-bindings/src/lightning/chain/channelmonitor.rs @@ -54,6 +54,12 @@ pub struct ChannelMonitorUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelMonitorUpdate { + type Target = nativeChannelMonitorUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelMonitorUpdate { } +unsafe impl core::marker::Sync for ChannelMonitorUpdate { } impl Drop for ChannelMonitorUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelMonitorUpdate>::is_null(self.inner) { @@ -84,6 +90,9 @@ impl ChannelMonitorUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The sequence number of this update. Updates *must* be replayed in-order according to this /// sequence number (and updates may panic if they are not). The update_id values are strictly @@ -124,6 +133,29 @@ pub extern "C" fn ChannelMonitorUpdate_get_update_id(this_ptr: &ChannelMonitorUp pub extern "C" fn ChannelMonitorUpdate_set_update_id(this_ptr: &mut ChannelMonitorUpdate, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.update_id = val; } +/// The channel ID associated with these updates. +/// +/// Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and +/// always `Some` otherwise. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdate_get_channel_id(this_ptr: &ChannelMonitorUpdate) -> crate::lightning::ln::types::ChannelId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + let mut local_inner_val = crate::lightning::ln::types::ChannelId { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::types::ChannelId<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel ID associated with these updates. +/// +/// Will be `None` for `ChannelMonitorUpdate`s constructed on LDK versions prior to 0.0.121 and +/// always `Some` otherwise. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelMonitorUpdate_set_channel_id(this_ptr: &mut ChannelMonitorUpdate, mut val: crate::lightning::ln::types::ChannelId) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = local_val; +} impl Clone for ChannelMonitorUpdate { fn clone(&self) -> Self { Self { @@ -173,7 +205,7 @@ pub extern "C" fn ChannelMonitorUpdate_write(obj: &crate::lightning::chain::chan } #[allow(unused)] pub(crate) extern "C" fn ChannelMonitorUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitorUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeChannelMonitorUpdate) }) } #[no_mangle] /// Read a ChannelMonitorUpdate from a byte array, created by ChannelMonitorUpdate_write @@ -191,6 +223,16 @@ pub enum MonitorEvent { HTLCEvent( crate::lightning::chain::channelmonitor::HTLCUpdate), /// Indicates we broadcasted the channel's latest commitment transaction and thus closed the + /// channel. Holds information about the channel and why it was closed. + HolderForceClosedWithInfo { + /// The reason the channel was closed. + reason: crate::lightning::events::ClosureReason, + /// The funding outpoint of the channel. + outpoint: crate::lightning::chain::transaction::OutPoint, + /// The channel ID of the channel. + channel_id: crate::lightning::ln::types::ChannelId, + }, + /// Indicates we broadcasted the channel's latest commitment transaction and thus closed the /// channel. HolderForceClosed( crate::lightning::chain::transaction::OutPoint), @@ -201,6 +243,8 @@ pub enum MonitorEvent { Completed { /// The funding outpoint of the [`ChannelMonitor`] that was updated funding_txo: crate::lightning::chain::transaction::OutPoint, + /// The channel ID of the channel associated with the [`ChannelMonitor`] + channel_id: crate::lightning::ln::types::ChannelId, /// The Update ID from [`ChannelMonitorUpdate::update_id`] which was applied or /// [`ChannelMonitor::get_latest_update_id`]. /// @@ -222,17 +266,29 @@ impl MonitorEvent { *unsafe { Box::from_raw(a_nonref.take_inner()) }, ) }, + MonitorEvent::HolderForceClosedWithInfo {ref reason, ref outpoint, ref channel_id, } => { + let mut reason_nonref = Clone::clone(reason); + let mut outpoint_nonref = Clone::clone(outpoint); + let mut channel_id_nonref = Clone::clone(channel_id); + nativeMonitorEvent::HolderForceClosedWithInfo { + reason: reason_nonref.into_native(), + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, + } + }, MonitorEvent::HolderForceClosed (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeMonitorEvent::HolderForceClosed ( *unsafe { Box::from_raw(a_nonref.take_inner()) }, ) }, - MonitorEvent::Completed {ref funding_txo, ref monitor_update_id, } => { + MonitorEvent::Completed {ref funding_txo, ref channel_id, ref monitor_update_id, } => { let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut channel_id_nonref = Clone::clone(channel_id); let mut monitor_update_id_nonref = Clone::clone(monitor_update_id); nativeMonitorEvent::Completed { funding_txo: *unsafe { Box::from_raw(funding_txo_nonref.take_inner()) }, + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, monitor_update_id: monitor_update_id_nonref, } }, @@ -246,14 +302,22 @@ impl MonitorEvent { *unsafe { Box::from_raw(a.take_inner()) }, ) }, + MonitorEvent::HolderForceClosedWithInfo {mut reason, mut outpoint, mut channel_id, } => { + nativeMonitorEvent::HolderForceClosedWithInfo { + reason: reason.into_native(), + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + } + }, MonitorEvent::HolderForceClosed (mut a, ) => { nativeMonitorEvent::HolderForceClosed ( *unsafe { Box::from_raw(a.take_inner()) }, ) }, - MonitorEvent::Completed {mut funding_txo, mut monitor_update_id, } => { + MonitorEvent::Completed {mut funding_txo, mut channel_id, mut monitor_update_id, } => { nativeMonitorEvent::Completed { funding_txo: *unsafe { Box::from_raw(funding_txo.take_inner()) }, + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, monitor_update_id: monitor_update_id, } }, @@ -269,17 +333,29 @@ impl MonitorEvent { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, ) }, + nativeMonitorEvent::HolderForceClosedWithInfo {ref reason, ref outpoint, ref channel_id, } => { + let mut reason_nonref = Clone::clone(reason); + let mut outpoint_nonref = Clone::clone(outpoint); + let mut channel_id_nonref = Clone::clone(channel_id); + MonitorEvent::HolderForceClosedWithInfo { + reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + } + }, nativeMonitorEvent::HolderForceClosed (ref a, ) => { let mut a_nonref = Clone::clone(a); MonitorEvent::HolderForceClosed ( crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, ) }, - nativeMonitorEvent::Completed {ref funding_txo, ref monitor_update_id, } => { + nativeMonitorEvent::Completed {ref funding_txo, ref channel_id, ref monitor_update_id, } => { let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut channel_id_nonref = Clone::clone(channel_id); let mut monitor_update_id_nonref = Clone::clone(monitor_update_id); MonitorEvent::Completed { funding_txo: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo_nonref), is_owned: true }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, monitor_update_id: monitor_update_id_nonref, } }, @@ -293,14 +369,22 @@ impl MonitorEvent { crate::lightning::chain::channelmonitor::HTLCUpdate { inner: ObjOps::heap_alloc(a), is_owned: true }, ) }, + nativeMonitorEvent::HolderForceClosedWithInfo {mut reason, mut outpoint, mut channel_id, } => { + MonitorEvent::HolderForceClosedWithInfo { + reason: crate::lightning::events::ClosureReason::native_into(reason), + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + } + }, nativeMonitorEvent::HolderForceClosed (mut a, ) => { MonitorEvent::HolderForceClosed ( crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(a), is_owned: true }, ) }, - nativeMonitorEvent::Completed {mut funding_txo, mut monitor_update_id, } => { + nativeMonitorEvent::Completed {mut funding_txo, mut channel_id, mut monitor_update_id, } => { MonitorEvent::Completed { funding_txo: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, monitor_update_id: monitor_update_id, } }, @@ -331,15 +415,25 @@ pub extern "C" fn MonitorEvent_htlcevent(a: crate::lightning::chain::channelmoni MonitorEvent::HTLCEvent(a, ) } #[no_mangle] +/// Utility method to constructs a new HolderForceClosedWithInfo-variant MonitorEvent +pub extern "C" fn MonitorEvent_holder_force_closed_with_info(reason: crate::lightning::events::ClosureReason, outpoint: crate::lightning::chain::transaction::OutPoint, channel_id: crate::lightning::ln::types::ChannelId) -> MonitorEvent { + MonitorEvent::HolderForceClosedWithInfo { + reason, + outpoint, + channel_id, + } +} +#[no_mangle] /// Utility method to constructs a new HolderForceClosed-variant MonitorEvent pub extern "C" fn MonitorEvent_holder_force_closed(a: crate::lightning::chain::transaction::OutPoint) -> MonitorEvent { MonitorEvent::HolderForceClosed(a, ) } #[no_mangle] /// Utility method to constructs a new Completed-variant MonitorEvent -pub extern "C" fn MonitorEvent_completed(funding_txo: crate::lightning::chain::transaction::OutPoint, monitor_update_id: u64) -> MonitorEvent { +pub extern "C" fn MonitorEvent_completed(funding_txo: crate::lightning::chain::transaction::OutPoint, channel_id: crate::lightning::ln::types::ChannelId, monitor_update_id: u64) -> MonitorEvent { MonitorEvent::Completed { funding_txo, + channel_id, monitor_update_id, } } @@ -387,6 +481,12 @@ pub struct HTLCUpdate { pub is_owned: bool, } +impl core::ops::Deref for HTLCUpdate { + type Target = nativeHTLCUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCUpdate { } +unsafe impl core::marker::Sync for HTLCUpdate { } impl Drop for HTLCUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCUpdate>::is_null(self.inner) { @@ -417,6 +517,9 @@ impl HTLCUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for HTLCUpdate { fn clone(&self) -> Self { @@ -453,7 +556,7 @@ pub extern "C" fn HTLCUpdate_write(obj: &crate::lightning::chain::channelmonitor } #[allow(unused)] pub(crate) extern "C" fn HTLCUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeHTLCUpdate) }) } #[no_mangle] /// Read a HTLCUpdate from a byte array, created by HTLCUpdate_write @@ -472,6 +575,103 @@ pub extern "C" fn HTLCUpdate_read(ser: crate::c_types::u8slice) -> crate::c_type #[no_mangle] pub static ANTI_REORG_DELAY: u32 = lightning::chain::channelmonitor::ANTI_REORG_DELAY; +/// Indicates whether the balance is derived from a cooperative close, a force-close +/// (for holder or counterparty), or whether it is for an HTLC. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum BalanceSource { + /// The channel was force closed by the holder. + HolderForceClosed, + /// The channel was force closed by the counterparty. + CounterpartyForceClosed, + /// The channel was cooperatively closed. + CoopClose, + /// This balance is the result of an HTLC. + Htlc, +} +use lightning::chain::channelmonitor::BalanceSource as BalanceSourceImport; +pub(crate) type nativeBalanceSource = BalanceSourceImport; + +impl BalanceSource { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBalanceSource { + match self { + BalanceSource::HolderForceClosed => nativeBalanceSource::HolderForceClosed, + BalanceSource::CounterpartyForceClosed => nativeBalanceSource::CounterpartyForceClosed, + BalanceSource::CoopClose => nativeBalanceSource::CoopClose, + BalanceSource::Htlc => nativeBalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBalanceSource { + match self { + BalanceSource::HolderForceClosed => nativeBalanceSource::HolderForceClosed, + BalanceSource::CounterpartyForceClosed => nativeBalanceSource::CounterpartyForceClosed, + BalanceSource::CoopClose => nativeBalanceSource::CoopClose, + BalanceSource::Htlc => nativeBalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &BalanceSourceImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBalanceSource) }; + match native { + nativeBalanceSource::HolderForceClosed => BalanceSource::HolderForceClosed, + nativeBalanceSource::CounterpartyForceClosed => BalanceSource::CounterpartyForceClosed, + nativeBalanceSource::CoopClose => BalanceSource::CoopClose, + nativeBalanceSource::Htlc => BalanceSource::Htlc, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBalanceSource) -> Self { + match native { + nativeBalanceSource::HolderForceClosed => BalanceSource::HolderForceClosed, + nativeBalanceSource::CounterpartyForceClosed => BalanceSource::CounterpartyForceClosed, + nativeBalanceSource::CoopClose => BalanceSource::CoopClose, + nativeBalanceSource::Htlc => BalanceSource::Htlc, + } + } +} +/// Creates a copy of the BalanceSource +#[no_mangle] +pub extern "C" fn BalanceSource_clone(orig: &BalanceSource) -> BalanceSource { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BalanceSource_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const BalanceSource)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BalanceSource_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut BalanceSource) }; +} +#[no_mangle] +/// Utility method to constructs a new HolderForceClosed-variant BalanceSource +pub extern "C" fn BalanceSource_holder_force_closed() -> BalanceSource { + BalanceSource::HolderForceClosed} +#[no_mangle] +/// Utility method to constructs a new CounterpartyForceClosed-variant BalanceSource +pub extern "C" fn BalanceSource_counterparty_force_closed() -> BalanceSource { + BalanceSource::CounterpartyForceClosed} +#[no_mangle] +/// Utility method to constructs a new CoopClose-variant BalanceSource +pub extern "C" fn BalanceSource_coop_close() -> BalanceSource { + BalanceSource::CoopClose} +#[no_mangle] +/// Utility method to constructs a new Htlc-variant BalanceSource +pub extern "C" fn BalanceSource_htlc() -> BalanceSource { + BalanceSource::Htlc} +/// Get a string which allows debug introspection of a BalanceSource object +pub extern "C" fn BalanceSource_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::channelmonitor::BalanceSource }).into()} +/// Checks if two BalanceSources contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn BalanceSource_eq(a: &BalanceSource, b: &BalanceSource) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// Details about the balance(s) available for spending once the channel appears on chain. /// /// See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not @@ -487,6 +687,49 @@ pub enum Balance { /// The amount available to claim, in satoshis, excluding the on-chain fees which will be /// required to do so. amount_satoshis: u64, + /// The transaction fee we pay for the closing commitment transaction. This amount is not + /// included in the [`Balance::ClaimableOnChannelClose::amount_satoshis`] value. + /// + /// Note that if this channel is inbound (and thus our counterparty pays the commitment + /// transaction fee) this value will be zero. For [`ChannelMonitor`]s created prior to LDK + /// 0.0.124, the channel is always treated as outbound (and thus this value is never zero). + transaction_fee_satoshis: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + /// from us and are related to a payment which was sent by us. This is the sum of the + /// millisatoshis part of all HTLCs which are otherwise represented by + /// [`Balance::MaybeTimeoutClaimableHTLC`] with their + /// [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag set, as well as any dust + /// HTLCs which would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + outbound_payment_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are outbound + /// from us and are related to a forwarded HTLC. This is the sum of the millisatoshis part + /// of all HTLCs which are otherwise represented by [`Balance::MaybeTimeoutClaimableHTLC`] + /// with their [`Balance::MaybeTimeoutClaimableHTLC::outbound_payment`] flag *not* set, as + /// well as any dust HTLCs which would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in `amount_satoshis`. + outbound_forwarded_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + /// to us and for which we know the preimage. This is the sum of the millisatoshis part of + /// all HTLCs which would be represented by [`Balance::ContentiousClaimable`] on channel + /// close, but whose current value is included in + /// [`Balance::ClaimableOnChannelClose::amount_satoshis`], as well as any dust HTLCs which + /// would otherwise be represented the same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + /// `amount_satoshis`. + inbound_claiming_htlc_rounded_msat: u64, + /// The amount of millisatoshis which has been burned to fees from HTLCs which are inbound + /// to us and for which we do not know the preimage. This is the sum of the millisatoshis + /// part of all HTLCs which would be represented by [`Balance::MaybePreimageClaimableHTLC`] + /// on channel close, as well as any dust HTLCs which would otherwise be represented the + /// same. + /// + /// This amount (rounded up to a whole satoshi value) will not be included in the counterparty's + /// `amount_satoshis`. + inbound_htlc_rounded_msat: u64, }, /// The channel has been closed, and the given balance is ours but awaiting confirmations until /// we consider it spendable. @@ -497,6 +740,8 @@ pub enum Balance { /// The height at which an [`Event::SpendableOutputs`] event will be generated for this /// amount. confirmation_height: u32, + /// Whether this balance is a result of cooperative close, a force-close, or an HTLC. + source: crate::lightning::chain::channelmonitor::BalanceSource, }, /// The channel has been closed, and the given balance should be ours but awaiting spending /// transaction confirmation. If the spending transaction does not confirm in time, it is @@ -529,6 +774,10 @@ pub enum Balance { claimable_height: u32, /// The payment hash whose preimage our counterparty needs to claim this HTLC. payment_hash: crate::c_types::ThirtyTwoBytes, + /// Whether this HTLC represents a payment which was sent outbound from us. Otherwise it + /// represents an HTLC which was forwarded (and should, thus, have a corresponding inbound + /// edge on another channel). + outbound_payment: bool, }, /// HTLCs which we received from our counterparty which are claimable with a preimage which we /// do not currently have. This will only be claimable if we receive the preimage from the node @@ -563,18 +812,30 @@ impl Balance { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeBalance { match self { - Balance::ClaimableOnChannelClose {ref amount_satoshis, } => { + Balance::ClaimableOnChannelClose {ref amount_satoshis, ref transaction_fee_satoshis, ref outbound_payment_htlc_rounded_msat, ref outbound_forwarded_htlc_rounded_msat, ref inbound_claiming_htlc_rounded_msat, ref inbound_htlc_rounded_msat, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); + let mut transaction_fee_satoshis_nonref = Clone::clone(transaction_fee_satoshis); + let mut outbound_payment_htlc_rounded_msat_nonref = Clone::clone(outbound_payment_htlc_rounded_msat); + let mut outbound_forwarded_htlc_rounded_msat_nonref = Clone::clone(outbound_forwarded_htlc_rounded_msat); + let mut inbound_claiming_htlc_rounded_msat_nonref = Clone::clone(inbound_claiming_htlc_rounded_msat); + let mut inbound_htlc_rounded_msat_nonref = Clone::clone(inbound_htlc_rounded_msat); nativeBalance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis_nonref, + transaction_fee_satoshis: transaction_fee_satoshis_nonref, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat_nonref, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat_nonref, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat_nonref, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat_nonref, } }, - Balance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, } => { + Balance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, ref source, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut source_nonref = Clone::clone(source); nativeBalance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis_nonref, confirmation_height: confirmation_height_nonref, + source: source_nonref.into_native(), } }, Balance::ContentiousClaimable {ref amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { @@ -585,18 +846,20 @@ impl Balance { nativeBalance::ContentiousClaimable { amount_satoshis: amount_satoshis_nonref, timeout_height: timeout_height_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_nonref.data), } }, - Balance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, } => { + Balance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, ref outbound_payment, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut outbound_payment_nonref = Clone::clone(outbound_payment); nativeBalance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis_nonref, claimable_height: claimable_height_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), + outbound_payment: outbound_payment_nonref, } }, Balance::MaybePreimageClaimableHTLC {ref amount_satoshis, ref expiry_height, ref payment_hash, } => { @@ -606,7 +869,7 @@ impl Balance { nativeBalance::MaybePreimageClaimableHTLC { amount_satoshis: amount_satoshis_nonref, expiry_height: expiry_height_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), } }, Balance::CounterpartyRevokedOutputClaimable {ref amount_satoshis, } => { @@ -620,37 +883,44 @@ impl Balance { #[allow(unused)] pub(crate) fn into_native(self) -> nativeBalance { match self { - Balance::ClaimableOnChannelClose {mut amount_satoshis, } => { + Balance::ClaimableOnChannelClose {mut amount_satoshis, mut transaction_fee_satoshis, mut outbound_payment_htlc_rounded_msat, mut outbound_forwarded_htlc_rounded_msat, mut inbound_claiming_htlc_rounded_msat, mut inbound_htlc_rounded_msat, } => { nativeBalance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis, + transaction_fee_satoshis: transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat, } }, - Balance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, } => { + Balance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, mut source, } => { nativeBalance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis, confirmation_height: confirmation_height, + source: source.into_native(), } }, Balance::ContentiousClaimable {mut amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { nativeBalance::ContentiousClaimable { amount_satoshis: amount_satoshis, timeout_height: timeout_height, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage.data), } }, - Balance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, } => { + Balance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, mut outbound_payment, } => { nativeBalance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis, claimable_height: claimable_height, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), + outbound_payment: outbound_payment, } }, Balance::MaybePreimageClaimableHTLC {mut amount_satoshis, mut expiry_height, mut payment_hash, } => { nativeBalance::MaybePreimageClaimableHTLC { amount_satoshis: amount_satoshis, expiry_height: expiry_height, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), } }, Balance::CounterpartyRevokedOutputClaimable {mut amount_satoshis, } => { @@ -664,18 +934,30 @@ impl Balance { pub(crate) fn from_native(native: &BalanceImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBalance) }; match native { - nativeBalance::ClaimableOnChannelClose {ref amount_satoshis, } => { + nativeBalance::ClaimableOnChannelClose {ref amount_satoshis, ref transaction_fee_satoshis, ref outbound_payment_htlc_rounded_msat, ref outbound_forwarded_htlc_rounded_msat, ref inbound_claiming_htlc_rounded_msat, ref inbound_htlc_rounded_msat, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); + let mut transaction_fee_satoshis_nonref = Clone::clone(transaction_fee_satoshis); + let mut outbound_payment_htlc_rounded_msat_nonref = Clone::clone(outbound_payment_htlc_rounded_msat); + let mut outbound_forwarded_htlc_rounded_msat_nonref = Clone::clone(outbound_forwarded_htlc_rounded_msat); + let mut inbound_claiming_htlc_rounded_msat_nonref = Clone::clone(inbound_claiming_htlc_rounded_msat); + let mut inbound_htlc_rounded_msat_nonref = Clone::clone(inbound_htlc_rounded_msat); Balance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis_nonref, + transaction_fee_satoshis: transaction_fee_satoshis_nonref, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat_nonref, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat_nonref, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat_nonref, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat_nonref, } }, - nativeBalance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, } => { + nativeBalance::ClaimableAwaitingConfirmations {ref amount_satoshis, ref confirmation_height, ref source, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut source_nonref = Clone::clone(source); Balance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis_nonref, confirmation_height: confirmation_height_nonref, + source: crate::lightning::chain::channelmonitor::BalanceSource::native_into(source_nonref), } }, nativeBalance::ContentiousClaimable {ref amount_satoshis, ref timeout_height, ref payment_hash, ref payment_preimage, } => { @@ -690,14 +972,16 @@ impl Balance { payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {ref amount_satoshis, ref claimable_height, ref payment_hash, ref outbound_payment, } => { let mut amount_satoshis_nonref = Clone::clone(amount_satoshis); let mut claimable_height_nonref = Clone::clone(claimable_height); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut outbound_payment_nonref = Clone::clone(outbound_payment); Balance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis_nonref, claimable_height: claimable_height_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + outbound_payment: outbound_payment_nonref, } }, nativeBalance::MaybePreimageClaimableHTLC {ref amount_satoshis, ref expiry_height, ref payment_hash, } => { @@ -721,15 +1005,21 @@ impl Balance { #[allow(unused)] pub(crate) fn native_into(native: nativeBalance) -> Self { match native { - nativeBalance::ClaimableOnChannelClose {mut amount_satoshis, } => { + nativeBalance::ClaimableOnChannelClose {mut amount_satoshis, mut transaction_fee_satoshis, mut outbound_payment_htlc_rounded_msat, mut outbound_forwarded_htlc_rounded_msat, mut inbound_claiming_htlc_rounded_msat, mut inbound_htlc_rounded_msat, } => { Balance::ClaimableOnChannelClose { amount_satoshis: amount_satoshis, + transaction_fee_satoshis: transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat: outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat: outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat: inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat: inbound_htlc_rounded_msat, } }, - nativeBalance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, } => { + nativeBalance::ClaimableAwaitingConfirmations {mut amount_satoshis, mut confirmation_height, mut source, } => { Balance::ClaimableAwaitingConfirmations { amount_satoshis: amount_satoshis, confirmation_height: confirmation_height, + source: crate::lightning::chain::channelmonitor::BalanceSource::native_into(source), } }, nativeBalance::ContentiousClaimable {mut amount_satoshis, mut timeout_height, mut payment_hash, mut payment_preimage, } => { @@ -740,11 +1030,12 @@ impl Balance { payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage.0 }, } }, - nativeBalance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, } => { + nativeBalance::MaybeTimeoutClaimableHTLC {mut amount_satoshis, mut claimable_height, mut payment_hash, mut outbound_payment, } => { Balance::MaybeTimeoutClaimableHTLC { amount_satoshis: amount_satoshis, claimable_height: claimable_height, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + outbound_payment: outbound_payment, } }, nativeBalance::MaybePreimageClaimableHTLC {mut amount_satoshis, mut expiry_height, mut payment_hash, } => { @@ -782,17 +1073,23 @@ pub(crate) extern "C" fn Balance_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new ClaimableOnChannelClose-variant Balance -pub extern "C" fn Balance_claimable_on_channel_close(amount_satoshis: u64) -> Balance { +pub extern "C" fn Balance_claimable_on_channel_close(amount_satoshis: u64, transaction_fee_satoshis: u64, outbound_payment_htlc_rounded_msat: u64, outbound_forwarded_htlc_rounded_msat: u64, inbound_claiming_htlc_rounded_msat: u64, inbound_htlc_rounded_msat: u64) -> Balance { Balance::ClaimableOnChannelClose { amount_satoshis, + transaction_fee_satoshis, + outbound_payment_htlc_rounded_msat, + outbound_forwarded_htlc_rounded_msat, + inbound_claiming_htlc_rounded_msat, + inbound_htlc_rounded_msat, } } #[no_mangle] /// Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance -pub extern "C" fn Balance_claimable_awaiting_confirmations(amount_satoshis: u64, confirmation_height: u32) -> Balance { +pub extern "C" fn Balance_claimable_awaiting_confirmations(amount_satoshis: u64, confirmation_height: u32, source: crate::lightning::chain::channelmonitor::BalanceSource) -> Balance { Balance::ClaimableAwaitingConfirmations { amount_satoshis, confirmation_height, + source, } } #[no_mangle] @@ -807,11 +1104,12 @@ pub extern "C" fn Balance_contentious_claimable(amount_satoshis: u64, timeout_he } #[no_mangle] /// Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance -pub extern "C" fn Balance_maybe_timeout_claimable_htlc(amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes) -> Balance { +pub extern "C" fn Balance_maybe_timeout_claimable_htlc(amount_satoshis: u64, claimable_height: u32, payment_hash: crate::c_types::ThirtyTwoBytes, outbound_payment: bool) -> Balance { Balance::MaybeTimeoutClaimableHTLC { amount_satoshis, claimable_height, payment_hash, + outbound_payment, } } #[no_mangle] @@ -839,9 +1137,15 @@ pub extern "C" fn Balance_debug_str_void(o: *const c_void) -> Str { pub extern "C" fn Balance_eq(a: &Balance, b: &Balance) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } -/// The amount claimable, in satoshis. This excludes balances that we are unsure if we are able -/// to claim, this is because we are waiting for a preimage or for a timeout to expire. For more -/// information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and +/// The amount claimable, in satoshis. +/// +/// For outbound payments, this excludes the balance from the possible HTLC timeout. +/// +/// For forwarded payments, this includes the balance from the possible HTLC timeout as +/// (to be conservative) that balance does not include routing fees we'd earn if we'd claim +/// the balance from a preimage in a successful forward. +/// +/// For more information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and /// [`Balance::MaybePreimageClaimableHTLC`]. /// /// On-chain fees required to claim the balance are not included in this amount. @@ -854,7 +1158,7 @@ pub extern "C" fn Balance_claimable_amount_satoshis(this_arg: &crate::lightning: use lightning::chain::channelmonitor::ChannelMonitor as nativeChannelMonitorImport; -pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; +pub(crate) type nativeChannelMonitor = nativeChannelMonitorImport; /// A ChannelMonitor handles chain events (blocks connected and disconnected) and generates /// on-chain transactions to ensure no loss of funds occurs. @@ -882,6 +1186,12 @@ pub struct ChannelMonitor { pub is_owned: bool, } +impl core::ops::Deref for ChannelMonitor { + type Target = nativeChannelMonitor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelMonitor { } +unsafe impl core::marker::Sync for ChannelMonitor { } impl Drop for ChannelMonitor { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelMonitor>::is_null(self.inner) { @@ -912,6 +1222,9 @@ impl ChannelMonitor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ChannelMonitor { fn clone(&self) -> Self { @@ -939,7 +1252,7 @@ pub extern "C" fn ChannelMonitor_write(obj: &crate::lightning::chain::channelmon } #[allow(unused)] pub(crate) extern "C" fn ChannelMonitor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelMonitor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::channelmonitor::nativeChannelMonitor) }) } /// Updates a ChannelMonitor on the basis of some new information provided by the Channel /// itself. @@ -971,6 +1284,14 @@ pub extern "C" fn ChannelMonitor_get_funding_txo(this_arg: &crate::lightning::ch local_ret } +/// Gets the channel_id of the channel this ChannelMonitor is monitoring for. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_channel_id(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::ln::types::ChannelId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_id(); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + /// Gets a list of txids, with their output scripts (in the order they appear in the /// transaction), which we must learn about spends of via block_connected(). #[must_use] @@ -1010,11 +1331,16 @@ pub extern "C" fn ChannelMonitor_get_and_clear_pending_monitor_events(this_arg: /// An [`EventHandler`] may safely call back to the provider, though this shouldn't be needed in /// order to handle these events. /// +/// Will return a [`ReplayEvent`] error if event handling failed and should eventually be retried. +/// /// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs /// [`BumpTransaction`]: crate::events::Event::BumpTransaction +#[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_process_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, handler: &crate::lightning::events::EventHandler) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_events(handler) +pub extern "C" fn ChannelMonitor_process_pending_events(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, handler: &crate::lightning::events::EventHandler) -> crate::c_types::derived::CResult_NoneReplayEventZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.process_pending_events(handler); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::events::ReplayEvent { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; + local_ret } /// Gets the counterparty's initial commitment transaction. The returned commitment @@ -1106,26 +1432,18 @@ pub extern "C" fn ChannelMonitor_get_counterparty_node_id(this_arg: &crate::ligh local_ret } -/// Used by [`ChannelManager`] deserialization to broadcast the latest holder state if its copy -/// of the channel state was out-of-date. -/// -/// You may also use this to broadcast the latest local commitment transaction, either because +/// You may use this to broadcast the latest local commitment transaction, either because /// a monitor update failed or because we've fallen behind (i.e. we've received proof that our /// counterparty side knows a revocation secret we gave them that they shouldn't know). /// -/// Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty +/// Broadcasting these transactions in this manner is UNSAFE, as they allow counterparty /// side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't /// close channel with their commitment transaction after a substantial amount of time. Best /// may be to contact the other node operator out-of-band to coordinate other options available /// to you. -/// -/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager -#[must_use] #[no_mangle] -pub extern "C" fn ChannelMonitor_get_latest_holder_commitment_txn(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, logger: &crate::lightning::util::logger::Logger) -> crate::c_types::derived::CVec_TransactionZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_latest_holder_commitment_txn(logger); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::c_types::Transaction::from_bitcoin(&item) }); }; - local_ret.into() +pub extern "C" fn ChannelMonitor_broadcast_latest_holder_commitment_txn(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator, logger: &crate::lightning::util::logger::Logger) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.broadcast_latest_holder_commitment_txn(broadcaster, fee_estimator, logger) } /// Processes transactions in a newly connected block, which may result in any of the following: @@ -1225,6 +1543,21 @@ pub extern "C" fn ChannelMonitor_rebroadcast_pending_claims(this_arg: &crate::li unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.rebroadcast_pending_claims(broadcaster, fee_estimator, logger) } +/// Returns true if the monitor has pending claim requests that are not fully confirmed yet. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_has_pending_claims(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.has_pending_claims(); + ret +} + +/// Triggers rebroadcasts of pending claims from a force-closed channel after a transaction +/// signature generation failure. +#[no_mangle] +pub extern "C" fn ChannelMonitor_signer_unblocked(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, logger: &crate::lightning::util::logger::Logger) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signer_unblocked(broadcaster, fee_estimator, logger) +} + /// Returns the descriptors for relevant outputs (i.e., those that we can spend) within the /// transaction if they exist and the transaction has at least [`ANTI_REORG_DELAY`] /// confirmations. For [`SpendableOutputDescriptor::DelayedPaymentOutput`] descriptors to be @@ -1251,6 +1584,18 @@ pub extern "C" fn ChannelMonitor_get_spendable_outputs(this_arg: &crate::lightni local_ret.into() } +/// Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of +/// its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set). +/// +/// This function returns true only if [`Self::get_claimable_balances`] has been empty for at least +/// 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelMonitor_is_fully_resolved(this_arg: &crate::lightning::chain::channelmonitor::ChannelMonitor, logger: &crate::lightning::util::logger::Logger) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_fully_resolved(logger); + ret +} + /// Gets the balances in this channel which are either claimable by us if we were to /// force-close the channel now or which are claimable on-chain (possibly awaiting /// confirmation). @@ -1279,7 +1624,7 @@ pub extern "C" fn C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser: crate::c_types let arg_a_conv = arg_a; let arg_b_conv = arg_b; let arg_conv = (arg_a_conv, arg_b_conv); - let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let res: Result<(bitcoin::hash_types::BlockHash, lightning::chain::channelmonitor::ChannelMonitor), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_res_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/chain/mod.rs b/lightning-c-bindings/src/lightning/chain/mod.rs index fdb0902..c981ca3 100644 --- a/lightning-c-bindings/src/lightning/chain/mod.rs +++ b/lightning-c-bindings/src/lightning/chain/mod.rs @@ -65,6 +65,12 @@ pub struct BestBlock { pub is_owned: bool, } +impl core::ops::Deref for BestBlock { + type Target = nativeBestBlock; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BestBlock { } +unsafe impl core::marker::Sync for BestBlock { } impl Drop for BestBlock { fn drop(&mut self) { if self.is_owned && !<*mut nativeBestBlock>::is_null(self.inner) { @@ -95,6 +101,40 @@ impl BestBlock { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The block's hash +#[no_mangle] +pub extern "C" fn BestBlock_get_block_hash(this_ptr: &BestBlock) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().block_hash; + inner_val.as_ref() +} +/// The block's hash +#[no_mangle] +pub extern "C" fn BestBlock_set_block_hash(this_ptr: &mut BestBlock, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.block_hash = ::bitcoin::hash_types::BlockHash::from_slice(&val.data[..]).unwrap(); +} +/// The height at which the block was confirmed. +#[no_mangle] +pub extern "C" fn BestBlock_get_height(this_ptr: &BestBlock) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().height; + *inner_val +} +/// The height at which the block was confirmed. +#[no_mangle] +pub extern "C" fn BestBlock_set_height(this_ptr: &mut BestBlock, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.height = val; +} +/// Constructs a new BestBlock given each field +#[must_use] +#[no_mangle] +pub extern "C" fn BestBlock_new(mut block_hash_arg: crate::c_types::ThirtyTwoBytes, mut height_arg: u32) -> BestBlock { + BestBlock { inner: ObjOps::heap_alloc(nativeBestBlock { + block_hash: ::bitcoin::hash_types::BlockHash::from_slice(&block_hash_arg.data[..]).unwrap(), + height: height_arg, + }), is_owned: true } } impl Clone for BestBlock { fn clone(&self) -> Self { @@ -115,6 +155,19 @@ pub(crate) extern "C" fn BestBlock_clone_void(this_ptr: *const c_void) -> *mut c pub extern "C" fn BestBlock_clone(orig: &BestBlock) -> BestBlock { orig.clone() } +/// Get a string which allows debug introspection of a BestBlock object +pub extern "C" fn BestBlock_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::chain::BestBlock }).into()} +/// Generates a non-cryptographic 64-bit hash of the BestBlock. +#[no_mangle] +pub extern "C" fn BestBlock_hash(o: &BestBlock) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Checks if two BestBlocks contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. @@ -133,30 +186,22 @@ pub extern "C" fn BestBlock_from_network(mut network: crate::bitcoin::network::N crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Returns a `BestBlock` as identified by the given block hash and height. -#[must_use] #[no_mangle] -pub extern "C" fn BestBlock_new(mut block_hash: crate::c_types::ThirtyTwoBytes, mut height: u32) -> crate::lightning::chain::BestBlock { - let mut ret = lightning::chain::BestBlock::new(::bitcoin::hash_types::BlockHash::from_slice(&block_hash.data[..]).unwrap(), height); - crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true } +/// Serialize the BestBlock object into a byte array which can be read by BestBlock_read +pub extern "C" fn BestBlock_write(obj: &crate::lightning::chain::BestBlock) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } - -/// Returns the best block hash. -#[must_use] -#[no_mangle] -pub extern "C" fn BestBlock_block_hash(this_arg: &crate::lightning::chain::BestBlock) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.block_hash(); - crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() } +#[allow(unused)] +pub(crate) extern "C" fn BestBlock_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::nativeBestBlock) }) } - -/// Returns the best block height. -#[must_use] #[no_mangle] -pub extern "C" fn BestBlock_height(this_arg: &crate::lightning::chain::BestBlock) -> u32 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.height(); - ret +/// Read a BestBlock from a byte array, created by BestBlock_write +pub extern "C" fn BestBlock_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BestBlockDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res } - /// The `Listen` trait is used to notify when blocks have been connected or disconnected from the /// chain. /// @@ -199,32 +244,49 @@ pub(crate) fn Listen_clone_fields(orig: &Listen) -> Listen { use lightning::chain::Listen as rustListen; impl rustListen for Listen { - fn filtered_block_connected(&self, mut header: &bitcoin::blockdata::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + fn filtered_block_connected(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; (self.filtered_block_connected)(self.this_arg, &local_header, local_txdata.into(), height) } - fn block_connected(&self, mut block: &bitcoin::blockdata::block::Block, mut height: u32) { + fn block_connected(&self, mut block: &bitcoin::block::Block, mut height: u32) { let mut local_block = ::bitcoin::consensus::encode::serialize(block); (self.block_connected)(self.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) } - fn block_disconnected(&self, mut header: &bitcoin::blockdata::block::Header, mut height: u32) { + fn block_disconnected(&self, mut header: &bitcoin::block::Header, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; (self.block_disconnected)(self.this_arg, &local_header, height) } } +pub struct ListenRef(Listen); +impl rustListen for ListenRef { + fn filtered_block_connected(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; + (self.0.filtered_block_connected)(self.0.this_arg, &local_header, local_txdata.into(), height) + } + fn block_connected(&self, mut block: &bitcoin::block::Block, mut height: u32) { + let mut local_block = ::bitcoin::consensus::encode::serialize(block); + (self.0.block_connected)(self.0.this_arg, crate::c_types::u8slice::from_slice(&local_block), height) + } + fn block_disconnected(&self, mut header: &bitcoin::block::Header, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + (self.0.block_disconnected)(self.0.this_arg, &local_header, height) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Listen { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ListenRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ListenRef) } } } impl core::ops::DerefMut for Listen { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ListenRef { + unsafe { &mut *(self as *mut _ as *mut ListenRef) } } } /// Calls the free function if one is set @@ -349,7 +411,7 @@ pub(crate) fn Confirm_clone_fields(orig: &Confirm) -> Confirm { use lightning::chain::Confirm as rustConfirm; impl rustConfirm for Confirm { - fn transactions_confirmed(&self, mut header: &bitcoin::blockdata::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + fn transactions_confirmed(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; (self.transactions_confirmed)(self.this_arg, &local_header, local_txdata.into(), height) @@ -357,7 +419,7 @@ impl rustConfirm for Confirm { fn transaction_unconfirmed(&self, mut txid: &bitcoin::hash_types::Txid) { (self.transaction_unconfirmed)(self.this_arg, txid.as_ref()) } - fn best_block_updated(&self, mut header: &bitcoin::blockdata::block::Header, mut height: u32) { + fn best_block_updated(&self, mut header: &bitcoin::block::Header, mut height: u32) { let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; (self.best_block_updated)(self.this_arg, &local_header, height) } @@ -368,17 +430,38 @@ impl rustConfirm for Confirm { } } +pub struct ConfirmRef(Confirm); +impl rustConfirm for ConfirmRef { + fn transactions_confirmed(&self, mut header: &bitcoin::block::Header, mut txdata: &lightning::chain::transaction::TransactionData, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + let mut local_txdata = Vec::new(); for item in txdata.iter() { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item; let mut local_txdata_0 = (orig_txdata_0_0, crate::c_types::Transaction::from_bitcoin(&orig_txdata_0_1)).into(); local_txdata_0 }); }; + (self.0.transactions_confirmed)(self.0.this_arg, &local_header, local_txdata.into(), height) + } + fn transaction_unconfirmed(&self, mut txid: &bitcoin::hash_types::Txid) { + (self.0.transaction_unconfirmed)(self.0.this_arg, txid.as_ref()) + } + fn best_block_updated(&self, mut header: &bitcoin::block::Header, mut height: u32) { + let mut local_header = { let mut s = [0u8; 80]; s[..].copy_from_slice(&::bitcoin::consensus::encode::serialize(header)); s }; + (self.0.best_block_updated)(self.0.this_arg, &local_header, height) + } + fn get_relevant_txids(&self) -> Vec<(bitcoin::hash_types::Txid, u32, Option)> { + let mut ret = (self.0.get_relevant_txids)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = { /*orig_ret_0_2*/ let orig_ret_0_2_opt = orig_ret_0_2; if orig_ret_0_2_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::BlockHash::from_slice(&{ orig_ret_0_2_opt.take() }.data[..]).unwrap() }})} }; let mut local_ret_0 = (::bitcoin::hash_types::Txid::from_slice(&orig_ret_0_0.data[..]).unwrap(), orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Confirm { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ConfirmRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ConfirmRef) } } } impl core::ops::DerefMut for Confirm { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ConfirmRef { + unsafe { &mut *(self as *mut _ as *mut ConfirmRef) } } } /// Calls the free function if one is set @@ -590,7 +673,7 @@ pub struct Watch { /// /// For details on asynchronous [`ChannelMonitor`] updating and returning /// [`MonitorEvent::Completed`] here, see [`ChannelMonitorUpdateStatus::InProgress`]. - pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ, + pub release_pending_monitor_events: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -609,8 +692,8 @@ pub(crate) fn Watch_clone_fields(orig: &Watch) -> Watch { } use lightning::chain::Watch as rustWatch; -impl rustWatch for Watch { - fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result { +impl rustWatch for Watch { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result { let mut ret = (self.watch_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(monitor), is_owned: true }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_native() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret @@ -619,9 +702,27 @@ impl rustWatch for W let mut ret = (self.update_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((update as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _) }, is_owned: false }); ret.into_native() } - fn release_pending_monitor_events(&self) -> Vec<(lightning::chain::transaction::OutPoint, Vec, Option)> { + fn release_pending_monitor_events(&self) -> Vec<(lightning::chain::transaction::OutPoint, lightning::ln::types::ChannelId, Vec, Option)> { let mut ret = (self.release_pending_monitor_events)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_null() { None } else { Some( { orig_ret_0_2.into_rust() }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2, mut orig_ret_0_3) = item.to_rust(); let mut local_orig_ret_0_2 = Vec::new(); for mut item in orig_ret_0_2.into_rust().drain(..) { local_orig_ret_0_2.push( { item.into_native() }); }; let mut local_orig_ret_0_3 = if orig_ret_0_3.is_null() { None } else { Some( { orig_ret_0_3.into_rust() }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }, local_orig_ret_0_2, local_orig_ret_0_3); local_ret_0 }); }; + local_ret + } +} + +pub struct WatchRef(Watch); +impl rustWatch for WatchRef { + fn watch_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut monitor: lightning::chain::channelmonitor::ChannelMonitor) -> Result { + let mut ret = (self.0.watch_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(monitor), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_native() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn update_channel(&self, mut funding_txo: lightning::chain::transaction::OutPoint, mut update: &lightning::chain::channelmonitor::ChannelMonitorUpdate) -> lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = (self.0.update_channel)(self.0.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(funding_txo), is_owned: true }, &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((update as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _) }, is_owned: false }); + ret.into_native() + } + fn release_pending_monitor_events(&self) -> Vec<(lightning::chain::transaction::OutPoint, lightning::ln::types::ChannelId, Vec, Option)> { + let mut ret = (self.0.release_pending_monitor_events)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2, mut orig_ret_0_3) = item.to_rust(); let mut local_orig_ret_0_2 = Vec::new(); for mut item in orig_ret_0_2.into_rust().drain(..) { local_orig_ret_0_2.push( { item.into_native() }); }; let mut local_orig_ret_0_3 = if orig_ret_0_3.is_null() { None } else { Some( { orig_ret_0_3.into_rust() }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }, local_orig_ret_0_2, local_orig_ret_0_3); local_ret_0 }); }; local_ret } } @@ -629,14 +730,14 @@ impl rustWatch for W // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Watch { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = WatchRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WatchRef) } } } impl core::ops::DerefMut for Watch { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WatchRef { + unsafe { &mut *(self as *mut _ as *mut WatchRef) } } } /// Calls the free function if one is set @@ -676,6 +777,11 @@ pub struct Filter { pub this_arg: *mut c_void, /// Registers interest in a transaction with `txid` and having an output with `script_pubkey` as /// a spending condition. + /// + /// This may be used, for example, to monitor for when a funding transaction confirms. + /// + /// The `script_pubkey` is provided for informational purposes and may be useful for block + /// sources which only support filtering on scripts. pub register_tx: extern "C" fn (this_arg: *const c_void, txid: *const [u8; 32], script_pubkey: crate::c_types::u8slice), /// Registers interest in spends of a transaction output. /// @@ -683,6 +789,9 @@ pub struct Filter { /// to ensure that also dependent output spents within an already connected block are correctly /// handled, e.g., by re-scanning the block in question whenever new outputs have been /// registered mid-processing. + /// + /// This may be used, for example, to monitor for when a funding output is spent (by any + /// transaction). pub register_output: extern "C" fn (this_arg: *const c_void, output: crate::lightning::chain::WatchedOutput), /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. @@ -702,7 +811,7 @@ pub(crate) fn Filter_clone_fields(orig: &Filter) -> Filter { use lightning::chain::Filter as rustFilter; impl rustFilter for Filter { - fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::blockdata::script::Script) { + fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::script::Script) { (self.register_tx)(self.this_arg, txid.as_ref(), crate::c_types::u8slice::from_slice(script_pubkey.as_ref())) } fn register_output(&self, mut output: lightning::chain::WatchedOutput) { @@ -710,17 +819,27 @@ impl rustFilter for Filter { } } +pub struct FilterRef(Filter); +impl rustFilter for FilterRef { + fn register_tx(&self, mut txid: &bitcoin::hash_types::Txid, mut script_pubkey: &bitcoin::script::Script) { + (self.0.register_tx)(self.0.this_arg, txid.as_ref(), crate::c_types::u8slice::from_slice(script_pubkey.as_ref())) + } + fn register_output(&self, mut output: lightning::chain::WatchedOutput) { + (self.0.register_output)(self.0.this_arg, crate::lightning::chain::WatchedOutput { inner: ObjOps::heap_alloc(output), is_owned: true }) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Filter { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FilterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FilterRef) } } } impl core::ops::DerefMut for Filter { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FilterRef { + unsafe { &mut *(self as *mut _ as *mut FilterRef) } } } /// Calls the free function if one is set @@ -746,6 +865,9 @@ pub(crate) type nativeWatchedOutput = nativeWatchedOutputImport; /// If `block_hash` is `Some`, this indicates the output was created in the corresponding block and /// may have been spent there. See [`Filter::register_output`] for details. /// +/// Depending on your block source, you may need one or both of either [`Self::outpoint`] or +/// [`Self::script_pubkey`]. +/// /// [`ChannelMonitor`]: channelmonitor::ChannelMonitor /// [`ChannelMonitor::block_connected`]: channelmonitor::ChannelMonitor::block_connected #[must_use] @@ -763,6 +885,12 @@ pub struct WatchedOutput { pub is_owned: bool, } +impl core::ops::Deref for WatchedOutput { + type Target = nativeWatchedOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for WatchedOutput { } +unsafe impl core::marker::Sync for WatchedOutput { } impl Drop for WatchedOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeWatchedOutput>::is_null(self.inner) { @@ -793,6 +921,9 @@ impl WatchedOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// First block where the transaction output may have been spent. #[no_mangle] @@ -827,7 +958,7 @@ pub extern "C" fn WatchedOutput_get_script_pubkey(this_ptr: &WatchedOutput) -> c /// Spending condition of the transaction output. #[no_mangle] pub extern "C" fn WatchedOutput_set_script_pubkey(this_ptr: &mut WatchedOutput, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script_pubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script_pubkey = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new WatchedOutput given each field #[must_use] @@ -837,7 +968,7 @@ pub extern "C" fn WatchedOutput_new(mut block_hash_arg: crate::c_types::derived: WatchedOutput { inner: ObjOps::heap_alloc(nativeWatchedOutput { block_hash: local_block_hash_arg, outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, - script_pubkey: ::bitcoin::blockdata::script::ScriptBuf::from(script_pubkey_arg.into_rust()), + script_pubkey: ::bitcoin::script::ScriptBuf::from(script_pubkey_arg.into_rust()), }), is_owned: true } } impl Clone for WatchedOutput { diff --git a/lightning-c-bindings/src/lightning/chain/transaction.rs b/lightning-c-bindings/src/lightning/chain/transaction.rs index a6800ad..d807fc3 100644 --- a/lightning-c-bindings/src/lightning/chain/transaction.rs +++ b/lightning-c-bindings/src/lightning/chain/transaction.rs @@ -23,7 +23,7 @@ pub(crate) type nativeOutPoint = nativeOutPointImport; /// A reference to a transaction output. /// -/// Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32 +/// Differs from bitcoin::transaction::OutPoint as the index is a u16 instead of u32 /// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. #[must_use] #[repr(C)] @@ -40,6 +40,12 @@ pub struct OutPoint { pub is_owned: bool, } +impl core::ops::Deref for OutPoint { + type Target = nativeOutPoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutPoint { } +unsafe impl core::marker::Sync for OutPoint { } impl Drop for OutPoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeOutPoint>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl OutPoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The referenced transaction's txid. #[no_mangle] @@ -143,14 +152,11 @@ pub extern "C" fn OutPoint_hash(o: &OutPoint) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Convert an `OutPoint` to a lightning channel id. -#[must_use] #[no_mangle] -pub extern "C" fn OutPoint_to_channel_id(this_arg: &crate::lightning::chain::transaction::OutPoint) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_channel_id(); - crate::c_types::ThirtyTwoBytes { data: ret.0 } +/// Get the string representation of a OutPoint object +pub extern "C" fn OutPoint_to_str(o: &crate::lightning::chain::transaction::OutPoint) -> Str { + alloc::format!("{}", o.get_native_ref()).into() } - #[no_mangle] /// Serialize the OutPoint object into a byte array which can be read by OutPoint_read pub extern "C" fn OutPoint_write(obj: &crate::lightning::chain::transaction::OutPoint) -> crate::c_types::derived::CVec_u8Z { @@ -158,7 +164,7 @@ pub extern "C" fn OutPoint_write(obj: &crate::lightning::chain::transaction::Out } #[allow(unused)] pub(crate) extern "C" fn OutPoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOutPoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::chain::transaction::nativeOutPoint) }) } #[no_mangle] /// Read a OutPoint from a byte array, created by OutPoint_write diff --git a/lightning-c-bindings/src/lightning/events/bump_transaction.rs b/lightning-c-bindings/src/lightning/events/bump_transaction.rs index dd81170..1d50071 100644 --- a/lightning-c-bindings/src/lightning/events/bump_transaction.rs +++ b/lightning-c-bindings/src/lightning/events/bump_transaction.rs @@ -39,6 +39,12 @@ pub struct AnchorDescriptor { pub is_owned: bool, } +impl core::ops::Deref for AnchorDescriptor { + type Target = nativeAnchorDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AnchorDescriptor { } +unsafe impl core::marker::Sync for AnchorDescriptor { } impl Drop for AnchorDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeAnchorDescriptor>::is_null(self.inner) { @@ -69,6 +75,9 @@ impl AnchorDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters required to derive the signer for the anchor input. #[no_mangle] @@ -172,7 +181,7 @@ pub extern "C" fn AnchorDescriptor_tx_input_witness(this_arg: &crate::lightning: /// Derives the channel signer required to sign the anchor input. #[must_use] #[no_mangle] -pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { +pub extern "C" fn AnchorDescriptor_derive_channel_signer(this_arg: &crate::lightning::events::bump_transaction::AnchorDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); Into::into(ret) } @@ -222,6 +231,10 @@ pub enum BumpTransactionEvent { /// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_holder_anchor_input /// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness ChannelClose { + /// The `channel_id` of the channel which has been closed. + channel_id: crate::lightning::ln::types::ChannelId, + /// Counterparty in the closed channel. + counterparty_node_id: crate::c_types::PublicKey, /// The unique identifier for the claim of the anchor output in the commitment transaction. /// /// The identifier must map to the set of external UTXOs assigned to the claim, such that @@ -275,6 +288,10 @@ pub enum BumpTransactionEvent { /// [`EcdsaChannelSigner`]: crate::sign::ecdsa::EcdsaChannelSigner /// [`EcdsaChannelSigner::sign_holder_htlc_transaction`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_holder_htlc_transaction HTLCResolution { + /// The `channel_id` of the channel which has been closed. + channel_id: crate::lightning::ln::types::ChannelId, + /// Counterparty in the closed channel. + counterparty_node_id: crate::c_types::PublicKey, /// The unique identifier for the claim of the HTLCs in the confirmed commitment /// transaction. /// @@ -298,7 +315,9 @@ impl BumpTransactionEvent { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeBumpTransactionEvent { match self { - BumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + BumpTransactionEvent::ChannelClose {ref channel_id, ref counterparty_node_id, ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut claim_id_nonref = Clone::clone(claim_id); let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight); let mut commitment_tx_nonref = Clone::clone(commitment_tx); @@ -307,6 +326,8 @@ impl BumpTransactionEvent { let mut pending_htlcs_nonref = Clone::clone(pending_htlcs); let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.into_rust().drain(..) { local_pending_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeBumpTransactionEvent::ChannelClose { + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data), package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref, commitment_tx: commitment_tx_nonref.into_bitcoin(), @@ -315,17 +336,21 @@ impl BumpTransactionEvent { pending_htlcs: local_pending_htlcs_nonref, } }, - BumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + BumpTransactionEvent::HTLCResolution {ref channel_id, ref counterparty_node_id, ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut claim_id_nonref = Clone::clone(claim_id); let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight); let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors); let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.into_rust().drain(..) { local_htlc_descriptors_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut tx_lock_time_nonref = Clone::clone(tx_lock_time); nativeBumpTransactionEvent::HTLCResolution { + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, + counterparty_node_id: counterparty_node_id_nonref.into_rust(), claim_id: ::lightning::chain::ClaimId(claim_id_nonref.data), target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref, htlc_descriptors: local_htlc_descriptors_nonref, - tx_lock_time: ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time_nonref), + tx_lock_time: ::bitcoin::locktime::absolute::LockTime::from_consensus(tx_lock_time_nonref), } }, } @@ -333,9 +358,11 @@ impl BumpTransactionEvent { #[allow(unused)] pub(crate) fn into_native(self) -> nativeBumpTransactionEvent { match self { - BumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { + BumpTransactionEvent::ChannelClose {mut channel_id, mut counterparty_node_id, mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.into_rust().drain(..) { local_pending_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeBumpTransactionEvent::ChannelClose { + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), claim_id: ::lightning::chain::ClaimId(claim_id.data), package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight, commitment_tx: commitment_tx.into_bitcoin(), @@ -344,13 +371,15 @@ impl BumpTransactionEvent { pending_htlcs: local_pending_htlcs, } }, - BumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { + BumpTransactionEvent::HTLCResolution {mut channel_id, mut counterparty_node_id, mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.into_rust().drain(..) { local_htlc_descriptors.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; nativeBumpTransactionEvent::HTLCResolution { + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + counterparty_node_id: counterparty_node_id.into_rust(), claim_id: ::lightning::chain::ClaimId(claim_id.data), target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight, htlc_descriptors: local_htlc_descriptors, - tx_lock_time: ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus(tx_lock_time), + tx_lock_time: ::bitcoin::locktime::absolute::LockTime::from_consensus(tx_lock_time), } }, } @@ -359,7 +388,9 @@ impl BumpTransactionEvent { pub(crate) fn from_native(native: &BumpTransactionEventImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBumpTransactionEvent) }; match native { - nativeBumpTransactionEvent::ChannelClose {ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + nativeBumpTransactionEvent::ChannelClose {ref channel_id, ref counterparty_node_id, ref claim_id, ref package_target_feerate_sat_per_1000_weight, ref commitment_tx, ref commitment_tx_fee_satoshis, ref anchor_descriptor, ref pending_htlcs, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut claim_id_nonref = Clone::clone(claim_id); let mut package_target_feerate_sat_per_1000_weight_nonref = Clone::clone(package_target_feerate_sat_per_1000_weight); let mut commitment_tx_nonref = Clone::clone(commitment_tx); @@ -368,6 +399,8 @@ impl BumpTransactionEvent { let mut pending_htlcs_nonref = Clone::clone(pending_htlcs); let mut local_pending_htlcs_nonref = Vec::new(); for mut item in pending_htlcs_nonref.drain(..) { local_pending_htlcs_nonref.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; BumpTransactionEvent::ChannelClose { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 }, package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight_nonref, commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx_nonref), @@ -376,13 +409,17 @@ impl BumpTransactionEvent { pending_htlcs: local_pending_htlcs_nonref.into(), } }, - nativeBumpTransactionEvent::HTLCResolution {ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + nativeBumpTransactionEvent::HTLCResolution {ref channel_id, ref counterparty_node_id, ref claim_id, ref target_feerate_sat_per_1000_weight, ref htlc_descriptors, ref tx_lock_time, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut claim_id_nonref = Clone::clone(claim_id); let mut target_feerate_sat_per_1000_weight_nonref = Clone::clone(target_feerate_sat_per_1000_weight); let mut htlc_descriptors_nonref = Clone::clone(htlc_descriptors); let mut local_htlc_descriptors_nonref = Vec::new(); for mut item in htlc_descriptors_nonref.drain(..) { local_htlc_descriptors_nonref.push( { crate::lightning::sign::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut tx_lock_time_nonref = Clone::clone(tx_lock_time); BumpTransactionEvent::HTLCResolution { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id_nonref.0 }, target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight_nonref, htlc_descriptors: local_htlc_descriptors_nonref.into(), @@ -394,9 +431,11 @@ impl BumpTransactionEvent { #[allow(unused)] pub(crate) fn native_into(native: nativeBumpTransactionEvent) -> Self { match native { - nativeBumpTransactionEvent::ChannelClose {mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { + nativeBumpTransactionEvent::ChannelClose {mut channel_id, mut counterparty_node_id, mut claim_id, mut package_target_feerate_sat_per_1000_weight, mut commitment_tx, mut commitment_tx_fee_satoshis, mut anchor_descriptor, mut pending_htlcs, } => { let mut local_pending_htlcs = Vec::new(); for mut item in pending_htlcs.drain(..) { local_pending_htlcs.push( { crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; BumpTransactionEvent::ChannelClose { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, package_target_feerate_sat_per_1000_weight: package_target_feerate_sat_per_1000_weight, commitment_tx: crate::c_types::Transaction::from_bitcoin(&commitment_tx), @@ -405,9 +444,11 @@ impl BumpTransactionEvent { pending_htlcs: local_pending_htlcs.into(), } }, - nativeBumpTransactionEvent::HTLCResolution {mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { + nativeBumpTransactionEvent::HTLCResolution {mut channel_id, mut counterparty_node_id, mut claim_id, mut target_feerate_sat_per_1000_weight, mut htlc_descriptors, mut tx_lock_time, } => { let mut local_htlc_descriptors = Vec::new(); for mut item in htlc_descriptors.drain(..) { local_htlc_descriptors.push( { crate::lightning::sign::HTLCDescriptor { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; BumpTransactionEvent::HTLCResolution { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), claim_id: crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, target_feerate_sat_per_1000_weight: target_feerate_sat_per_1000_weight, htlc_descriptors: local_htlc_descriptors.into(), @@ -437,8 +478,10 @@ pub(crate) extern "C" fn BumpTransactionEvent_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new ChannelClose-variant BumpTransactionEvent -pub extern "C" fn BumpTransactionEvent_channel_close(claim_id: crate::c_types::ThirtyTwoBytes, package_target_feerate_sat_per_1000_weight: u32, commitment_tx: crate::c_types::Transaction, commitment_tx_fee_satoshis: u64, anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> BumpTransactionEvent { +pub extern "C" fn BumpTransactionEvent_channel_close(channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, claim_id: crate::c_types::ThirtyTwoBytes, package_target_feerate_sat_per_1000_weight: u32, commitment_tx: crate::c_types::Transaction, commitment_tx_fee_satoshis: u64, anchor_descriptor: crate::lightning::events::bump_transaction::AnchorDescriptor, pending_htlcs: crate::c_types::derived::CVec_HTLCOutputInCommitmentZ) -> BumpTransactionEvent { BumpTransactionEvent::ChannelClose { + channel_id, + counterparty_node_id, claim_id, package_target_feerate_sat_per_1000_weight, commitment_tx, @@ -449,8 +492,10 @@ pub extern "C" fn BumpTransactionEvent_channel_close(claim_id: crate::c_types::T } #[no_mangle] /// Utility method to constructs a new HTLCResolution-variant BumpTransactionEvent -pub extern "C" fn BumpTransactionEvent_htlcresolution(claim_id: crate::c_types::ThirtyTwoBytes, target_feerate_sat_per_1000_weight: u32, htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, tx_lock_time: u32) -> BumpTransactionEvent { +pub extern "C" fn BumpTransactionEvent_htlcresolution(channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, claim_id: crate::c_types::ThirtyTwoBytes, target_feerate_sat_per_1000_weight: u32, htlc_descriptors: crate::c_types::derived::CVec_HTLCDescriptorZ, tx_lock_time: u32) -> BumpTransactionEvent { BumpTransactionEvent::HTLCResolution { + channel_id, + counterparty_node_id, claim_id, target_feerate_sat_per_1000_weight, htlc_descriptors, @@ -488,6 +533,12 @@ pub struct Input { pub is_owned: bool, } +impl core::ops::Deref for Input { + type Target = nativeInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Input { } +unsafe impl core::marker::Sync for Input { } impl Drop for Input { fn drop(&mut self) { if self.is_owned && !<*mut nativeInput>::is_null(self.inner) { @@ -518,6 +569,9 @@ impl Input { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The unique identifier of the input. #[no_mangle] @@ -628,6 +682,12 @@ pub struct Utxo { pub is_owned: bool, } +impl core::ops::Deref for Utxo { + type Target = nativeUtxo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Utxo { } +unsafe impl core::marker::Sync for Utxo { } impl Drop for Utxo { fn drop(&mut self) { if self.is_owned && !<*mut nativeUtxo>::is_null(self.inner) { @@ -658,6 +718,9 @@ impl Utxo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The unique identifier of the output. #[no_mangle] @@ -751,7 +814,7 @@ pub extern "C" fn Utxo_eq(a: &Utxo, b: &Utxo) -> bool { #[must_use] #[no_mangle] pub extern "C" fn Utxo_new_p2pkh(mut outpoint: crate::lightning::chain::transaction::OutPoint, mut value: u64, pubkey_hash: *const [u8; 20]) -> crate::lightning::events::bump_transaction::Utxo { - let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), value, &bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = lightning::events::bump_transaction::Utxo::new_p2pkh(crate::c_types::C_to_bitcoin_outpoint(outpoint), ::bitcoin::amount::Amount::from_sat(value), &bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); crate::lightning::events::bump_transaction::Utxo { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -776,6 +839,12 @@ pub struct CoinSelection { pub is_owned: bool, } +impl core::ops::Deref for CoinSelection { + type Target = nativeCoinSelection; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CoinSelection { } +unsafe impl core::marker::Sync for CoinSelection { } impl Drop for CoinSelection { fn drop(&mut self) { if self.is_owned && !<*mut nativeCoinSelection>::is_null(self.inner) { @@ -806,6 +875,9 @@ impl CoinSelection { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The set of UTXOs (with at least 1 confirmation) to spend and use within a transaction /// requiring additional fees. @@ -941,24 +1013,40 @@ impl rustCoinSelectionSource for CoinSelectionSource { let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result { + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into()); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } } +pub struct CoinSelectionSourceRef(CoinSelectionSource); +impl rustCoinSelectionSource for CoinSelectionSourceRef { + fn select_confirmed_utxos(&self, mut claim_id: lightning::chain::ClaimId, mut must_spend: Vec, mut must_pay_to: &[bitcoin::TxOut], mut target_feerate_sat_per_1000_weight: u32) -> Result { + let mut local_must_spend = Vec::new(); for mut item in must_spend.drain(..) { local_must_spend.push( { crate::lightning::events::bump_transaction::Input { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_must_pay_to_clone = Vec::new(); local_must_pay_to_clone.extend_from_slice(must_pay_to); let mut must_pay_to = local_must_pay_to_clone; let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.drain(..) { local_must_pay_to.push( { crate::c_types::TxOut::from_rust(&item) }); }; + let mut ret = (self.0.select_confirmed_utxos)(self.0.this_arg, crate::c_types::ThirtyTwoBytes { data: claim_id.0 }, local_must_spend.into(), local_must_pay_to.into(), target_feerate_sat_per_1000_weight); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { + let mut ret = (self.0.sign_psbt)(self.0.this_arg, psbt.serialize().into()); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for CoinSelectionSource { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CoinSelectionSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CoinSelectionSourceRef) } } } impl core::ops::DerefMut for CoinSelectionSource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CoinSelectionSourceRef { + unsafe { &mut *(self as *mut _ as *mut CoinSelectionSourceRef) } } } /// Calls the free function if one is set @@ -1016,27 +1104,46 @@ impl rustWalletSource for WalletSource { } fn get_change_script(&self) -> Result { let mut ret = (self.get_change_script)(self.this_arg); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_psbt(&self, mut psbt: bitcoin::psbt::PartiallySignedTransaction) -> Result { + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { let mut ret = (self.sign_psbt)(self.this_arg, psbt.serialize().into()); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } } +pub struct WalletSourceRef(WalletSource); +impl rustWalletSource for WalletSourceRef { + fn list_confirmed_utxos(&self) -> Result, ()> { + let mut ret = (self.0.list_confirmed_utxos)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn get_change_script(&self) -> Result { + let mut ret = (self.0.get_change_script)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_psbt(&self, mut psbt: bitcoin::Psbt) -> Result { + let mut ret = (self.0.sign_psbt)(self.0.this_arg, psbt.serialize().into()); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for WalletSource { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = WalletSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WalletSourceRef) } } } impl core::ops::DerefMut for WalletSource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WalletSourceRef { + unsafe { &mut *(self as *mut _ as *mut WalletSourceRef) } } } /// Calls the free function if one is set @@ -1051,7 +1158,7 @@ impl Drop for WalletSource { } use lightning::events::bump_transaction::Wallet as nativeWalletImport; -pub(crate) type nativeWallet = nativeWalletImport; +pub(crate) type nativeWallet = nativeWalletImport; /// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would /// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double @@ -1071,6 +1178,12 @@ pub struct Wallet { pub is_owned: bool, } +impl core::ops::Deref for Wallet { + type Target = nativeWallet; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Wallet { } +unsafe impl core::marker::Sync for Wallet { } impl Drop for Wallet { fn drop(&mut self) { if self.is_owned && !<*mut nativeWallet>::is_null(self.inner) { @@ -1101,6 +1214,9 @@ impl Wallet { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Returns a new instance backed by the given [`WalletSource`] that serves as an implementation /// of [`CoinSelectionSource`]. @@ -1137,20 +1253,20 @@ pub extern "C" fn Wallet_as_CoinSelectionSource(this_arg: &Wallet) -> crate::lig extern "C" fn Wallet_CoinSelectionSource_select_confirmed_utxos(this_arg: *const c_void, mut claim_id: crate::c_types::ThirtyTwoBytes, mut must_spend: crate::c_types::derived::CVec_InputZ, mut must_pay_to: crate::c_types::derived::CVec_TxOutZ, mut target_feerate_sat_per_1000_weight: u32) -> crate::c_types::derived::CResult_CoinSelectionNoneZ { let mut local_must_spend = Vec::new(); for mut item in must_spend.into_rust().drain(..) { local_must_spend.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_must_pay_to = Vec::new(); for mut item in must_pay_to.into_rust().drain(..) { local_must_pay_to.push( { item.into_rust() }); }; - let mut ret = >::select_confirmed_utxos(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::lightning::chain::ClaimId(claim_id.data), local_must_spend, &local_must_pay_to[..], target_feerate_sat_per_1000_weight); + let mut ret = ::select_confirmed_utxos(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::lightning::chain::ClaimId(claim_id.data), local_must_spend, &local_must_pay_to[..], target_feerate_sat_per_1000_weight); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::bump_transaction::CoinSelection { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn Wallet_CoinSelectionSource_sign_psbt(this_arg: *const c_void, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut ret = >::sign_psbt(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::bitcoin::psbt::PartiallySignedTransaction::deserialize(psbt.as_slice()).expect("Invalid PSBT format")); + let mut ret = ::sign_psbt(unsafe { &mut *(this_arg as *mut nativeWallet) }, ::bitcoin::Psbt::deserialize(psbt.as_slice()).expect("Invalid PSBT format")); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } use lightning::events::bump_transaction::BumpTransactionEventHandler as nativeBumpTransactionEventHandlerImport; -pub(crate) type nativeBumpTransactionEventHandler = nativeBumpTransactionEventHandlerImport; +pub(crate) type nativeBumpTransactionEventHandler = nativeBumpTransactionEventHandlerImport; /// A handler for [`Event::BumpTransaction`] events that sources confirmed UTXOs from a /// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or @@ -1172,6 +1288,12 @@ pub struct BumpTransactionEventHandler { pub is_owned: bool, } +impl core::ops::Deref for BumpTransactionEventHandler { + type Target = nativeBumpTransactionEventHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BumpTransactionEventHandler { } +unsafe impl core::marker::Sync for BumpTransactionEventHandler { } impl Drop for BumpTransactionEventHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeBumpTransactionEventHandler>::is_null(self.inner) { @@ -1202,6 +1324,9 @@ impl BumpTransactionEventHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Returns a new instance capable of handling [`Event::BumpTransaction`] events. /// diff --git a/lightning-c-bindings/src/lightning/events/mod.rs b/lightning-c-bindings/src/lightning/events/mod.rs index 1e53afb..8b4c756 100644 --- a/lightning-c-bindings/src/lightning/events/mod.rs +++ b/lightning-c-bindings/src/lightning/events/mod.rs @@ -23,17 +23,168 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; pub mod bump_transaction; +/// `FundingInfo` holds information about a channel's funding transaction. +/// +/// When LDK is set to manual propagation of the funding transaction +/// (via [`ChannelManager::unsafe_manual_funding_transaction_generated`), +/// LDK does not have the full transaction data. Instead, the `OutPoint` +/// for the funding is provided here. +/// +/// [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum FundingInfo { + /// The full funding `Transaction`. + Tx { + /// The funding transaction + transaction: crate::c_types::Transaction, + }, + /// The `OutPoint` of the funding. + OutPoint { + /// The outpoint of the funding + outpoint: crate::lightning::chain::transaction::OutPoint, + }, +} +use lightning::events::FundingInfo as FundingInfoImport; +pub(crate) type nativeFundingInfo = FundingInfoImport; + +impl FundingInfo { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeFundingInfo { + match self { + FundingInfo::Tx {ref transaction, } => { + let mut transaction_nonref = Clone::clone(transaction); + nativeFundingInfo::Tx { + transaction: transaction_nonref.into_bitcoin(), + } + }, + FundingInfo::OutPoint {ref outpoint, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + nativeFundingInfo::OutPoint { + outpoint: *unsafe { Box::from_raw(outpoint_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeFundingInfo { + match self { + FundingInfo::Tx {mut transaction, } => { + nativeFundingInfo::Tx { + transaction: transaction.into_bitcoin(), + } + }, + FundingInfo::OutPoint {mut outpoint, } => { + nativeFundingInfo::OutPoint { + outpoint: *unsafe { Box::from_raw(outpoint.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &FundingInfoImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeFundingInfo) }; + match native { + nativeFundingInfo::Tx {ref transaction, } => { + let mut transaction_nonref = Clone::clone(transaction); + FundingInfo::Tx { + transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), + } + }, + nativeFundingInfo::OutPoint {ref outpoint, } => { + let mut outpoint_nonref = Clone::clone(outpoint); + FundingInfo::OutPoint { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeFundingInfo) -> Self { + match native { + nativeFundingInfo::Tx {mut transaction, } => { + FundingInfo::Tx { + transaction: crate::c_types::Transaction::from_bitcoin(&transaction), + } + }, + nativeFundingInfo::OutPoint {mut outpoint, } => { + FundingInfo::OutPoint { + outpoint: crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(outpoint), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the FundingInfo +#[no_mangle] +pub extern "C" fn FundingInfo_free(this_ptr: FundingInfo) { } +/// Creates a copy of the FundingInfo +#[no_mangle] +pub extern "C" fn FundingInfo_clone(orig: &FundingInfo) -> FundingInfo { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn FundingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const FundingInfo)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn FundingInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut FundingInfo) }; +} +#[no_mangle] +/// Utility method to constructs a new Tx-variant FundingInfo +pub extern "C" fn FundingInfo_tx(transaction: crate::c_types::Transaction) -> FundingInfo { + FundingInfo::Tx { + transaction, + } +} +#[no_mangle] +/// Utility method to constructs a new OutPoint-variant FundingInfo +pub extern "C" fn FundingInfo_out_point(outpoint: crate::lightning::chain::transaction::OutPoint) -> FundingInfo { + FundingInfo::OutPoint { + outpoint, + } +} +/// Get a string which allows debug introspection of a FundingInfo object +pub extern "C" fn FundingInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::FundingInfo }).into()} +/// Checks if two FundingInfos contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn FundingInfo_eq(a: &FundingInfo, b: &FundingInfo) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the FundingInfo object into a byte array which can be read by FundingInfo_read +pub extern "C" fn FundingInfo_write(obj: &crate::lightning::events::FundingInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn FundingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + FundingInfo_write(unsafe { &*(obj as *const FundingInfo) }) +} +#[no_mangle] +/// Read a FundingInfo from a byte array, created by FundingInfo_write +pub extern "C" fn FundingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_FundingInfoDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::FundingInfo::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} /// Some information provided on receipt of payment depends on whether the payment received is a /// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. #[derive(Clone)] #[must_use] #[repr(C)] pub enum PaymentPurpose { - /// Information for receiving a payment that we generated an invoice for. - InvoicePayment { + /// A payment for a BOLT 11 invoice. + Bolt11InvoicePayment { /// The preimage to the payment_hash, if the payment hash (and secret) were fetched via - /// [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to - /// [`ChannelManager::claim_funds`]. + /// [`ChannelManager::create_inbound_payment`]. When handling [`Event::PaymentClaimable`], + /// this can be passed directly to [`ChannelManager::claim_funds`] to claim the payment. No + /// action is needed when seen in [`Event::PaymentClaimed`]. /// /// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds @@ -50,6 +201,48 @@ pub enum PaymentPurpose { /// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash payment_secret: crate::c_types::ThirtyTwoBytes, }, + /// A payment for a BOLT 12 [`Offer`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + Bolt12OfferPayment { + /// The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be + /// passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed + /// when seen in [`Event::PaymentClaimed`]. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, + /// The secret used to authenticate the sender to the recipient, preventing a number of + /// de-anonymization attacks while routing a payment. + /// + /// See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details. + payment_secret: crate::c_types::ThirtyTwoBytes, + /// The context of the payment such as information about the corresponding [`Offer`] and + /// [`InvoiceRequest`]. + /// + /// [`Offer`]: crate::offers::offer::Offer + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + payment_context: crate::lightning::blinded_path::payment::Bolt12OfferContext, + }, + /// A payment for a BOLT 12 [`Refund`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + Bolt12RefundPayment { + /// The preimage to the payment hash. When handling [`Event::PaymentClaimable`], this can be + /// passed directly to [`ChannelManager::claim_funds`], if provided. No action is needed + /// when seen in [`Event::PaymentClaimed`]. + /// + /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds + payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, + /// The secret used to authenticate the sender to the recipient, preventing a number of + /// de-anonymization attacks while routing a payment. + /// + /// See [`PaymentPurpose::Bolt11InvoicePayment::payment_secret`] for further details. + payment_secret: crate::c_types::ThirtyTwoBytes, + /// The context of the payment such as information about the corresponding [`Refund`]. + /// + /// [`Refund`]: crate::offers::refund::Refund + payment_context: crate::lightning::blinded_path::payment::Bolt12RefundContext, + }, /// Because this is a spontaneous payment, the payer generated their own preimage rather than us /// (the payee) providing a preimage. SpontaneousPayment( @@ -62,19 +255,41 @@ impl PaymentPurpose { #[allow(unused)] pub(crate) fn to_native(&self) -> nativePaymentPurpose { match self { - PaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { + PaymentPurpose::Bolt11InvoicePayment {ref payment_preimage, ref payment_secret, } => { let mut payment_preimage_nonref = Clone::clone(payment_preimage); - let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} }; + let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} }; let mut payment_secret_nonref = Clone::clone(payment_secret); - nativePaymentPurpose::InvoicePayment { + nativePaymentPurpose::Bolt11InvoicePayment { payment_preimage: local_payment_preimage_nonref, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret_nonref.data), + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_nonref.data), + } + }, + PaymentPurpose::Bolt12OfferPayment {ref payment_preimage, ref payment_secret, ref payment_context, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + let mut payment_context_nonref = Clone::clone(payment_context); + nativePaymentPurpose::Bolt12OfferPayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_nonref.data), + payment_context: *unsafe { Box::from_raw(payment_context_nonref.take_inner()) }, + } + }, + PaymentPurpose::Bolt12RefundPayment {ref payment_preimage, ref payment_secret, ref payment_context, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = { /*payment_preimage_nonref*/ let payment_preimage_nonref_opt = payment_preimage_nonref; if payment_preimage_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_nonref_opt.take() }.data) }})} }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + let mut payment_context_nonref = Clone::clone(payment_context); + nativePaymentPurpose::Bolt12RefundPayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_nonref.data), + payment_context: *unsafe { Box::from_raw(payment_context_nonref.take_inner()) }, } }, PaymentPurpose::SpontaneousPayment (ref a, ) => { let mut a_nonref = Clone::clone(a); nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a_nonref.data), + ::lightning::ln::types::PaymentPreimage(a_nonref.data), ) }, } @@ -82,16 +297,32 @@ impl PaymentPurpose { #[allow(unused)] pub(crate) fn into_native(self) -> nativePaymentPurpose { match self { - PaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { - let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; - nativePaymentPurpose::InvoicePayment { + PaymentPurpose::Bolt11InvoicePayment {mut payment_preimage, mut payment_secret, } => { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + nativePaymentPurpose::Bolt11InvoicePayment { + payment_preimage: local_payment_preimage, + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret.data), + } + }, + PaymentPurpose::Bolt12OfferPayment {mut payment_preimage, mut payment_secret, mut payment_context, } => { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + nativePaymentPurpose::Bolt12OfferPayment { payment_preimage: local_payment_preimage, - payment_secret: ::lightning::ln::PaymentSecret(payment_secret.data), + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret.data), + payment_context: *unsafe { Box::from_raw(payment_context.take_inner()) }, + } + }, + PaymentPurpose::Bolt12RefundPayment {mut payment_preimage, mut payment_secret, mut payment_context, } => { + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + nativePaymentPurpose::Bolt12RefundPayment { + payment_preimage: local_payment_preimage, + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret.data), + payment_context: *unsafe { Box::from_raw(payment_context.take_inner()) }, } }, PaymentPurpose::SpontaneousPayment (mut a, ) => { nativePaymentPurpose::SpontaneousPayment ( - ::lightning::ln::PaymentPreimage(a.data), + ::lightning::ln::types::PaymentPreimage(a.data), ) }, } @@ -100,13 +331,35 @@ impl PaymentPurpose { pub(crate) fn from_native(native: &PaymentPurposeImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativePaymentPurpose) }; match native { - nativePaymentPurpose::InvoicePayment {ref payment_preimage, ref payment_secret, } => { + nativePaymentPurpose::Bolt11InvoicePayment {ref payment_preimage, ref payment_secret, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.unwrap().0 } }) }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + PaymentPurpose::Bolt11InvoicePayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, + } + }, + nativePaymentPurpose::Bolt12OfferPayment {ref payment_preimage, ref payment_secret, ref payment_context, } => { + let mut payment_preimage_nonref = Clone::clone(payment_preimage); + let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.unwrap().0 } }) }; + let mut payment_secret_nonref = Clone::clone(payment_secret); + let mut payment_context_nonref = Clone::clone(payment_context); + PaymentPurpose::Bolt12OfferPayment { + payment_preimage: local_payment_preimage_nonref, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, + payment_context: crate::lightning::blinded_path::payment::Bolt12OfferContext { inner: ObjOps::heap_alloc(payment_context_nonref), is_owned: true }, + } + }, + nativePaymentPurpose::Bolt12RefundPayment {ref payment_preimage, ref payment_secret, ref payment_context, } => { let mut payment_preimage_nonref = Clone::clone(payment_preimage); let mut local_payment_preimage_nonref = if payment_preimage_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.unwrap().0 } }) }; let mut payment_secret_nonref = Clone::clone(payment_secret); - PaymentPurpose::InvoicePayment { + let mut payment_context_nonref = Clone::clone(payment_context); + PaymentPurpose::Bolt12RefundPayment { payment_preimage: local_payment_preimage_nonref, payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret_nonref.0 }, + payment_context: crate::lightning::blinded_path::payment::Bolt12RefundContext { inner: ObjOps::heap_alloc(payment_context_nonref), is_owned: true }, } }, nativePaymentPurpose::SpontaneousPayment (ref a, ) => { @@ -120,11 +373,27 @@ impl PaymentPurpose { #[allow(unused)] pub(crate) fn native_into(native: nativePaymentPurpose) -> Self { match native { - nativePaymentPurpose::InvoicePayment {mut payment_preimage, mut payment_secret, } => { + nativePaymentPurpose::Bolt11InvoicePayment {mut payment_preimage, mut payment_secret, } => { + let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage.unwrap().0 } }) }; + PaymentPurpose::Bolt11InvoicePayment { + payment_preimage: local_payment_preimage, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, + } + }, + nativePaymentPurpose::Bolt12OfferPayment {mut payment_preimage, mut payment_secret, mut payment_context, } => { let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage.unwrap().0 } }) }; - PaymentPurpose::InvoicePayment { + PaymentPurpose::Bolt12OfferPayment { payment_preimage: local_payment_preimage, payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, + payment_context: crate::lightning::blinded_path::payment::Bolt12OfferContext { inner: ObjOps::heap_alloc(payment_context), is_owned: true }, + } + }, + nativePaymentPurpose::Bolt12RefundPayment {mut payment_preimage, mut payment_secret, mut payment_context, } => { + let mut local_payment_preimage = if payment_preimage.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_preimage.unwrap().0 } }) }; + PaymentPurpose::Bolt12RefundPayment { + payment_preimage: local_payment_preimage, + payment_secret: crate::c_types::ThirtyTwoBytes { data: payment_secret.0 }, + payment_context: crate::lightning::blinded_path::payment::Bolt12RefundContext { inner: ObjOps::heap_alloc(payment_context), is_owned: true }, } }, nativePaymentPurpose::SpontaneousPayment (mut a, ) => { @@ -154,14 +423,32 @@ pub(crate) extern "C" fn PaymentPurpose_free_void(this_ptr: *mut c_void) { let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentPurpose) }; } #[no_mangle] -/// Utility method to constructs a new InvoicePayment-variant PaymentPurpose -pub extern "C" fn PaymentPurpose_invoice_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { - PaymentPurpose::InvoicePayment { +/// Utility method to constructs a new Bolt11InvoicePayment-variant PaymentPurpose +pub extern "C" fn PaymentPurpose_bolt11_invoice_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { + PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, } } #[no_mangle] +/// Utility method to constructs a new Bolt12OfferPayment-variant PaymentPurpose +pub extern "C" fn PaymentPurpose_bolt12_offer_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes, payment_context: crate::lightning::blinded_path::payment::Bolt12OfferContext) -> PaymentPurpose { + PaymentPurpose::Bolt12OfferPayment { + payment_preimage, + payment_secret, + payment_context, + } +} +#[no_mangle] +/// Utility method to constructs a new Bolt12RefundPayment-variant PaymentPurpose +pub extern "C" fn PaymentPurpose_bolt12_refund_payment(payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, payment_secret: crate::c_types::ThirtyTwoBytes, payment_context: crate::lightning::blinded_path::payment::Bolt12RefundContext) -> PaymentPurpose { + PaymentPurpose::Bolt12RefundPayment { + payment_preimage, + payment_secret, + payment_context, + } +} +#[no_mangle] /// Utility method to constructs a new SpontaneousPayment-variant PaymentPurpose pub extern "C" fn PaymentPurpose_spontaneous_payment(a: crate::c_types::ThirtyTwoBytes) -> PaymentPurpose { PaymentPurpose::SpontaneousPayment(a, ) @@ -220,6 +507,12 @@ pub struct ClaimedHTLC { pub is_owned: bool, } +impl core::ops::Deref for ClaimedHTLC { + type Target = nativeClaimedHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClaimedHTLC { } +unsafe impl core::marker::Sync for ClaimedHTLC { } impl Drop for ClaimedHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeClaimedHTLC>::is_null(self.inner) { @@ -250,17 +543,20 @@ impl ClaimedHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The `channel_id` of the channel over which the HTLC was received. #[no_mangle] -pub extern "C" fn ClaimedHTLC_get_channel_id(this_ptr: &ClaimedHTLC) -> *const [u8; 32] { +pub extern "C" fn ClaimedHTLC_get_channel_id(this_ptr: &ClaimedHTLC) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The `channel_id` of the channel over which the HTLC was received. #[no_mangle] -pub extern "C" fn ClaimedHTLC_set_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn ClaimedHTLC_set_channel_id(this_ptr: &mut ClaimedHTLC, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The `user_channel_id` of the channel over which the HTLC was received. This is the value /// passed in to [`ChannelManager::create_channel`] for outbound channels, or to @@ -339,9 +635,9 @@ pub extern "C" fn ClaimedHTLC_set_counterparty_skimmed_fee_msat(this_ptr: &mut C /// Constructs a new ClaimedHTLC given each field #[must_use] #[no_mangle] -pub extern "C" fn ClaimedHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut user_channel_id_arg: crate::c_types::U128, mut cltv_expiry_arg: u32, mut value_msat_arg: u64, mut counterparty_skimmed_fee_msat_arg: u64) -> ClaimedHTLC { +pub extern "C" fn ClaimedHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut user_channel_id_arg: crate::c_types::U128, mut cltv_expiry_arg: u32, mut value_msat_arg: u64, mut counterparty_skimmed_fee_msat_arg: u64) -> ClaimedHTLC { ClaimedHTLC { inner: ObjOps::heap_alloc(nativeClaimedHTLC { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, user_channel_id: user_channel_id_arg.into(), cltv_expiry: cltv_expiry_arg, value_msat: value_msat_arg, @@ -386,7 +682,7 @@ pub extern "C" fn ClaimedHTLC_write(obj: &crate::lightning::events::ClaimedHTLC) } #[allow(unused)] pub(crate) extern "C" fn ClaimedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClaimedHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::events::nativeClaimedHTLC) }) } #[no_mangle] /// Read a ClaimedHTLC from a byte array, created by ClaimedHTLC_write @@ -568,15 +864,41 @@ pub enum ClosureReason { /// To be safe, use `Display` on `UntrustedString` /// /// [`UntrustedString`]: crate::util::string::UntrustedString - peer_msg: crate::lightning::util::string::UntrustedString, + peer_msg: crate::lightning_types::string::UntrustedString, }, /// Closure generated from [`ChannelManager::force_close_channel`], called by the user. /// /// [`ChannelManager::force_close_channel`]: crate::ln::channelmanager::ChannelManager::force_close_channel. - HolderForceClosed, + HolderForceClosed { + /// Whether or not the latest transaction was broadcasted when the channel was force + /// closed. + /// + /// Channels closed using [`ChannelManager::force_close_broadcasting_latest_txn`] will have + /// this field set to true, whereas channels closed using [`ChannelManager::force_close_without_broadcasting_txn`] + /// or force-closed prior to being funded will have this field set to false. + /// + /// This will be `None` for objects generated or written by LDK 0.0.123 and + /// earlier. + /// + /// [`ChannelManager::force_close_broadcasting_latest_txn`]: crate::ln::channelmanager::ChannelManager::force_close_broadcasting_latest_txn. + /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn. + broadcasted_latest_txn: crate::c_types::derived::COption_boolZ, + }, /// The channel was closed after negotiating a cooperative close and we've now broadcasted /// the cooperative close transaction. Note the shutdown may have been initiated by us. - CooperativeClosure, + /// + /// This was only set in versions of LDK prior to 0.0.122. + LegacyCooperativeClosure, + /// The channel was closed after negotiating a cooperative close and we've now broadcasted + /// the cooperative close transaction. This indicates that the shutdown was initiated by our + /// counterparty. + /// + /// In rare cases where we initiated closure immediately prior to shutting down without + /// persisting, this value may be provided for channels we initiated closure for. + CounterpartyInitiatedCooperativeClosure, + /// The channel was closed after negotiating a cooperative close and we've now broadcasted + /// the cooperative close transaction. This indicates that the shutdown was initiated by us. + LocallyInitiatedCooperativeClosure, /// A commitment transaction was confirmed on chain, closing the channel. Most likely this /// commitment transaction came from our counterparty, but it may also have come from /// a copy of our own `ChannelMonitor`. @@ -611,6 +933,23 @@ pub enum ClosureReason { /// Another channel in the same funding batch closed before the funding transaction /// was ready to be broadcast. FundingBatchClosure, + /// One of our HTLCs timed out in a channel, causing us to force close the channel. + HTLCsTimedOut, + /// Our peer provided a feerate which violated our required minimum (fetched from our + /// [`FeeEstimator`] either as [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`] or + /// [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]). + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + /// [`ConfirmationTarget::MinAllowedAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedAnchorChannelRemoteFee + /// [`ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee`]: crate::chain::chaininterface::ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee + PeerFeerateTooLow { + /// The feerate on our channel set by our peer. + peer_feerate_sat_per_kw: u32, + /// The required feerate we enforce, from our [`FeeEstimator`]. + /// + /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + required_feerate_sat_per_kw: u32, + }, } use lightning::events::ClosureReason as ClosureReasonImport; pub(crate) type nativeClosureReason = ClosureReasonImport; @@ -625,8 +964,16 @@ impl ClosureReason { peer_msg: *unsafe { Box::from_raw(peer_msg_nonref.take_inner()) }, } }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, + ClosureReason::HolderForceClosed {ref broadcasted_latest_txn, } => { + let mut broadcasted_latest_txn_nonref = Clone::clone(broadcasted_latest_txn); + let mut local_broadcasted_latest_txn_nonref = if broadcasted_latest_txn_nonref.is_some() { Some( { broadcasted_latest_txn_nonref.take() }) } else { None }; + nativeClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn_nonref, + } + }, + ClosureReason::LegacyCooperativeClosure => nativeClosureReason::LegacyCooperativeClosure, + ClosureReason::CounterpartyInitiatedCooperativeClosure => nativeClosureReason::CounterpartyInitiatedCooperativeClosure, + ClosureReason::LocallyInitiatedCooperativeClosure => nativeClosureReason::LocallyInitiatedCooperativeClosure, ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, ClosureReason::ProcessingError {ref err, } => { @@ -639,6 +986,15 @@ impl ClosureReason { ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure, + ClosureReason::HTLCsTimedOut => nativeClosureReason::HTLCsTimedOut, + ClosureReason::PeerFeerateTooLow {ref peer_feerate_sat_per_kw, ref required_feerate_sat_per_kw, } => { + let mut peer_feerate_sat_per_kw_nonref = Clone::clone(peer_feerate_sat_per_kw); + let mut required_feerate_sat_per_kw_nonref = Clone::clone(required_feerate_sat_per_kw); + nativeClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw_nonref, + required_feerate_sat_per_kw: required_feerate_sat_per_kw_nonref, + } + }, } } #[allow(unused)] @@ -649,8 +1005,15 @@ impl ClosureReason { peer_msg: *unsafe { Box::from_raw(peer_msg.take_inner()) }, } }, - ClosureReason::HolderForceClosed => nativeClosureReason::HolderForceClosed, - ClosureReason::CooperativeClosure => nativeClosureReason::CooperativeClosure, + ClosureReason::HolderForceClosed {mut broadcasted_latest_txn, } => { + let mut local_broadcasted_latest_txn = if broadcasted_latest_txn.is_some() { Some( { broadcasted_latest_txn.take() }) } else { None }; + nativeClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn, + } + }, + ClosureReason::LegacyCooperativeClosure => nativeClosureReason::LegacyCooperativeClosure, + ClosureReason::CounterpartyInitiatedCooperativeClosure => nativeClosureReason::CounterpartyInitiatedCooperativeClosure, + ClosureReason::LocallyInitiatedCooperativeClosure => nativeClosureReason::LocallyInitiatedCooperativeClosure, ClosureReason::CommitmentTxConfirmed => nativeClosureReason::CommitmentTxConfirmed, ClosureReason::FundingTimedOut => nativeClosureReason::FundingTimedOut, ClosureReason::ProcessingError {mut err, } => { @@ -662,6 +1025,13 @@ impl ClosureReason { ClosureReason::OutdatedChannelManager => nativeClosureReason::OutdatedChannelManager, ClosureReason::CounterpartyCoopClosedUnfundedChannel => nativeClosureReason::CounterpartyCoopClosedUnfundedChannel, ClosureReason::FundingBatchClosure => nativeClosureReason::FundingBatchClosure, + ClosureReason::HTLCsTimedOut => nativeClosureReason::HTLCsTimedOut, + ClosureReason::PeerFeerateTooLow {mut peer_feerate_sat_per_kw, mut required_feerate_sat_per_kw, } => { + nativeClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw, + required_feerate_sat_per_kw: required_feerate_sat_per_kw, + } + }, } } #[allow(unused)] @@ -671,11 +1041,19 @@ impl ClosureReason { nativeClosureReason::CounterpartyForceClosed {ref peer_msg, } => { let mut peer_msg_nonref = Clone::clone(peer_msg); ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, + peer_msg: crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg_nonref), is_owned: true }, } }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, + nativeClosureReason::HolderForceClosed {ref broadcasted_latest_txn, } => { + let mut broadcasted_latest_txn_nonref = Clone::clone(broadcasted_latest_txn); + let mut local_broadcasted_latest_txn_nonref = if broadcasted_latest_txn_nonref.is_none() { crate::c_types::derived::COption_boolZ::None } else { crate::c_types::derived::COption_boolZ::Some( { broadcasted_latest_txn_nonref.unwrap() }) }; + ClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn_nonref, + } + }, + nativeClosureReason::LegacyCooperativeClosure => ClosureReason::LegacyCooperativeClosure, + nativeClosureReason::CounterpartyInitiatedCooperativeClosure => ClosureReason::CounterpartyInitiatedCooperativeClosure, + nativeClosureReason::LocallyInitiatedCooperativeClosure => ClosureReason::LocallyInitiatedCooperativeClosure, nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, nativeClosureReason::ProcessingError {ref err, } => { @@ -688,6 +1066,15 @@ impl ClosureReason { nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure, + nativeClosureReason::HTLCsTimedOut => ClosureReason::HTLCsTimedOut, + nativeClosureReason::PeerFeerateTooLow {ref peer_feerate_sat_per_kw, ref required_feerate_sat_per_kw, } => { + let mut peer_feerate_sat_per_kw_nonref = Clone::clone(peer_feerate_sat_per_kw); + let mut required_feerate_sat_per_kw_nonref = Clone::clone(required_feerate_sat_per_kw); + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw_nonref, + required_feerate_sat_per_kw: required_feerate_sat_per_kw_nonref, + } + }, } } #[allow(unused)] @@ -695,11 +1082,18 @@ impl ClosureReason { match native { nativeClosureReason::CounterpartyForceClosed {mut peer_msg, } => { ClosureReason::CounterpartyForceClosed { - peer_msg: crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, + peer_msg: crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(peer_msg), is_owned: true }, } }, - nativeClosureReason::HolderForceClosed => ClosureReason::HolderForceClosed, - nativeClosureReason::CooperativeClosure => ClosureReason::CooperativeClosure, + nativeClosureReason::HolderForceClosed {mut broadcasted_latest_txn, } => { + let mut local_broadcasted_latest_txn = if broadcasted_latest_txn.is_none() { crate::c_types::derived::COption_boolZ::None } else { crate::c_types::derived::COption_boolZ::Some( { broadcasted_latest_txn.unwrap() }) }; + ClosureReason::HolderForceClosed { + broadcasted_latest_txn: local_broadcasted_latest_txn, + } + }, + nativeClosureReason::LegacyCooperativeClosure => ClosureReason::LegacyCooperativeClosure, + nativeClosureReason::CounterpartyInitiatedCooperativeClosure => ClosureReason::CounterpartyInitiatedCooperativeClosure, + nativeClosureReason::LocallyInitiatedCooperativeClosure => ClosureReason::LocallyInitiatedCooperativeClosure, nativeClosureReason::CommitmentTxConfirmed => ClosureReason::CommitmentTxConfirmed, nativeClosureReason::FundingTimedOut => ClosureReason::FundingTimedOut, nativeClosureReason::ProcessingError {mut err, } => { @@ -711,6 +1105,13 @@ impl ClosureReason { nativeClosureReason::OutdatedChannelManager => ClosureReason::OutdatedChannelManager, nativeClosureReason::CounterpartyCoopClosedUnfundedChannel => ClosureReason::CounterpartyCoopClosedUnfundedChannel, nativeClosureReason::FundingBatchClosure => ClosureReason::FundingBatchClosure, + nativeClosureReason::HTLCsTimedOut => ClosureReason::HTLCsTimedOut, + nativeClosureReason::PeerFeerateTooLow {mut peer_feerate_sat_per_kw, mut required_feerate_sat_per_kw, } => { + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw: peer_feerate_sat_per_kw, + required_feerate_sat_per_kw: required_feerate_sat_per_kw, + } + }, } } } @@ -734,19 +1135,30 @@ pub(crate) extern "C" fn ClosureReason_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new CounterpartyForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning::util::string::UntrustedString) -> ClosureReason { +pub extern "C" fn ClosureReason_counterparty_force_closed(peer_msg: crate::lightning_types::string::UntrustedString) -> ClosureReason { ClosureReason::CounterpartyForceClosed { peer_msg, } } #[no_mangle] /// Utility method to constructs a new HolderForceClosed-variant ClosureReason -pub extern "C" fn ClosureReason_holder_force_closed() -> ClosureReason { - ClosureReason::HolderForceClosed} +pub extern "C" fn ClosureReason_holder_force_closed(broadcasted_latest_txn: crate::c_types::derived::COption_boolZ) -> ClosureReason { + ClosureReason::HolderForceClosed { + broadcasted_latest_txn, + } +} +#[no_mangle] +/// Utility method to constructs a new LegacyCooperativeClosure-variant ClosureReason +pub extern "C" fn ClosureReason_legacy_cooperative_closure() -> ClosureReason { + ClosureReason::LegacyCooperativeClosure} #[no_mangle] -/// Utility method to constructs a new CooperativeClosure-variant ClosureReason -pub extern "C" fn ClosureReason_cooperative_closure() -> ClosureReason { - ClosureReason::CooperativeClosure} +/// Utility method to constructs a new CounterpartyInitiatedCooperativeClosure-variant ClosureReason +pub extern "C" fn ClosureReason_counterparty_initiated_cooperative_closure() -> ClosureReason { + ClosureReason::CounterpartyInitiatedCooperativeClosure} +#[no_mangle] +/// Utility method to constructs a new LocallyInitiatedCooperativeClosure-variant ClosureReason +pub extern "C" fn ClosureReason_locally_initiated_cooperative_closure() -> ClosureReason { + ClosureReason::LocallyInitiatedCooperativeClosure} #[no_mangle] /// Utility method to constructs a new CommitmentTxConfirmed-variant ClosureReason pub extern "C" fn ClosureReason_commitment_tx_confirmed() -> ClosureReason { @@ -778,6 +1190,18 @@ pub extern "C" fn ClosureReason_counterparty_coop_closed_unfunded_channel() -> C /// Utility method to constructs a new FundingBatchClosure-variant ClosureReason pub extern "C" fn ClosureReason_funding_batch_closure() -> ClosureReason { ClosureReason::FundingBatchClosure} +#[no_mangle] +/// Utility method to constructs a new HTLCsTimedOut-variant ClosureReason +pub extern "C" fn ClosureReason_htlcs_timed_out() -> ClosureReason { + ClosureReason::HTLCsTimedOut} +#[no_mangle] +/// Utility method to constructs a new PeerFeerateTooLow-variant ClosureReason +pub extern "C" fn ClosureReason_peer_feerate_too_low(peer_feerate_sat_per_kw: u32, required_feerate_sat_per_kw: u32) -> ClosureReason { + ClosureReason::PeerFeerateTooLow { + peer_feerate_sat_per_kw, + required_feerate_sat_per_kw, + } +} /// Get a string which allows debug introspection of a ClosureReason object pub extern "C" fn ClosureReason_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::ClosureReason }).into()} @@ -788,6 +1212,11 @@ pub extern "C" fn ClosureReason_eq(a: &ClosureReason, b: &ClosureReason) -> bool if &a.to_native() == &b.to_native() { true } else { false } } #[no_mangle] +/// Get the string representation of a ClosureReason object +pub extern "C" fn ClosureReason_to_str(o: &crate::lightning::events::ClosureReason) -> Str { + alloc::format!("{}", &o.to_native()).into() +} +#[no_mangle] /// Serialize the ClosureReason object into a byte array which can be read by ClosureReason_read pub extern "C" fn ClosureReason_write(obj: &crate::lightning::events::ClosureReason) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) @@ -818,7 +1247,7 @@ pub enum HTLCDestination { /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None node_id: crate::c_types::PublicKey, /// The outgoing `channel_id` between us and the next node. - channel_id: crate::c_types::ThirtyTwoBytes, + channel_id: crate::lightning::ln::types::ChannelId, }, /// Scenario where we are unsure of the next node to forward the HTLC to. UnknownNextHop { @@ -831,6 +1260,8 @@ pub enum HTLCDestination { /// Short channel id we are requesting to forward an HTLC to. requested_forward_scid: u64, }, + /// We couldn't decode the incoming onion to obtain the forwarding details. + InvalidOnion, /// Failure scenario where an HTLC may have been forwarded to be intended for us, /// but is invalid for some reason, so we reject it. /// @@ -859,7 +1290,7 @@ impl HTLCDestination { let mut channel_id_nonref = Clone::clone(channel_id); nativeHTLCDestination::NextHopChannel { node_id: local_node_id_nonref, - channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data), + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, } }, HTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { @@ -874,10 +1305,11 @@ impl HTLCDestination { requested_forward_scid: requested_forward_scid_nonref, } }, + HTLCDestination::InvalidOnion => nativeHTLCDestination::InvalidOnion, HTLCDestination::FailedPayment {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), } }, } @@ -889,7 +1321,7 @@ impl HTLCDestination { let mut local_node_id = if node_id.is_null() { None } else { Some( { node_id.into_rust() }) }; nativeHTLCDestination::NextHopChannel { node_id: local_node_id, - channel_id: ::lightning::ln::ChannelId(channel_id.data), + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, } }, HTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { @@ -902,9 +1334,10 @@ impl HTLCDestination { requested_forward_scid: requested_forward_scid, } }, + HTLCDestination::InvalidOnion => nativeHTLCDestination::InvalidOnion, HTLCDestination::FailedPayment {mut payment_hash, } => { nativeHTLCDestination::FailedPayment { - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), } }, } @@ -919,7 +1352,7 @@ impl HTLCDestination { let mut channel_id_nonref = Clone::clone(channel_id); HTLCDestination::NextHopChannel { node_id: local_node_id_nonref, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, } }, nativeHTLCDestination::UnknownNextHop {ref requested_forward_scid, } => { @@ -934,6 +1367,7 @@ impl HTLCDestination { requested_forward_scid: requested_forward_scid_nonref, } }, + nativeHTLCDestination::InvalidOnion => HTLCDestination::InvalidOnion, nativeHTLCDestination::FailedPayment {ref payment_hash, } => { let mut payment_hash_nonref = Clone::clone(payment_hash); HTLCDestination::FailedPayment { @@ -949,7 +1383,7 @@ impl HTLCDestination { let mut local_node_id = if node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(node_id.unwrap())) } }; HTLCDestination::NextHopChannel { node_id: local_node_id, - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, } }, nativeHTLCDestination::UnknownNextHop {mut requested_forward_scid, } => { @@ -962,6 +1396,7 @@ impl HTLCDestination { requested_forward_scid: requested_forward_scid, } }, + nativeHTLCDestination::InvalidOnion => HTLCDestination::InvalidOnion, nativeHTLCDestination::FailedPayment {mut payment_hash, } => { HTLCDestination::FailedPayment { payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, @@ -990,7 +1425,7 @@ pub(crate) extern "C" fn HTLCDestination_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new NextHopChannel-variant HTLCDestination -pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { +pub extern "C" fn HTLCDestination_next_hop_channel(node_id: crate::c_types::PublicKey, channel_id: crate::lightning::ln::types::ChannelId) -> HTLCDestination { HTLCDestination::NextHopChannel { node_id, channel_id, @@ -1011,6 +1446,10 @@ pub extern "C" fn HTLCDestination_invalid_forward(requested_forward_scid: u64) - } } #[no_mangle] +/// Utility method to constructs a new InvalidOnion-variant HTLCDestination +pub extern "C" fn HTLCDestination_invalid_onion() -> HTLCDestination { + HTLCDestination::InvalidOnion} +#[no_mangle] /// Utility method to constructs a new FailedPayment-variant HTLCDestination pub extern "C" fn HTLCDestination_failed_payment(payment_hash: crate::c_types::ThirtyTwoBytes) -> HTLCDestination { HTLCDestination::FailedPayment { @@ -1048,6 +1487,12 @@ pub extern "C" fn HTLCDestination_read(ser: crate::c_types::u8slice) -> crate::c #[repr(C)] pub enum PaymentFailureReason { /// The intended recipient rejected our payment. + /// + /// Also used for [`UnknownRequiredFeatures`] and [`InvoiceRequestRejected`] when downgrading to + /// version prior to 0.0.124. + /// + /// [`UnknownRequiredFeatures`]: Self::UnknownRequiredFeatures + /// [`InvoiceRequestRejected`]: Self::InvoiceRequestRejected RecipientRejected, /// The user chose to abandon this payment by calling [`ChannelManager::abandon_payment`]. /// @@ -1063,13 +1508,28 @@ pub enum PaymentFailureReason { /// The payment expired while retrying, based on the provided /// [`PaymentParameters::expiry_time`]. /// + /// Also used for [`InvoiceRequestExpired`] when downgrading to version prior to 0.0.124. + /// /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time + /// [`InvoiceRequestExpired`]: Self::InvoiceRequestExpired PaymentExpired, /// We failed to find a route while retrying the payment. + /// + /// Note that this generally indicates that we've exhausted the available set of possible + /// routes - we tried the payment over a few routes but were not able to find any further + /// candidate routes beyond those. RouteNotFound, /// This error should generally never happen. This likely means that there is a problem with /// your router. UnexpectedError, + /// An invoice was received that required unknown features. + UnknownRequiredFeatures, + /// A [`Bolt12Invoice`] was not received in a reasonable amount of time. + InvoiceRequestExpired, + /// An [`InvoiceRequest`] for the payment was rejected by the recipient. + /// + /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest + InvoiceRequestRejected, } use lightning::events::PaymentFailureReason as PaymentFailureReasonImport; pub(crate) type nativePaymentFailureReason = PaymentFailureReasonImport; @@ -1084,6 +1544,9 @@ impl PaymentFailureReason { PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + PaymentFailureReason::UnknownRequiredFeatures => nativePaymentFailureReason::UnknownRequiredFeatures, + PaymentFailureReason::InvoiceRequestExpired => nativePaymentFailureReason::InvoiceRequestExpired, + PaymentFailureReason::InvoiceRequestRejected => nativePaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1095,6 +1558,9 @@ impl PaymentFailureReason { PaymentFailureReason::PaymentExpired => nativePaymentFailureReason::PaymentExpired, PaymentFailureReason::RouteNotFound => nativePaymentFailureReason::RouteNotFound, PaymentFailureReason::UnexpectedError => nativePaymentFailureReason::UnexpectedError, + PaymentFailureReason::UnknownRequiredFeatures => nativePaymentFailureReason::UnknownRequiredFeatures, + PaymentFailureReason::InvoiceRequestExpired => nativePaymentFailureReason::InvoiceRequestExpired, + PaymentFailureReason::InvoiceRequestRejected => nativePaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1107,6 +1573,9 @@ impl PaymentFailureReason { nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + nativePaymentFailureReason::UnknownRequiredFeatures => PaymentFailureReason::UnknownRequiredFeatures, + nativePaymentFailureReason::InvoiceRequestExpired => PaymentFailureReason::InvoiceRequestExpired, + nativePaymentFailureReason::InvoiceRequestRejected => PaymentFailureReason::InvoiceRequestRejected, } } #[allow(unused)] @@ -1118,6 +1587,9 @@ impl PaymentFailureReason { nativePaymentFailureReason::PaymentExpired => PaymentFailureReason::PaymentExpired, nativePaymentFailureReason::RouteNotFound => PaymentFailureReason::RouteNotFound, nativePaymentFailureReason::UnexpectedError => PaymentFailureReason::UnexpectedError, + nativePaymentFailureReason::UnknownRequiredFeatures => PaymentFailureReason::UnknownRequiredFeatures, + nativePaymentFailureReason::InvoiceRequestExpired => PaymentFailureReason::InvoiceRequestExpired, + nativePaymentFailureReason::InvoiceRequestRejected => PaymentFailureReason::InvoiceRequestRejected, } } } @@ -1160,6 +1632,18 @@ pub extern "C" fn PaymentFailureReason_route_not_found() -> PaymentFailureReason /// Utility method to constructs a new UnexpectedError-variant PaymentFailureReason pub extern "C" fn PaymentFailureReason_unexpected_error() -> PaymentFailureReason { PaymentFailureReason::UnexpectedError} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_unknown_required_features() -> PaymentFailureReason { + PaymentFailureReason::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequestExpired-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_invoice_request_expired() -> PaymentFailureReason { + PaymentFailureReason::InvoiceRequestExpired} +#[no_mangle] +/// Utility method to constructs a new InvoiceRequestRejected-variant PaymentFailureReason +pub extern "C" fn PaymentFailureReason_invoice_request_rejected() -> PaymentFailureReason { + PaymentFailureReason::InvoiceRequestRejected} /// Get a string which allows debug introspection of a PaymentFailureReason object pub extern "C" fn PaymentFailureReason_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::PaymentFailureReason }).into()} @@ -1180,9 +1664,9 @@ pub(crate) extern "C" fn PaymentFailureReason_write_void(obj: *const c_void) -> } #[no_mangle] /// Read a PaymentFailureReason from a byte array, created by PaymentFailureReason_write -pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_PaymentFailureReasonDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::events::PaymentFailureReason::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; +pub extern "C" fn PaymentFailureReason_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_PaymentFailureReasonZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } /// An Event which you should probably take some action in response to. @@ -1200,6 +1684,10 @@ pub enum Event { /// Note that *all inputs* in the funding transaction must spend SegWit outputs or your /// counterparty can steal your funds! /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated FundingGenerationReady { @@ -1207,7 +1695,7 @@ pub enum Event { /// [`ChannelManager::funding_transaction_generated`]. /// /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated - temporary_channel_id: crate::c_types::ThirtyTwoBytes, + temporary_channel_id: crate::lightning::ln::types::ChannelId, /// The counterparty's node_id, which you'll need to pass back into /// [`ChannelManager::funding_transaction_generated`]. /// @@ -1228,6 +1716,32 @@ pub enum Event { /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels user_channel_id: crate::c_types::U128, }, + /// Used to indicate that the counterparty node has provided the signature(s) required to + /// recover our funds in case they go offline. + /// + /// It is safe (and your responsibility) to broadcast the funding transaction upon receiving this + /// event. + /// + /// This event is only emitted if you called + /// [`ChannelManager::unsafe_manual_funding_transaction_generated`] instead of + /// [`ChannelManager::funding_transaction_generated`]. + /// + /// [`ChannelManager::unsafe_manual_funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::unsafe_manual_funding_transaction_generated + /// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated + FundingTxBroadcastSafe { + /// The `channel_id` indicating which channel has reached this stage. + channel_id: crate::lightning::ln::types::ChannelId, + /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`]. + /// + /// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel + user_channel_id: crate::c_types::U128, + /// The outpoint of the channel's funding transaction. + funding_txo: crate::lightning::chain::transaction::OutPoint, + /// The `node_id` of the channel counterparty. + counterparty_node_id: crate::c_types::PublicKey, + /// The `temporary_channel_id` this channel used to be known by during channel establishment. + former_temporary_channel_id: crate::lightning::ln::types::ChannelId, + }, /// Indicates that we've been offered a payment and it needs to be claimed via calling /// [`ChannelManager::claim_funds`] with the preimage given in [`PaymentPurpose`]. /// @@ -1257,6 +1771,10 @@ pub enum Event { /// # Note /// This event used to be called `PaymentReceived` in LDK versions 0.0.112 and earlier. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds /// [`ChannelManager::claim_funds_with_known_custom_tlvs`]: crate::ln::channelmanager::ChannelManager::claim_funds_with_known_custom_tlvs /// [`FailureCode::InvalidOnionPayload`]: crate::ln::channelmanager::FailureCode::InvalidOnionPayload @@ -1305,7 +1823,9 @@ pub enum Event { /// payment is to pay an invoice or to send a spontaneous payment. purpose: crate::lightning::events::PaymentPurpose, /// The `channel_id` indicating over which channel we received the payment. - via_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + via_channel_id: crate::lightning::ln::types::ChannelId, /// The `user_channel_id` indicating over which channel we received the payment. via_user_channel_id: crate::c_types::derived::COption_U128Z, /// The block height at which this payment will be failed back and will no longer be @@ -1330,6 +1850,10 @@ pub enum Event { /// [`ChannelManager::claim_funds`] twice for the same [`Event::PaymentClaimable`] you may get /// multiple `PaymentClaimed` events. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds PaymentClaimed { /// The node that received the payment. @@ -1356,6 +1880,13 @@ pub enum Event { /// The sender-intended sum total of all the MPP parts. This will be `None` for events /// serialized prior to LDK version 0.0.117. sender_intended_total_msat: crate::c_types::derived::COption_u64Z, + /// The fields in the onion which were received with each HTLC. Only fields which were + /// identical in each HTLC involved in the payment will be included here. + /// + /// Payments received on LDK versions prior to 0.0.124 will have this field unset. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, }, /// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`]. /// @@ -1366,6 +1897,11 @@ pub enum Event { /// This event will not be generated for onion message forwards; only for sends including /// replies. Handlers should connect to the node otherwise any buffered messages may be lost. /// + /// # Failure Behavior and Persistence + /// This event won't be replayed after failures-to-handle + /// (i.e., the event handler returning `Err(ReplayEvent ())`), and also won't be persisted + /// across restarts. + /// /// [`OnionMessage`]: msgs::OnionMessage /// [`MessageRouter`]: crate::onion_message::messenger::MessageRouter /// [`Destination`]: crate::onion_message::messenger::Destination @@ -1376,23 +1912,50 @@ pub enum Event { /// Sockets for connecting to the node. addresses: crate::c_types::derived::CVec_SocketAddressZ, }, - /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time - /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an - /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed. + /// Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was + /// received. + /// + /// This event will only be generated if [`UserConfig::manually_handle_bolt12_invoices`] is set. + /// Use [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or + /// [`ChannelManager::abandon_payment`] to abandon the associated payment. See those docs for + /// further details. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. /// - /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest - /// [`Offer`]: crate::offers::offer::Offer /// [`Refund`]: crate::offers::refund::Refund - InvoiceRequestFailed { - /// The `payment_id` to have been associated with payment for the requested invoice. + /// [`UserConfig::manually_handle_bolt12_invoices`]: crate::util::config::UserConfig::manually_handle_bolt12_invoices + /// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice + /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment + InvoiceReceived { + /// The `payment_id` associated with payment for the invoice. payment_id: crate::c_types::ThirtyTwoBytes, + /// The invoice to pay. + invoice: crate::lightning::offers::invoice::Bolt12Invoice, + /// The context of the [`BlindedMessagePath`] used to send the invoice. + /// + /// [`BlindedMessagePath`]: crate::blinded_path::message::BlindedMessagePath + context: crate::c_types::derived::COption_OffersContextZ, + /// A responder for replying with an [`InvoiceError`] if needed. + /// + /// `None` if the invoice wasn't sent with a reply path. + /// + /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + responder: crate::lightning::onion_message::messenger::Responder, }, /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target /// and we got back the payment preimage for it). /// /// Note for MPP payments: in rare cases, this event may be preceded by a `PaymentPathFailed` /// event. In this situation, you SHOULD treat this payment as having succeeded. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentSent { /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// @@ -1414,6 +1977,8 @@ pub enum Event { /// If the recipient or an intermediate node misbehaves and gives us free money, this may /// overstate the amount paid, though this is unlikely. /// + /// This is only `None` for payments initiated on LDK versions prior to 0.0.103. + /// /// [`Route::get_total_fees`]: crate::routing::router::Route::get_total_fees fee_paid_msat: crate::c_types::derived::COption_u64Z, }, @@ -1429,6 +1994,10 @@ pub enum Event { /// received and processed. In this case, the [`Event::PaymentFailed`] event MUST be ignored, /// and the payment MUST be treated as having succeeded. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`Retry`]: crate::ln::channelmanager::Retry /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentFailed { @@ -1436,18 +2005,25 @@ pub enum Event { /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment payment_id: crate::c_types::ThirtyTwoBytes, - /// The hash that was given to [`ChannelManager::send_payment`]. + /// The hash that was given to [`ChannelManager::send_payment`]. `None` if the payment failed + /// before receiving an invoice when paying a BOLT12 [`Offer`]. /// /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment - payment_hash: crate::c_types::ThirtyTwoBytes, + /// [`Offer`]: crate::offers::offer::Offer + payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, /// The reason the payment failed. This is only `None` for events generated or serialized - /// by versions prior to 0.0.115. + /// by versions prior to 0.0.115, or when downgrading to a version with a reason that was + /// added after. reason: crate::c_types::derived::COption_PaymentFailureReasonZ, }, /// Indicates that a path for an outbound payment was successful. /// /// Always generated after [`Event::PaymentSent`] and thus useful for scoring channels. See /// [`Event::PaymentSent`] for obtaining the payment preimage. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentPathSuccessful { /// The `payment_id` passed to [`ChannelManager::send_payment`]. /// @@ -1473,6 +2049,10 @@ pub enum Event { /// See [`ChannelManager::abandon_payment`] for giving up on this payment before its retries have /// been exhausted. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment PaymentPathFailed { /// The `payment_id` passed to [`ChannelManager::send_payment`]. @@ -1508,6 +2088,10 @@ pub enum Event { short_channel_id: crate::c_types::derived::COption_u64Z, }, /// Indicates that a probe payment we sent returned successful, i.e., only failed at the destination. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ProbeSuccessful { /// The id returned by [`ChannelManager::send_probe`]. /// @@ -1521,6 +2105,10 @@ pub enum Event { path: crate::lightning::routing::router::Path, }, /// Indicates that a probe payment we sent failed at an intermediary node on the path. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ProbeFailed { /// The id returned by [`ChannelManager::send_probe`]. /// @@ -1542,6 +2130,10 @@ pub enum Event { /// Used to indicate that [`ChannelManager::process_pending_htlc_forwards`] should be called at /// a time in the future. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be regenerated after restarts. + /// /// [`ChannelManager::process_pending_htlc_forwards`]: crate::ln::channelmanager::ChannelManager::process_pending_htlc_forwards PendingHTLCsForwardable { /// The minimum amount of time that should be waited prior to calling @@ -1558,6 +2150,10 @@ pub enum Event { /// [`ChannelManager::fail_intercepted_htlc`] MUST be called in response to this event. See /// their docs for more information. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`UserConfig::accept_intercept_htlcs`]: crate::util::config::UserConfig::accept_intercept_htlcs /// [`ChannelManager::forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -1585,27 +2181,59 @@ pub enum Event { }, /// Used to indicate that an output which you should know how to spend was confirmed on chain /// and is now spendable. - /// Such an output will *not* ever be spent by rust-lightning, and are not at risk of your + /// + /// Such an output will *never* be spent directly by LDK, and are not at risk of your /// counterparty spending them due to some kind of timeout. Thus, you need to store them /// somewhere and spend them when you create on-chain transactions. + /// + /// You may hand them to the [`OutputSweeper`] utility which will store and (re-)generate spending + /// transactions for you. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// + /// [`OutputSweeper`]: crate::util::sweep::OutputSweeper SpendableOutputs { /// The outputs which you should store as spendable by you. outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, /// The `channel_id` indicating which channel the spendable outputs belong to. /// /// This will always be `Some` for events generated by LDK versions 0.0.117 and above. - channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + channel_id: crate::lightning::ln::types::ChannelId, }, /// This event is generated when a payment has been successfully forwarded through us and a /// forwarding fee earned. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. PaymentForwarded { - /// The incoming channel between the previous node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - prev_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, - /// The outgoing channel between the next node and us. This is only `None` for events - /// generated or serialized by versions prior to 0.0.107. - next_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, - /// The fee, in milli-satoshis, which was earned as a result of the payment. + /// The channel id of the incoming channel between the previous node and us. + /// + /// This is only `None` for events generated or serialized by versions prior to 0.0.107. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + prev_channel_id: crate::lightning::ln::types::ChannelId, + /// The channel id of the outgoing channel between the next node and us. + /// + /// This is only `None` for events generated or serialized by versions prior to 0.0.107. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + next_channel_id: crate::lightning::ln::types::ChannelId, + /// The `user_channel_id` of the incoming channel between the previous node and us. + /// + /// This is only `None` for events generated or serialized by versions prior to 0.0.122. + prev_user_channel_id: crate::c_types::derived::COption_U128Z, + /// The `user_channel_id` of the outgoing channel between the next node and us. + /// + /// This will be `None` if the payment was settled via an on-chain transaction. See the + /// caveat described for the `total_fee_earned_msat` field. Moreover it will be `None` for + /// events generated or serialized by versions prior to 0.0.122. + next_user_channel_id: crate::c_types::derived::COption_U128Z, + /// The total fee, in milli-satoshis, which was earned as a result of the payment. /// /// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC /// was pending, the amount the next hop claimed will have been rounded down to the nearest @@ -1616,15 +2244,29 @@ pub enum Event { /// If the channel which sent us the payment has been force-closed, we will claim the funds /// via an on-chain transaction. In that case we do not yet know the on-chain transaction /// fees which we will spend and will instead set this to `None`. It is possible duplicate - /// `PaymentForwarded` events are generated for the same payment iff `fee_earned_msat` is + /// `PaymentForwarded` events are generated for the same payment iff `total_fee_earned_msat` is /// `None`. - fee_earned_msat: crate::c_types::derived::COption_u64Z, + total_fee_earned_msat: crate::c_types::derived::COption_u64Z, + /// The share of the total fee, in milli-satoshis, which was withheld in addition to the + /// forwarding fee. + /// + /// This will only be `Some` if we forwarded an intercepted HTLC with less than the + /// expected amount. This means our counterparty accepted to receive less than the invoice + /// amount, e.g., by claiming the payment featuring a corresponding + /// [`PaymentClaimable::counterparty_skimmed_fee_msat`]. + /// + /// Will also always be `None` for events serialized with LDK prior to version 0.0.122. + /// + /// The caveat described above the `total_fee_earned_msat` field applies here as well. + /// + /// [`PaymentClaimable::counterparty_skimmed_fee_msat`]: Self::PaymentClaimable::counterparty_skimmed_fee_msat + skimmed_fee_msat: crate::c_types::derived::COption_u64Z, /// If this is `true`, the forwarded HTLC was claimed by our counterparty via an on-chain /// transaction. claim_from_onchain_tx: bool, /// The final amount forwarded, in milli-satoshis, after the fee is deducted. /// - /// The caveat described above the `fee_earned_msat` field applies here as well. + /// The caveat described above the `total_fee_earned_msat` field applies here as well. outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z, }, /// Used to indicate that a channel with the given `channel_id` is being opened and pending @@ -1633,9 +2275,13 @@ pub enum Event { /// This event is emitted when the funding transaction has been signed and is broadcast to the /// network. For 0conf channels it will be immediately followed by the corresponding /// [`Event::ChannelReady`] event. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelPending { /// The `channel_id` of the channel that is pending confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, + channel_id: crate::lightning::ln::types::ChannelId, /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise @@ -1648,19 +2294,31 @@ pub enum Event { /// The `temporary_channel_id` this channel used to be known by during channel establishment. /// /// Will be `None` for channels created prior to LDK version 0.0.115. - former_temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + former_temporary_channel_id: crate::lightning::ln::types::ChannelId, /// The `node_id` of the channel counterparty. counterparty_node_id: crate::c_types::PublicKey, /// The outpoint of the channel's funding transaction. funding_txo: crate::lightning::chain::transaction::OutPoint, + /// The features that this channel will operate with. + /// + /// Will be `None` for channels created prior to LDK version 0.0.122. + /// + /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None + channel_type: crate::lightning_types::features::ChannelTypeFeatures, }, /// Used to indicate that a channel with the given `channel_id` is ready to /// be used. This event is emitted either when the funding transaction has been confirmed /// on-chain, or, in case of a 0conf channel, when both parties have confirmed the channel /// establishment. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelReady { /// The `channel_id` of the channel that is ready. - channel_id: crate::c_types::ThirtyTwoBytes, + channel_id: crate::lightning::ln::types::ChannelId, /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise @@ -1673,10 +2331,10 @@ pub enum Event { /// The `node_id` of the channel counterparty. counterparty_node_id: crate::c_types::PublicKey, /// The features that this channel will operate with. - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + channel_type: crate::lightning_types::features::ChannelTypeFeatures, }, - /// Used to indicate that a previously opened channel with the given `channel_id` is in the - /// process of closure. + /// Used to indicate that a channel that got past the initial handshake with the given `channel_id` is in the + /// process of closure. This includes previously opened channels, and channels that time out from not being funded. /// /// Note that this event is only triggered for accepted channels: if the /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true and the channel is @@ -1684,10 +2342,14 @@ pub enum Event { /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. ChannelClosed { /// The `channel_id` of the channel which has been closed. Note that on-chain transactions /// resolving the channel are likely still awaiting confirmation. - channel_id: crate::c_types::ThirtyTwoBytes, + channel_id: crate::lightning::ln::types::ChannelId, /// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound /// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise @@ -1722,11 +2384,15 @@ pub enum Event { /// inputs for another purpose. /// /// This event is not guaranteed to be generated for channels that are closed due to a restart. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. DiscardFunding { /// The channel_id of the channel which has been closed. - channel_id: crate::c_types::ThirtyTwoBytes, + channel_id: crate::lightning::ln::types::ChannelId, /// The full transaction received from the user - transaction: crate::c_types::Transaction, + funding_info: crate::lightning::events::FundingInfo, }, /// Indicates a request to open a new channel by a peer. /// @@ -1737,6 +2403,10 @@ pub enum Event { /// The event is only triggered when a new open channel request is received and the /// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. + /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn /// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels @@ -1749,7 +2419,7 @@ pub enum Event { /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`ChannelManager::force_close_without_broadcasting_txn`]: crate::ln::channelmanager::ChannelManager::force_close_without_broadcasting_txn - temporary_channel_id: crate::c_types::ThirtyTwoBytes, + temporary_channel_id: crate::lightning::ln::types::ChannelId, /// The node_id of the counterparty requesting to open the channel. /// /// When responding to the request, the `counterparty_node_id` should be passed @@ -1779,7 +2449,11 @@ pub enum Event { /// or will be rejected otherwise. /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - channel_type: crate::lightning::ln::features::ChannelTypeFeatures, + channel_type: crate::lightning_types::features::ChannelTypeFeatures, + /// True if this channel is (or will be) publicly-announced. + is_announced: bool, + /// Channel parameters given by the counterparty. + params: crate::lightning::ln::msgs::ChannelParameters, }, /// Indicates that the HTLC was accepted, but could not be processed when or after attempting to /// forward it. @@ -1793,9 +2467,13 @@ pub enum Event { /// /// This event, however, does not get generated if an HTLC fails to meet the forwarding /// requirements (i.e. insufficient fees paid, or a CLTV that is too soon). + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`) and will be persisted across restarts. HTLCHandlingFailed { /// The channel over which the HTLC was received. - prev_channel_id: crate::c_types::ThirtyTwoBytes, + prev_channel_id: crate::lightning::ln::types::ChannelId, /// Destination of the HTLC that failed to be processed. failed_next_destination: crate::lightning::events::HTLCDestination, }, @@ -1806,9 +2484,45 @@ pub enum Event { /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`] config flag is set to true. /// It is limited to the scope of channels with anchor outputs. /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but will only be regenerated as needed after restarts. + /// /// [`ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx`]: crate::util::config::ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_tx BumpTransaction( crate::lightning::events::bump_transaction::BumpTransactionEvent), + /// We received an onion message that is intended to be forwarded to a peer + /// that is currently offline. This event will only be generated if the + /// `OnionMessenger` was initialized with + /// [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// + /// [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + OnionMessageIntercepted { + /// The node id of the offline peer. + peer_node_id: crate::c_types::PublicKey, + /// The onion message intended to be forwarded to `peer_node_id`. + message: crate::lightning::ln::msgs::OnionMessage, + }, + /// Indicates that an onion message supporting peer has come online and it may + /// be time to forward any onion messages that were previously intercepted for + /// them. This event will only be generated if the `OnionMessenger` was + /// initialized with + /// [`OnionMessenger::new_with_offline_peer_interception`], see its docs. + /// + /// # Failure Behavior and Persistence + /// This event will eventually be replayed after failures-to-handle (i.e., the event handler + /// returning `Err(ReplayEvent ())`), but won't be persisted across restarts. + /// + /// [`OnionMessenger::new_with_offline_peer_interception`]: crate::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception + OnionMessagePeerConnected { + /// The node id of the peer we just connected to, who advertises support for + /// onion messages. + peer_node_id: crate::c_types::PublicKey, + }, } use lightning::events::Event as EventImport; pub(crate) type nativeEvent = EventImport; @@ -1824,13 +2538,27 @@ impl Event { let mut output_script_nonref = Clone::clone(output_script); let mut user_channel_id_nonref = Clone::clone(user_channel_id); nativeEvent::FundingGenerationReady { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_nonref.take_inner()) }, counterparty_node_id: counterparty_node_id_nonref.into_rust(), channel_value_satoshis: channel_value_satoshis_nonref, - output_script: ::bitcoin::blockdata::script::ScriptBuf::from(output_script_nonref.into_rust()), + output_script: ::bitcoin::script::ScriptBuf::from(output_script_nonref.into_rust()), user_channel_id: user_channel_id_nonref.into(), } }, + Event::FundingTxBroadcastSafe {ref channel_id, ref user_channel_id, ref funding_txo, ref counterparty_node_id, ref former_temporary_channel_id, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + nativeEvent::FundingTxBroadcastSafe { + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, + user_channel_id: user_channel_id_nonref.into(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), + counterparty_node_id: counterparty_node_id_nonref.into_rust(), + former_temporary_channel_id: *unsafe { Box::from_raw(former_temporary_channel_id_nonref.take_inner()) }, + } + }, Event::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; @@ -1841,14 +2569,14 @@ impl Event { let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat); let mut purpose_nonref = Clone::clone(purpose); let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = { /*via_channel_id_nonref*/ let via_channel_id_nonref_opt = via_channel_id_nonref; if via_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ via_channel_id_nonref_opt.take() }.data) }})} }; + let mut local_via_channel_id_nonref = if via_channel_id_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(via_channel_id_nonref.take_inner()) } }) }; let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); let mut local_via_user_channel_id_nonref = { /*via_user_channel_id_nonref*/ let via_user_channel_id_nonref_opt = via_user_channel_id_nonref; if via_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { via_user_channel_id_nonref_opt.take() }.into() }})} }; let mut claim_deadline_nonref = Clone::clone(claim_deadline); let mut local_claim_deadline_nonref = if claim_deadline_nonref.is_some() { Some( { claim_deadline_nonref.take() }) } else { None }; nativeEvent::PaymentClaimable { receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), onion_fields: local_onion_fields_nonref, amount_msat: amount_msat_nonref, counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat_nonref, @@ -1858,7 +2586,7 @@ impl Event { claim_deadline: local_claim_deadline_nonref, } }, - Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => { + Event::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, ref onion_fields, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_null() { None } else { Some( { receiver_node_id_nonref.into_rust() }) }; let mut payment_hash_nonref = Clone::clone(payment_hash); @@ -1868,13 +2596,16 @@ impl Event { let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.into_rust().drain(..) { local_htlcs_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat); let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_some() { Some( { sender_intended_total_msat_nonref.take() }) } else { None }; + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = if onion_fields_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields_nonref.take_inner()) } }) }; nativeEvent::PaymentClaimed { receiver_node_id: local_receiver_node_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), amount_msat: amount_msat_nonref, purpose: purpose_nonref.into_native(), htlcs: local_htlcs_nonref, sender_intended_total_msat: local_sender_intended_total_msat_nonref, + onion_fields: local_onion_fields_nonref, } }, Event::ConnectionNeeded {ref node_id, ref addresses, } => { @@ -1886,10 +2617,18 @@ impl Event { addresses: local_addresses_nonref, } }, - Event::InvoiceRequestFailed {ref payment_id, } => { + Event::InvoiceReceived {ref payment_id, ref invoice, ref context, ref responder, } => { let mut payment_id_nonref = Clone::clone(payment_id); - nativeEvent::InvoiceRequestFailed { + let mut invoice_nonref = Clone::clone(invoice); + let mut context_nonref = Clone::clone(context); + let mut local_context_nonref = { /*context_nonref*/ let context_nonref_opt = context_nonref; if context_nonref_opt.is_none() { None } else { Some({ { { context_nonref_opt.take() }.into_native() }})} }; + let mut responder_nonref = Clone::clone(responder); + let mut local_responder_nonref = if responder_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder_nonref.take_inner()) } }) }; + nativeEvent::InvoiceReceived { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), + invoice: *unsafe { Box::from_raw(invoice_nonref.take_inner()) }, + context: local_context_nonref, + responder: local_responder_nonref, } }, Event::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { @@ -1901,26 +2640,27 @@ impl Event { let mut local_fee_paid_msat_nonref = if fee_paid_msat_nonref.is_some() { Some( { fee_paid_msat_nonref.take() }) } else { None }; nativeEvent::PaymentSent { payment_id: local_payment_id_nonref, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), fee_paid_msat: local_fee_paid_msat_nonref, } }, Event::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; let mut reason_nonref = Clone::clone(reason); let mut local_reason_nonref = { /*reason_nonref*/ let reason_nonref_opt = reason_nonref; if reason_nonref_opt.is_none() { None } else { Some({ { { reason_nonref_opt.take() }.into_native() }})} }; nativeEvent::PaymentFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: local_payment_hash_nonref, reason: local_reason_nonref, } }, Event::PaymentPathSuccessful {ref payment_id, ref payment_hash, ref path, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; let mut path_nonref = Clone::clone(path); nativeEvent::PaymentPathSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), @@ -1939,7 +2679,7 @@ impl Event { let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; nativeEvent::PaymentPathFailed { payment_id: local_payment_id_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), payment_failed_permanently: payment_failed_permanently_nonref, failure: failure_nonref.into_native(), path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, @@ -1952,7 +2692,7 @@ impl Event { let mut path_nonref = Clone::clone(path); nativeEvent::ProbeSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, } }, @@ -1964,7 +2704,7 @@ impl Event { let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_some() { Some( { short_channel_id_nonref.take() }) } else { None }; nativeEvent::ProbeFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), path: *unsafe { Box::from_raw(path_nonref.take_inner()) }, short_channel_id: local_short_channel_id_nonref, } @@ -1984,7 +2724,7 @@ impl Event { nativeEvent::HTLCIntercepted { intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id_nonref.data), requested_next_hop_scid: requested_next_hop_scid_nonref, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), inbound_amount_msat: inbound_amount_msat_nonref, expected_outbound_amount_msat: expected_outbound_amount_msat_nonref, } @@ -1993,43 +2733,55 @@ impl Event { let mut outputs_nonref = Clone::clone(outputs); let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.into_rust().drain(..) { local_outputs_nonref.push( { item.into_native() }); }; let mut channel_id_nonref = Clone::clone(channel_id); - let mut local_channel_id_nonref = { /*channel_id_nonref*/ let channel_id_nonref_opt = channel_id_nonref; if channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ channel_id_nonref_opt.take() }.data) }})} }; + let mut local_channel_id_nonref = if channel_id_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id_nonref.take_inner()) } }) }; nativeEvent::SpendableOutputs { outputs: local_outputs_nonref, channel_id: local_channel_id_nonref, } }, - Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { + Event::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref prev_user_channel_id, ref next_user_channel_id, ref total_fee_earned_msat, ref skimmed_fee_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = { /*prev_channel_id_nonref*/ let prev_channel_id_nonref_opt = prev_channel_id_nonref; if prev_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ prev_channel_id_nonref_opt.take() }.data) }})} }; + let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(prev_channel_id_nonref.take_inner()) } }) }; let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = { /*next_channel_id_nonref*/ let next_channel_id_nonref_opt = next_channel_id_nonref; if next_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ next_channel_id_nonref_opt.take() }.data) }})} }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_some() { Some( { fee_earned_msat_nonref.take() }) } else { None }; + let mut local_next_channel_id_nonref = if next_channel_id_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(next_channel_id_nonref.take_inner()) } }) }; + let mut prev_user_channel_id_nonref = Clone::clone(prev_user_channel_id); + let mut local_prev_user_channel_id_nonref = { /*prev_user_channel_id_nonref*/ let prev_user_channel_id_nonref_opt = prev_user_channel_id_nonref; if prev_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { prev_user_channel_id_nonref_opt.take() }.into() }})} }; + let mut next_user_channel_id_nonref = Clone::clone(next_user_channel_id); + let mut local_next_user_channel_id_nonref = { /*next_user_channel_id_nonref*/ let next_user_channel_id_nonref_opt = next_user_channel_id_nonref; if next_user_channel_id_nonref_opt.is_none() { None } else { Some({ { { next_user_channel_id_nonref_opt.take() }.into() }})} }; + let mut total_fee_earned_msat_nonref = Clone::clone(total_fee_earned_msat); + let mut local_total_fee_earned_msat_nonref = if total_fee_earned_msat_nonref.is_some() { Some( { total_fee_earned_msat_nonref.take() }) } else { None }; + let mut skimmed_fee_msat_nonref = Clone::clone(skimmed_fee_msat); + let mut local_skimmed_fee_msat_nonref = if skimmed_fee_msat_nonref.is_some() { Some( { skimmed_fee_msat_nonref.take() }) } else { None }; let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_some() { Some( { outbound_amount_forwarded_msat_nonref.take() }) } else { None }; nativeEvent::PaymentForwarded { prev_channel_id: local_prev_channel_id_nonref, next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, + prev_user_channel_id: local_prev_user_channel_id_nonref, + next_user_channel_id: local_next_user_channel_id_nonref, + total_fee_earned_msat: local_total_fee_earned_msat_nonref, + skimmed_fee_msat: local_skimmed_fee_msat_nonref, claim_from_onchain_tx: claim_from_onchain_tx_nonref, outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, } }, - Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + Event::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, ref channel_type, } => { let mut channel_id_nonref = Clone::clone(channel_id); let mut user_channel_id_nonref = Clone::clone(user_channel_id); let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = { /*former_temporary_channel_id_nonref*/ let former_temporary_channel_id_nonref_opt = former_temporary_channel_id_nonref; if former_temporary_channel_id_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ former_temporary_channel_id_nonref_opt.take() }.data) }})} }; + let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(former_temporary_channel_id_nonref.take_inner()) } }) }; let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut channel_type_nonref = Clone::clone(channel_type); + let mut local_channel_type_nonref = if channel_type_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_nonref.take_inner()) } }) }; nativeEvent::ChannelPending { - channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data), + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, user_channel_id: user_channel_id_nonref.into(), former_temporary_channel_id: local_former_temporary_channel_id_nonref, counterparty_node_id: counterparty_node_id_nonref.into_rust(), funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo_nonref), + channel_type: local_channel_type_nonref, } }, Event::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { @@ -2038,7 +2790,7 @@ impl Event { let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut channel_type_nonref = Clone::clone(channel_type); nativeEvent::ChannelReady { - channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data), + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, user_channel_id: user_channel_id_nonref.into(), counterparty_node_id: counterparty_node_id_nonref.into_rust(), channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, @@ -2055,7 +2807,7 @@ impl Event { let mut channel_funding_txo_nonref = Clone::clone(channel_funding_txo); let mut local_channel_funding_txo_nonref = if channel_funding_txo_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_funding_txo_nonref.take_inner()) } }) }; nativeEvent::ChannelClosed { - channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data), + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, user_channel_id: user_channel_id_nonref.into(), reason: reason_nonref.into_native(), counterparty_node_id: local_counterparty_node_id_nonref, @@ -2063,33 +2815,37 @@ impl Event { channel_funding_txo: local_channel_funding_txo_nonref, } }, - Event::DiscardFunding {ref channel_id, ref transaction, } => { + Event::DiscardFunding {ref channel_id, ref funding_info, } => { let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); + let mut funding_info_nonref = Clone::clone(funding_info); nativeEvent::DiscardFunding { - channel_id: ::lightning::ln::ChannelId(channel_id_nonref.data), - transaction: transaction_nonref.into_bitcoin(), + channel_id: *unsafe { Box::from_raw(channel_id_nonref.take_inner()) }, + funding_info: funding_info_nonref.into_native(), } }, - Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + Event::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, ref is_announced, ref params, } => { let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); let mut push_msat_nonref = Clone::clone(push_msat); let mut channel_type_nonref = Clone::clone(channel_type); + let mut is_announced_nonref = Clone::clone(is_announced); + let mut params_nonref = Clone::clone(params); nativeEvent::OpenChannelRequest { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_nonref.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_nonref.take_inner()) }, counterparty_node_id: counterparty_node_id_nonref.into_rust(), funding_satoshis: funding_satoshis_nonref, push_msat: push_msat_nonref, channel_type: *unsafe { Box::from_raw(channel_type_nonref.take_inner()) }, + is_announced: is_announced_nonref, + params: *unsafe { Box::from_raw(params_nonref.take_inner()) }, } }, Event::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); nativeEvent::HTLCHandlingFailed { - prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id_nonref.data), + prev_channel_id: *unsafe { Box::from_raw(prev_channel_id_nonref.take_inner()) }, failed_next_destination: failed_next_destination_nonref.into_native(), } }, @@ -2099,6 +2855,20 @@ impl Event { a_nonref.into_native(), ) }, + Event::OnionMessageIntercepted {ref peer_node_id, ref message, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + let mut message_nonref = Clone::clone(message); + nativeEvent::OnionMessageIntercepted { + peer_node_id: peer_node_id_nonref.into_rust(), + message: *unsafe { Box::from_raw(message_nonref.take_inner()) }, + } + }, + Event::OnionMessagePeerConnected {ref peer_node_id, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + nativeEvent::OnionMessagePeerConnected { + peer_node_id: peer_node_id_nonref.into_rust(), + } + }, } } #[allow(unused)] @@ -2106,22 +2876,31 @@ impl Event { match self { Event::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { nativeEvent::FundingGenerationReady { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id: counterparty_node_id.into_rust(), channel_value_satoshis: channel_value_satoshis, - output_script: ::bitcoin::blockdata::script::ScriptBuf::from(output_script.into_rust()), + output_script: ::bitcoin::script::ScriptBuf::from(output_script.into_rust()), user_channel_id: user_channel_id.into(), } }, + Event::FundingTxBroadcastSafe {mut channel_id, mut user_channel_id, mut funding_txo, mut counterparty_node_id, mut former_temporary_channel_id, } => { + nativeEvent::FundingTxBroadcastSafe { + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + user_channel_id: user_channel_id.into(), + funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), + counterparty_node_id: counterparty_node_id.into_rust(), + former_temporary_channel_id: *unsafe { Box::from_raw(former_temporary_channel_id.take_inner()) }, + } + }, Event::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; - let mut local_via_channel_id = { /*via_channel_id*/ let via_channel_id_opt = via_channel_id; if via_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ via_channel_id_opt.take() }.data) }})} }; + let mut local_via_channel_id = if via_channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(via_channel_id.take_inner()) } }) }; let mut local_via_user_channel_id = { /*via_user_channel_id*/ let via_user_channel_id_opt = via_user_channel_id; if via_user_channel_id_opt.is_none() { None } else { Some({ { { via_user_channel_id_opt.take() }.into() }})} }; let mut local_claim_deadline = if claim_deadline.is_some() { Some( { claim_deadline.take() }) } else { None }; nativeEvent::PaymentClaimable { receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), onion_fields: local_onion_fields, amount_msat: amount_msat, counterparty_skimmed_fee_msat: counterparty_skimmed_fee_msat, @@ -2131,17 +2910,19 @@ impl Event { claim_deadline: local_claim_deadline, } }, - Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => { + Event::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, mut onion_fields, } => { let mut local_receiver_node_id = if receiver_node_id.is_null() { None } else { Some( { receiver_node_id.into_rust() }) }; let mut local_htlcs = Vec::new(); for mut item in htlcs.into_rust().drain(..) { local_htlcs.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_some() { Some( { sender_intended_total_msat.take() }) } else { None }; + let mut local_onion_fields = if onion_fields.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(onion_fields.take_inner()) } }) }; nativeEvent::PaymentClaimed { receiver_node_id: local_receiver_node_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), amount_msat: amount_msat, purpose: purpose.into_native(), htlcs: local_htlcs, sender_intended_total_msat: local_sender_intended_total_msat, + onion_fields: local_onion_fields, } }, Event::ConnectionNeeded {mut node_id, mut addresses, } => { @@ -2151,9 +2932,14 @@ impl Event { addresses: local_addresses, } }, - Event::InvoiceRequestFailed {mut payment_id, } => { - nativeEvent::InvoiceRequestFailed { + Event::InvoiceReceived {mut payment_id, mut invoice, mut context, mut responder, } => { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + nativeEvent::InvoiceReceived { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), + invoice: *unsafe { Box::from_raw(invoice.take_inner()) }, + context: local_context, + responder: local_responder, } }, Event::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { @@ -2161,21 +2947,22 @@ impl Event { let mut local_fee_paid_msat = if fee_paid_msat.is_some() { Some( { fee_paid_msat.take() }) } else { None }; nativeEvent::PaymentSent { payment_id: local_payment_id, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), fee_paid_msat: local_fee_paid_msat, } }, Event::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; let mut local_reason = { /*reason*/ let reason_opt = reason; if reason_opt.is_none() { None } else { Some({ { { reason_opt.take() }.into_native() }})} }; nativeEvent::PaymentFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: local_payment_hash, reason: local_reason, } }, Event::PaymentPathSuccessful {mut payment_id, mut payment_hash, mut path, } => { - let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; nativeEvent::PaymentPathSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: local_payment_hash, @@ -2187,7 +2974,7 @@ impl Event { let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; nativeEvent::PaymentPathFailed { payment_id: local_payment_id, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), payment_failed_permanently: payment_failed_permanently, failure: failure.into_native(), path: *unsafe { Box::from_raw(path.take_inner()) }, @@ -2197,7 +2984,7 @@ impl Event { Event::ProbeSuccessful {mut payment_id, mut payment_hash, mut path, } => { nativeEvent::ProbeSuccessful { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), path: *unsafe { Box::from_raw(path.take_inner()) }, } }, @@ -2205,7 +2992,7 @@ impl Event { let mut local_short_channel_id = if short_channel_id.is_some() { Some( { short_channel_id.take() }) } else { None }; nativeEvent::ProbeFailed { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), path: *unsafe { Box::from_raw(path.take_inner()) }, short_channel_id: local_short_channel_id, } @@ -2219,45 +3006,53 @@ impl Event { nativeEvent::HTLCIntercepted { intercept_id: ::lightning::ln::channelmanager::InterceptId(intercept_id.data), requested_next_hop_scid: requested_next_hop_scid, - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), inbound_amount_msat: inbound_amount_msat, expected_outbound_amount_msat: expected_outbound_amount_msat, } }, Event::SpendableOutputs {mut outputs, mut channel_id, } => { let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_native() }); }; - let mut local_channel_id = { /*channel_id*/ let channel_id_opt = channel_id; if channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ channel_id_opt.take() }.data) }})} }; + let mut local_channel_id = if channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id.take_inner()) } }) }; nativeEvent::SpendableOutputs { outputs: local_outputs, channel_id: local_channel_id, } }, - Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = { /*prev_channel_id*/ let prev_channel_id_opt = prev_channel_id; if prev_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ prev_channel_id_opt.take() }.data) }})} }; - let mut local_next_channel_id = { /*next_channel_id*/ let next_channel_id_opt = next_channel_id; if next_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ next_channel_id_opt.take() }.data) }})} }; - let mut local_fee_earned_msat = if fee_earned_msat.is_some() { Some( { fee_earned_msat.take() }) } else { None }; + Event::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut prev_user_channel_id, mut next_user_channel_id, mut total_fee_earned_msat, mut skimmed_fee_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { + let mut local_prev_channel_id = if prev_channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(prev_channel_id.take_inner()) } }) }; + let mut local_next_channel_id = if next_channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(next_channel_id.take_inner()) } }) }; + let mut local_prev_user_channel_id = { /*prev_user_channel_id*/ let prev_user_channel_id_opt = prev_user_channel_id; if prev_user_channel_id_opt.is_none() { None } else { Some({ { { prev_user_channel_id_opt.take() }.into() }})} }; + let mut local_next_user_channel_id = { /*next_user_channel_id*/ let next_user_channel_id_opt = next_user_channel_id; if next_user_channel_id_opt.is_none() { None } else { Some({ { { next_user_channel_id_opt.take() }.into() }})} }; + let mut local_total_fee_earned_msat = if total_fee_earned_msat.is_some() { Some( { total_fee_earned_msat.take() }) } else { None }; + let mut local_skimmed_fee_msat = if skimmed_fee_msat.is_some() { Some( { skimmed_fee_msat.take() }) } else { None }; let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_some() { Some( { outbound_amount_forwarded_msat.take() }) } else { None }; nativeEvent::PaymentForwarded { prev_channel_id: local_prev_channel_id, next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, + prev_user_channel_id: local_prev_user_channel_id, + next_user_channel_id: local_next_user_channel_id, + total_fee_earned_msat: local_total_fee_earned_msat, + skimmed_fee_msat: local_skimmed_fee_msat, claim_from_onchain_tx: claim_from_onchain_tx, outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, } }, - Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = { /*former_temporary_channel_id*/ let former_temporary_channel_id_opt = former_temporary_channel_id; if former_temporary_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ former_temporary_channel_id_opt.take() }.data) }})} }; + Event::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, mut channel_type, } => { + let mut local_former_temporary_channel_id = if former_temporary_channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(former_temporary_channel_id.take_inner()) } }) }; + let mut local_channel_type = if channel_type.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type.take_inner()) } }) }; nativeEvent::ChannelPending { - channel_id: ::lightning::ln::ChannelId(channel_id.data), + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, user_channel_id: user_channel_id.into(), former_temporary_channel_id: local_former_temporary_channel_id, counterparty_node_id: counterparty_node_id.into_rust(), funding_txo: crate::c_types::C_to_bitcoin_outpoint(funding_txo), + channel_type: local_channel_type, } }, Event::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { nativeEvent::ChannelReady { - channel_id: ::lightning::ln::ChannelId(channel_id.data), + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, user_channel_id: user_channel_id.into(), counterparty_node_id: counterparty_node_id.into_rust(), channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, @@ -2268,7 +3063,7 @@ impl Event { let mut local_channel_capacity_sats = if channel_capacity_sats.is_some() { Some( { channel_capacity_sats.take() }) } else { None }; let mut local_channel_funding_txo = if channel_funding_txo.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_funding_txo.take_inner()) } }) }; nativeEvent::ChannelClosed { - channel_id: ::lightning::ln::ChannelId(channel_id.data), + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, user_channel_id: user_channel_id.into(), reason: reason.into_native(), counterparty_node_id: local_counterparty_node_id, @@ -2276,24 +3071,26 @@ impl Event { channel_funding_txo: local_channel_funding_txo, } }, - Event::DiscardFunding {mut channel_id, mut transaction, } => { + Event::DiscardFunding {mut channel_id, mut funding_info, } => { nativeEvent::DiscardFunding { - channel_id: ::lightning::ln::ChannelId(channel_id.data), - transaction: transaction.into_bitcoin(), + channel_id: *unsafe { Box::from_raw(channel_id.take_inner()) }, + funding_info: funding_info.into_native(), } }, - Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + Event::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, mut is_announced, mut params, } => { nativeEvent::OpenChannelRequest { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id: counterparty_node_id.into_rust(), funding_satoshis: funding_satoshis, push_msat: push_msat, channel_type: *unsafe { Box::from_raw(channel_type.take_inner()) }, + is_announced: is_announced, + params: *unsafe { Box::from_raw(params.take_inner()) }, } }, Event::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { nativeEvent::HTLCHandlingFailed { - prev_channel_id: ::lightning::ln::ChannelId(prev_channel_id.data), + prev_channel_id: *unsafe { Box::from_raw(prev_channel_id.take_inner()) }, failed_next_destination: failed_next_destination.into_native(), } }, @@ -2302,6 +3099,17 @@ impl Event { a.into_native(), ) }, + Event::OnionMessageIntercepted {mut peer_node_id, mut message, } => { + nativeEvent::OnionMessageIntercepted { + peer_node_id: peer_node_id.into_rust(), + message: *unsafe { Box::from_raw(message.take_inner()) }, + } + }, + Event::OnionMessagePeerConnected {mut peer_node_id, } => { + nativeEvent::OnionMessagePeerConnected { + peer_node_id: peer_node_id.into_rust(), + } + }, } } #[allow(unused)] @@ -2315,13 +3123,27 @@ impl Event { let mut output_script_nonref = Clone::clone(output_script); let mut user_channel_id_nonref = Clone::clone(user_channel_id); Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 }, + temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id_nonref), is_owned: true }, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), channel_value_satoshis: channel_value_satoshis_nonref, output_script: output_script_nonref.to_bytes().into(), user_channel_id: user_channel_id_nonref.into(), } }, + nativeEvent::FundingTxBroadcastSafe {ref channel_id, ref user_channel_id, ref funding_txo, ref counterparty_node_id, ref former_temporary_channel_id, } => { + let mut channel_id_nonref = Clone::clone(channel_id); + let mut user_channel_id_nonref = Clone::clone(user_channel_id); + let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); + let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); + Event::FundingTxBroadcastSafe { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + user_channel_id: user_channel_id_nonref.into(), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), + former_temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(former_temporary_channel_id_nonref), is_owned: true }, + } + }, nativeEvent::PaymentClaimable {ref receiver_node_id, ref payment_hash, ref onion_fields, ref amount_msat, ref counterparty_skimmed_fee_msat, ref purpose, ref via_channel_id, ref via_user_channel_id, ref claim_deadline, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; @@ -2332,7 +3154,7 @@ impl Event { let mut counterparty_skimmed_fee_msat_nonref = Clone::clone(counterparty_skimmed_fee_msat); let mut purpose_nonref = Clone::clone(purpose); let mut via_channel_id_nonref = Clone::clone(via_channel_id); - let mut local_via_channel_id_nonref = if via_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: via_channel_id_nonref.unwrap().0 } }) }; + let mut local_via_channel_id_nonref = crate::lightning::ln::types::ChannelId { inner: if via_channel_id_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((via_channel_id_nonref.unwrap())) } }, is_owned: true }; let mut via_user_channel_id_nonref = Clone::clone(via_user_channel_id); let mut local_via_user_channel_id_nonref = if via_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { via_user_channel_id_nonref.unwrap().into() }) }; let mut claim_deadline_nonref = Clone::clone(claim_deadline); @@ -2349,7 +3171,7 @@ impl Event { claim_deadline: local_claim_deadline_nonref, } }, - nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, } => { + nativeEvent::PaymentClaimed {ref receiver_node_id, ref payment_hash, ref amount_msat, ref purpose, ref htlcs, ref sender_intended_total_msat, ref onion_fields, } => { let mut receiver_node_id_nonref = Clone::clone(receiver_node_id); let mut local_receiver_node_id_nonref = if receiver_node_id_nonref.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id_nonref.unwrap())) } }; let mut payment_hash_nonref = Clone::clone(payment_hash); @@ -2359,6 +3181,8 @@ impl Event { let mut local_htlcs_nonref = Vec::new(); for mut item in htlcs_nonref.drain(..) { local_htlcs_nonref.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut sender_intended_total_msat_nonref = Clone::clone(sender_intended_total_msat); let mut local_sender_intended_total_msat_nonref = if sender_intended_total_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat_nonref.unwrap() }) }; + let mut onion_fields_nonref = Clone::clone(onion_fields); + let mut local_onion_fields_nonref = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields_nonref.unwrap())) } }, is_owned: true }; Event::PaymentClaimed { receiver_node_id: local_receiver_node_id_nonref, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, @@ -2366,6 +3190,7 @@ impl Event { purpose: crate::lightning::events::PaymentPurpose::native_into(purpose_nonref), htlcs: local_htlcs_nonref.into(), sender_intended_total_msat: local_sender_intended_total_msat_nonref, + onion_fields: local_onion_fields_nonref, } }, nativeEvent::ConnectionNeeded {ref node_id, ref addresses, } => { @@ -2377,10 +3202,18 @@ impl Event { addresses: local_addresses_nonref.into(), } }, - nativeEvent::InvoiceRequestFailed {ref payment_id, } => { + nativeEvent::InvoiceReceived {ref payment_id, ref invoice, ref context, ref responder, } => { let mut payment_id_nonref = Clone::clone(payment_id); - Event::InvoiceRequestFailed { + let mut invoice_nonref = Clone::clone(invoice); + let mut context_nonref = Clone::clone(context); + let mut local_context_nonref = if context_nonref.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context_nonref.unwrap()) }) }; + let mut responder_nonref = Clone::clone(responder); + let mut local_responder_nonref = crate::lightning::onion_message::messenger::Responder { inner: if responder_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder_nonref.unwrap())) } }, is_owned: true }; + Event::InvoiceReceived { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, + invoice: crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(invoice_nonref), is_owned: true }, + context: local_context_nonref, + responder: local_responder_nonref, } }, nativeEvent::PaymentSent {ref payment_id, ref payment_preimage, ref payment_hash, ref fee_paid_msat, } => { @@ -2400,11 +3233,12 @@ impl Event { nativeEvent::PaymentFailed {ref payment_id, ref payment_hash, ref reason, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); + let mut local_payment_hash_nonref = if payment_hash_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.unwrap().0 } }) }; let mut reason_nonref = Clone::clone(reason); let mut local_reason_nonref = if reason_nonref.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason_nonref.unwrap()) }) }; Event::PaymentFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id_nonref.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 }, + payment_hash: local_payment_hash_nonref, reason: local_reason_nonref, } }, @@ -2484,43 +3318,55 @@ impl Event { let mut outputs_nonref = Clone::clone(outputs); let mut local_outputs_nonref = Vec::new(); for mut item in outputs_nonref.drain(..) { local_outputs_nonref.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); }; let mut channel_id_nonref = Clone::clone(channel_id); - let mut local_channel_id_nonref = if channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.unwrap().0 } }) }; + let mut local_channel_id_nonref = crate::lightning::ln::types::ChannelId { inner: if channel_id_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_id_nonref.unwrap())) } }, is_owned: true }; Event::SpendableOutputs { outputs: local_outputs_nonref.into(), channel_id: local_channel_id_nonref, } }, - nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref fee_earned_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { + nativeEvent::PaymentForwarded {ref prev_channel_id, ref next_channel_id, ref prev_user_channel_id, ref next_user_channel_id, ref total_fee_earned_msat, ref skimmed_fee_msat, ref claim_from_onchain_tx, ref outbound_amount_forwarded_msat, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); - let mut local_prev_channel_id_nonref = if prev_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref.unwrap().0 } }) }; + let mut local_prev_channel_id_nonref = crate::lightning::ln::types::ChannelId { inner: if prev_channel_id_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((prev_channel_id_nonref.unwrap())) } }, is_owned: true }; let mut next_channel_id_nonref = Clone::clone(next_channel_id); - let mut local_next_channel_id_nonref = if next_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: next_channel_id_nonref.unwrap().0 } }) }; - let mut fee_earned_msat_nonref = Clone::clone(fee_earned_msat); - let mut local_fee_earned_msat_nonref = if fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat_nonref.unwrap() }) }; + let mut local_next_channel_id_nonref = crate::lightning::ln::types::ChannelId { inner: if next_channel_id_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((next_channel_id_nonref.unwrap())) } }, is_owned: true }; + let mut prev_user_channel_id_nonref = Clone::clone(prev_user_channel_id); + let mut local_prev_user_channel_id_nonref = if prev_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { prev_user_channel_id_nonref.unwrap().into() }) }; + let mut next_user_channel_id_nonref = Clone::clone(next_user_channel_id); + let mut local_next_user_channel_id_nonref = if next_user_channel_id_nonref.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { next_user_channel_id_nonref.unwrap().into() }) }; + let mut total_fee_earned_msat_nonref = Clone::clone(total_fee_earned_msat); + let mut local_total_fee_earned_msat_nonref = if total_fee_earned_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { total_fee_earned_msat_nonref.unwrap() }) }; + let mut skimmed_fee_msat_nonref = Clone::clone(skimmed_fee_msat); + let mut local_skimmed_fee_msat_nonref = if skimmed_fee_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { skimmed_fee_msat_nonref.unwrap() }) }; let mut claim_from_onchain_tx_nonref = Clone::clone(claim_from_onchain_tx); let mut outbound_amount_forwarded_msat_nonref = Clone::clone(outbound_amount_forwarded_msat); let mut local_outbound_amount_forwarded_msat_nonref = if outbound_amount_forwarded_msat_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat_nonref.unwrap() }) }; Event::PaymentForwarded { prev_channel_id: local_prev_channel_id_nonref, next_channel_id: local_next_channel_id_nonref, - fee_earned_msat: local_fee_earned_msat_nonref, + prev_user_channel_id: local_prev_user_channel_id_nonref, + next_user_channel_id: local_next_user_channel_id_nonref, + total_fee_earned_msat: local_total_fee_earned_msat_nonref, + skimmed_fee_msat: local_skimmed_fee_msat_nonref, claim_from_onchain_tx: claim_from_onchain_tx_nonref, outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat_nonref, } }, - nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, } => { + nativeEvent::ChannelPending {ref channel_id, ref user_channel_id, ref former_temporary_channel_id, ref counterparty_node_id, ref funding_txo, ref channel_type, } => { let mut channel_id_nonref = Clone::clone(channel_id); let mut user_channel_id_nonref = Clone::clone(user_channel_id); let mut former_temporary_channel_id_nonref = Clone::clone(former_temporary_channel_id); - let mut local_former_temporary_channel_id_nonref = if former_temporary_channel_id_nonref.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: former_temporary_channel_id_nonref.unwrap().0 } }) }; + let mut local_former_temporary_channel_id_nonref = crate::lightning::ln::types::ChannelId { inner: if former_temporary_channel_id_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((former_temporary_channel_id_nonref.unwrap())) } }, is_owned: true }; let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut funding_txo_nonref = Clone::clone(funding_txo); + let mut channel_type_nonref = Clone::clone(channel_type); + let mut local_channel_type_nonref = crate::lightning_types::features::ChannelTypeFeatures { inner: if channel_type_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type_nonref.unwrap())) } }, is_owned: true }; Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, user_channel_id: user_channel_id_nonref.into(), former_temporary_channel_id: local_former_temporary_channel_id_nonref, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo_nonref), + channel_type: local_channel_type_nonref, } }, nativeEvent::ChannelReady {ref channel_id, ref user_channel_id, ref counterparty_node_id, ref channel_type, } => { @@ -2529,10 +3375,10 @@ impl Event { let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut channel_type_nonref = Clone::clone(channel_type); Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, user_channel_id: user_channel_id_nonref.into(), counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, } }, nativeEvent::ChannelClosed {ref channel_id, ref user_channel_id, ref reason, ref counterparty_node_id, ref channel_capacity_sats, ref channel_funding_txo, } => { @@ -2546,7 +3392,7 @@ impl Event { let mut channel_funding_txo_nonref = Clone::clone(channel_funding_txo); let mut local_channel_funding_txo_nonref = crate::lightning::chain::transaction::OutPoint { inner: if channel_funding_txo_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_funding_txo_nonref.unwrap())) } }, is_owned: true }; Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, user_channel_id: user_channel_id_nonref.into(), reason: crate::lightning::events::ClosureReason::native_into(reason_nonref), counterparty_node_id: local_counterparty_node_id_nonref, @@ -2554,33 +3400,37 @@ impl Event { channel_funding_txo: local_channel_funding_txo_nonref, } }, - nativeEvent::DiscardFunding {ref channel_id, ref transaction, } => { + nativeEvent::DiscardFunding {ref channel_id, ref funding_info, } => { let mut channel_id_nonref = Clone::clone(channel_id); - let mut transaction_nonref = Clone::clone(transaction); + let mut funding_info_nonref = Clone::clone(funding_info); Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id_nonref.0 }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction_nonref), + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id_nonref), is_owned: true }, + funding_info: crate::lightning::events::FundingInfo::native_into(funding_info_nonref), } }, - nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, } => { + nativeEvent::OpenChannelRequest {ref temporary_channel_id, ref counterparty_node_id, ref funding_satoshis, ref push_msat, ref channel_type, ref is_announced, ref params, } => { let mut temporary_channel_id_nonref = Clone::clone(temporary_channel_id); let mut counterparty_node_id_nonref = Clone::clone(counterparty_node_id); let mut funding_satoshis_nonref = Clone::clone(funding_satoshis); let mut push_msat_nonref = Clone::clone(push_msat); let mut channel_type_nonref = Clone::clone(channel_type); + let mut is_announced_nonref = Clone::clone(is_announced); + let mut params_nonref = Clone::clone(params); Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id_nonref.0 }, + temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id_nonref), is_owned: true }, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id_nonref), funding_satoshis: funding_satoshis_nonref, push_msat: push_msat_nonref, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type_nonref), is_owned: true }, + is_announced: is_announced_nonref, + params: crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(params_nonref), is_owned: true }, } }, nativeEvent::HTLCHandlingFailed {ref prev_channel_id, ref failed_next_destination, } => { let mut prev_channel_id_nonref = Clone::clone(prev_channel_id); let mut failed_next_destination_nonref = Clone::clone(failed_next_destination); Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id_nonref.0 }, + prev_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(prev_channel_id_nonref), is_owned: true }, failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination_nonref), } }, @@ -2590,6 +3440,20 @@ impl Event { crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a_nonref), ) }, + nativeEvent::OnionMessageIntercepted {ref peer_node_id, ref message, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + let mut message_nonref = Clone::clone(message); + Event::OnionMessageIntercepted { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id_nonref), + message: crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(message_nonref), is_owned: true }, + } + }, + nativeEvent::OnionMessagePeerConnected {ref peer_node_id, } => { + let mut peer_node_id_nonref = Clone::clone(peer_node_id); + Event::OnionMessagePeerConnected { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id_nonref), + } + }, } } #[allow(unused)] @@ -2597,17 +3461,26 @@ impl Event { match native { nativeEvent::FundingGenerationReady {mut temporary_channel_id, mut counterparty_node_id, mut channel_value_satoshis, mut output_script, mut user_channel_id, } => { Event::FundingGenerationReady { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 }, + temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id), is_owned: true }, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), channel_value_satoshis: channel_value_satoshis, output_script: output_script.to_bytes().into(), user_channel_id: user_channel_id.into(), } }, + nativeEvent::FundingTxBroadcastSafe {mut channel_id, mut user_channel_id, mut funding_txo, mut counterparty_node_id, mut former_temporary_channel_id, } => { + Event::FundingTxBroadcastSafe { + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + user_channel_id: user_channel_id.into(), + funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo), + counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), + former_temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(former_temporary_channel_id), is_owned: true }, + } + }, nativeEvent::PaymentClaimable {mut receiver_node_id, mut payment_hash, mut onion_fields, mut amount_msat, mut counterparty_skimmed_fee_msat, mut purpose, mut via_channel_id, mut via_user_channel_id, mut claim_deadline, } => { let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; - let mut local_via_channel_id = if via_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: via_channel_id.unwrap().0 } }) }; + let mut local_via_channel_id = crate::lightning::ln::types::ChannelId { inner: if via_channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((via_channel_id.unwrap())) } }, is_owned: true }; let mut local_via_user_channel_id = if via_user_channel_id.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { via_user_channel_id.unwrap().into() }) }; let mut local_claim_deadline = if claim_deadline.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { claim_deadline.unwrap() }) }; Event::PaymentClaimable { @@ -2622,10 +3495,11 @@ impl Event { claim_deadline: local_claim_deadline, } }, - nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, } => { + nativeEvent::PaymentClaimed {mut receiver_node_id, mut payment_hash, mut amount_msat, mut purpose, mut htlcs, mut sender_intended_total_msat, mut onion_fields, } => { let mut local_receiver_node_id = if receiver_node_id.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(receiver_node_id.unwrap())) } }; let mut local_htlcs = Vec::new(); for mut item in htlcs.drain(..) { local_htlcs.push( { crate::lightning::events::ClaimedHTLC { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut local_sender_intended_total_msat = if sender_intended_total_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { sender_intended_total_msat.unwrap() }) }; + let mut local_onion_fields = crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: if onion_fields.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((onion_fields.unwrap())) } }, is_owned: true }; Event::PaymentClaimed { receiver_node_id: local_receiver_node_id, payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, @@ -2633,6 +3507,7 @@ impl Event { purpose: crate::lightning::events::PaymentPurpose::native_into(purpose), htlcs: local_htlcs.into(), sender_intended_total_msat: local_sender_intended_total_msat, + onion_fields: local_onion_fields, } }, nativeEvent::ConnectionNeeded {mut node_id, mut addresses, } => { @@ -2642,9 +3517,14 @@ impl Event { addresses: local_addresses.into(), } }, - nativeEvent::InvoiceRequestFailed {mut payment_id, } => { - Event::InvoiceRequestFailed { + nativeEvent::InvoiceReceived {mut payment_id, mut invoice, mut context, mut responder, } => { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + Event::InvoiceReceived { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, + invoice: crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(invoice), is_owned: true }, + context: local_context, + responder: local_responder, } }, nativeEvent::PaymentSent {mut payment_id, mut payment_preimage, mut payment_hash, mut fee_paid_msat, } => { @@ -2658,10 +3538,11 @@ impl Event { } }, nativeEvent::PaymentFailed {mut payment_id, mut payment_hash, mut reason, } => { + let mut local_payment_hash = if payment_hash.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: payment_hash.unwrap().0 } }) }; let mut local_reason = if reason.is_none() { crate::c_types::derived::COption_PaymentFailureReasonZ::None } else { crate::c_types::derived::COption_PaymentFailureReasonZ::Some( { crate::lightning::events::PaymentFailureReason::native_into(reason.unwrap()) }) }; Event::PaymentFailed { payment_id: crate::c_types::ThirtyTwoBytes { data: payment_id.0 }, - payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 }, + payment_hash: local_payment_hash, reason: local_reason, } }, @@ -2717,41 +3598,49 @@ impl Event { }, nativeEvent::SpendableOutputs {mut outputs, mut channel_id, } => { let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::lightning::sign::SpendableOutputDescriptor::native_into(item) }); }; - let mut local_channel_id = if channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: channel_id.unwrap().0 } }) }; + let mut local_channel_id = crate::lightning::ln::types::ChannelId { inner: if channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_id.unwrap())) } }, is_owned: true }; Event::SpendableOutputs { outputs: local_outputs.into(), channel_id: local_channel_id, } }, - nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut fee_earned_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { - let mut local_prev_channel_id = if prev_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: prev_channel_id.unwrap().0 } }) }; - let mut local_next_channel_id = if next_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: next_channel_id.unwrap().0 } }) }; - let mut local_fee_earned_msat = if fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { fee_earned_msat.unwrap() }) }; + nativeEvent::PaymentForwarded {mut prev_channel_id, mut next_channel_id, mut prev_user_channel_id, mut next_user_channel_id, mut total_fee_earned_msat, mut skimmed_fee_msat, mut claim_from_onchain_tx, mut outbound_amount_forwarded_msat, } => { + let mut local_prev_channel_id = crate::lightning::ln::types::ChannelId { inner: if prev_channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((prev_channel_id.unwrap())) } }, is_owned: true }; + let mut local_next_channel_id = crate::lightning::ln::types::ChannelId { inner: if next_channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((next_channel_id.unwrap())) } }, is_owned: true }; + let mut local_prev_user_channel_id = if prev_user_channel_id.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { prev_user_channel_id.unwrap().into() }) }; + let mut local_next_user_channel_id = if next_user_channel_id.is_none() { crate::c_types::derived::COption_U128Z::None } else { crate::c_types::derived::COption_U128Z::Some( { next_user_channel_id.unwrap().into() }) }; + let mut local_total_fee_earned_msat = if total_fee_earned_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { total_fee_earned_msat.unwrap() }) }; + let mut local_skimmed_fee_msat = if skimmed_fee_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { skimmed_fee_msat.unwrap() }) }; let mut local_outbound_amount_forwarded_msat = if outbound_amount_forwarded_msat.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { outbound_amount_forwarded_msat.unwrap() }) }; Event::PaymentForwarded { prev_channel_id: local_prev_channel_id, next_channel_id: local_next_channel_id, - fee_earned_msat: local_fee_earned_msat, + prev_user_channel_id: local_prev_user_channel_id, + next_user_channel_id: local_next_user_channel_id, + total_fee_earned_msat: local_total_fee_earned_msat, + skimmed_fee_msat: local_skimmed_fee_msat, claim_from_onchain_tx: claim_from_onchain_tx, outbound_amount_forwarded_msat: local_outbound_amount_forwarded_msat, } }, - nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, } => { - let mut local_former_temporary_channel_id = if former_temporary_channel_id.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: former_temporary_channel_id.unwrap().0 } }) }; + nativeEvent::ChannelPending {mut channel_id, mut user_channel_id, mut former_temporary_channel_id, mut counterparty_node_id, mut funding_txo, mut channel_type, } => { + let mut local_former_temporary_channel_id = crate::lightning::ln::types::ChannelId { inner: if former_temporary_channel_id.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((former_temporary_channel_id.unwrap())) } }, is_owned: true }; + let mut local_channel_type = crate::lightning_types::features::ChannelTypeFeatures { inner: if channel_type.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_type.unwrap())) } }, is_owned: true }; Event::ChannelPending { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, user_channel_id: user_channel_id.into(), former_temporary_channel_id: local_former_temporary_channel_id, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), funding_txo: crate::c_types::bitcoin_to_C_outpoint(&funding_txo), + channel_type: local_channel_type, } }, nativeEvent::ChannelReady {mut channel_id, mut user_channel_id, mut counterparty_node_id, mut channel_type, } => { Event::ChannelReady { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, user_channel_id: user_channel_id.into(), counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, } }, nativeEvent::ChannelClosed {mut channel_id, mut user_channel_id, mut reason, mut counterparty_node_id, mut channel_capacity_sats, mut channel_funding_txo, } => { @@ -2759,7 +3648,7 @@ impl Event { let mut local_channel_capacity_sats = if channel_capacity_sats.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { channel_capacity_sats.unwrap() }) }; let mut local_channel_funding_txo = crate::lightning::chain::transaction::OutPoint { inner: if channel_funding_txo.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((channel_funding_txo.unwrap())) } }, is_owned: true }; Event::ChannelClosed { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 }, + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, user_channel_id: user_channel_id.into(), reason: crate::lightning::events::ClosureReason::native_into(reason), counterparty_node_id: local_counterparty_node_id, @@ -2767,24 +3656,26 @@ impl Event { channel_funding_txo: local_channel_funding_txo, } }, - nativeEvent::DiscardFunding {mut channel_id, mut transaction, } => { + nativeEvent::DiscardFunding {mut channel_id, mut funding_info, } => { Event::DiscardFunding { - channel_id: crate::c_types::ThirtyTwoBytes { data: channel_id.0 }, - transaction: crate::c_types::Transaction::from_bitcoin(&transaction), + channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, + funding_info: crate::lightning::events::FundingInfo::native_into(funding_info), } }, - nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, } => { + nativeEvent::OpenChannelRequest {mut temporary_channel_id, mut counterparty_node_id, mut funding_satoshis, mut push_msat, mut channel_type, mut is_announced, mut params, } => { Event::OpenChannelRequest { - temporary_channel_id: crate::c_types::ThirtyTwoBytes { data: temporary_channel_id.0 }, + temporary_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(temporary_channel_id), is_owned: true }, counterparty_node_id: crate::c_types::PublicKey::from_rust(&counterparty_node_id), funding_satoshis: funding_satoshis, push_msat: push_msat, - channel_type: crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + channel_type: crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(channel_type), is_owned: true }, + is_announced: is_announced, + params: crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(params), is_owned: true }, } }, nativeEvent::HTLCHandlingFailed {mut prev_channel_id, mut failed_next_destination, } => { Event::HTLCHandlingFailed { - prev_channel_id: crate::c_types::ThirtyTwoBytes { data: prev_channel_id.0 }, + prev_channel_id: crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(prev_channel_id), is_owned: true }, failed_next_destination: crate::lightning::events::HTLCDestination::native_into(failed_next_destination), } }, @@ -2793,6 +3684,17 @@ impl Event { crate::lightning::events::bump_transaction::BumpTransactionEvent::native_into(a), ) }, + nativeEvent::OnionMessageIntercepted {mut peer_node_id, mut message, } => { + Event::OnionMessageIntercepted { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id), + message: crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(message), is_owned: true }, + } + }, + nativeEvent::OnionMessagePeerConnected {mut peer_node_id, } => { + Event::OnionMessagePeerConnected { + peer_node_id: crate::c_types::PublicKey::from_rust(&peer_node_id), + } + }, } } } @@ -2816,7 +3718,7 @@ pub(crate) extern "C" fn Event_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new FundingGenerationReady-variant Event -pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: crate::c_types::U128) -> Event { +pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, channel_value_satoshis: u64, output_script: crate::c_types::derived::CVec_u8Z, user_channel_id: crate::c_types::U128) -> Event { Event::FundingGenerationReady { temporary_channel_id, counterparty_node_id, @@ -2826,8 +3728,19 @@ pub extern "C" fn Event_funding_generation_ready(temporary_channel_id: crate::c_ } } #[no_mangle] +/// Utility method to constructs a new FundingTxBroadcastSafe-variant Event +pub extern "C" fn Event_funding_tx_broadcast_safe(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, funding_txo: crate::lightning::chain::transaction::OutPoint, counterparty_node_id: crate::c_types::PublicKey, former_temporary_channel_id: crate::lightning::ln::types::ChannelId) -> Event { + Event::FundingTxBroadcastSafe { + channel_id, + user_channel_id, + funding_txo, + counterparty_node_id, + former_temporary_channel_id, + } +} +#[no_mangle] /// Utility method to constructs a new PaymentClaimable-variant Event -pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, counterparty_skimmed_fee_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, via_user_channel_id: crate::c_types::derived::COption_U128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { +pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields, amount_msat: u64, counterparty_skimmed_fee_msat: u64, purpose: crate::lightning::events::PaymentPurpose, via_channel_id: crate::lightning::ln::types::ChannelId, via_user_channel_id: crate::c_types::derived::COption_U128Z, claim_deadline: crate::c_types::derived::COption_u32Z) -> Event { Event::PaymentClaimable { receiver_node_id, payment_hash, @@ -2842,7 +3755,7 @@ pub extern "C" fn Event_payment_claimable(receiver_node_id: crate::c_types::Publ } #[no_mangle] /// Utility method to constructs a new PaymentClaimed-variant Event -pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ, sender_intended_total_msat: crate::c_types::derived::COption_u64Z) -> Event { +pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::PublicKey, payment_hash: crate::c_types::ThirtyTwoBytes, amount_msat: u64, purpose: crate::lightning::events::PaymentPurpose, htlcs: crate::c_types::derived::CVec_ClaimedHTLCZ, sender_intended_total_msat: crate::c_types::derived::COption_u64Z, onion_fields: crate::lightning::ln::outbound_payment::RecipientOnionFields) -> Event { Event::PaymentClaimed { receiver_node_id, payment_hash, @@ -2850,6 +3763,7 @@ pub extern "C" fn Event_payment_claimed(receiver_node_id: crate::c_types::Public purpose, htlcs, sender_intended_total_msat, + onion_fields, } } #[no_mangle] @@ -2861,10 +3775,13 @@ pub extern "C" fn Event_connection_needed(node_id: crate::c_types::PublicKey, ad } } #[no_mangle] -/// Utility method to constructs a new InvoiceRequestFailed-variant Event -pub extern "C" fn Event_invoice_request_failed(payment_id: crate::c_types::ThirtyTwoBytes) -> Event { - Event::InvoiceRequestFailed { +/// Utility method to constructs a new InvoiceReceived-variant Event +pub extern "C" fn Event_invoice_received(payment_id: crate::c_types::ThirtyTwoBytes, invoice: crate::lightning::offers::invoice::Bolt12Invoice, context: crate::c_types::derived::COption_OffersContextZ, responder: crate::lightning::onion_message::messenger::Responder) -> Event { + Event::InvoiceReceived { payment_id, + invoice, + context, + responder, } } #[no_mangle] @@ -2879,7 +3796,7 @@ pub extern "C" fn Event_payment_sent(payment_id: crate::c_types::derived::COptio } #[no_mangle] /// Utility method to constructs a new PaymentFailed-variant Event -pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::ThirtyTwoBytes, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { +pub extern "C" fn Event_payment_failed(payment_id: crate::c_types::ThirtyTwoBytes, payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, reason: crate::c_types::derived::COption_PaymentFailureReasonZ) -> Event { Event::PaymentFailed { payment_id, payment_hash, @@ -2946,7 +3863,7 @@ pub extern "C" fn Event_htlcintercepted(intercept_id: crate::c_types::ThirtyTwoB } #[no_mangle] /// Utility method to constructs a new SpendableOutputs-variant Event -pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> Event { +pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, channel_id: crate::lightning::ln::types::ChannelId) -> Event { Event::SpendableOutputs { outputs, channel_id, @@ -2954,29 +3871,33 @@ pub extern "C" fn Event_spendable_outputs(outputs: crate::c_types::derived::CVec } #[no_mangle] /// Utility method to constructs a new PaymentForwarded-variant Event -pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, next_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, fee_earned_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { +pub extern "C" fn Event_payment_forwarded(prev_channel_id: crate::lightning::ln::types::ChannelId, next_channel_id: crate::lightning::ln::types::ChannelId, prev_user_channel_id: crate::c_types::derived::COption_U128Z, next_user_channel_id: crate::c_types::derived::COption_U128Z, total_fee_earned_msat: crate::c_types::derived::COption_u64Z, skimmed_fee_msat: crate::c_types::derived::COption_u64Z, claim_from_onchain_tx: bool, outbound_amount_forwarded_msat: crate::c_types::derived::COption_u64Z) -> Event { Event::PaymentForwarded { prev_channel_id, next_channel_id, - fee_earned_msat, + prev_user_channel_id, + next_user_channel_id, + total_fee_earned_msat, + skimmed_fee_msat, claim_from_onchain_tx, outbound_amount_forwarded_msat, } } #[no_mangle] /// Utility method to constructs a new ChannelPending-variant Event -pub extern "C" fn Event_channel_pending(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { +pub extern "C" fn Event_channel_pending(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, former_temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_txo: crate::lightning::chain::transaction::OutPoint, channel_type: crate::lightning_types::features::ChannelTypeFeatures) -> Event { Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, counterparty_node_id, funding_txo, + channel_type, } } #[no_mangle] /// Utility method to constructs a new ChannelReady-variant Event -pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { +pub extern "C" fn Event_channel_ready(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, counterparty_node_id: crate::c_types::PublicKey, channel_type: crate::lightning_types::features::ChannelTypeFeatures) -> Event { Event::ChannelReady { channel_id, user_channel_id, @@ -2986,7 +3907,7 @@ pub extern "C" fn Event_channel_ready(channel_id: crate::c_types::ThirtyTwoBytes } #[no_mangle] /// Utility method to constructs a new ChannelClosed-variant Event -pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoBytes, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason, counterparty_node_id: crate::c_types::PublicKey, channel_capacity_sats: crate::c_types::derived::COption_u64Z, channel_funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { +pub extern "C" fn Event_channel_closed(channel_id: crate::lightning::ln::types::ChannelId, user_channel_id: crate::c_types::U128, reason: crate::lightning::events::ClosureReason, counterparty_node_id: crate::c_types::PublicKey, channel_capacity_sats: crate::c_types::derived::COption_u64Z, channel_funding_txo: crate::lightning::chain::transaction::OutPoint) -> Event { Event::ChannelClosed { channel_id, user_channel_id, @@ -2998,26 +3919,28 @@ pub extern "C" fn Event_channel_closed(channel_id: crate::c_types::ThirtyTwoByte } #[no_mangle] /// Utility method to constructs a new DiscardFunding-variant Event -pub extern "C" fn Event_discard_funding(channel_id: crate::c_types::ThirtyTwoBytes, transaction: crate::c_types::Transaction) -> Event { +pub extern "C" fn Event_discard_funding(channel_id: crate::lightning::ln::types::ChannelId, funding_info: crate::lightning::events::FundingInfo) -> Event { Event::DiscardFunding { channel_id, - transaction, + funding_info, } } #[no_mangle] /// Utility method to constructs a new OpenChannelRequest-variant Event -pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::c_types::ThirtyTwoBytes, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning::ln::features::ChannelTypeFeatures) -> Event { +pub extern "C" fn Event_open_channel_request(temporary_channel_id: crate::lightning::ln::types::ChannelId, counterparty_node_id: crate::c_types::PublicKey, funding_satoshis: u64, push_msat: u64, channel_type: crate::lightning_types::features::ChannelTypeFeatures, is_announced: bool, params: crate::lightning::ln::msgs::ChannelParameters) -> Event { Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, funding_satoshis, push_msat, channel_type, + is_announced, + params, } } #[no_mangle] /// Utility method to constructs a new HTLCHandlingFailed-variant Event -pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::ThirtyTwoBytes, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { +pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::lightning::ln::types::ChannelId, failed_next_destination: crate::lightning::events::HTLCDestination) -> Event { Event::HTLCHandlingFailed { prev_channel_id, failed_next_destination, @@ -3028,6 +3951,21 @@ pub extern "C" fn Event_htlchandling_failed(prev_channel_id: crate::c_types::Thi pub extern "C" fn Event_bump_transaction(a: crate::lightning::events::bump_transaction::BumpTransactionEvent) -> Event { Event::BumpTransaction(a, ) } +#[no_mangle] +/// Utility method to constructs a new OnionMessageIntercepted-variant Event +pub extern "C" fn Event_onion_message_intercepted(peer_node_id: crate::c_types::PublicKey, message: crate::lightning::ln::msgs::OnionMessage) -> Event { + Event::OnionMessageIntercepted { + peer_node_id, + message, + } +} +#[no_mangle] +/// Utility method to constructs a new OnionMessagePeerConnected-variant Event +pub extern "C" fn Event_onion_message_peer_connected(peer_node_id: crate::c_types::PublicKey) -> Event { + Event::OnionMessagePeerConnected { + peer_node_id, + } +} /// Get a string which allows debug introspection of a Event object pub extern "C" fn Event_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::Event }).into()} @@ -3113,12 +4051,12 @@ pub enum MessageSendEvent { /// The message which should be sent. msg: crate::lightning::ln::msgs::Stfu, }, - /// Used to indicate that a splice message should be sent to the peer with the given node id. - SendSplice { + /// Used to indicate that a splice_init message should be sent to the peer with the given node id. + SendSpliceInit { /// The node_id of the node which should receive this message node_id: crate::c_types::PublicKey, /// The message which should be sent. - msg: crate::lightning::ln::msgs::Splice, + msg: crate::lightning::ln::msgs::SpliceInit, }, /// Used to indicate that a splice_ack message should be sent to the peer with the given node id. SendSpliceAck { @@ -3396,10 +4334,10 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } }, - MessageSendEvent::SendSplice {ref node_id, ref msg, } => { + MessageSendEvent::SendSpliceInit {ref node_id, ref msg, } => { let mut node_id_nonref = Clone::clone(node_id); let mut msg_nonref = Clone::clone(msg); - nativeMessageSendEvent::SendSplice { + nativeMessageSendEvent::SendSpliceInit { node_id: node_id_nonref.into_rust(), msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, } @@ -3674,8 +4612,8 @@ impl MessageSendEvent { msg: *unsafe { Box::from_raw(msg.take_inner()) }, } }, - MessageSendEvent::SendSplice {mut node_id, mut msg, } => { - nativeMessageSendEvent::SendSplice { + MessageSendEvent::SendSpliceInit {mut node_id, mut msg, } => { + nativeMessageSendEvent::SendSpliceInit { node_id: node_id.into_rust(), msg: *unsafe { Box::from_raw(msg.take_inner()) }, } @@ -3910,12 +4848,12 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, } }, - nativeMessageSendEvent::SendSplice {ref node_id, ref msg, } => { + nativeMessageSendEvent::SendSpliceInit {ref node_id, ref msg, } => { let mut node_id_nonref = Clone::clone(node_id); let mut msg_nonref = Clone::clone(msg); - MessageSendEvent::SendSplice { + MessageSendEvent::SendSpliceInit { node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), - msg: crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, + msg: crate::lightning::ln::msgs::SpliceInit { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, } }, nativeMessageSendEvent::SendSpliceAck {ref node_id, ref msg, } => { @@ -4188,10 +5126,10 @@ impl MessageSendEvent { msg: crate::lightning::ln::msgs::Stfu { inner: ObjOps::heap_alloc(msg), is_owned: true }, } }, - nativeMessageSendEvent::SendSplice {mut node_id, mut msg, } => { - MessageSendEvent::SendSplice { + nativeMessageSendEvent::SendSpliceInit {mut node_id, mut msg, } => { + MessageSendEvent::SendSpliceInit { node_id: crate::c_types::PublicKey::from_rust(&node_id), - msg: crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(msg), is_owned: true }, + msg: crate::lightning::ln::msgs::SpliceInit { inner: ObjOps::heap_alloc(msg), is_owned: true }, } }, nativeMessageSendEvent::SendSpliceAck {mut node_id, mut msg, } => { @@ -4440,9 +5378,9 @@ pub extern "C" fn MessageSendEvent_send_stfu(node_id: crate::c_types::PublicKey, } } #[no_mangle] -/// Utility method to constructs a new SendSplice-variant MessageSendEvent -pub extern "C" fn MessageSendEvent_send_splice(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::Splice) -> MessageSendEvent { - MessageSendEvent::SendSplice { +/// Utility method to constructs a new SendSpliceInit-variant MessageSendEvent +pub extern "C" fn MessageSendEvent_send_splice_init(node_id: crate::c_types::PublicKey, msg: crate::lightning::ln::msgs::SpliceInit) -> MessageSendEvent { + MessageSendEvent::SendSpliceInit { node_id, msg, } @@ -4706,17 +5644,26 @@ impl rustMessageSendEventsProvider for MessageSendEventsProvider { } } +pub struct MessageSendEventsProviderRef(MessageSendEventsProvider); +impl rustMessageSendEventsProvider for MessageSendEventsProviderRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.get_and_clear_pending_msg_events)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for MessageSendEventsProvider { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = MessageSendEventsProviderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const MessageSendEventsProviderRef) } } } impl core::ops::DerefMut for MessageSendEventsProvider { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut MessageSendEventsProviderRef { + unsafe { &mut *(self as *mut _ as *mut MessageSendEventsProviderRef) } } } /// Calls the free function if one is set @@ -4744,8 +5691,12 @@ impl Drop for MessageSendEventsProvider { /// /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s /// and replay any unhandled events on startup. An [`Event`] is considered handled when -/// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any -/// relevant changes to disk *before* returning. +/// [`process_pending_events`] returns `Ok(())`, thus handlers MUST fully handle [`Event`]s and +/// persist any relevant changes to disk *before* returning `Ok(())`. In case of an error (e.g., +/// persistence failure) implementors should return `Err(ReplayEvent())`, signalling to the +/// [`EventsProvider`] to replay unhandled events on the next invocation (generally immediately). +/// Note that some events might not be replayed, please refer to the documentation for +/// the individual [`Event`] variants for more detail. /// /// Further, because an application may crash between an [`Event`] being handled and the /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in @@ -4800,11 +5751,104 @@ impl Drop for EventsProvider { } } } + +use lightning::events::ReplayEvent as nativeReplayEventImport; +pub(crate) type nativeReplayEvent = nativeReplayEventImport; + +/// An error type that may be returned to LDK in order to safely abort event handling if it can't +/// currently succeed (e.g., due to a persistence failure). +/// +/// Depending on the type, LDK may ensure the event is persisted and will eventually be replayed. +/// Please refer to the documentation of each [`Event`] variant for more details. +#[must_use] +#[repr(C)] +pub struct ReplayEvent { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeReplayEvent, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ReplayEvent { + type Target = nativeReplayEvent; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplayEvent { } +unsafe impl core::marker::Sync for ReplayEvent { } +impl Drop for ReplayEvent { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReplayEvent>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ReplayEvent, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReplayEvent_free(this_obj: ReplayEvent) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReplayEvent_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReplayEvent) }; +} +#[allow(unused)] +impl ReplayEvent { + pub(crate) fn get_native_ref(&self) -> &'static nativeReplayEvent { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReplayEvent { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeReplayEvent { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new ReplayEvent given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReplayEvent_new() -> ReplayEvent { + ReplayEvent { inner: ObjOps::heap_alloc(lightning::events::ReplayEvent ( + )), is_owned: true } +} +impl Clone for ReplayEvent { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReplayEvent>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReplayEvent_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReplayEvent)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReplayEvent +pub extern "C" fn ReplayEvent_clone(orig: &ReplayEvent) -> ReplayEvent { + orig.clone() +} +/// Get a string which allows debug introspection of a ReplayEvent object +pub extern "C" fn ReplayEvent_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::events::ReplayEvent }).into()} /// A trait implemented for objects handling events from [`EventsProvider`]. /// /// An async variation also exists for implementations of [`EventsProvider`] that support async /// event handling. The async event handler should satisfy the generic bounds: `F: -/// core::future::Future, H: Fn(Event) -> F`. +/// core::future::Future>, H: Fn(Event) -> F`. #[repr(C)] pub struct EventHandler { /// An opaque pointer which is passed to your function implementations as an argument. @@ -4813,7 +5857,7 @@ pub struct EventHandler { /// Handles the given [`Event`]. /// /// See [`EventsProvider`] for details that must be considered when implementing this method. - pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event), + pub handle_event: extern "C" fn (this_arg: *const c_void, event: crate::lightning::events::Event) -> crate::c_types::derived::CResult_NoneReplayEventZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -4831,22 +5875,33 @@ pub(crate) fn EventHandler_clone_fields(orig: &EventHandler) -> EventHandler { use lightning::events::EventHandler as rustEventHandler; impl rustEventHandler for EventHandler { - fn handle_event(&self, mut event: lightning::events::Event) { - (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)) + fn handle_event(&self, mut event: lightning::events::Event) -> Result<(), lightning::events::ReplayEvent> { + let mut ret = (self.handle_event)(self.this_arg, crate::lightning::events::Event::native_into(event)); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } +} + +pub struct EventHandlerRef(EventHandler); +impl rustEventHandler for EventHandlerRef { + fn handle_event(&self, mut event: lightning::events::Event) -> Result<(), lightning::events::ReplayEvent> { + let mut ret = (self.0.handle_event)(self.0.this_arg, crate::lightning::events::Event::native_into(event)); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for EventHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = EventHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EventHandlerRef) } } } impl core::ops::DerefMut for EventHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut EventHandlerRef { + unsafe { &mut *(self as *mut _ as *mut EventHandlerRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/io.rs b/lightning-c-bindings/src/lightning/io.rs new file mode 100644 index 0000000..d0f9fec --- /dev/null +++ b/lightning-c-bindings/src/lightning/io.rs @@ -0,0 +1,19 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +/// Extension of the bitcoin::io module + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + diff --git a/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs b/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs new file mode 100644 index 0000000..1e91910 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/bolt11_payment.rs @@ -0,0 +1,56 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Convenient utilities for paying Lightning invoices. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount +/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or +/// [`ChannelManager::send_preflight_probes`]. +/// +/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the +/// same [`PaymentHash`] has never been paid before. +/// +/// Will always succeed unless the invoice has an amount specified, in which case +/// [`payment_parameters_from_invoice`] should be used. +/// +/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes +#[no_mangle] +pub extern "C" fn payment_parameters_from_zero_amount_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msat: u64) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + let mut ret = lightning::ln::bolt11_payment::payment_parameters_from_zero_amount_invoice(invoice.get_native_ref(), amount_msat); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using +/// [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. +/// +/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the +/// same [`PaymentHash`] has never been paid before. +/// +/// Will always succeed unless the invoice has no amount specified, in which case +/// [`payment_parameters_from_zero_amount_invoice`] should be used. +/// +/// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment +/// [`ChannelManager::send_preflight_probes`]: crate::ln::channelmanager::ChannelManager::send_preflight_probes +#[no_mangle] +pub extern "C" fn payment_parameters_from_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { + let mut ret = lightning::ln::bolt11_payment::payment_parameters_from_invoice(invoice.get_native_ref()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/ln/chan_utils.rs b/lightning-c-bindings/src/lightning/ln/chan_utils.rs index bb8a139..a5fa45c 100644 --- a/lightning-c-bindings/src/lightning/ln/chan_utils.rs +++ b/lightning-c-bindings/src/lightning/ln/chan_utils.rs @@ -52,14 +52,14 @@ pub static HTLC_TIMEOUT_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_u pub static HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT: u64 = lightning::ln::chan_utils::HTLC_SUCCESS_INPUT_ANCHOR_WITNESS_WEIGHT; /// Gets the weight for an HTLC-Success transaction. #[no_mangle] -pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { +pub extern "C" fn htlc_success_tx_weight(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> u64 { let mut ret = lightning::ln::chan_utils::htlc_success_tx_weight(channel_type_features.get_native_ref()); ret } /// Gets the weight for an HTLC-Timeout transaction. #[no_mangle] -pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> u64 { +pub extern "C" fn htlc_timeout_tx_weight(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> u64 { let mut ret = lightning::ln::chan_utils::htlc_timeout_tx_weight(channel_type_features.get_native_ref()); ret } @@ -186,7 +186,7 @@ pub extern "C" fn build_commitment_secret(commitment_seed: *const [u8; 32], mut /// Build a closing transaction #[no_mangle] pub extern "C" fn build_closing_transaction(mut to_holder_value_sat: u64, mut to_counterparty_value_sat: u64, mut to_holder_script: crate::c_types::derived::CVec_u8Z, mut to_counterparty_script: crate::c_types::derived::CVec_u8Z, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::c_types::Transaction { - let mut ret = lightning::ln::chan_utils::build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::blockdata::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); + let mut ret = lightning::ln::chan_utils::build_closing_transaction(::bitcoin::amount::Amount::from_sat(to_holder_value_sat), ::bitcoin::amount::Amount::from_sat(to_counterparty_value_sat), ::bitcoin::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); crate::c_types::Transaction::from_bitcoin(&ret) } @@ -214,6 +214,12 @@ pub struct CounterpartyCommitmentSecrets { pub is_owned: bool, } +impl core::ops::Deref for CounterpartyCommitmentSecrets { + type Target = nativeCounterpartyCommitmentSecrets; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyCommitmentSecrets { } +unsafe impl core::marker::Sync for CounterpartyCommitmentSecrets { } impl Drop for CounterpartyCommitmentSecrets { fn drop(&mut self) { if self.is_owned && !<*mut nativeCounterpartyCommitmentSecrets>::is_null(self.inner) { @@ -244,6 +250,9 @@ impl CounterpartyCommitmentSecrets { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for CounterpartyCommitmentSecrets { fn clone(&self) -> Self { @@ -310,7 +319,7 @@ pub extern "C" fn CounterpartyCommitmentSecrets_write(obj: &crate::lightning::ln } #[allow(unused)] pub(crate) extern "C" fn CounterpartyCommitmentSecrets_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyCommitmentSecrets) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCounterpartyCommitmentSecrets) }) } #[no_mangle] /// Read a CounterpartyCommitmentSecrets from a byte array, created by CounterpartyCommitmentSecrets_write @@ -369,6 +378,12 @@ pub struct TxCreationKeys { pub is_owned: bool, } +impl core::ops::Deref for TxCreationKeys { + type Target = nativeTxCreationKeys; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxCreationKeys { } +unsafe impl core::marker::Sync for TxCreationKeys { } impl Drop for TxCreationKeys { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxCreationKeys>::is_null(self.inner) { @@ -399,6 +414,9 @@ impl TxCreationKeys { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The broadcaster's per-commitment public key which was used to derive the other keys. #[no_mangle] @@ -509,7 +527,7 @@ pub extern "C" fn TxCreationKeys_write(obj: &crate::lightning::ln::chan_utils::T } #[allow(unused)] pub(crate) extern "C" fn TxCreationKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxCreationKeys) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeTxCreationKeys) }) } #[no_mangle] /// Read a TxCreationKeys from a byte array, created by TxCreationKeys_write @@ -538,6 +556,12 @@ pub struct ChannelPublicKeys { pub is_owned: bool, } +impl core::ops::Deref for ChannelPublicKeys { + type Target = nativeChannelPublicKeys; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelPublicKeys { } +unsafe impl core::marker::Sync for ChannelPublicKeys { } impl Drop for ChannelPublicKeys { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelPublicKeys>::is_null(self.inner) { @@ -568,6 +592,9 @@ impl ChannelPublicKeys { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The public key which is used to sign all commitment transactions, as it appears in the /// on-chain channel lock-in 2-of-2 multisig output. @@ -582,7 +609,7 @@ pub extern "C" fn ChannelPublicKeys_get_funding_pubkey(this_ptr: &ChannelPublicK pub extern "C" fn ChannelPublicKeys_set_funding_pubkey(this_ptr: &mut ChannelPublicKeys, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } -/// The base point which is used (with derive_public_revocation_key) to derive per-commitment +/// The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment /// revocation keys. This is combined with the per-commitment-secret generated by the /// counterparty to create a secret which the counterparty can reveal to revoke previous /// states. @@ -591,7 +618,7 @@ pub extern "C" fn ChannelPublicKeys_get_revocation_basepoint(this_ptr: &ChannelP let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; crate::lightning::ln::channel_keys::RevocationBasepoint { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channel_keys::RevocationBasepoint<>) as *mut _) }, is_owned: false } } -/// The base point which is used (with derive_public_revocation_key) to derive per-commitment +/// The base point which is used (with [`RevocationKey::from_basepoint`]) to derive per-commitment /// revocation keys. This is combined with the per-commitment-secret generated by the /// counterparty to create a secret which the counterparty can reveal to revoke previous /// states. @@ -702,7 +729,7 @@ pub extern "C" fn ChannelPublicKeys_write(obj: &crate::lightning::ln::chan_utils } #[allow(unused)] pub(crate) extern "C" fn ChannelPublicKeys_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelPublicKeys) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeChannelPublicKeys) }) } #[no_mangle] /// Read a ChannelPublicKeys from a byte array, created by ChannelPublicKeys_write @@ -745,7 +772,7 @@ pub extern "C" fn get_revokeable_redeemscript(revocation_key: &crate::lightning: /// Returns the script for the counterparty's output on a holder's commitment transaction based on /// the channel type. #[no_mangle] -pub extern "C" fn get_counterparty_payment_script(channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, mut payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn get_counterparty_payment_script(channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures, mut payment_key: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_u8Z { let mut ret = lightning::ln::chan_utils::get_counterparty_payment_script(channel_type_features.get_native_ref(), &payment_key.into_rust()); ret.to_bytes().into() } @@ -770,6 +797,12 @@ pub struct HTLCOutputInCommitment { pub is_owned: bool, } +impl core::ops::Deref for HTLCOutputInCommitment { + type Target = nativeHTLCOutputInCommitment; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCOutputInCommitment { } +unsafe impl core::marker::Sync for HTLCOutputInCommitment { } impl Drop for HTLCOutputInCommitment { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { @@ -800,6 +833,9 @@ impl HTLCOutputInCommitment { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Whether the HTLC was \"offered\" (ie outbound in relation to this commitment transaction). /// Note that this is not the same as whether it is ountbound *from us*. To determine that you @@ -851,7 +887,7 @@ pub extern "C" fn HTLCOutputInCommitment_get_payment_hash(this_ptr: &HTLCOutputI /// The hash of the preimage which unlocks this HTLC. #[no_mangle] pub extern "C" fn HTLCOutputInCommitment_set_payment_hash(this_ptr: &mut HTLCOutputInCommitment, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data); } /// The position within the commitment transactions' outputs. This may be None if the value is /// below the dust limit (in which case no output appears in the commitment transaction and the @@ -879,7 +915,7 @@ pub extern "C" fn HTLCOutputInCommitment_new(mut offered_arg: bool, mut amount_m offered: offered_arg, amount_msat: amount_msat_arg, cltv_expiry: cltv_expiry_arg, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data), transaction_output_index: local_transaction_output_index_arg, }), is_owned: true } } @@ -914,6 +950,16 @@ pub extern "C" fn HTLCOutputInCommitment_eq(a: &HTLCOutputInCommitment, b: &HTLC if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Converts HTLC's value with millisatoshi precision into [bitcoin::Amount] with satoshi precision. +/// Typically this conversion is needed when transitioning from LN into base-layer Bitcoin, +/// e. g. in commitment transactions. +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCOutputInCommitment_to_bitcoin_amount(this_arg: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.to_bitcoin_amount(); + ret.to_sat() +} + #[no_mangle] /// Serialize the HTLCOutputInCommitment object into a byte array which can be read by HTLCOutputInCommitment_read pub extern "C" fn HTLCOutputInCommitment_write(obj: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CVec_u8Z { @@ -921,7 +967,7 @@ pub extern "C" fn HTLCOutputInCommitment_write(obj: &crate::lightning::ln::chan_ } #[allow(unused)] pub(crate) extern "C" fn HTLCOutputInCommitment_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCOutputInCommitment) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeHTLCOutputInCommitment) }) } #[no_mangle] /// Read a HTLCOutputInCommitment from a byte array, created by HTLCOutputInCommitment_write @@ -933,7 +979,7 @@ pub extern "C" fn HTLCOutputInCommitment_read(ser: crate::c_types::u8slice) -> c /// Gets the witness redeemscript for an HTLC output in a commitment transaction. Note that htlc /// does not need to have its previous_output_index filled. #[no_mangle] -pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn get_htlc_redeemscript(htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures, keys: &crate::lightning::ln::chan_utils::TxCreationKeys) -> crate::c_types::derived::CVec_u8Z { let mut ret = lightning::ln::chan_utils::get_htlc_redeemscript(htlc.get_native_ref(), channel_type_features.get_native_ref(), keys.get_native_ref()); ret.to_bytes().into() } @@ -954,16 +1000,16 @@ pub extern "C" fn make_funding_redeemscript(mut broadcaster: crate::c_types::Pub /// Panics if htlc.transaction_output_index.is_none() (as such HTLCs do not appear in the /// commitment transaction). #[no_mangle] -pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures, broadcaster_delayed_payment_key: &crate::lightning::ln::channel_keys::DelayedPaymentKey, revocation_key: &crate::lightning::ln::channel_keys::RevocationKey) -> crate::c_types::Transaction { +pub extern "C" fn build_htlc_transaction(commitment_txid: *const [u8; 32], mut feerate_per_kw: u32, mut contest_delay: u16, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment, channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures, broadcaster_delayed_payment_key: &crate::lightning::ln::channel_keys::DelayedPaymentKey, revocation_key: &crate::lightning::ln::channel_keys::RevocationKey) -> crate::c_types::Transaction { let mut ret = lightning::ln::chan_utils::build_htlc_transaction(&::bitcoin::hash_types::Txid::from_slice(&unsafe { &*commitment_txid }[..]).unwrap(), feerate_per_kw, contest_delay, htlc.get_native_ref(), channel_type_features.get_native_ref(), broadcaster_delayed_payment_key.get_native_ref(), revocation_key.get_native_ref()); crate::c_types::Transaction::from_bitcoin(&ret) } /// Returns the witness required to satisfy and spend a HTLC input. #[no_mangle] -pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::ECDSASignature, mut remote_sig: crate::c_types::ECDSASignature, mut preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::Witness { - let mut local_preimage = { /*preimage*/ let preimage_opt = preimage; if preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ preimage_opt.take() }.data) }})} }; - let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, ::bitcoin::blockdata::script::Script::from_bytes(redeem_script.to_slice()), channel_type_features.get_native_ref()); +pub extern "C" fn build_htlc_input_witness(mut local_sig: crate::c_types::ECDSASignature, mut remote_sig: crate::c_types::ECDSASignature, mut preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut redeem_script: crate::c_types::u8slice, channel_type_features: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::Witness { + let mut local_preimage = { /*preimage*/ let preimage_opt = preimage; if preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ preimage_opt.take() }.data) }})} }; + let mut ret = lightning::ln::chan_utils::build_htlc_input_witness(&local_sig.into_rust(), &remote_sig.into_rust(), &local_preimage, ::bitcoin::script::Script::from_bytes(redeem_script.to_slice()), channel_type_features.get_native_ref()); crate::c_types::Witness::from_bitcoin(&ret) } @@ -1017,6 +1063,12 @@ pub struct ChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for ChannelTransactionParameters { + type Target = nativeChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelTransactionParameters { } +unsafe impl core::marker::Sync for ChannelTransactionParameters { } impl Drop for ChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelTransactionParameters>::is_null(self.inner) { @@ -1047,6 +1099,9 @@ impl ChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Holder public keys #[no_mangle] @@ -1122,14 +1177,14 @@ pub extern "C" fn ChannelTransactionParameters_set_funding_outpoint(this_ptr: &m /// This channel's type, as negotiated during channel open. For old objects where this field /// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_get_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn ChannelTransactionParameters_get_channel_type_features(this_ptr: &ChannelTransactionParameters) -> crate::lightning_types::features::ChannelTypeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type_features; - crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// This channel's type, as negotiated during channel open. For old objects where this field /// wasn't serialized, it will default to static_remote_key at deserialization. #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_ptr: &mut ChannelTransactionParameters, mut val: crate::lightning_types::features::ChannelTypeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Constructs a new ChannelTransactionParameters given each field @@ -1138,7 +1193,7 @@ pub extern "C" fn ChannelTransactionParameters_set_channel_type_features(this_pt /// Note that funding_outpoint_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_features_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> ChannelTransactionParameters { +pub extern "C" fn ChannelTransactionParameters_new(mut holder_pubkeys_arg: crate::lightning::ln::chan_utils::ChannelPublicKeys, mut holder_selected_contest_delay_arg: u16, mut is_outbound_from_holder_arg: bool, mut counterparty_parameters_arg: crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, mut funding_outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_features_arg: crate::lightning_types::features::ChannelTypeFeatures) -> ChannelTransactionParameters { let mut local_counterparty_parameters_arg = if counterparty_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(counterparty_parameters_arg.take_inner()) } }) }; let mut local_funding_outpoint_arg = if funding_outpoint_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_outpoint_arg.take_inner()) } }) }; ChannelTransactionParameters { inner: ObjOps::heap_alloc(nativeChannelTransactionParameters { @@ -1211,6 +1266,12 @@ pub struct CounterpartyChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for CounterpartyChannelTransactionParameters { + type Target = nativeCounterpartyChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyChannelTransactionParameters { } +unsafe impl core::marker::Sync for CounterpartyChannelTransactionParameters { } impl Drop for CounterpartyChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { @@ -1241,6 +1302,9 @@ impl CounterpartyChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Counter-party public keys #[no_mangle] @@ -1351,7 +1415,7 @@ pub extern "C" fn CounterpartyChannelTransactionParameters_write(obj: &crate::li } #[allow(unused)] pub(crate) extern "C" fn CounterpartyChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyChannelTransactionParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCounterpartyChannelTransactionParameters) }) } #[no_mangle] /// Read a CounterpartyChannelTransactionParameters from a byte array, created by CounterpartyChannelTransactionParameters_write @@ -1367,7 +1431,7 @@ pub extern "C" fn ChannelTransactionParameters_write(obj: &crate::lightning::ln: } #[allow(unused)] pub(crate) extern "C" fn ChannelTransactionParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTransactionParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeChannelTransactionParameters) }) } #[no_mangle] /// Read a ChannelTransactionParameters from a byte array, created by ChannelTransactionParameters_write @@ -1378,7 +1442,7 @@ pub extern "C" fn ChannelTransactionParameters_read(ser: crate::c_types::u8slice } use lightning::ln::chan_utils::DirectedChannelTransactionParameters as nativeDirectedChannelTransactionParametersImport; -pub(crate) type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static>; +pub(crate) type nativeDirectedChannelTransactionParameters = nativeDirectedChannelTransactionParametersImport<'static, >; /// Static channel fields used to build transactions given per-commitment fields, organized by /// broadcaster/countersignatory. @@ -1400,6 +1464,12 @@ pub struct DirectedChannelTransactionParameters { pub is_owned: bool, } +impl core::ops::Deref for DirectedChannelTransactionParameters { + type Target = nativeDirectedChannelTransactionParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DirectedChannelTransactionParameters { } +unsafe impl core::marker::Sync for DirectedChannelTransactionParameters { } impl Drop for DirectedChannelTransactionParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeDirectedChannelTransactionParameters>::is_null(self.inner) { @@ -1430,6 +1500,9 @@ impl DirectedChannelTransactionParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Get the channel pubkeys for the broadcaster #[must_use] @@ -1478,9 +1551,9 @@ pub extern "C" fn DirectedChannelTransactionParameters_funding_outpoint(this_arg /// Whether to use anchors for this channel #[must_use] #[no_mangle] -pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn DirectedChannelTransactionParameters_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::DirectedChannelTransactionParameters) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } @@ -1505,6 +1578,12 @@ pub struct HolderCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for HolderCommitmentTransaction { + type Target = nativeHolderCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HolderCommitmentTransaction { } +unsafe impl core::marker::Sync for HolderCommitmentTransaction { } impl Drop for HolderCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { @@ -1535,6 +1614,9 @@ impl HolderCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Our counterparty's signature for the transaction #[no_mangle] @@ -1591,7 +1673,7 @@ pub extern "C" fn HolderCommitmentTransaction_write(obj: &crate::lightning::ln:: } #[allow(unused)] pub(crate) extern "C" fn HolderCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHolderCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeHolderCommitmentTransaction) }) } #[no_mangle] /// Read a HolderCommitmentTransaction from a byte array, created by HolderCommitmentTransaction_write @@ -1630,6 +1712,12 @@ pub struct BuiltCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for BuiltCommitmentTransaction { + type Target = nativeBuiltCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BuiltCommitmentTransaction { } +unsafe impl core::marker::Sync for BuiltCommitmentTransaction { } impl Drop for BuiltCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { @@ -1660,6 +1748,9 @@ impl BuiltCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The commitment transaction #[no_mangle] @@ -1727,7 +1818,7 @@ pub extern "C" fn BuiltCommitmentTransaction_write(obj: &crate::lightning::ln::c } #[allow(unused)] pub(crate) extern "C" fn BuiltCommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBuiltCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeBuiltCommitmentTransaction) }) } #[no_mangle] /// Read a BuiltCommitmentTransaction from a byte array, created by BuiltCommitmentTransaction_write @@ -1742,7 +1833,7 @@ pub extern "C" fn BuiltCommitmentTransaction_read(ser: crate::c_types::u8slice) #[must_use] #[no_mangle] pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } } @@ -1750,7 +1841,7 @@ pub extern "C" fn BuiltCommitmentTransaction_get_sighash_all(this_arg: &crate::l #[must_use] #[no_mangle] pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ECDSASignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_counterparty_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -1758,7 +1849,7 @@ pub extern "C" fn BuiltCommitmentTransaction_sign_counterparty_commitment(this_a #[must_use] #[no_mangle] pub extern "C" fn BuiltCommitmentTransaction_sign_holder_commitment(this_arg: &crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64, entropy_source: &crate::lightning::sign::EntropySource) -> crate::c_types::ECDSASignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_holder_commitment(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, entropy_source, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -1786,6 +1877,12 @@ pub struct ClosingTransaction { pub is_owned: bool, } +impl core::ops::Deref for ClosingTransaction { + type Target = nativeClosingTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingTransaction { } +unsafe impl core::marker::Sync for ClosingTransaction { } impl Drop for ClosingTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingTransaction>::is_null(self.inner) { @@ -1816,6 +1913,9 @@ impl ClosingTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ClosingTransaction { fn clone(&self) -> Self { @@ -1859,7 +1959,7 @@ pub extern "C" fn ClosingTransaction_eq(a: &ClosingTransaction, b: &ClosingTrans #[must_use] #[no_mangle] pub extern "C" fn ClosingTransaction_new(mut to_holder_value_sat: u64, mut to_counterparty_value_sat: u64, mut to_holder_script: crate::c_types::derived::CVec_u8Z, mut to_counterparty_script: crate::c_types::derived::CVec_u8Z, mut funding_outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::lightning::ln::chan_utils::ClosingTransaction { - let mut ret = lightning::ln::chan_utils::ClosingTransaction::new(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::blockdata::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::blockdata::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); + let mut ret = lightning::ln::chan_utils::ClosingTransaction::new(to_holder_value_sat, to_counterparty_value_sat, ::bitcoin::script::ScriptBuf::from(to_holder_script.into_rust()), ::bitcoin::script::ScriptBuf::from(to_counterparty_script.into_rust()), crate::c_types::C_to_bitcoin_outpoint(funding_outpoint)); crate::lightning::ln::chan_utils::ClosingTransaction { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1924,7 +2024,7 @@ pub extern "C" fn ClosingTransaction_to_counterparty_script(this_arg: &crate::li use lightning::ln::chan_utils::TrustedClosingTransaction as nativeTrustedClosingTransactionImport; -pub(crate) type nativeTrustedClosingTransaction = nativeTrustedClosingTransactionImport<'static>; +pub(crate) type nativeTrustedClosingTransaction = nativeTrustedClosingTransactionImport<'static, >; /// A wrapper on ClosingTransaction indicating that the built bitcoin /// transaction is trusted. @@ -1947,6 +2047,12 @@ pub struct TrustedClosingTransaction { pub is_owned: bool, } +impl core::ops::Deref for TrustedClosingTransaction { + type Target = nativeTrustedClosingTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrustedClosingTransaction { } +unsafe impl core::marker::Sync for TrustedClosingTransaction { } impl Drop for TrustedClosingTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrustedClosingTransaction>::is_null(self.inner) { @@ -1977,6 +2083,9 @@ impl TrustedClosingTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The pre-built Bitcoin commitment transaction #[must_use] @@ -1992,7 +2101,7 @@ pub extern "C" fn TrustedClosingTransaction_built_transaction(this_arg: &crate:: #[must_use] #[no_mangle] pub extern "C" fn TrustedClosingTransaction_get_sighash_all(this_arg: &crate::lightning::ln::chan_utils::TrustedClosingTransaction, mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_sighash_all(::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis); crate::c_types::ThirtyTwoBytes { data: ret.as_ref().clone() } } @@ -2001,7 +2110,7 @@ pub extern "C" fn TrustedClosingTransaction_get_sighash_all(this_arg: &crate::li #[must_use] #[no_mangle] pub extern "C" fn TrustedClosingTransaction_sign(this_arg: &crate::lightning::ln::chan_utils::TrustedClosingTransaction, funding_key: *const [u8; 32], mut funding_redeemscript: crate::c_types::u8slice, mut channel_value_satoshis: u64) -> crate::c_types::ECDSASignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::blockdata::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign(&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *funding_key}[..]).unwrap(), ::bitcoin::script::Script::from_bytes(funding_redeemscript.to_slice()), channel_value_satoshis, secp256k1::global::SECP256K1); crate::c_types::ECDSASignature::from_rust(&ret) } @@ -2030,6 +2139,12 @@ pub struct CommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for CommitmentTransaction { + type Target = nativeCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentTransaction { } +unsafe impl core::marker::Sync for CommitmentTransaction { } impl Drop for CommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentTransaction>::is_null(self.inner) { @@ -2060,6 +2175,9 @@ impl CommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for CommitmentTransaction { fn clone(&self) -> Self { @@ -2090,7 +2208,7 @@ pub extern "C" fn CommitmentTransaction_write(obj: &crate::lightning::ln::chan_u } #[allow(unused)] pub(crate) extern "C" fn CommitmentTransaction_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentTransaction) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::chan_utils::nativeCommitmentTransaction) }) } #[no_mangle] /// Read a CommitmentTransaction from a byte array, created by CommitmentTransaction_write @@ -2168,7 +2286,7 @@ pub extern "C" fn CommitmentTransaction_verify(this_arg: &crate::lightning::ln:: use lightning::ln::chan_utils::TrustedCommitmentTransaction as nativeTrustedCommitmentTransactionImport; -pub(crate) type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static>; +pub(crate) type nativeTrustedCommitmentTransaction = nativeTrustedCommitmentTransactionImport<'static, >; /// A wrapper on CommitmentTransaction indicating that the derived fields (the built bitcoin /// transaction and the transaction creation keys) are trusted. @@ -2191,6 +2309,12 @@ pub struct TrustedCommitmentTransaction { pub is_owned: bool, } +impl core::ops::Deref for TrustedCommitmentTransaction { + type Target = nativeTrustedCommitmentTransaction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrustedCommitmentTransaction { } +unsafe impl core::marker::Sync for TrustedCommitmentTransaction { } impl Drop for TrustedCommitmentTransaction { fn drop(&mut self) { if self.is_owned && !<*mut nativeTrustedCommitmentTransaction>::is_null(self.inner) { @@ -2221,6 +2345,9 @@ impl TrustedCommitmentTransaction { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The transaction ID of the built Bitcoin transaction #[must_use] @@ -2249,9 +2376,9 @@ pub extern "C" fn TrustedCommitmentTransaction_keys(this_arg: &crate::lightning: /// Should anchors be used. #[must_use] #[no_mangle] -pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn TrustedCommitmentTransaction_channel_type_features(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _) }, is_owned: false } } /// Get a signature for each HTLC which was included in the commitment transaction (ie for @@ -2299,7 +2426,7 @@ pub extern "C" fn TrustedCommitmentTransaction_revokeable_output_index(this_arg: #[must_use] #[no_mangle] pub extern "C" fn TrustedCommitmentTransaction_build_to_local_justice_tx(this_arg: &crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, mut feerate_per_kw: u64, mut destination_script: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.build_to_local_justice_tx(feerate_per_kw, ::bitcoin::blockdata::script::ScriptBuf::from(destination_script.into_rust())); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.build_to_local_justice_tx(feerate_per_kw, ::bitcoin::script::ScriptBuf::from(destination_script.into_rust())); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/ln/channel_keys.rs b/lightning-c-bindings/src/lightning/ln/channel_keys.rs index 8fa82dc..a713ef0 100644 --- a/lightning-c-bindings/src/lightning/ln/channel_keys.rs +++ b/lightning-c-bindings/src/lightning/ln/channel_keys.rs @@ -42,6 +42,12 @@ pub struct DelayedPaymentBasepoint { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentBasepoint { + type Target = nativeDelayedPaymentBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentBasepoint { } +unsafe impl core::marker::Sync for DelayedPaymentBasepoint { } impl Drop for DelayedPaymentBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentBasepoint>::is_null(self.inner) { @@ -72,6 +78,9 @@ impl DelayedPaymentBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn DelayedPaymentBasepoint_get_a(this_ptr: &DelayedPaymentBasepoint) -> crate::c_types::PublicKey { @@ -139,6 +148,14 @@ pub extern "C" fn DelayedPaymentBasepoint_to_public_key(this_arg: &crate::lightn crate::c_types::PublicKey::from_rust(&ret) } +///Derives the \"tweak\" used in calculate [`DelayedPaymentKey::from_basepoint`].\n\n[`DelayedPaymentKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. +#[must_use] +#[no_mangle] +pub extern "C" fn DelayedPaymentBasepoint_derive_add_tweak(this_arg: &crate::lightning::ln::channel_keys::DelayedPaymentBasepoint, mut per_commitment_point: crate::c_types::PublicKey) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_add_tweak(&per_commitment_point.into_rust()); + crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() } +} + #[no_mangle] /// Serialize the DelayedPaymentBasepoint object into a byte array which can be read by DelayedPaymentBasepoint_read pub extern "C" fn DelayedPaymentBasepoint_write(obj: &crate::lightning::ln::channel_keys::DelayedPaymentBasepoint) -> crate::c_types::derived::CVec_u8Z { @@ -146,7 +163,7 @@ pub extern "C" fn DelayedPaymentBasepoint_write(obj: &crate::lightning::ln::chan } #[allow(unused)] pub(crate) extern "C" fn DelayedPaymentBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeDelayedPaymentBasepoint) }) } #[no_mangle] /// Read a DelayedPaymentBasepoint from a byte array, created by DelayedPaymentBasepoint_write @@ -166,7 +183,7 @@ pub(crate) type nativeDelayedPaymentKey = nativeDelayedPaymentKeyImport; /// punish and claim all the channel funds if the state broadcasted was previously revoked. /// /// [See the BOLT specs] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) +/// /// for more information on key derivation details. #[must_use] #[repr(C)] @@ -183,6 +200,12 @@ pub struct DelayedPaymentKey { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentKey { + type Target = nativeDelayedPaymentKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentKey { } +unsafe impl core::marker::Sync for DelayedPaymentKey { } impl Drop for DelayedPaymentKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentKey>::is_null(self.inner) { @@ -213,6 +236,9 @@ impl DelayedPaymentKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn DelayedPaymentKey_get_a(this_ptr: &DelayedPaymentKey) -> crate::c_types::PublicKey { @@ -293,7 +319,7 @@ pub extern "C" fn DelayedPaymentKey_write(obj: &crate::lightning::ln::channel_ke } #[allow(unused)] pub(crate) extern "C" fn DelayedPaymentKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeDelayedPaymentKey) }) } #[no_mangle] /// Read a DelayedPaymentKey from a byte array, created by DelayedPaymentKey_write @@ -326,6 +352,12 @@ pub struct HtlcBasepoint { pub is_owned: bool, } +impl core::ops::Deref for HtlcBasepoint { + type Target = nativeHtlcBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HtlcBasepoint { } +unsafe impl core::marker::Sync for HtlcBasepoint { } impl Drop for HtlcBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeHtlcBasepoint>::is_null(self.inner) { @@ -356,6 +388,9 @@ impl HtlcBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn HtlcBasepoint_get_a(this_ptr: &HtlcBasepoint) -> crate::c_types::PublicKey { @@ -423,6 +458,14 @@ pub extern "C" fn HtlcBasepoint_to_public_key(this_arg: &crate::lightning::ln::c crate::c_types::PublicKey::from_rust(&ret) } +///Derives the \"tweak\" used in calculate [`HtlcKey::from_basepoint`].\n\n[`HtlcKey::from_basepoint`] calculates a private key as:\n`privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)`\n\nThis calculates the hash part in the tweak derivation process, which is used to\nensure that each key is unique and cannot be guessed by an external party. +#[must_use] +#[no_mangle] +pub extern "C" fn HtlcBasepoint_derive_add_tweak(this_arg: &crate::lightning::ln::channel_keys::HtlcBasepoint, mut per_commitment_point: crate::c_types::PublicKey) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_add_tweak(&per_commitment_point.into_rust()); + crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() } +} + #[no_mangle] /// Serialize the HtlcBasepoint object into a byte array which can be read by HtlcBasepoint_read pub extern "C" fn HtlcBasepoint_write(obj: &crate::lightning::ln::channel_keys::HtlcBasepoint) -> crate::c_types::derived::CVec_u8Z { @@ -430,7 +473,7 @@ pub extern "C" fn HtlcBasepoint_write(obj: &crate::lightning::ln::channel_keys:: } #[allow(unused)] pub(crate) extern "C" fn HtlcBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHtlcBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeHtlcBasepoint) }) } #[no_mangle] /// Read a HtlcBasepoint from a byte array, created by HtlcBasepoint_write @@ -450,7 +493,7 @@ pub(crate) type nativeHtlcKey = nativeHtlcKeyImport; /// Thus, both channel counterparties' HTLC keys will appears in each HTLC output's script. /// /// [See the BOLT specs] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation) +/// /// for more information on key derivation details. #[must_use] #[repr(C)] @@ -467,6 +510,12 @@ pub struct HtlcKey { pub is_owned: bool, } +impl core::ops::Deref for HtlcKey { + type Target = nativeHtlcKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HtlcKey { } +unsafe impl core::marker::Sync for HtlcKey { } impl Drop for HtlcKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeHtlcKey>::is_null(self.inner) { @@ -497,6 +546,9 @@ impl HtlcKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn HtlcKey_get_a(this_ptr: &HtlcKey) -> crate::c_types::PublicKey { @@ -577,7 +629,7 @@ pub extern "C" fn HtlcKey_write(obj: &crate::lightning::ln::channel_keys::HtlcKe } #[allow(unused)] pub(crate) extern "C" fn HtlcKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHtlcKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeHtlcKey) }) } #[no_mangle] /// Read a HtlcKey from a byte array, created by HtlcKey_write @@ -586,6 +638,15 @@ pub extern "C" fn HtlcKey_read(ser: crate::c_types::u8slice) -> crate::c_types:: let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_keys::HtlcKey { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } +/// Adds a tweak to a public key to derive a new public key. +/// +/// May panic if `tweak` is not the output of a SHA-256 hash. +#[no_mangle] +pub extern "C" fn add_public_key_tweak(mut base_point: crate::c_types::PublicKey, tweak: *const [u8; 32]) -> crate::c_types::PublicKey { + let mut ret = lightning::ln::channel_keys::add_public_key_tweak(secp256k1::global::SECP256K1, &base_point.into_rust(), &::bitcoin::hashes::sha256::Hash::from_slice(&unsafe { &*tweak }[..]).unwrap()); + crate::c_types::PublicKey::from_rust(&ret) +} + use lightning::ln::channel_keys::RevocationBasepoint as nativeRevocationBasepointImport; pub(crate) type nativeRevocationBasepoint = nativeRevocationBasepointImport; @@ -607,6 +668,12 @@ pub struct RevocationBasepoint { pub is_owned: bool, } +impl core::ops::Deref for RevocationBasepoint { + type Target = nativeRevocationBasepoint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevocationBasepoint { } +unsafe impl core::marker::Sync for RevocationBasepoint { } impl Drop for RevocationBasepoint { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevocationBasepoint>::is_null(self.inner) { @@ -637,6 +704,9 @@ impl RevocationBasepoint { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn RevocationBasepoint_get_a(this_ptr: &RevocationBasepoint) -> crate::c_types::PublicKey { @@ -711,7 +781,7 @@ pub extern "C" fn RevocationBasepoint_write(obj: &crate::lightning::ln::channel_ } #[allow(unused)] pub(crate) extern "C" fn RevocationBasepoint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevocationBasepoint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeRevocationBasepoint) }) } #[no_mangle] /// Read a RevocationBasepoint from a byte array, created by RevocationBasepoint_write @@ -731,7 +801,7 @@ pub(crate) type nativeRevocationKey = nativeRevocationKeyImport; /// per_commitment_point which is used in both commitment and HTLC transactions. /// /// See [the BOLT spec for derivation details] -/// (https://github.com/lightning/bolts/blob/master/03-transactions.md#revocationpubkey-derivation) +/// #[must_use] #[repr(C)] pub struct RevocationKey { @@ -747,6 +817,12 @@ pub struct RevocationKey { pub is_owned: bool, } +impl core::ops::Deref for RevocationKey { + type Target = nativeRevocationKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevocationKey { } +unsafe impl core::marker::Sync for RevocationKey { } impl Drop for RevocationKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevocationKey>::is_null(self.inner) { @@ -777,6 +853,9 @@ impl RevocationKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn RevocationKey_get_a(this_ptr: &RevocationKey) -> crate::c_types::PublicKey { @@ -867,7 +946,7 @@ pub extern "C" fn RevocationKey_write(obj: &crate::lightning::ln::channel_keys:: } #[allow(unused)] pub(crate) extern "C" fn RevocationKey_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevocationKey) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_keys::nativeRevocationKey) }) } #[no_mangle] /// Read a RevocationKey from a byte array, created by RevocationKey_write diff --git a/lightning-c-bindings/src/lightning/ln/channel_state.rs b/lightning-c-bindings/src/lightning/ln/channel_state.rs new file mode 100644 index 0000000..e9dee8a --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/channel_state.rs @@ -0,0 +1,2041 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Information about the state of a channel. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Exposes the state of pending inbound HTLCs. +/// +/// At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes +/// through the following states in the state machine: +/// - Announced for addition by the originating node through the update_add_htlc message. +/// - Added to the commitment transaction of the receiving node and originating node in turn +/// through the exchange of commitment_signed and revoke_and_ack messages. +/// - Announced for resolution (fulfillment or failure) by the receiving node through either one of +/// the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages. +/// - Removed from the commitment transaction of the originating node and receiving node in turn +/// through the exchange of commitment_signed and revoke_and_ack messages. +/// +/// This can be used to inspect what next message an HTLC is waiting for to advance its state. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum InboundHTLCStateDetails { + /// We have added this HTLC in our commitment transaction by receiving commitment_signed and + /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + /// before this HTLC is included on the remote commitment transaction. + AwaitingRemoteRevokeToAdd, + /// This HTLC has been included in the commitment_signed and revoke_and_ack messages on both sides + /// and is included in both commitment transactions. + /// + /// This HTLC is now safe to either forward or be claimed as a payment by us. The HTLC will + /// remain in this state until the forwarded upstream HTLC has been resolved and we resolve this + /// HTLC correspondingly, or until we claim it as a payment. If it is part of a multipart + /// payment, it will only be claimed together with other required parts. + Committed, + /// We have received the preimage for this HTLC and it is being removed by fulfilling it with + /// update_fulfill_htlc. This HTLC is still on both commitment transactions, but we are awaiting + /// the appropriate revoke_and_ack's from the remote before this HTLC is removed from the remote + /// commitment transaction after update_fulfill_htlc. + AwaitingRemoteRevokeToRemoveFulfill, + /// The HTLC is being removed by failing it with update_fail_htlc or update_fail_malformed_htlc. + /// This HTLC is still on both commitment transactions, but we are awaiting the appropriate + /// revoke_and_ack's from the remote before this HTLC is removed from the remote commitment + /// transaction. + AwaitingRemoteRevokeToRemoveFail, +} +use lightning::ln::channel_state::InboundHTLCStateDetails as InboundHTLCStateDetailsImport; +pub(crate) type nativeInboundHTLCStateDetails = InboundHTLCStateDetailsImport; + +impl InboundHTLCStateDetails { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeInboundHTLCStateDetails { + match self { + InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed, + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill, + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeInboundHTLCStateDetails { + match self { + InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + InboundHTLCStateDetails::Committed => nativeInboundHTLCStateDetails::Committed, + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill, + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &InboundHTLCStateDetailsImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeInboundHTLCStateDetails) }; + match native { + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed, + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill, + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeInboundHTLCStateDetails) -> Self { + match native { + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + nativeInboundHTLCStateDetails::Committed => InboundHTLCStateDetails::Committed, + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill, + nativeInboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail => InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail, + } + } +} +/// Creates a copy of the InboundHTLCStateDetails +#[no_mangle] +pub extern "C" fn InboundHTLCStateDetails_clone(orig: &InboundHTLCStateDetails) -> InboundHTLCStateDetails { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InboundHTLCStateDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const InboundHTLCStateDetails)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InboundHTLCStateDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut InboundHTLCStateDetails) }; +} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant InboundHTLCStateDetails +pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_add() -> InboundHTLCStateDetails { + InboundHTLCStateDetails::AwaitingRemoteRevokeToAdd} +#[no_mangle] +/// Utility method to constructs a new Committed-variant InboundHTLCStateDetails +pub extern "C" fn InboundHTLCStateDetails_committed() -> InboundHTLCStateDetails { + InboundHTLCStateDetails::Committed} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFulfill-variant InboundHTLCStateDetails +pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fulfill() -> InboundHTLCStateDetails { + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFulfill} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFail-variant InboundHTLCStateDetails +pub extern "C" fn InboundHTLCStateDetails_awaiting_remote_revoke_to_remove_fail() -> InboundHTLCStateDetails { + InboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFail} +/// Get a string which allows debug introspection of a InboundHTLCStateDetails object +pub extern "C" fn InboundHTLCStateDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::InboundHTLCStateDetails }).into()} +#[no_mangle] +/// Serialize the InboundHTLCStateDetails object into a byte array which can be read by InboundHTLCStateDetails_read +pub extern "C" fn InboundHTLCStateDetails_write(obj: &crate::lightning::ln::channel_state::InboundHTLCStateDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn InboundHTLCStateDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + InboundHTLCStateDetails_write(unsafe { &*(obj as *const InboundHTLCStateDetails) }) +} +#[no_mangle] +/// Read a InboundHTLCStateDetails from a byte array, created by InboundHTLCStateDetails_write +pub extern "C" fn InboundHTLCStateDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_InboundHTLCStateDetailsZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::Some( { crate::lightning::ln::channel_state::InboundHTLCStateDetails::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::ln::channel_state::InboundHTLCDetails as nativeInboundHTLCDetailsImport; +pub(crate) type nativeInboundHTLCDetails = nativeInboundHTLCDetailsImport; + +/// Exposes details around pending inbound HTLCs. +#[must_use] +#[repr(C)] +pub struct InboundHTLCDetails { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInboundHTLCDetails, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InboundHTLCDetails { + type Target = nativeInboundHTLCDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InboundHTLCDetails { } +unsafe impl core::marker::Sync for InboundHTLCDetails { } +impl Drop for InboundHTLCDetails { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInboundHTLCDetails>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InboundHTLCDetails, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_free(this_obj: InboundHTLCDetails) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InboundHTLCDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInboundHTLCDetails) }; +} +#[allow(unused)] +impl InboundHTLCDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativeInboundHTLCDetails { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInboundHTLCDetails { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInboundHTLCDetails { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The HTLC ID. +/// The IDs are incremented by 1 starting from 0 for each offered HTLC. +/// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced +/// and not part of any commitment transaction. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_htlc_id(this_ptr: &InboundHTLCDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id; + *inner_val +} +/// The HTLC ID. +/// The IDs are incremented by 1 starting from 0 for each offered HTLC. +/// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced +/// and not part of any commitment transaction. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_htlc_id(this_ptr: &mut InboundHTLCDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val; +} +/// The amount in msat. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_amount_msat(this_ptr: &InboundHTLCDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat; + *inner_val +} +/// The amount in msat. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_amount_msat(this_ptr: &mut InboundHTLCDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val; +} +/// The block height at which this HTLC expires. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_cltv_expiry(this_ptr: &InboundHTLCDetails) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry; + *inner_val +} +/// The block height at which this HTLC expires. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_cltv_expiry(this_ptr: &mut InboundHTLCDetails, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val; +} +/// The payment hash. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_payment_hash(this_ptr: &InboundHTLCDetails) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash; + &inner_val.0 +} +/// The payment hash. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_payment_hash(this_ptr: &mut InboundHTLCDetails, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data); +} +/// The state of the HTLC in the state machine. +/// +/// Determines on which commitment transactions the HTLC is included and what message the HTLC is +/// waiting for to advance to the next state. +/// +/// See [`InboundHTLCStateDetails`] for information on the specific states. +/// +/// LDK will always fill this field in, but when downgrading to prior versions of LDK, new +/// states may result in `None` here. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_state(this_ptr: &InboundHTLCDetails) -> crate::c_types::derived::COption_InboundHTLCStateDetailsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().state; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_InboundHTLCStateDetailsZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::lightning::ln::channel_state::InboundHTLCStateDetails::native_into((*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// The state of the HTLC in the state machine. +/// +/// Determines on which commitment transactions the HTLC is included and what message the HTLC is +/// waiting for to advance to the next state. +/// +/// See [`InboundHTLCStateDetails`] for information on the specific states. +/// +/// LDK will always fill this field in, but when downgrading to prior versions of LDK, new +/// states may result in `None` here. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_state(this_ptr: &mut InboundHTLCDetails, mut val: crate::c_types::derived::COption_InboundHTLCStateDetailsZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = local_val; +} +/// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed +/// from the local commitment transaction and added to the commitment transaction fee. +/// For non-anchor channels, this takes into account the cost of the second-stage HTLC +/// transactions as well. +/// +/// When the local commitment transaction is broadcasted as part of a unilateral closure, +/// the value of this HTLC will therefore not be claimable but instead burned as a transaction +/// fee. +/// +/// Note that dust limits are specific to each party. An HTLC can be dust for the local +/// commitment transaction but not for the counterparty's commitment transaction and vice versa. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_get_is_dust(this_ptr: &InboundHTLCDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_dust; + *inner_val +} +/// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed +/// from the local commitment transaction and added to the commitment transaction fee. +/// For non-anchor channels, this takes into account the cost of the second-stage HTLC +/// transactions as well. +/// +/// When the local commitment transaction is broadcasted as part of a unilateral closure, +/// the value of this HTLC will therefore not be claimable but instead burned as a transaction +/// fee. +/// +/// Note that dust limits are specific to each party. An HTLC can be dust for the local +/// commitment transaction but not for the counterparty's commitment transaction and vice versa. +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_set_is_dust(this_ptr: &mut InboundHTLCDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_dust = val; +} +/// Constructs a new InboundHTLCDetails given each field +#[must_use] +#[no_mangle] +pub extern "C" fn InboundHTLCDetails_new(mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut state_arg: crate::c_types::derived::COption_InboundHTLCStateDetailsZ, mut is_dust_arg: bool) -> InboundHTLCDetails { + let mut local_state_arg = { /*state_arg*/ let state_arg_opt = state_arg; if state_arg_opt.is_none() { None } else { Some({ { { state_arg_opt.take() }.into_native() }})} }; + InboundHTLCDetails { inner: ObjOps::heap_alloc(nativeInboundHTLCDetails { + htlc_id: htlc_id_arg, + amount_msat: amount_msat_arg, + cltv_expiry: cltv_expiry_arg, + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data), + state: local_state_arg, + is_dust: is_dust_arg, + }), is_owned: true } +} +impl Clone for InboundHTLCDetails { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInboundHTLCDetails>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InboundHTLCDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInboundHTLCDetails)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InboundHTLCDetails +pub extern "C" fn InboundHTLCDetails_clone(orig: &InboundHTLCDetails) -> InboundHTLCDetails { + orig.clone() +} +/// Get a string which allows debug introspection of a InboundHTLCDetails object +pub extern "C" fn InboundHTLCDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::InboundHTLCDetails }).into()} +#[no_mangle] +/// Serialize the InboundHTLCDetails object into a byte array which can be read by InboundHTLCDetails_read +pub extern "C" fn InboundHTLCDetails_write(obj: &crate::lightning::ln::channel_state::InboundHTLCDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn InboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeInboundHTLCDetails) }) +} +#[no_mangle] +/// Read a InboundHTLCDetails from a byte array, created by InboundHTLCDetails_write +pub extern "C" fn InboundHTLCDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InboundHTLCDetailsDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::InboundHTLCDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Exposes the state of pending outbound HTLCs. +/// +/// At a high level, an HTLC being forwarded from one Lightning node to another Lightning node goes +/// through the following states in the state machine: +/// - Announced for addition by the originating node through the update_add_htlc message. +/// - Added to the commitment transaction of the receiving node and originating node in turn +/// through the exchange of commitment_signed and revoke_and_ack messages. +/// - Announced for resolution (fulfillment or failure) by the receiving node through either one of +/// the update_fulfill_htlc, update_fail_htlc, and update_fail_malformed_htlc messages. +/// - Removed from the commitment transaction of the originating node and receiving node in turn +/// through the exchange of commitment_signed and revoke_and_ack messages. +/// +/// This can be used to inspect what next message an HTLC is waiting for to advance its state. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum OutboundHTLCStateDetails { + /// We are awaiting the appropriate revoke_and_ack's from the remote before the HTLC is added + /// on the remote's commitment transaction after update_add_htlc. + AwaitingRemoteRevokeToAdd, + /// The HTLC has been added to the remote's commitment transaction by sending commitment_signed + /// and receiving revoke_and_ack in return. + /// + /// The HTLC will remain in this state until the remote node resolves the HTLC, or until we + /// unilaterally close the channel due to a timeout with an uncooperative remote node. + Committed, + /// The HTLC has been fulfilled successfully by the remote with a preimage in update_fulfill_htlc, + /// and we removed the HTLC from our commitment transaction by receiving commitment_signed and + /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + /// for the removal from its commitment transaction. + AwaitingRemoteRevokeToRemoveSuccess, + /// The HTLC has been failed by the remote with update_fail_htlc or update_fail_malformed_htlc, + /// and we removed the HTLC from our commitment transaction by receiving commitment_signed and + /// returning revoke_and_ack. We are awaiting the appropriate revoke_and_ack's from the remote + /// for the removal from its commitment transaction. + AwaitingRemoteRevokeToRemoveFailure, +} +use lightning::ln::channel_state::OutboundHTLCStateDetails as OutboundHTLCStateDetailsImport; +pub(crate) type nativeOutboundHTLCStateDetails = OutboundHTLCStateDetailsImport; + +impl OutboundHTLCStateDetails { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeOutboundHTLCStateDetails { + match self { + OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed, + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess, + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeOutboundHTLCStateDetails { + match self { + OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + OutboundHTLCStateDetails::Committed => nativeOutboundHTLCStateDetails::Committed, + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess, + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &OutboundHTLCStateDetailsImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOutboundHTLCStateDetails) }; + match native { + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed, + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess, + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeOutboundHTLCStateDetails) -> Self { + match native { + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd => OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd, + nativeOutboundHTLCStateDetails::Committed => OutboundHTLCStateDetails::Committed, + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess, + nativeOutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure => OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure, + } + } +} +/// Creates a copy of the OutboundHTLCStateDetails +#[no_mangle] +pub extern "C" fn OutboundHTLCStateDetails_clone(orig: &OutboundHTLCStateDetails) -> OutboundHTLCStateDetails { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutboundHTLCStateDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const OutboundHTLCStateDetails)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutboundHTLCStateDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut OutboundHTLCStateDetails) }; +} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToAdd-variant OutboundHTLCStateDetails +pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_add() -> OutboundHTLCStateDetails { + OutboundHTLCStateDetails::AwaitingRemoteRevokeToAdd} +#[no_mangle] +/// Utility method to constructs a new Committed-variant OutboundHTLCStateDetails +pub extern "C" fn OutboundHTLCStateDetails_committed() -> OutboundHTLCStateDetails { + OutboundHTLCStateDetails::Committed} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToRemoveSuccess-variant OutboundHTLCStateDetails +pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_success() -> OutboundHTLCStateDetails { + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveSuccess} +#[no_mangle] +/// Utility method to constructs a new AwaitingRemoteRevokeToRemoveFailure-variant OutboundHTLCStateDetails +pub extern "C" fn OutboundHTLCStateDetails_awaiting_remote_revoke_to_remove_failure() -> OutboundHTLCStateDetails { + OutboundHTLCStateDetails::AwaitingRemoteRevokeToRemoveFailure} +/// Get a string which allows debug introspection of a OutboundHTLCStateDetails object +pub extern "C" fn OutboundHTLCStateDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::OutboundHTLCStateDetails }).into()} +#[no_mangle] +/// Serialize the OutboundHTLCStateDetails object into a byte array which can be read by OutboundHTLCStateDetails_read +pub extern "C" fn OutboundHTLCStateDetails_write(obj: &crate::lightning::ln::channel_state::OutboundHTLCStateDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn OutboundHTLCStateDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + OutboundHTLCStateDetails_write(unsafe { &*(obj as *const OutboundHTLCStateDetails) }) +} +#[no_mangle] +/// Read a OutboundHTLCStateDetails from a byte array, created by OutboundHTLCStateDetails_write +pub extern "C" fn OutboundHTLCStateDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_OutboundHTLCStateDetailsZDecodeErrorZ { + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::maybe_deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_res_0 = if o.is_none() { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::Some( { crate::lightning::ln::channel_state::OutboundHTLCStateDetails::native_into(o.unwrap()) }) }; local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::ln::channel_state::OutboundHTLCDetails as nativeOutboundHTLCDetailsImport; +pub(crate) type nativeOutboundHTLCDetails = nativeOutboundHTLCDetailsImport; + +/// Exposes details around pending outbound HTLCs. +#[must_use] +#[repr(C)] +pub struct OutboundHTLCDetails { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOutboundHTLCDetails, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OutboundHTLCDetails { + type Target = nativeOutboundHTLCDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutboundHTLCDetails { } +unsafe impl core::marker::Sync for OutboundHTLCDetails { } +impl Drop for OutboundHTLCDetails { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOutboundHTLCDetails>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OutboundHTLCDetails, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_free(this_obj: OutboundHTLCDetails) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutboundHTLCDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOutboundHTLCDetails) }; +} +#[allow(unused)] +impl OutboundHTLCDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativeOutboundHTLCDetails { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOutboundHTLCDetails { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOutboundHTLCDetails { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The HTLC ID. +/// The IDs are incremented by 1 starting from 0 for each offered HTLC. +/// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced +/// and not part of any commitment transaction. +/// +/// Not present when we are awaiting a remote revocation and the HTLC is not added yet. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_htlc_id(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The HTLC ID. +/// The IDs are incremented by 1 starting from 0 for each offered HTLC. +/// They are unique per channel and inbound/outbound direction, unless an HTLC was only announced +/// and not part of any commitment transaction. +/// +/// Not present when we are awaiting a remote revocation and the HTLC is not added yet. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_htlc_id(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = local_val; +} +/// The amount in msat. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_amount_msat(this_ptr: &OutboundHTLCDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().amount_msat; + *inner_val +} +/// The amount in msat. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_amount_msat(this_ptr: &mut OutboundHTLCDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.amount_msat = val; +} +/// The block height at which this HTLC expires. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_cltv_expiry(this_ptr: &OutboundHTLCDetails) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry; + *inner_val +} +/// The block height at which this HTLC expires. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_cltv_expiry(this_ptr: &mut OutboundHTLCDetails, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry = val; +} +/// The payment hash. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_payment_hash(this_ptr: &OutboundHTLCDetails) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash; + &inner_val.0 +} +/// The payment hash. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_payment_hash(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data); +} +/// The state of the HTLC in the state machine. +/// +/// Determines on which commitment transactions the HTLC is included and what message the HTLC is +/// waiting for to advance to the next state. +/// +/// See [`OutboundHTLCStateDetails`] for information on the specific states. +/// +/// LDK will always fill this field in, but when downgrading to prior versions of LDK, new +/// states may result in `None` here. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_state(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_OutboundHTLCStateDetailsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().state; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::None } else { crate::c_types::derived::COption_OutboundHTLCStateDetailsZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::lightning::ln::channel_state::OutboundHTLCStateDetails::native_into((*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// The state of the HTLC in the state machine. +/// +/// Determines on which commitment transactions the HTLC is included and what message the HTLC is +/// waiting for to advance to the next state. +/// +/// See [`OutboundHTLCStateDetails`] for information on the specific states. +/// +/// LDK will always fill this field in, but when downgrading to prior versions of LDK, new +/// states may result in `None` here. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_state(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_OutboundHTLCStateDetailsZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.state = local_val; +} +/// The extra fee being skimmed off the top of this HTLC. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_skimmed_fee_msat(this_ptr: &OutboundHTLCDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().skimmed_fee_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The extra fee being skimmed off the top of this HTLC. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_skimmed_fee_msat(this_ptr: &mut OutboundHTLCDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.skimmed_fee_msat = local_val; +} +/// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed +/// from the local commitment transaction and added to the commitment transaction fee. +/// For non-anchor channels, this takes into account the cost of the second-stage HTLC +/// transactions as well. +/// +/// When the local commitment transaction is broadcasted as part of a unilateral closure, +/// the value of this HTLC will therefore not be claimable but instead burned as a transaction +/// fee. +/// +/// Note that dust limits are specific to each party. An HTLC can be dust for the local +/// commitment transaction but not for the counterparty's commitment transaction and vice versa. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_get_is_dust(this_ptr: &OutboundHTLCDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_dust; + *inner_val +} +/// Whether the HTLC has an output below the local dust limit. If so, the output will be trimmed +/// from the local commitment transaction and added to the commitment transaction fee. +/// For non-anchor channels, this takes into account the cost of the second-stage HTLC +/// transactions as well. +/// +/// When the local commitment transaction is broadcasted as part of a unilateral closure, +/// the value of this HTLC will therefore not be claimable but instead burned as a transaction +/// fee. +/// +/// Note that dust limits are specific to each party. An HTLC can be dust for the local +/// commitment transaction but not for the counterparty's commitment transaction and vice versa. +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_set_is_dust(this_ptr: &mut OutboundHTLCDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_dust = val; +} +/// Constructs a new OutboundHTLCDetails given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OutboundHTLCDetails_new(mut htlc_id_arg: crate::c_types::derived::COption_u64Z, mut amount_msat_arg: u64, mut cltv_expiry_arg: u32, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut state_arg: crate::c_types::derived::COption_OutboundHTLCStateDetailsZ, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut is_dust_arg: bool) -> OutboundHTLCDetails { + let mut local_htlc_id_arg = if htlc_id_arg.is_some() { Some( { htlc_id_arg.take() }) } else { None }; + let mut local_state_arg = { /*state_arg*/ let state_arg_opt = state_arg; if state_arg_opt.is_none() { None } else { Some({ { { state_arg_opt.take() }.into_native() }})} }; + let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None }; + OutboundHTLCDetails { inner: ObjOps::heap_alloc(nativeOutboundHTLCDetails { + htlc_id: local_htlc_id_arg, + amount_msat: amount_msat_arg, + cltv_expiry: cltv_expiry_arg, + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data), + state: local_state_arg, + skimmed_fee_msat: local_skimmed_fee_msat_arg, + is_dust: is_dust_arg, + }), is_owned: true } +} +impl Clone for OutboundHTLCDetails { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOutboundHTLCDetails>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutboundHTLCDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOutboundHTLCDetails)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OutboundHTLCDetails +pub extern "C" fn OutboundHTLCDetails_clone(orig: &OutboundHTLCDetails) -> OutboundHTLCDetails { + orig.clone() +} +/// Get a string which allows debug introspection of a OutboundHTLCDetails object +pub extern "C" fn OutboundHTLCDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::OutboundHTLCDetails }).into()} +#[no_mangle] +/// Serialize the OutboundHTLCDetails object into a byte array which can be read by OutboundHTLCDetails_read +pub extern "C" fn OutboundHTLCDetails_write(obj: &crate::lightning::ln::channel_state::OutboundHTLCDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn OutboundHTLCDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeOutboundHTLCDetails) }) +} +#[no_mangle] +/// Read a OutboundHTLCDetails from a byte array, created by OutboundHTLCDetails_write +pub extern "C" fn OutboundHTLCDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OutboundHTLCDetailsDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::OutboundHTLCDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::ln::channel_state::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport; +pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport; + +/// Information needed for constructing an invoice route hint for this channel. +#[must_use] +#[repr(C)] +pub struct CounterpartyForwardingInfo { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeCounterpartyForwardingInfo, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for CounterpartyForwardingInfo { + type Target = nativeCounterpartyForwardingInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CounterpartyForwardingInfo { } +unsafe impl core::marker::Sync for CounterpartyForwardingInfo { } +impl Drop for CounterpartyForwardingInfo { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) }; +} +#[allow(unused)] +impl CounterpartyForwardingInfo { + pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Base routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; + *inner_val +} +/// Base routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; +} +/// Amount in millionths of a satoshi the channel will charge per transferred satoshi. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; + *inner_val +} +/// Amount in millionths of a satoshi the channel will charge per transferred satoshi. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; +} +/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, +/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s +/// `cltv_expiry_delta` for more details. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, +/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s +/// `cltv_expiry_delta` for more details. +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// Constructs a new CounterpartyForwardingInfo given each field +#[must_use] +#[no_mangle] +pub extern "C" fn CounterpartyForwardingInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16) -> CounterpartyForwardingInfo { + CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo { + fee_base_msat: fee_base_msat_arg, + fee_proportional_millionths: fee_proportional_millionths_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + }), is_owned: true } +} +impl Clone for CounterpartyForwardingInfo { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CounterpartyForwardingInfo +pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo { + orig.clone() +} +/// Get a string which allows debug introspection of a CounterpartyForwardingInfo object +pub extern "C" fn CounterpartyForwardingInfo_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::CounterpartyForwardingInfo }).into()} +#[no_mangle] +/// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read +pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channel_state::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeCounterpartyForwardingInfo) }) +} +#[no_mangle] +/// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write +pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::ln::channel_state::ChannelCounterparty as nativeChannelCounterpartyImport; +pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport; + +/// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] +/// to better separate parameters. +#[must_use] +#[repr(C)] +pub struct ChannelCounterparty { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelCounterparty, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ChannelCounterparty { + type Target = nativeChannelCounterparty; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelCounterparty { } +unsafe impl core::marker::Sync for ChannelCounterparty { } +impl Drop for ChannelCounterparty { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) }; +} +#[allow(unused)] +impl ChannelCounterparty { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The node_id of our counterparty +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The node_id of our counterparty +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); +} +/// The Features the channel counterparty provided upon last connection. +/// Useful for routing as it is the most up-to-date copy of the counterparty's features and +/// many routing-relevant features are present in the init context. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning_types::features::InitFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().features; + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } +} +/// The Features the channel counterparty provided upon last connection. +/// Useful for routing as it is the most up-to-date copy of the counterparty's features and +/// many routing-relevant features are present in the init context. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning_types::features::InitFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The value, in satoshis, that must always be held in the channel for our counterparty. This +/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by +/// claiming at least this value on chain. +/// +/// This value is not included in [`inbound_capacity_msat`] as it can never be spent. +/// +/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve; + *inner_val +} +/// The value, in satoshis, that must always be held in the channel for our counterparty. This +/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by +/// claiming at least this value on chain. +/// +/// This value is not included in [`inbound_capacity_msat`] as it can never be spent. +/// +/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val; +} +/// Information on the fees and requirements that the counterparty requires when forwarding +/// payments to us through this channel. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channel_state::CounterpartyForwardingInfo { + let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info; + let mut local_inner_val = crate::lightning::ln::channel_state::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channel_state::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// Information on the fees and requirements that the counterparty requires when forwarding +/// payments to us through this channel. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channel_state::CounterpartyForwardingInfo) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val; +} +/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field +/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message +/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field +/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message +/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val; +} +/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. +#[no_mangle] +pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val; +} +/// Constructs a new ChannelCounterparty given each field +/// +/// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning_types::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channel_state::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty { + let mut local_forwarding_info_arg = if forwarding_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(forwarding_info_arg.take_inner()) } }) }; + let mut local_outbound_htlc_minimum_msat_arg = if outbound_htlc_minimum_msat_arg.is_some() { Some( { outbound_htlc_minimum_msat_arg.take() }) } else { None }; + let mut local_outbound_htlc_maximum_msat_arg = if outbound_htlc_maximum_msat_arg.is_some() { Some( { outbound_htlc_maximum_msat_arg.take() }) } else { None }; + ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty { + node_id: node_id_arg.into_rust(), + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + unspendable_punishment_reserve: unspendable_punishment_reserve_arg, + forwarding_info: local_forwarding_info_arg, + outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg, + outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg, + }), is_owned: true } +} +impl Clone for ChannelCounterparty { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelCounterparty)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelCounterparty +pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty { + orig.clone() +} +/// Get a string which allows debug introspection of a ChannelCounterparty object +pub extern "C" fn ChannelCounterparty_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelCounterparty }).into()} +#[no_mangle] +/// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read +pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channel_state::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeChannelCounterparty) }) +} +#[no_mangle] +/// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write +pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelCounterparty { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::ln::channel_state::ChannelDetails as nativeChannelDetailsImport; +pub(crate) type nativeChannelDetails = nativeChannelDetailsImport; + +/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] +/// +/// Balances of a channel are available through [`ChainMonitor::get_claimable_balances`] and +/// [`ChannelMonitor::get_claimable_balances`], calculated with respect to the corresponding on-chain +/// transactions. +/// +/// [`ChannelManager::list_channels`]: crate::ln::channelmanager::ChannelManager::list_channels +/// [`ChannelManager::list_usable_channels`]: crate::ln::channelmanager::ChannelManager::list_usable_channels +/// [`ChainMonitor::get_claimable_balances`]: crate::chain::chainmonitor::ChainMonitor::get_claimable_balances +/// [`ChannelMonitor::get_claimable_balances`]: crate::chain::channelmonitor::ChannelMonitor::get_claimable_balances +#[must_use] +#[repr(C)] +pub struct ChannelDetails { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelDetails, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ChannelDetails { + type Target = nativeChannelDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelDetails { } +unsafe impl core::marker::Sync for ChannelDetails { } +impl Drop for ChannelDetails { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) }; +} +#[allow(unused)] +impl ChannelDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, +/// thereafter this is the txid of the funding transaction xor the funding transaction output). +/// Note that this means this value is *not* persistent - it can change once during the +/// lifetime of the channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> crate::lightning::ln::types::ChannelId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } +} +/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, +/// thereafter this is the txid of the funding transaction xor the funding transaction output). +/// Note that this means this value is *not* persistent - it can change once during the +/// lifetime of the channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Parameters which apply to our counterparty. See individual fields for more information. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channel_state::ChannelCounterparty { + let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty; + crate::lightning::ln::channel_state::ChannelCounterparty { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channel_state::ChannelCounterparty<>) as *mut _) }, is_owned: false } +} +/// Parameters which apply to our counterparty. See individual fields for more information. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channel_state::ChannelCounterparty) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The Channel's funding transaction output, if we've negotiated the funding transaction with +/// our counterparty already. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo; + let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The Channel's funding transaction output, if we've negotiated the funding transaction with +/// our counterparty already. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val; +} +/// The features which this channel operates with. See individual features for more info. +/// +/// `None` until negotiation completes and the channel type is finalized. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning_types::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The features which this channel operates with. See individual features for more info. +/// +/// `None` until negotiation completes and the channel type is finalized. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning_types::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// The position of the funding transaction in the chain. None if the funding transaction has +/// not yet been confirmed and the channel fully opened. +/// +/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound +/// payments instead of this. See [`get_inbound_payment_scid`]. +/// +/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may +/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. +/// +/// [`inbound_scid_alias`]: Self::inbound_scid_alias +/// [`outbound_scid_alias`]: Self::outbound_scid_alias +/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid +/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid +/// [`confirmations_required`]: Self::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The position of the funding transaction in the chain. None if the funding transaction has +/// not yet been confirmed and the channel fully opened. +/// +/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound +/// payments instead of this. See [`get_inbound_payment_scid`]. +/// +/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may +/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. +/// +/// [`inbound_scid_alias`]: Self::inbound_scid_alias +/// [`outbound_scid_alias`]: Self::outbound_scid_alias +/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid +/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid +/// [`confirmations_required`]: Self::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val; +} +/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and +/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when +/// the channel has not yet been confirmed (as long as [`confirmations_required`] is +/// `Some(0)`). +/// +/// This will be `None` as long as the channel is not available for routing outbound payments. +/// +/// [`short_channel_id`]: Self::short_channel_id +/// [`confirmations_required`]: Self::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and +/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when +/// the channel has not yet been confirmed (as long as [`confirmations_required`] is +/// `Some(0)`). +/// +/// This will be `None` as long as the channel is not available for routing outbound payments. +/// +/// [`short_channel_id`]: Self::short_channel_id +/// [`confirmations_required`]: Self::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val; +} +/// An optional [`short_channel_id`] alias for this channel, randomly generated by our +/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our +/// counterparty will recognize the alias provided here in place of the [`short_channel_id`] +/// when they see a payment to be routed to us. +/// +/// Our counterparty may choose to rotate this value at any time, though will always recognize +/// previous values for inbound payment forwarding. +/// +/// [`short_channel_id`]: Self::short_channel_id +#[no_mangle] +pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// An optional [`short_channel_id`] alias for this channel, randomly generated by our +/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our +/// counterparty will recognize the alias provided here in place of the [`short_channel_id`] +/// when they see a payment to be routed to us. +/// +/// Our counterparty may choose to rotate this value at any time, though will always recognize +/// previous values for inbound payment forwarding. +/// +/// [`short_channel_id`]: Self::short_channel_id +#[no_mangle] +pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val; +} +/// The value, in satoshis, of this channel as appears in the funding output +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; + *inner_val +} +/// The value, in satoshis, of this channel as appears in the funding output +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; +} +/// The value, in satoshis, that must always be held in the channel for us. This value ensures +/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least +/// this value on chain. +/// +/// This value is not included in [`outbound_capacity_msat`] as it can never be spent. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +/// +/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat +#[no_mangle] +pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The value, in satoshis, that must always be held in the channel for us. This value ensures +/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least +/// this value on chain. +/// +/// This value is not included in [`outbound_capacity_msat`] as it can never be spent. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +/// +/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat +#[no_mangle] +pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val; +} +/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound +/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if +/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise +/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects +/// serialized with LDK versions prior to 0.0.113. +/// +/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels +#[no_mangle] +pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id; + inner_val.into() +} +/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound +/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if +/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise +/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects +/// serialized with LDK versions prior to 0.0.113. +/// +/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel +/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel +/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels +#[no_mangle] +pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into(); +} +/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, +/// which is applied to commitment and HTLC transactions. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, +/// which is applied to commitment and HTLC transactions. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val; +} +/// Our total balance. This is the amount we would get if we close the channel. +/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this +/// amount is not likely to be recoverable on close. +/// +/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose +/// balance is not available for inclusion in new outbound HTLCs). This further does not include +/// any pending outgoing HTLCs which are awaiting some other resolution to be sent. +/// This does not consider any on-chain fees. +/// +/// See also [`ChannelDetails::outbound_capacity_msat`] +#[no_mangle] +pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat; + *inner_val +} +/// Our total balance. This is the amount we would get if we close the channel. +/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this +/// amount is not likely to be recoverable on close. +/// +/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose +/// balance is not available for inclusion in new outbound HTLCs). This further does not include +/// any pending outgoing HTLCs which are awaiting some other resolution to be sent. +/// This does not consider any on-chain fees. +/// +/// See also [`ChannelDetails::outbound_capacity_msat`] +#[no_mangle] +pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val; +} +/// The available outbound capacity for sending HTLCs to the remote peer. This does not include +/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not +/// available for inclusion in new outbound HTLCs). This further does not include any pending +/// outgoing HTLCs which are awaiting some other resolution to be sent. +/// +/// See also [`ChannelDetails::balance_msat`] +/// +/// This value is not exact. Due to various in-flight changes, feerate changes, and our +/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we +/// should be able to spend nearly this amount. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat; + *inner_val +} +/// The available outbound capacity for sending HTLCs to the remote peer. This does not include +/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not +/// available for inclusion in new outbound HTLCs). This further does not include any pending +/// outgoing HTLCs which are awaiting some other resolution to be sent. +/// +/// See also [`ChannelDetails::balance_msat`] +/// +/// This value is not exact. Due to various in-flight changes, feerate changes, and our +/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we +/// should be able to spend nearly this amount. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val; +} +/// The available outbound capacity for sending a single HTLC to the remote peer. This is +/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by +/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us +/// to use a limit as close as possible to the HTLC limit we can currently send. +/// +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat; + *inner_val +} +/// The available outbound capacity for sending a single HTLC to the remote peer. This is +/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by +/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us +/// to use a limit as close as possible to the HTLC limit we can currently send. +/// +/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], +/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val; +} +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat; + *inner_val +} +/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of +/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than +/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a +/// route which is valid. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val; +} +/// The available inbound capacity for the remote peer to send HTLCs to us. This does not +/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not +/// available for inclusion in new inbound HTLCs). +/// Note that there are some corner cases not fully handled here, so the actual available +/// inbound capacity may be slightly higher than this. +/// +/// This value is not exact. Due to various in-flight changes, feerate changes, and our +/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. +/// However, our counterparty should be able to spend nearly this amount. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat; + *inner_val +} +/// The available inbound capacity for the remote peer to send HTLCs to us. This does not +/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not +/// available for inclusion in new inbound HTLCs). +/// Note that there are some corner cases not fully handled here, so the actual available +/// inbound capacity may be slightly higher than this. +/// +/// This value is not exact. Due to various in-flight changes, feerate changes, and our +/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. +/// However, our counterparty should be able to spend nearly this amount. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val; +} +/// The number of required confirmations on the funding transaction before the funding will be +/// considered \"locked\". This number is selected by the channel fundee (i.e. us if +/// [`is_outbound`] is *not* set), and can be selected for inbound channels with +/// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with +/// [`ChannelHandshakeLimits::max_minimum_depth`]. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +/// +/// [`is_outbound`]: ChannelDetails::is_outbound +/// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth +/// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth +#[no_mangle] +pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of required confirmations on the funding transaction before the funding will be +/// considered \"locked\". This number is selected by the channel fundee (i.e. us if +/// [`is_outbound`] is *not* set), and can be selected for inbound channels with +/// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with +/// [`ChannelHandshakeLimits::max_minimum_depth`]. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +/// +/// [`is_outbound`]: ChannelDetails::is_outbound +/// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth +/// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth +#[no_mangle] +pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val; +} +/// The current number of confirmations on the funding transaction. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.113. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The current number of confirmations on the funding transaction. +/// +/// This value will be `None` for objects serialized with LDK versions prior to 0.0.113. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val; +} +/// The number of blocks (after our commitment transaction confirms) that we will need to wait +/// until we can claim our funds after we force-close the channel. During this time our +/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty +/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any +/// time to claim our non-HTLC-encumbered funds. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The number of blocks (after our commitment transaction confirms) that we will need to wait +/// until we can claim our funds after we force-close the channel. During this time our +/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty +/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any +/// time to claim our non-HTLC-encumbered funds. +/// +/// This value will be `None` for outbound channels until the counterparty accepts the channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val; +} +/// True if the channel was initiated (and thus funded) by us. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound; + *inner_val +} +/// True if the channel was initiated (and thus funded) by us. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val; +} +/// True if the channel is confirmed, channel_ready messages have been exchanged, and the +/// channel is not currently being shut down. `channel_ready` message exchange implies the +/// required confirmation count has been reached (and we were connected to the peer at some +/// point after the funding transaction received enough confirmations). The required +/// confirmation count is provided in [`confirmations_required`]. +/// +/// [`confirmations_required`]: ChannelDetails::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready; + *inner_val +} +/// True if the channel is confirmed, channel_ready messages have been exchanged, and the +/// channel is not currently being shut down. `channel_ready` message exchange implies the +/// required confirmation count has been reached (and we were connected to the peer at some +/// point after the funding transaction received enough confirmations). The required +/// confirmation count is provided in [`confirmations_required`]. +/// +/// [`confirmations_required`]: ChannelDetails::confirmations_required +#[no_mangle] +pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val; +} +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ { + let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channel_state::ChannelShutdownState::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +/// The stage of the channel's shutdown. +/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val; +} +/// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) +/// the peer is connected, and (c) the channel is not currently negotiating a shutdown. +/// +/// This is a strict superset of `is_channel_ready`. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable; + *inner_val +} +/// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) +/// the peer is connected, and (c) the channel is not currently negotiating a shutdown. +/// +/// This is a strict superset of `is_channel_ready`. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val; +} +/// True if this channel is (or will be) publicly-announced. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_is_announced(this_ptr: &ChannelDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_announced; + *inner_val +} +/// True if this channel is (or will be) publicly-announced. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_is_announced(this_ptr: &mut ChannelDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_announced = val; +} +/// The smallest value HTLC (in msat) we will accept, for this channel. This field +/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 +#[no_mangle] +pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The smallest value HTLC (in msat) we will accept, for this channel. This field +/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 +#[no_mangle] +pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val; +} +/// The largest value HTLC (in msat) we currently will accept, for this channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The largest value HTLC (in msat) we currently will accept, for this channel. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val; +} +/// Set of configurable parameters that affect channel operation. +/// +/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig { + let mut inner_val = &mut this_ptr.get_native_mut_ref().config; + let mut local_inner_val = crate::lightning::util::config::ChannelConfig { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::config::ChannelConfig<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// Set of configurable parameters that affect channel operation. +/// +/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val; +} +/// Pending inbound HTLCs. +/// +/// This field is empty for objects serialized with LDK versions prior to 0.0.122. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_pending_inbound_htlcs(this_ptr: &ChannelDetails) -> crate::c_types::derived::CVec_InboundHTLCDetailsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().pending_inbound_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channel_state::InboundHTLCDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channel_state::InboundHTLCDetails<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// Pending inbound HTLCs. +/// +/// This field is empty for objects serialized with LDK versions prior to 0.0.122. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_pending_inbound_htlcs(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::CVec_InboundHTLCDetailsZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pending_inbound_htlcs = local_val; +} +/// Pending outbound HTLCs. +/// +/// This field is empty for objects serialized with LDK versions prior to 0.0.122. +#[no_mangle] +pub extern "C" fn ChannelDetails_get_pending_outbound_htlcs(this_ptr: &ChannelDetails) -> crate::c_types::derived::CVec_OutboundHTLCDetailsZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().pending_outbound_htlcs; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channel_state::OutboundHTLCDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channel_state::OutboundHTLCDetails<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +/// Pending outbound HTLCs. +/// +/// This field is empty for objects serialized with LDK versions prior to 0.0.122. +#[no_mangle] +pub extern "C" fn ChannelDetails_set_pending_outbound_htlcs(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.pending_outbound_htlcs = local_val; +} +/// Constructs a new ChannelDetails given each field +/// +/// Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut counterparty_arg: crate::lightning::ln::channel_state::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning_types::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut next_outbound_htlc_minimum_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, mut is_usable_arg: bool, mut is_announced_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig, mut pending_inbound_htlcs_arg: crate::c_types::derived::CVec_InboundHTLCDetailsZ, mut pending_outbound_htlcs_arg: crate::c_types::derived::CVec_OutboundHTLCDetailsZ) -> ChannelDetails { + let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; + let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None }; + let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None }; + let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None }; + let mut local_feerate_sat_per_1000_weight_arg = if feerate_sat_per_1000_weight_arg.is_some() { Some( { feerate_sat_per_1000_weight_arg.take() }) } else { None }; + let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None }; + let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None }; + let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None }; + let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} }; + let mut local_inbound_htlc_minimum_msat_arg = if inbound_htlc_minimum_msat_arg.is_some() { Some( { inbound_htlc_minimum_msat_arg.take() }) } else { None }; + let mut local_inbound_htlc_maximum_msat_arg = if inbound_htlc_maximum_msat_arg.is_some() { Some( { inbound_htlc_maximum_msat_arg.take() }) } else { None }; + let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) }; + let mut local_pending_inbound_htlcs_arg = Vec::new(); for mut item in pending_inbound_htlcs_arg.into_rust().drain(..) { local_pending_inbound_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_pending_outbound_htlcs_arg = Vec::new(); for mut item in pending_outbound_htlcs_arg.into_rust().drain(..) { local_pending_outbound_htlcs_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails { + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) }, + funding_txo: local_funding_txo_arg, + channel_type: local_channel_type_arg, + short_channel_id: local_short_channel_id_arg, + outbound_scid_alias: local_outbound_scid_alias_arg, + inbound_scid_alias: local_inbound_scid_alias_arg, + channel_value_satoshis: channel_value_satoshis_arg, + unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg, + user_channel_id: user_channel_id_arg.into(), + feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg, + balance_msat: balance_msat_arg, + outbound_capacity_msat: outbound_capacity_msat_arg, + next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg, + next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg, + inbound_capacity_msat: inbound_capacity_msat_arg, + confirmations_required: local_confirmations_required_arg, + confirmations: local_confirmations_arg, + force_close_spend_delay: local_force_close_spend_delay_arg, + is_outbound: is_outbound_arg, + is_channel_ready: is_channel_ready_arg, + channel_shutdown_state: local_channel_shutdown_state_arg, + is_usable: is_usable_arg, + is_announced: is_announced_arg, + inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg, + inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg, + config: local_config_arg, + pending_inbound_htlcs: local_pending_inbound_htlcs_arg, + pending_outbound_htlcs: local_pending_outbound_htlcs_arg, + }), is_owned: true } +} +impl Clone for ChannelDetails { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelDetails)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelDetails +pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails { + orig.clone() +} +/// Get a string which allows debug introspection of a ChannelDetails object +pub extern "C" fn ChannelDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelDetails }).into()} +/// Gets the current SCID which should be used to identify this channel for inbound payments. +/// This should be used for providing invoice hints or in any other context where our +/// counterparty will forward a payment to us. +/// +/// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the +/// [`ChannelDetails::short_channel_id`]. See those for more information. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + +/// Gets the current SCID which should be used to identify this channel for outbound payments. +/// This should be used in [`Route`]s to describe the first hop or in other contexts where +/// we're sending or forwarding a payment outbound over this channel. +/// +/// This is either the [`ChannelDetails::short_channel_id`], if set, or the +/// [`ChannelDetails::outbound_scid_alias`]. See those for more information. +/// +/// [`Route`]: crate::routing::router::Route +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::COption_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid(); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; + local_ret +} + +#[no_mangle] +/// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read +pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channel_state::ChannelDetails) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channel_state::nativeChannelDetails) }) +} +#[no_mangle] +/// Read a ChannelDetails from a byte array, created by ChannelDetails_write +pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Further information on the details of the channel shutdown. +/// Upon channels being forced closed (i.e. commitment transaction confirmation detected +/// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or +/// the channel will be removed shortly. +/// Also note, that in normal operation, peers could disconnect at any of these states +/// and require peer re-connection before making progress onto other states +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum ChannelShutdownState { + /// Channel has not sent or received a shutdown message. + NotShuttingDown, + /// Local node has sent a shutdown message for this channel. + ShutdownInitiated, + /// Shutdown message exchanges have concluded and the channels are in the midst of + /// resolving all existing open HTLCs before closing can continue. + ResolvingHTLCs, + /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. + NegotiatingClosingFee, + /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about + /// to drop the channel. + ShutdownComplete, +} +use lightning::ln::channel_state::ChannelShutdownState as ChannelShutdownStateImport; +pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport; + +impl ChannelShutdownState { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeChannelShutdownState { + match self { + ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, + ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, + ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, + ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, + ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &ChannelShutdownStateImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeChannelShutdownState) }; + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self { + match native { + nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, + nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, + nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, + nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, + nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, + } + } +} +/// Creates a copy of the ChannelShutdownState +#[no_mangle] +pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelShutdownState_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ChannelShutdownState)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelShutdownState_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut ChannelShutdownState) }; +} +#[no_mangle] +/// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState { + ChannelShutdownState::NotShuttingDown} +#[no_mangle] +/// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState { + ChannelShutdownState::ShutdownInitiated} +#[no_mangle] +/// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState { + ChannelShutdownState::ResolvingHTLCs} +#[no_mangle] +/// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState { + ChannelShutdownState::NegotiatingClosingFee} +#[no_mangle] +/// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState +pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState { + ChannelShutdownState::ShutdownComplete} +/// Get a string which allows debug introspection of a ChannelShutdownState object +pub extern "C" fn ChannelShutdownState_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channel_state::ChannelShutdownState }).into()} +/// Checks if two ChannelShutdownStates contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read +pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channel_state::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn ChannelShutdownState_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + ChannelShutdownState_write(unsafe { &*(obj as *const ChannelShutdownState) }) +} +#[no_mangle] +/// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write +pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channel_state::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/ln/channelmanager.rs b/lightning-c-bindings/src/lightning/ln/channelmanager.rs index b1dedd5..4ee248d 100644 --- a/lightning-c-bindings/src/lightning/ln/channelmanager.rs +++ b/lightning-c-bindings/src/lightning/ln/channelmanager.rs @@ -61,6 +61,11 @@ pub enum PendingHTLCRouting { /// [`Event::PaymentClaimable::onion_fields`] as /// [`RecipientOnionFields::payment_metadata`]. payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, + /// The context of the payment included by the recipient in a blinded path, or `None` if a + /// blinded path was not used. + /// + /// Used in part to determine the [`events::PaymentPurpose`]. + payment_context: crate::c_types::derived::COption_PaymentContextZ, /// CLTV expiry of the received HTLC. /// /// Used to track when we should expire pending HTLCs that go unclaimed. @@ -109,6 +114,8 @@ pub enum PendingHTLCRouting { /// For HTLCs received by LDK, these will ultimately bubble back up as /// [`RecipientOnionFields::custom_tlvs`]. custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, + /// Set if this HTLC is the final hop in a multi-hop blinded path. + requires_blinded_error: bool, }, } use lightning::ln::channelmanager::PendingHTLCRouting as PendingHTLCRoutingImport; @@ -129,10 +136,12 @@ impl PendingHTLCRouting { blinded: local_blinded_nonref, } }, - PendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { + PendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref payment_context, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { let mut payment_data_nonref = Clone::clone(payment_data); let mut payment_metadata_nonref = Clone::clone(payment_metadata); let mut local_payment_metadata_nonref = { /*payment_metadata_nonref*/ let payment_metadata_nonref_opt = payment_metadata_nonref; if payment_metadata_nonref_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in { payment_metadata_nonref_opt.take() }.into_rust().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0 }})} }; + let mut payment_context_nonref = Clone::clone(payment_context); + let mut local_payment_context_nonref = { /*payment_context_nonref*/ let payment_context_nonref_opt = payment_context_nonref; if payment_context_nonref_opt.is_none() { None } else { Some({ { { payment_context_nonref_opt.take() }.into_native() }})} }; let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); let mut phantom_shared_secret_nonref = Clone::clone(phantom_shared_secret); let mut local_phantom_shared_secret_nonref = if phantom_shared_secret_nonref.data == [0; 32] { None } else { Some( { phantom_shared_secret_nonref.data }) }; @@ -142,13 +151,14 @@ impl PendingHTLCRouting { nativePendingHTLCRouting::Receive { payment_data: *unsafe { Box::from_raw(payment_data_nonref.take_inner()) }, payment_metadata: local_payment_metadata_nonref, + payment_context: local_payment_context_nonref, incoming_cltv_expiry: incoming_cltv_expiry_nonref, phantom_shared_secret: local_phantom_shared_secret_nonref, custom_tlvs: local_custom_tlvs_nonref, requires_blinded_error: requires_blinded_error_nonref, } }, - PendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, } => { + PendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, ref requires_blinded_error, } => { let mut payment_data_nonref = Clone::clone(payment_data); let mut local_payment_data_nonref = if payment_data_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_data_nonref.take_inner()) } }) }; let mut payment_preimage_nonref = Clone::clone(payment_preimage); @@ -157,12 +167,14 @@ impl PendingHTLCRouting { let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.into_rust().drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.into_rust().drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1); local_custom_tlvs_nonref_0 }); }; + let mut requires_blinded_error_nonref = Clone::clone(requires_blinded_error); nativePendingHTLCRouting::ReceiveKeysend { payment_data: local_payment_data_nonref, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_nonref.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_nonref.data), payment_metadata: local_payment_metadata_nonref, incoming_cltv_expiry: incoming_cltv_expiry_nonref, custom_tlvs: local_custom_tlvs_nonref, + requires_blinded_error: requires_blinded_error_nonref, } }, } @@ -178,29 +190,32 @@ impl PendingHTLCRouting { blinded: local_blinded, } }, - PendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { + PendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut payment_context, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { let mut local_payment_metadata = { /*payment_metadata*/ let payment_metadata_opt = payment_metadata; if payment_metadata_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_0 = Vec::new(); for mut item in { payment_metadata_opt.take() }.into_rust().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0 }})} }; + let mut local_payment_context = { /*payment_context*/ let payment_context_opt = payment_context; if payment_context_opt.is_none() { None } else { Some({ { { payment_context_opt.take() }.into_native() }})} }; let mut local_phantom_shared_secret = if phantom_shared_secret.data == [0; 32] { None } else { Some( { phantom_shared_secret.data }) }; let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.into_rust().drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.into_rust().drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1); local_custom_tlvs_0 }); }; nativePendingHTLCRouting::Receive { payment_data: *unsafe { Box::from_raw(payment_data.take_inner()) }, payment_metadata: local_payment_metadata, + payment_context: local_payment_context, incoming_cltv_expiry: incoming_cltv_expiry, phantom_shared_secret: local_phantom_shared_secret, custom_tlvs: local_custom_tlvs, requires_blinded_error: requires_blinded_error, } }, - PendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, } => { + PendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, mut requires_blinded_error, } => { let mut local_payment_data = if payment_data.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payment_data.take_inner()) } }) }; let mut local_payment_metadata = { /*payment_metadata*/ let payment_metadata_opt = payment_metadata; if payment_metadata_opt.is_none() { None } else { Some({ { let mut local_payment_metadata_0 = Vec::new(); for mut item in { payment_metadata_opt.take() }.into_rust().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0 }})} }; let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.into_rust().drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item.to_rust(); let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.into_rust().drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1); local_custom_tlvs_0 }); }; nativePendingHTLCRouting::ReceiveKeysend { payment_data: local_payment_data, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage.data), payment_metadata: local_payment_metadata, incoming_cltv_expiry: incoming_cltv_expiry, custom_tlvs: local_custom_tlvs, + requires_blinded_error: requires_blinded_error, } }, } @@ -220,10 +235,12 @@ impl PendingHTLCRouting { blinded: local_blinded_nonref, } }, - nativePendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { + nativePendingHTLCRouting::Receive {ref payment_data, ref payment_metadata, ref payment_context, ref incoming_cltv_expiry, ref phantom_shared_secret, ref custom_tlvs, ref requires_blinded_error, } => { let mut payment_data_nonref = Clone::clone(payment_data); let mut payment_metadata_nonref = Clone::clone(payment_metadata); let mut local_payment_metadata_nonref = if payment_metadata_nonref.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_nonref_0 = Vec::new(); for mut item in payment_metadata_nonref.unwrap().drain(..) { local_payment_metadata_nonref_0.push( { item }); }; local_payment_metadata_nonref_0.into() }) }; + let mut payment_context_nonref = Clone::clone(payment_context); + let mut local_payment_context_nonref = if payment_context_nonref.is_none() { crate::c_types::derived::COption_PaymentContextZ::None } else { crate::c_types::derived::COption_PaymentContextZ::Some( { crate::lightning::blinded_path::payment::PaymentContext::native_into(payment_context_nonref.unwrap()) }) }; let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); let mut phantom_shared_secret_nonref = Clone::clone(phantom_shared_secret); let mut local_phantom_shared_secret_nonref = if phantom_shared_secret_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (phantom_shared_secret_nonref.unwrap()) } } }; @@ -233,13 +250,14 @@ impl PendingHTLCRouting { PendingHTLCRouting::Receive { payment_data: crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(payment_data_nonref), is_owned: true }, payment_metadata: local_payment_metadata_nonref, + payment_context: local_payment_context_nonref, incoming_cltv_expiry: incoming_cltv_expiry_nonref, phantom_shared_secret: local_phantom_shared_secret_nonref, custom_tlvs: local_custom_tlvs_nonref.into(), requires_blinded_error: requires_blinded_error_nonref, } }, - nativePendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, } => { + nativePendingHTLCRouting::ReceiveKeysend {ref payment_data, ref payment_preimage, ref payment_metadata, ref incoming_cltv_expiry, ref custom_tlvs, ref requires_blinded_error, } => { let mut payment_data_nonref = Clone::clone(payment_data); let mut local_payment_data_nonref = crate::lightning::ln::msgs::FinalOnionHopData { inner: if payment_data_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((payment_data_nonref.unwrap())) } }, is_owned: true }; let mut payment_preimage_nonref = Clone::clone(payment_preimage); @@ -248,12 +266,14 @@ impl PendingHTLCRouting { let mut incoming_cltv_expiry_nonref = Clone::clone(incoming_cltv_expiry); let mut custom_tlvs_nonref = Clone::clone(custom_tlvs); let mut local_custom_tlvs_nonref = Vec::new(); for mut item in custom_tlvs_nonref.drain(..) { local_custom_tlvs_nonref.push( { let (mut orig_custom_tlvs_nonref_0_0, mut orig_custom_tlvs_nonref_0_1) = item; let mut local_orig_custom_tlvs_nonref_0_1 = Vec::new(); for mut item in orig_custom_tlvs_nonref_0_1.drain(..) { local_orig_custom_tlvs_nonref_0_1.push( { item }); }; let mut local_custom_tlvs_nonref_0 = (orig_custom_tlvs_nonref_0_0, local_orig_custom_tlvs_nonref_0_1.into()).into(); local_custom_tlvs_nonref_0 }); }; + let mut requires_blinded_error_nonref = Clone::clone(requires_blinded_error); PendingHTLCRouting::ReceiveKeysend { payment_data: local_payment_data_nonref, payment_preimage: crate::c_types::ThirtyTwoBytes { data: payment_preimage_nonref.0 }, payment_metadata: local_payment_metadata_nonref, incoming_cltv_expiry: incoming_cltv_expiry_nonref, custom_tlvs: local_custom_tlvs_nonref.into(), + requires_blinded_error: requires_blinded_error_nonref, } }, } @@ -269,20 +289,22 @@ impl PendingHTLCRouting { blinded: local_blinded, } }, - nativePendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { + nativePendingHTLCRouting::Receive {mut payment_data, mut payment_metadata, mut payment_context, mut incoming_cltv_expiry, mut phantom_shared_secret, mut custom_tlvs, mut requires_blinded_error, } => { let mut local_payment_metadata = if payment_metadata.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_0 = Vec::new(); for mut item in payment_metadata.unwrap().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0.into() }) }; + let mut local_payment_context = if payment_context.is_none() { crate::c_types::derived::COption_PaymentContextZ::None } else { crate::c_types::derived::COption_PaymentContextZ::Some( { crate::lightning::blinded_path::payment::PaymentContext::native_into(payment_context.unwrap()) }) }; let mut local_phantom_shared_secret = if phantom_shared_secret.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (phantom_shared_secret.unwrap()) } } }; let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item; let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1.into()).into(); local_custom_tlvs_0 }); }; PendingHTLCRouting::Receive { payment_data: crate::lightning::ln::msgs::FinalOnionHopData { inner: ObjOps::heap_alloc(payment_data), is_owned: true }, payment_metadata: local_payment_metadata, + payment_context: local_payment_context, incoming_cltv_expiry: incoming_cltv_expiry, phantom_shared_secret: local_phantom_shared_secret, custom_tlvs: local_custom_tlvs.into(), requires_blinded_error: requires_blinded_error, } }, - nativePendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, } => { + nativePendingHTLCRouting::ReceiveKeysend {mut payment_data, mut payment_preimage, mut payment_metadata, mut incoming_cltv_expiry, mut custom_tlvs, mut requires_blinded_error, } => { let mut local_payment_data = crate::lightning::ln::msgs::FinalOnionHopData { inner: if payment_data.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((payment_data.unwrap())) } }, is_owned: true }; let mut local_payment_metadata = if payment_metadata.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_payment_metadata_0 = Vec::new(); for mut item in payment_metadata.unwrap().drain(..) { local_payment_metadata_0.push( { item }); }; local_payment_metadata_0.into() }) }; let mut local_custom_tlvs = Vec::new(); for mut item in custom_tlvs.drain(..) { local_custom_tlvs.push( { let (mut orig_custom_tlvs_0_0, mut orig_custom_tlvs_0_1) = item; let mut local_orig_custom_tlvs_0_1 = Vec::new(); for mut item in orig_custom_tlvs_0_1.drain(..) { local_orig_custom_tlvs_0_1.push( { item }); }; let mut local_custom_tlvs_0 = (orig_custom_tlvs_0_0, local_orig_custom_tlvs_0_1.into()).into(); local_custom_tlvs_0 }); }; @@ -292,6 +314,7 @@ impl PendingHTLCRouting { payment_metadata: local_payment_metadata, incoming_cltv_expiry: incoming_cltv_expiry, custom_tlvs: local_custom_tlvs.into(), + requires_blinded_error: requires_blinded_error, } }, } @@ -326,10 +349,11 @@ pub extern "C" fn PendingHTLCRouting_forward(onion_packet: crate::lightning::ln: } #[no_mangle] /// Utility method to constructs a new Receive-variant PendingHTLCRouting -pub extern "C" fn PendingHTLCRouting_receive(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, incoming_cltv_expiry: u32, phantom_shared_secret: crate::c_types::ThirtyTwoBytes, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, requires_blinded_error: bool) -> PendingHTLCRouting { +pub extern "C" fn PendingHTLCRouting_receive(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, payment_context: crate::c_types::derived::COption_PaymentContextZ, incoming_cltv_expiry: u32, phantom_shared_secret: crate::c_types::ThirtyTwoBytes, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, requires_blinded_error: bool) -> PendingHTLCRouting { PendingHTLCRouting::Receive { payment_data, payment_metadata, + payment_context, incoming_cltv_expiry, phantom_shared_secret, custom_tlvs, @@ -338,13 +362,14 @@ pub extern "C" fn PendingHTLCRouting_receive(payment_data: crate::lightning::ln: } #[no_mangle] /// Utility method to constructs a new ReceiveKeysend-variant PendingHTLCRouting -pub extern "C" fn PendingHTLCRouting_receive_keysend(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, incoming_cltv_expiry: u32, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ) -> PendingHTLCRouting { +pub extern "C" fn PendingHTLCRouting_receive_keysend(payment_data: crate::lightning::ln::msgs::FinalOnionHopData, payment_preimage: crate::c_types::ThirtyTwoBytes, payment_metadata: crate::c_types::derived::COption_CVec_u8ZZ, incoming_cltv_expiry: u32, custom_tlvs: crate::c_types::derived::CVec_C2Tuple_u64CVec_u8ZZZ, requires_blinded_error: bool) -> PendingHTLCRouting { PendingHTLCRouting::ReceiveKeysend { payment_data, payment_preimage, payment_metadata, incoming_cltv_expiry, custom_tlvs, + requires_blinded_error, } } @@ -367,6 +392,12 @@ pub struct BlindedForward { pub is_owned: bool, } +impl core::ops::Deref for BlindedForward { + type Target = nativeBlindedForward; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedForward { } +unsafe impl core::marker::Sync for BlindedForward { } impl Drop for BlindedForward { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedForward>::is_null(self.inner) { @@ -397,6 +428,9 @@ impl BlindedForward { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The `blinding_point` that was set in the inbound [`msgs::UpdateAddHTLC`], or in the inbound /// onion payload if we're the introduction node. Useful for calculating the next hop's @@ -426,13 +460,38 @@ pub extern "C" fn BlindedForward_get_failure(this_ptr: &BlindedForward) -> crate pub extern "C" fn BlindedForward_set_failure(this_ptr: &mut BlindedForward, mut val: crate::lightning::ln::channelmanager::BlindedFailure) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure = val.into_native(); } +/// Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being +/// forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that +/// starts at the next hop. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn BlindedForward_get_next_blinding_override(this_ptr: &BlindedForward) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().next_blinding_override; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(inner_val.unwrap())) } }; + local_inner_val +} +/// Overrides the next hop's [`msgs::UpdateAddHTLC::blinding_point`]. Set if this HTLC is being +/// forwarded within a [`BlindedPaymentPath`] that was concatenated to another blinded path that +/// starts at the next hop. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn BlindedForward_set_next_blinding_override(this_ptr: &mut BlindedForward, mut val: crate::c_types::PublicKey) { + let mut local_val = if val.is_null() { None } else { Some( { val.into_rust() }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_blinding_override = local_val; +} /// Constructs a new BlindedForward given each field +/// +/// Note that next_blinding_override_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn BlindedForward_new(mut inbound_blinding_point_arg: crate::c_types::PublicKey, mut failure_arg: crate::lightning::ln::channelmanager::BlindedFailure) -> BlindedForward { +pub extern "C" fn BlindedForward_new(mut inbound_blinding_point_arg: crate::c_types::PublicKey, mut failure_arg: crate::lightning::ln::channelmanager::BlindedFailure, mut next_blinding_override_arg: crate::c_types::PublicKey) -> BlindedForward { + let mut local_next_blinding_override_arg = if next_blinding_override_arg.is_null() { None } else { Some( { next_blinding_override_arg.into_rust() }) }; BlindedForward { inner: ObjOps::heap_alloc(nativeBlindedForward { inbound_blinding_point: inbound_blinding_point_arg.into_rust(), failure: failure_arg.into_native(), + next_blinding_override: local_next_blinding_override_arg, }), is_owned: true } } impl Clone for BlindedForward { @@ -497,6 +556,12 @@ pub struct PendingHTLCInfo { pub is_owned: bool, } +impl core::ops::Deref for PendingHTLCInfo { + type Target = nativePendingHTLCInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PendingHTLCInfo { } +unsafe impl core::marker::Sync for PendingHTLCInfo { } impl Drop for PendingHTLCInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativePendingHTLCInfo>::is_null(self.inner) { @@ -527,6 +592,9 @@ impl PendingHTLCInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Further routing details based on whether the HTLC is being forwarded or received. #[no_mangle] @@ -563,7 +631,7 @@ pub extern "C" fn PendingHTLCInfo_get_payment_hash(this_ptr: &PendingHTLCInfo) - /// Hash of the payment preimage, to lock the payment until the receiver releases the preimage. #[no_mangle] pub extern "C" fn PendingHTLCInfo_set_payment_hash(this_ptr: &mut PendingHTLCInfo, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data); } /// Amount received in the incoming HTLC. /// @@ -666,7 +734,7 @@ pub extern "C" fn PendingHTLCInfo_new(mut routing_arg: crate::lightning::ln::cha PendingHTLCInfo { inner: ObjOps::heap_alloc(nativePendingHTLCInfo { routing: routing_arg.into_native(), incoming_shared_secret: incoming_shared_secret_arg.data, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data), incoming_amt_msat: local_incoming_amt_msat_arg, outgoing_amt_msat: outgoing_amt_msat_arg, outgoing_cltv_value: outgoing_cltv_value_arg, @@ -908,13 +976,658 @@ pub extern "C" fn FailureCode_invalid_onion_payload(a: crate::c_types::derived:: } use lightning::ln::channelmanager::ChannelManager as nativeChannelManagerImport; -pub(crate) type nativeChannelManager = nativeChannelManagerImport; +pub(crate) type nativeChannelManager = nativeChannelManagerImport; -/// Manager which keeps track of a number of channels and sends messages to the appropriate -/// channel, also tracking HTLC preimages and forwarding onion packets appropriately. -/// -/// Implements [`ChannelMessageHandler`], handling the multi-channel parts and passing things through -/// to individual Channels. +/// A lightning node's channel state machine and payment management logic, which facilitates +/// sending, forwarding, and receiving payments through lightning channels. +/// +/// [`ChannelManager`] is parameterized by a number of components to achieve this. +/// - [`chain::Watch`] (typically [`ChainMonitor`]) for on-chain monitoring and enforcement of each +/// channel +/// - [`BroadcasterInterface`] for broadcasting transactions related to opening, funding, and +/// closing channels +/// - [`EntropySource`] for providing random data needed for cryptographic operations +/// - [`NodeSigner`] for cryptographic operations scoped to the node +/// - [`SignerProvider`] for providing signers whose operations are scoped to individual channels +/// - [`FeeEstimator`] to determine transaction fee rates needed to have a transaction mined in a +/// timely manner +/// - [`Router`] for finding payment paths when initiating and retrying payments +/// - [`Logger`] for logging operational information of varying degrees +/// +/// Additionally, it implements the following traits: +/// - [`ChannelMessageHandler`] to handle off-chain channel activity from peers +/// - [`MessageSendEventsProvider`] to similarly send such messages to peers +/// - [`OffersMessageHandler`] for BOLT 12 message handling and sending +/// - [`EventsProvider`] to generate user-actionable [`Event`]s +/// - [`chain::Listen`] and [`chain::Confirm`] for notification of on-chain activity +/// +/// Thus, [`ChannelManager`] is typically used to parameterize a [`MessageHandler`] and an +/// [`OnionMessenger`]. The latter is required to support BOLT 12 functionality. +/// +/// # `ChannelManager` vs `ChannelMonitor` +/// +/// It's important to distinguish between the *off-chain* management and *on-chain* enforcement of +/// lightning channels. [`ChannelManager`] exchanges messages with peers to manage the off-chain +/// state of each channel. During this process, it generates a [`ChannelMonitor`] for each channel +/// and a [`ChannelMonitorUpdate`] for each relevant change, notifying its parameterized +/// [`chain::Watch`] of them. +/// +/// An implementation of [`chain::Watch`], such as [`ChainMonitor`], is responsible for aggregating +/// these [`ChannelMonitor`]s and applying any [`ChannelMonitorUpdate`]s to them. It then monitors +/// for any pertinent on-chain activity, enforcing claims as needed. +/// +/// This division of off-chain management and on-chain enforcement allows for interesting node +/// setups. For instance, on-chain enforcement could be moved to a separate host or have added +/// redundancy, possibly as a watchtower. See [`chain::Watch`] for the relevant interface. +/// +/// # Initialization +/// +/// Use [`ChannelManager::new`] with the most recent [`BlockHash`] when creating a fresh instance. +/// Otherwise, if restarting, construct [`ChannelManagerReadArgs`] with the necessary parameters and +/// references to any deserialized [`ChannelMonitor`]s that were previously persisted. Use this to +/// deserialize the [`ChannelManager`] and feed it any new chain data since it was last online, as +/// detailed in the [`ChannelManagerReadArgs`] documentation. +/// +/// ``` +/// use bitcoin::BlockHash; +/// use bitcoin::network::Network; +/// use lightning::chain::BestBlock; +/// # use lightning::chain::channelmonitor::ChannelMonitor; +/// use lightning::ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs}; +/// # use lightning::routing::gossip::NetworkGraph; +/// use lightning::util::config::UserConfig; +/// use lightning::util::ser::ReadableArgs; +/// +/// # fn read_channel_monitors() -> Vec> { vec![] } +/// # fn example< +/// # 'a, +/// # L: lightning::util::logger::Logger, +/// # ES: lightning::sign::EntropySource, +/// # S: for <'b> lightning::routing::scoring::LockableScore<'b, ScoreLookUp = SL>, +/// # SL: lightning::routing::scoring::ScoreLookUp, +/// # SP: Sized, +/// # R: lightning::io::Read, +/// # >( +/// # fee_estimator: &dyn lightning::chain::chaininterface::FeeEstimator, +/// # chain_monitor: &dyn lightning::chain::Watch, +/// # tx_broadcaster: &dyn lightning::chain::chaininterface::BroadcasterInterface, +/// # router: &lightning::routing::router::DefaultRouter<&NetworkGraph<&'a L>, &'a L, &ES, &S, SP, SL>, +/// # logger: &L, +/// # entropy_source: &ES, +/// # node_signer: &dyn lightning::sign::NodeSigner, +/// # signer_provider: &lightning::sign::DynSignerProvider, +/// # best_block: lightning::chain::BestBlock, +/// # current_timestamp: u32, +/// # mut reader: R, +/// # ) -> Result<(), lightning::ln::msgs::DecodeError> { +/// // Fresh start with no channels +/// let params = ChainParameters { +/// network: Network::Bitcoin, +/// best_block, +/// }; +/// let default_config = UserConfig::default(); +/// let channel_manager = ChannelManager::new( +/// fee_estimator, chain_monitor, tx_broadcaster, router, logger, entropy_source, node_signer, +/// signer_provider, default_config, params, current_timestamp +/// ); +/// +/// // Restart from deserialized data +/// let mut channel_monitors = read_channel_monitors(); +/// let args = ChannelManagerReadArgs::new( +/// entropy_source, node_signer, signer_provider, fee_estimator, chain_monitor, tx_broadcaster, +/// router, logger, default_config, channel_monitors.iter_mut().collect() +/// ); +/// let (block_hash, channel_manager) = +/// <(BlockHash, ChannelManager<_, _, _, _, _, _, _, _>)>::read(&mut reader, args)?; +/// +/// // Update the ChannelManager and ChannelMonitors with the latest chain data +/// // ... +/// +/// // Move the monitors to the ChannelManager's chain::Watch parameter +/// for monitor in channel_monitors { +/// chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor); +/// } +/// # Ok(()) +/// # } +/// ``` +/// +/// # Operation +/// +/// The following is required for [`ChannelManager`] to function properly: +/// - Handle messages from peers using its [`ChannelMessageHandler`] implementation (typically +/// called by [`PeerManager::read_event`] when processing network I/O) +/// - Send messages to peers obtained via its [`MessageSendEventsProvider`] implementation +/// (typically initiated when [`PeerManager::process_events`] is called) +/// - Feed on-chain activity using either its [`chain::Listen`] or [`chain::Confirm`] implementation +/// as documented by those traits +/// - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly +/// every minute +/// - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a +/// [`Persister`] such as a [`KVStore`] implementation +/// - Handle [`Event`]s obtained via its [`EventsProvider`] implementation +/// +/// The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining +/// when the last two requirements need to be checked. +/// +/// The [`lightning-block-sync`] and [`lightning-transaction-sync`] crates provide utilities that +/// simplify feeding in on-chain activity using the [`chain::Listen`] and [`chain::Confirm`] traits, +/// respectively. The remaining requirements can be met using the [`lightning-background-processor`] +/// crate. For languages other than Rust, the availability of similar utilities may vary. +/// +/// # Channels +/// +/// [`ChannelManager`]'s primary function involves managing a channel state. Without channels, +/// payments can't be sent. Use [`list_channels`] or [`list_usable_channels`] for a snapshot of the +/// currently open channels. +/// +/// ``` +/// # use lightning::ln::channelmanager::AChannelManager; +/// # +/// # fn example(channel_manager: T) { +/// # let channel_manager = channel_manager.get_cm(); +/// let channels = channel_manager.list_usable_channels(); +/// for details in channels { +/// println!(\"{:?}\", details); +/// } +/// # } +/// ``` +/// +/// Each channel is identified using a [`ChannelId`], which will change throughout the channel's +/// life cycle. Additionally, channels are assigned a `user_channel_id`, which is given in +/// [`Event`]s associated with the channel and serves as a fixed identifier but is otherwise unused +/// by [`ChannelManager`]. +/// +/// ## Opening Channels +/// +/// To an open a channel with a peer, call [`create_channel`]. This will initiate the process of +/// opening an outbound channel, which requires self-funding when handling +/// [`Event::FundingGenerationReady`]. +/// +/// ``` +/// # use bitcoin::{ScriptBuf, Transaction}; +/// # use bitcoin::secp256k1::PublicKey; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # use lightning::events::{Event, EventsProvider}; +/// # +/// # trait Wallet { +/// # fn create_funding_transaction( +/// # &self, _amount_sats: u64, _output_script: ScriptBuf +/// # ) -> Transaction; +/// # } +/// # +/// # fn example(channel_manager: T, wallet: W, peer_id: PublicKey) { +/// # let channel_manager = channel_manager.get_cm(); +/// let value_sats = 1_000_000; +/// let push_msats = 10_000_000; +/// match channel_manager.create_channel(peer_id, value_sats, push_msats, 42, None, None) { +/// Ok(channel_id) => println!(\"Opening channel {}\", channel_id), +/// Err(e) => println!(\"Error opening channel: {:?}\", e), +/// } +/// +/// // On the event processing thread once the peer has responded +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::FundingGenerationReady { +/// temporary_channel_id, counterparty_node_id, channel_value_satoshis, output_script, +/// user_channel_id, .. +/// } => { +/// assert_eq!(user_channel_id, 42); +/// let funding_transaction = wallet.create_funding_transaction( +/// channel_value_satoshis, output_script +/// ); +/// match channel_manager.funding_transaction_generated( +/// temporary_channel_id, counterparty_node_id, funding_transaction +/// ) { +/// Ok(()) => println!(\"Funding channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error funding channel {}: {:?}\", temporary_channel_id, e), +/// } +/// }, +/// Event::ChannelPending { channel_id, user_channel_id, former_temporary_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!( +/// \"Channel {} now {} pending (funding transaction has been broadcasted)\", channel_id, +/// former_temporary_channel_id.unwrap() +/// ); +/// }, +/// Event::ChannelReady { channel_id, user_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!(\"Channel {} ready\", channel_id); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// ## Accepting Channels +/// +/// Inbound channels are initiated by peers and are automatically accepted unless [`ChannelManager`] +/// has [`UserConfig::manually_accept_inbound_channels`] set. In that case, the channel may be +/// either accepted or rejected when handling [`Event::OpenChannelRequest`]. +/// +/// ``` +/// # use bitcoin::secp256k1::PublicKey; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # use lightning::events::{Event, EventsProvider}; +/// # +/// # fn is_trusted(counterparty_node_id: PublicKey) -> bool { +/// # // ... +/// # unimplemented!() +/// # } +/// # +/// # fn example(channel_manager: T) { +/// # let channel_manager = channel_manager.get_cm(); +/// # let error_message = \"Channel force-closed\"; +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::OpenChannelRequest { temporary_channel_id, counterparty_node_id, .. } => { +/// if !is_trusted(counterparty_node_id) { +/// match channel_manager.force_close_without_broadcasting_txn( +/// &temporary_channel_id, &counterparty_node_id, error_message.to_string() +/// ) { +/// Ok(()) => println!(\"Rejecting channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error rejecting channel {}: {:?}\", temporary_channel_id, e), +/// } +/// return Ok(()); +/// } +/// +/// let user_channel_id = 43; +/// match channel_manager.accept_inbound_channel( +/// &temporary_channel_id, &counterparty_node_id, user_channel_id +/// ) { +/// Ok(()) => println!(\"Accepting channel {}\", temporary_channel_id), +/// Err(e) => println!(\"Error accepting channel {}: {:?}\", temporary_channel_id, e), +/// } +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// ## Closing Channels +/// +/// There are two ways to close a channel: either cooperatively using [`close_channel`] or +/// unilaterally using [`force_close_broadcasting_latest_txn`]. The former is ideal as it makes for +/// lower fees and immediate access to funds. However, the latter may be necessary if the +/// counterparty isn't behaving properly or has gone offline. [`Event::ChannelClosed`] is generated +/// once the channel has been closed successfully. +/// +/// ``` +/// # use bitcoin::secp256k1::PublicKey; +/// # use lightning::ln::types::ChannelId; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # use lightning::events::{Event, EventsProvider}; +/// # +/// # fn example( +/// # channel_manager: T, channel_id: ChannelId, counterparty_node_id: PublicKey +/// # ) { +/// # let channel_manager = channel_manager.get_cm(); +/// match channel_manager.close_channel(&channel_id, &counterparty_node_id) { +/// Ok(()) => println!(\"Closing channel {}\", channel_id), +/// Err(e) => println!(\"Error closing channel {}: {:?}\", channel_id, e), +/// } +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::ChannelClosed { channel_id, user_channel_id, .. } => { +/// assert_eq!(user_channel_id, 42); +/// println!(\"Channel {} closed\", channel_id); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// # Payments +/// +/// [`ChannelManager`] is responsible for sending, forwarding, and receiving payments through its +/// channels. A payment is typically initiated from a [BOLT 11] invoice or a [BOLT 12] offer, though +/// spontaneous (i.e., keysend) payments are also possible. Incoming payments don't require +/// maintaining any additional state as [`ChannelManager`] can reconstruct the [`PaymentPreimage`] +/// from the [`PaymentSecret`]. Sending payments, however, require tracking in order to retry failed +/// HTLCs. +/// +/// After a payment is initiated, it will appear in [`list_recent_payments`] until a short time +/// after either an [`Event::PaymentSent`] or [`Event::PaymentFailed`] is handled. Failed HTLCs +/// for a payment will be retried according to the payment's [`Retry`] strategy or until +/// [`abandon_payment`] is called. +/// +/// ## BOLT 11 Invoices +/// +/// The [`lightning-invoice`] crate is useful for creating BOLT 11 invoices. Specifically, use the +/// functions in its `utils` module for constructing invoices that are compatible with +/// [`ChannelManager`]. These functions serve as a convenience for building invoices with the +/// [`PaymentHash`] and [`PaymentSecret`] returned from [`create_inbound_payment`]. To provide your +/// own [`PaymentHash`], use [`create_inbound_payment_for_hash`] or the corresponding functions in +/// the [`lightning-invoice`] `utils` module. +/// +/// [`ChannelManager`] generates an [`Event::PaymentClaimable`] once the full payment has been +/// received. Call [`claim_funds`] to release the [`PaymentPreimage`], which in turn will result in +/// an [`Event::PaymentClaimed`]. +/// +/// ``` +/// # use lightning::events::{Event, EventsProvider, PaymentPurpose}; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # +/// # fn example(channel_manager: T) { +/// # let channel_manager = channel_manager.get_cm(); +/// // Or use utils::create_invoice_from_channelmanager +/// let known_payment_hash = match channel_manager.create_inbound_payment( +/// Some(10_000_000), 3600, None +/// ) { +/// Ok((payment_hash, _payment_secret)) => { +/// println!(\"Creating inbound payment {}\", payment_hash); +/// payment_hash +/// }, +/// Err(()) => panic!(\"Error creating inbound payment\"), +/// }; +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: Some(payment_preimage), .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt11InvoicePayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// }, +/// PaymentPurpose::SpontaneousPayment(payment_preimage) => { +/// assert_ne!(payment_hash, known_payment_hash); +/// println!(\"Claiming spontaneous payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// // ... +/// # _ => {}, +/// }, +/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claimed {} msats\", amount_msat); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// For paying an invoice, [`lightning-invoice`] provides a `payment` module with convenience +/// functions for use with [`send_payment`]. +/// +/// ``` +/// # use lightning::events::{Event, EventsProvider}; +/// # use lightning::ln::types::PaymentHash; +/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, RecipientOnionFields, Retry}; +/// # use lightning::routing::router::RouteParameters; +/// # +/// # fn example( +/// # channel_manager: T, payment_hash: PaymentHash, recipient_onion: RecipientOnionFields, +/// # route_params: RouteParameters, retry: Retry +/// # ) { +/// # let channel_manager = channel_manager.get_cm(); +/// // let (payment_hash, recipient_onion, route_params) = +/// // payment::payment_parameters_from_invoice(&invoice); +/// let payment_id = PaymentId([42; 32]); +/// match channel_manager.send_payment( +/// payment_hash, recipient_onion, payment_id, route_params, retry +/// ) { +/// Ok(()) => println!(\"Sending payment with hash {}\", payment_hash), +/// Err(e) => println!(\"Failed sending payment with hash {}: {:?}\", payment_hash, e), +/// } +/// +/// let expected_payment_id = payment_id; +/// let expected_payment_hash = payment_hash; +/// assert!( +/// channel_manager.list_recent_payments().iter().find(|details| matches!( +/// details, +/// RecentPaymentDetails::Pending { +/// payment_id: expected_payment_id, +/// payment_hash: expected_payment_hash, +/// .. +/// } +/// )).is_some() +/// ); +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_hash, .. } => println!(\"Paid {}\", payment_hash), +/// Event::PaymentFailed { payment_hash: Some(payment_hash), .. } => +/// println!(\"Failed paying {}\", payment_hash), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// ## BOLT 12 Offers +/// +/// The [`offers`] module is useful for creating BOLT 12 offers. An [`Offer`] is a precursor to a +/// [`Bolt12Invoice`], which must first be requested by the payer. The interchange of these messages +/// as defined in the specification is handled by [`ChannelManager`] and its implementation of +/// [`OffersMessageHandler`]. However, this only works with an [`Offer`] created using a builder +/// returned by [`create_offer_builder`]. With this approach, BOLT 12 offers and invoices are +/// stateless just as BOLT 11 invoices are. +/// +/// ``` +/// # use lightning::events::{Event, EventsProvider, PaymentPurpose}; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # use lightning::offers::parse::Bolt12SemanticError; +/// # +/// # fn example(channel_manager: T) -> Result<(), Bolt12SemanticError> { +/// # let channel_manager = channel_manager.get_cm(); +/// # let absolute_expiry = None; +/// let offer = channel_manager +/// .create_offer_builder(absolute_expiry)? +/// # ; +/// # // Needed for compiling for c_bindings +/// # let builder: lightning::offers::offer::OfferBuilder<_, _> = offer.into(); +/// # let offer = builder +/// .description(\"coffee\".to_string()) +/// .amount_msats(10_000_000) +/// .build()?; +/// let bech32_offer = offer.to_string(); +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: Some(payment_preimage), .. } => { +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt12OfferPayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// } +/// # _ => {}, +/// }, +/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { +/// println!(\"Claimed {} msats\", amount_msat); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # Ok(()) +/// # } +/// ``` +/// +/// Use [`pay_for_offer`] to initiated payment, which sends an [`InvoiceRequest`] for an [`Offer`] +/// and pays the [`Bolt12Invoice`] response. +/// +/// ``` +/// # use lightning::events::{Event, EventsProvider}; +/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; +/// # use lightning::offers::offer::Offer; +/// # +/// # fn example( +/// # channel_manager: T, offer: &Offer, quantity: Option, amount_msats: Option, +/// # payer_note: Option, retry: Retry, max_total_routing_fee_msat: Option +/// # ) { +/// # let channel_manager = channel_manager.get_cm(); +/// let payment_id = PaymentId([42; 32]); +/// match channel_manager.pay_for_offer( +/// offer, quantity, amount_msats, payer_note, payment_id, retry, max_total_routing_fee_msat +/// ) { +/// Ok(()) => println!(\"Requesting invoice for offer\"), +/// Err(e) => println!(\"Unable to request invoice for offer: {:?}\", e), +/// } +/// +/// // First the payment will be waiting on an invoice +/// let expected_payment_id = payment_id; +/// assert!( +/// channel_manager.list_recent_payments().iter().find(|details| matches!( +/// details, +/// RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id } +/// )).is_some() +/// ); +/// +/// // Once the invoice is received, a payment will be sent +/// assert!( +/// channel_manager.list_recent_payments().iter().find(|details| matches!( +/// details, +/// RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. } +/// )).is_some() +/// ); +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), +/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// ## BOLT 12 Refunds +/// +/// A [`Refund`] is a request for an invoice to be paid. Like *paying* for an [`Offer`], *creating* +/// a [`Refund`] involves maintaining state since it represents a future outbound payment. +/// Therefore, use [`create_refund_builder`] when creating one, otherwise [`ChannelManager`] will +/// refuse to pay any corresponding [`Bolt12Invoice`] that it receives. +/// +/// ``` +/// # use core::time::Duration; +/// # use lightning::events::{Event, EventsProvider}; +/// # use lightning::ln::channelmanager::{AChannelManager, PaymentId, RecentPaymentDetails, Retry}; +/// # use lightning::offers::parse::Bolt12SemanticError; +/// # +/// # fn example( +/// # channel_manager: T, amount_msats: u64, absolute_expiry: Duration, retry: Retry, +/// # max_total_routing_fee_msat: Option +/// # ) -> Result<(), Bolt12SemanticError> { +/// # let channel_manager = channel_manager.get_cm(); +/// let payment_id = PaymentId([42; 32]); +/// let refund = channel_manager +/// .create_refund_builder( +/// amount_msats, absolute_expiry, payment_id, retry, max_total_routing_fee_msat +/// )? +/// # ; +/// # // Needed for compiling for c_bindings +/// # let builder: lightning::offers::refund::RefundBuilder<_> = refund.into(); +/// # let refund = builder +/// .description(\"coffee\".to_string()) +/// .payer_note(\"refund for order 1234\".to_string()) +/// .build()?; +/// let bech32_refund = refund.to_string(); +/// +/// // First the payment will be waiting on an invoice +/// let expected_payment_id = payment_id; +/// assert!( +/// channel_manager.list_recent_payments().iter().find(|details| matches!( +/// details, +/// RecentPaymentDetails::AwaitingInvoice { payment_id: expected_payment_id } +/// )).is_some() +/// ); +/// +/// // Once the invoice is received, a payment will be sent +/// assert!( +/// channel_manager.list_recent_payments().iter().find(|details| matches!( +/// details, +/// RecentPaymentDetails::Pending { payment_id: expected_payment_id, .. } +/// )).is_some() +/// ); +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentSent { payment_id: Some(payment_id), .. } => println!(\"Paid {}\", payment_id), +/// Event::PaymentFailed { payment_id, .. } => println!(\"Failed paying {}\", payment_id), +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # Ok(()) +/// # } +/// ``` +/// +/// Use [`request_refund_payment`] to send a [`Bolt12Invoice`] for receiving the refund. Similar to +/// *creating* an [`Offer`], this is stateless as it represents an inbound payment. +/// +/// ``` +/// # use lightning::events::{Event, EventsProvider, PaymentPurpose}; +/// # use lightning::ln::channelmanager::AChannelManager; +/// # use lightning::offers::refund::Refund; +/// # +/// # fn example(channel_manager: T, refund: &Refund) { +/// # let channel_manager = channel_manager.get_cm(); +/// let known_payment_hash = match channel_manager.request_refund_payment(refund) { +/// Ok(invoice) => { +/// let payment_hash = invoice.payment_hash(); +/// println!(\"Requesting refund payment {}\", payment_hash); +/// payment_hash +/// }, +/// Err(e) => panic!(\"Unable to request payment for refund: {:?}\", e), +/// }; +/// +/// // On the event processing thread +/// channel_manager.process_pending_events(&|event| { +/// match event { +/// Event::PaymentClaimable { payment_hash, purpose, .. } => match purpose { +/// PaymentPurpose::Bolt12RefundPayment { payment_preimage: Some(payment_preimage), .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claiming payment {}\", payment_hash); +/// channel_manager.claim_funds(payment_preimage); +/// }, +/// PaymentPurpose::Bolt12RefundPayment { payment_preimage: None, .. } => { +/// println!(\"Unknown payment hash: {}\", payment_hash); +/// }, +/// // ... +/// # _ => {}, +/// }, +/// Event::PaymentClaimed { payment_hash, amount_msat, .. } => { +/// assert_eq!(payment_hash, known_payment_hash); +/// println!(\"Claimed {} msats\", amount_msat); +/// }, +/// // ... +/// # _ => {}, +/// } +/// Ok(()) +/// }); +/// # } +/// ``` +/// +/// # Persistence /// /// Implements [`Writeable`] to write out all channel state to disk. Implies [`peer_disconnected`] for /// all peers during write/read (though does not modify this instance, only the instance being @@ -935,12 +1648,16 @@ pub(crate) type nativeChannelManager = nativeChannelManagerImport &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelManager { } +unsafe impl core::marker::Sync for ChannelManager { } impl Drop for ChannelManager { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelManager>::is_null(self.inner) { @@ -1009,6 +1766,9 @@ impl ChannelManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::ln::channelmanager::ChainParameters as nativeChainParametersImport; @@ -1034,6 +1794,12 @@ pub struct ChainParameters { pub is_owned: bool, } +impl core::ops::Deref for ChainParameters { + type Target = nativeChainParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChainParameters { } +unsafe impl core::marker::Sync for ChainParameters { } impl Drop for ChainParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChainParameters>::is_null(self.inner) { @@ -1056,1095 +1822,57 @@ impl ChainParameters { } pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChainParameters { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The network for determining the `chain_hash` in Lightning messages. -#[no_mangle] -pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network { - let mut inner_val = &mut this_ptr.get_native_mut_ref().network; - crate::bitcoin::network::Network::from_bitcoin(inner_val) -} -/// The network for determining the `chain_hash` in Lightning messages. -#[no_mangle] -pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin(); -} -/// The hash and height of the latest block successfully connected. -/// -/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. -#[no_mangle] -pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock { - let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block; - crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false } -} -/// The hash and height of the latest block successfully connected. -/// -/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. -#[no_mangle] -pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Constructs a new ChainParameters given each field -#[must_use] -#[no_mangle] -pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters { - ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters { - network: network_arg.into_bitcoin(), - best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) }, - }), is_owned: true } -} -impl Clone for ChainParameters { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChainParameters)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChainParameters -pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters { - orig.clone() -} -/// The amount of time in blocks we require our counterparty wait to claim their money (ie time -/// between when we, or our watchtower, must check for them having broadcast a theft transaction). -/// -/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`] -/// -/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay - -#[no_mangle] -pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; -/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound -/// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour. -/// -/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`] -/// -/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta - -#[no_mangle] -pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; -/// Minimum CLTV difference between the current block height and received inbound payments. -/// Invoices generated for payment to us must set their `min_final_cltv_expiry_delta` field to at least -/// this value. - -#[no_mangle] -pub static MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; - -use lightning::ln::channelmanager::CounterpartyForwardingInfo as nativeCounterpartyForwardingInfoImport; -pub(crate) type nativeCounterpartyForwardingInfo = nativeCounterpartyForwardingInfoImport; - -/// Information needed for constructing an invoice route hint for this channel. -#[must_use] -#[repr(C)] -pub struct CounterpartyForwardingInfo { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeCounterpartyForwardingInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for CounterpartyForwardingInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the CounterpartyForwardingInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_free(this_obj: CounterpartyForwardingInfo) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn CounterpartyForwardingInfo_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCounterpartyForwardingInfo) }; -} -#[allow(unused)] -impl CounterpartyForwardingInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeCounterpartyForwardingInfo { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCounterpartyForwardingInfo { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Base routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_get_fee_base_msat(this_ptr: &CounterpartyForwardingInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; - *inner_val -} -/// Base routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_set_fee_base_msat(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; -} -/// Amount in millionths of a satoshi the channel will charge per transferred satoshi. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_get_fee_proportional_millionths(this_ptr: &CounterpartyForwardingInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; - *inner_val -} -/// Amount in millionths of a satoshi the channel will charge per transferred satoshi. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_set_fee_proportional_millionths(this_ptr: &mut CounterpartyForwardingInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; -} -/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, -/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s -/// `cltv_expiry_delta` for more details. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_get_cltv_expiry_delta(this_ptr: &CounterpartyForwardingInfo) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// The minimum difference in cltv_expiry between an ingoing HTLC and its outgoing counterpart, -/// such that the outgoing HTLC is forwardable to this counterparty. See `msgs::ChannelUpdate`'s -/// `cltv_expiry_delta` for more details. -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_set_cltv_expiry_delta(this_ptr: &mut CounterpartyForwardingInfo, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; -} -/// Constructs a new CounterpartyForwardingInfo given each field -#[must_use] -#[no_mangle] -pub extern "C" fn CounterpartyForwardingInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16) -> CounterpartyForwardingInfo { - CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(nativeCounterpartyForwardingInfo { - fee_base_msat: fee_base_msat_arg, - fee_proportional_millionths: fee_proportional_millionths_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, - }), is_owned: true } -} -impl Clone for CounterpartyForwardingInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn CounterpartyForwardingInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCounterpartyForwardingInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the CounterpartyForwardingInfo -pub extern "C" fn CounterpartyForwardingInfo_clone(orig: &CounterpartyForwardingInfo) -> CounterpartyForwardingInfo { - orig.clone() -} -/// Get a string which allows debug introspection of a CounterpartyForwardingInfo object -pub extern "C" fn CounterpartyForwardingInfo_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::CounterpartyForwardingInfo }).into()} - -use lightning::ln::channelmanager::ChannelCounterparty as nativeChannelCounterpartyImport; -pub(crate) type nativeChannelCounterparty = nativeChannelCounterpartyImport; - -/// Channel parameters which apply to our counterparty. These are split out from [`ChannelDetails`] -/// to better separate parameters. -#[must_use] -#[repr(C)] -pub struct ChannelCounterparty { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeChannelCounterparty, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelCounterparty { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelCounterparty>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelCounterparty, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_free(this_obj: ChannelCounterparty) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelCounterparty_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelCounterparty) }; -} -#[allow(unused)] -impl ChannelCounterparty { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelCounterparty { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelCounterparty { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The node_id of our counterparty -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_node_id(this_ptr: &ChannelCounterparty) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().node_id; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The node_id of our counterparty -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_node_id(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_id = val.into_rust(); -} -/// The Features the channel counterparty provided upon last connection. -/// Useful for routing as it is the most up-to-date copy of the counterparty's features and -/// many routing-relevant features are present in the init context. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_features(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::features::InitFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } -} -/// The Features the channel counterparty provided upon last connection. -/// Useful for routing as it is the most up-to-date copy of the counterparty's features and -/// many routing-relevant features are present in the init context. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_features(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::features::InitFeatures) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The value, in satoshis, that must always be held in the channel for our counterparty. This -/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by -/// claiming at least this value on chain. -/// -/// This value is not included in [`inbound_capacity_msat`] as it can never be spent. -/// -/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_unspendable_punishment_reserve(this_ptr: &ChannelCounterparty) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve; - *inner_val -} -/// The value, in satoshis, that must always be held in the channel for our counterparty. This -/// value ensures that if our counterparty broadcasts a revoked state, we can punish them by -/// claiming at least this value on chain. -/// -/// This value is not included in [`inbound_capacity_msat`] as it can never be spent. -/// -/// [`inbound_capacity_msat`]: ChannelDetails::inbound_capacity_msat -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_unspendable_punishment_reserve(this_ptr: &mut ChannelCounterparty, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = val; -} -/// Information on the fees and requirements that the counterparty requires when forwarding -/// payments to us through this channel. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { - let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info; - let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false }; - local_inner_val -} -/// Information on the fees and requirements that the counterparty requires when forwarding -/// payments to us through this channel. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_forwarding_info(this_ptr: &mut ChannelCounterparty, mut val: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_info = local_val; -} -/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field -/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message -/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_outbound_htlc_minimum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_minimum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The smallest value HTLC (in msat) the remote peer will accept, for this channel. This field -/// is only `None` before we have received either the `OpenChannel` or `AcceptChannel` message -/// from the remote peer, or for `ChannelCounterparty` objects serialized prior to LDK 0.0.107. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_outbound_htlc_minimum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_minimum_msat = local_val; -} -/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_get_outbound_htlc_maximum_msat(this_ptr: &ChannelCounterparty) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_htlc_maximum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The largest value HTLC (in msat) the remote peer currently will accept, for this channel. -#[no_mangle] -pub extern "C" fn ChannelCounterparty_set_outbound_htlc_maximum_msat(this_ptr: &mut ChannelCounterparty, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_htlc_maximum_msat = local_val; -} -/// Constructs a new ChannelCounterparty given each field -/// -/// Note that forwarding_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelCounterparty_new(mut node_id_arg: crate::c_types::PublicKey, mut features_arg: crate::lightning::ln::features::InitFeatures, mut unspendable_punishment_reserve_arg: u64, mut forwarding_info_arg: crate::lightning::ln::channelmanager::CounterpartyForwardingInfo, mut outbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut outbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> ChannelCounterparty { - let mut local_forwarding_info_arg = if forwarding_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(forwarding_info_arg.take_inner()) } }) }; - let mut local_outbound_htlc_minimum_msat_arg = if outbound_htlc_minimum_msat_arg.is_some() { Some( { outbound_htlc_minimum_msat_arg.take() }) } else { None }; - let mut local_outbound_htlc_maximum_msat_arg = if outbound_htlc_maximum_msat_arg.is_some() { Some( { outbound_htlc_maximum_msat_arg.take() }) } else { None }; - ChannelCounterparty { inner: ObjOps::heap_alloc(nativeChannelCounterparty { - node_id: node_id_arg.into_rust(), - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - unspendable_punishment_reserve: unspendable_punishment_reserve_arg, - forwarding_info: local_forwarding_info_arg, - outbound_htlc_minimum_msat: local_outbound_htlc_minimum_msat_arg, - outbound_htlc_maximum_msat: local_outbound_htlc_maximum_msat_arg, - }), is_owned: true } -} -impl Clone for ChannelCounterparty { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelCounterparty_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelCounterparty)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelCounterparty -pub extern "C" fn ChannelCounterparty_clone(orig: &ChannelCounterparty) -> ChannelCounterparty { - orig.clone() -} -/// Get a string which allows debug introspection of a ChannelCounterparty object -pub extern "C" fn ChannelCounterparty_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelCounterparty }).into()} - -use lightning::ln::channelmanager::ChannelDetails as nativeChannelDetailsImport; -pub(crate) type nativeChannelDetails = nativeChannelDetailsImport; - -/// Details of a channel, as returned by [`ChannelManager::list_channels`] and [`ChannelManager::list_usable_channels`] -#[must_use] -#[repr(C)] -pub struct ChannelDetails { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeChannelDetails, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelDetails { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelDetails>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelDetails, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelDetails_free(this_obj: ChannelDetails) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelDetails_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelDetails) }; -} -#[allow(unused)] -impl ChannelDetails { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelDetails { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelDetails { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, -/// thereafter this is the txid of the funding transaction xor the funding transaction output). -/// Note that this means this value is *not* persistent - it can change once during the -/// lifetime of the channel. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_channel_id(this_ptr: &ChannelDetails) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 -} -/// The channel's ID (prior to funding transaction generation, this is a random 32 bytes, -/// thereafter this is the txid of the funding transaction xor the funding transaction output). -/// Note that this means this value is *not* persistent - it can change once during the -/// lifetime of the channel. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); -} -/// Parameters which apply to our counterparty. See individual fields for more information. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_counterparty(this_ptr: &ChannelDetails) -> crate::lightning::ln::channelmanager::ChannelCounterparty { - let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty; - crate::lightning::ln::channelmanager::ChannelCounterparty { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::channelmanager::ChannelCounterparty<>) as *mut _) }, is_owned: false } -} -/// Parameters which apply to our counterparty. See individual fields for more information. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_counterparty(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::channelmanager::ChannelCounterparty) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The Channel's funding transaction output, if we've negotiated the funding transaction with -/// our counterparty already. -/// -/// Note that, if this has been set, `channel_id` will be equivalent to -/// `funding_txo.unwrap().to_channel_id()`. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo; - let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false }; - local_inner_val -} -/// The Channel's funding transaction output, if we've negotiated the funding transaction with -/// our counterparty already. -/// -/// Note that, if this has been set, `channel_id` will be equivalent to -/// `funding_txo.unwrap().to_channel_id()`. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelDetails_set_funding_txo(this_ptr: &mut ChannelDetails, mut val: crate::lightning::chain::transaction::OutPoint) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txo = local_val; -} -/// The features which this channel operates with. See individual features for more info. -/// -/// `None` until negotiation completes and the channel type is finalized. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelDetails_get_channel_type(this_ptr: &ChannelDetails) -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; - let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; - local_inner_val -} -/// The features which this channel operates with. See individual features for more info. -/// -/// `None` until negotiation completes and the channel type is finalized. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn ChannelDetails_set_channel_type(this_ptr: &mut ChannelDetails, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; -} -/// The position of the funding transaction in the chain. None if the funding transaction has -/// not yet been confirmed and the channel fully opened. -/// -/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound -/// payments instead of this. See [`get_inbound_payment_scid`]. -/// -/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may -/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. -/// -/// [`inbound_scid_alias`]: Self::inbound_scid_alias -/// [`outbound_scid_alias`]: Self::outbound_scid_alias -/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid -/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid -/// [`confirmations_required`]: Self::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_get_short_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The position of the funding transaction in the chain. None if the funding transaction has -/// not yet been confirmed and the channel fully opened. -/// -/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound -/// payments instead of this. See [`get_inbound_payment_scid`]. -/// -/// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may -/// be used in place of this in outbound routes. See [`get_outbound_payment_scid`]. -/// -/// [`inbound_scid_alias`]: Self::inbound_scid_alias -/// [`outbound_scid_alias`]: Self::outbound_scid_alias -/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid -/// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid -/// [`confirmations_required`]: Self::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_set_short_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = local_val; -} -/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and -/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when -/// the channel has not yet been confirmed (as long as [`confirmations_required`] is -/// `Some(0)`). -/// -/// This will be `None` as long as the channel is not available for routing outbound payments. -/// -/// [`short_channel_id`]: Self::short_channel_id -/// [`confirmations_required`]: Self::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_get_outbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_scid_alias; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// An optional [`short_channel_id`] alias for this channel, randomly generated by us and -/// usable in place of [`short_channel_id`] to reference the channel in outbound routes when -/// the channel has not yet been confirmed (as long as [`confirmations_required`] is -/// `Some(0)`). -/// -/// This will be `None` as long as the channel is not available for routing outbound payments. -/// -/// [`short_channel_id`]: Self::short_channel_id -/// [`confirmations_required`]: Self::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_set_outbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_scid_alias = local_val; -} -/// An optional [`short_channel_id`] alias for this channel, randomly generated by our -/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our -/// counterparty will recognize the alias provided here in place of the [`short_channel_id`] -/// when they see a payment to be routed to us. -/// -/// Our counterparty may choose to rotate this value at any time, though will always recognize -/// previous values for inbound payment forwarding. -/// -/// [`short_channel_id`]: Self::short_channel_id -#[no_mangle] -pub extern "C" fn ChannelDetails_get_inbound_scid_alias(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_scid_alias; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// An optional [`short_channel_id`] alias for this channel, randomly generated by our -/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our -/// counterparty will recognize the alias provided here in place of the [`short_channel_id`] -/// when they see a payment to be routed to us. -/// -/// Our counterparty may choose to rotate this value at any time, though will always recognize -/// previous values for inbound payment forwarding. -/// -/// [`short_channel_id`]: Self::short_channel_id -#[no_mangle] -pub extern "C" fn ChannelDetails_set_inbound_scid_alias(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_scid_alias = local_val; -} -/// The value, in satoshis, of this channel as appears in the funding output -#[no_mangle] -pub extern "C" fn ChannelDetails_get_channel_value_satoshis(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_value_satoshis; - *inner_val -} -/// The value, in satoshis, of this channel as appears in the funding output -#[no_mangle] -pub extern "C" fn ChannelDetails_set_channel_value_satoshis(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; -} -/// The value, in satoshis, that must always be held in the channel for us. This value ensures -/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least -/// this value on chain. -/// -/// This value is not included in [`outbound_capacity_msat`] as it can never be spent. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -/// -/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat -#[no_mangle] -pub extern "C" fn ChannelDetails_get_unspendable_punishment_reserve(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().unspendable_punishment_reserve; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The value, in satoshis, that must always be held in the channel for us. This value ensures -/// that if we broadcast a revoked state, our counterparty can punish us by claiming at least -/// this value on chain. -/// -/// This value is not included in [`outbound_capacity_msat`] as it can never be spent. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -/// -/// [`outbound_capacity_msat`]: ChannelDetails::outbound_capacity_msat -#[no_mangle] -pub extern "C" fn ChannelDetails_set_unspendable_punishment_reserve(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.unspendable_punishment_reserve = local_val; -} -/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound -/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if -/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise -/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects -/// serialized with LDK versions prior to 0.0.113. -/// -/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel -/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel -/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels -#[no_mangle] -pub extern "C" fn ChannelDetails_get_user_channel_id(this_ptr: &ChannelDetails) -> crate::c_types::U128 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().user_channel_id; - inner_val.into() -} -/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`] for outbound -/// channels, or to [`ChannelManager::accept_inbound_channel`] for inbound channels if -/// [`UserConfig::manually_accept_inbound_channels`] config flag is set to true. Otherwise -/// `user_channel_id` will be randomized for an inbound channel. This may be zero for objects -/// serialized with LDK versions prior to 0.0.113. -/// -/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel -/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel -/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels -#[no_mangle] -pub extern "C" fn ChannelDetails_set_user_channel_id(this_ptr: &mut ChannelDetails, mut val: crate::c_types::U128) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.user_channel_id = val.into(); -} -/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, -/// which is applied to commitment and HTLC transactions. -/// -/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_feerate_sat_per_1000_weight(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_sat_per_1000_weight; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The currently negotiated fee rate denominated in satoshi per 1000 weight units, -/// which is applied to commitment and HTLC transactions. -/// -/// This value will be `None` for objects serialized with LDK versions prior to 0.0.115. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_feerate_sat_per_1000_weight(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_sat_per_1000_weight = local_val; -} -/// Our total balance. This is the amount we would get if we close the channel. -/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this -/// amount is not likely to be recoverable on close. -/// -/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose -/// balance is not available for inclusion in new outbound HTLCs). This further does not include -/// any pending outgoing HTLCs which are awaiting some other resolution to be sent. -/// This does not consider any on-chain fees. -/// -/// See also [`ChannelDetails::outbound_capacity_msat`] -#[no_mangle] -pub extern "C" fn ChannelDetails_get_balance_msat(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().balance_msat; - *inner_val -} -/// Our total balance. This is the amount we would get if we close the channel. -/// This value is not exact. Due to various in-flight changes and feerate changes, exactly this -/// amount is not likely to be recoverable on close. -/// -/// This does not include any pending HTLCs which are not yet fully resolved (and, thus, whose -/// balance is not available for inclusion in new outbound HTLCs). This further does not include -/// any pending outgoing HTLCs which are awaiting some other resolution to be sent. -/// This does not consider any on-chain fees. -/// -/// See also [`ChannelDetails::outbound_capacity_msat`] -#[no_mangle] -pub extern "C" fn ChannelDetails_set_balance_msat(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.balance_msat = val; -} -/// The available outbound capacity for sending HTLCs to the remote peer. This does not include -/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not -/// available for inclusion in new outbound HTLCs). This further does not include any pending -/// outgoing HTLCs which are awaiting some other resolution to be sent. -/// -/// See also [`ChannelDetails::balance_msat`] -/// -/// This value is not exact. Due to various in-flight changes, feerate changes, and our -/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we -/// should be able to spend nearly this amount. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_outbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().outbound_capacity_msat; - *inner_val -} -/// The available outbound capacity for sending HTLCs to the remote peer. This does not include -/// any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not -/// available for inclusion in new outbound HTLCs). This further does not include any pending -/// outgoing HTLCs which are awaiting some other resolution to be sent. -/// -/// See also [`ChannelDetails::balance_msat`] -/// -/// This value is not exact. Due to various in-flight changes, feerate changes, and our -/// conflict-avoidance policy, exactly this amount is not likely to be spendable. However, we -/// should be able to spend nearly this amount. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_outbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.outbound_capacity_msat = val; -} -/// The available outbound capacity for sending a single HTLC to the remote peer. This is -/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by -/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us -/// to use a limit as close as possible to the HTLC limit we can currently send. -/// -/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], -/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_next_outbound_htlc_limit_msat(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_limit_msat; - *inner_val -} -/// The available outbound capacity for sending a single HTLC to the remote peer. This is -/// similar to [`ChannelDetails::outbound_capacity_msat`] but it may be further restricted by -/// the current state and per-HTLC limit(s). This is intended for use when routing, allowing us -/// to use a limit as close as possible to the HTLC limit we can currently send. -/// -/// See also [`ChannelDetails::next_outbound_htlc_minimum_msat`], -/// [`ChannelDetails::balance_msat`], and [`ChannelDetails::outbound_capacity_msat`]. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_next_outbound_htlc_limit_msat(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_limit_msat = val; -} -/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of -/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than -/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a -/// route which is valid. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_next_outbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().next_outbound_htlc_minimum_msat; - *inner_val -} -/// The minimum value for sending a single HTLC to the remote peer. This is the equivalent of -/// [`ChannelDetails::next_outbound_htlc_limit_msat`] but represents a lower-bound, rather than -/// an upper-bound. This is intended for use when routing, allowing us to ensure we pick a -/// route which is valid. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_next_outbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.next_outbound_htlc_minimum_msat = val; -} -/// The available inbound capacity for the remote peer to send HTLCs to us. This does not -/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not -/// available for inclusion in new inbound HTLCs). -/// Note that there are some corner cases not fully handled here, so the actual available -/// inbound capacity may be slightly higher than this. -/// -/// This value is not exact. Due to various in-flight changes, feerate changes, and our -/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. -/// However, our counterparty should be able to spend nearly this amount. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_inbound_capacity_msat(this_ptr: &ChannelDetails) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_capacity_msat; - *inner_val -} -/// The available inbound capacity for the remote peer to send HTLCs to us. This does not -/// include any pending HTLCs which are not yet fully resolved (and, thus, whose balance is not -/// available for inclusion in new inbound HTLCs). -/// Note that there are some corner cases not fully handled here, so the actual available -/// inbound capacity may be slightly higher than this. -/// -/// This value is not exact. Due to various in-flight changes, feerate changes, and our -/// counterparty's conflict-avoidance policy, exactly this amount is not likely to be spendable. -/// However, our counterparty should be able to spend nearly this amount. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_inbound_capacity_msat(this_ptr: &mut ChannelDetails, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_capacity_msat = val; -} -/// The number of required confirmations on the funding transaction before the funding will be -/// considered \"locked\". This number is selected by the channel fundee (i.e. us if -/// [`is_outbound`] is *not* set), and can be selected for inbound channels with -/// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with -/// [`ChannelHandshakeLimits::max_minimum_depth`]. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -/// -/// [`is_outbound`]: ChannelDetails::is_outbound -/// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth -/// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth -#[no_mangle] -pub extern "C" fn ChannelDetails_get_confirmations_required(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations_required; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The number of required confirmations on the funding transaction before the funding will be -/// considered \"locked\". This number is selected by the channel fundee (i.e. us if -/// [`is_outbound`] is *not* set), and can be selected for inbound channels with -/// [`ChannelHandshakeConfig::minimum_depth`] or limited for outbound channels with -/// [`ChannelHandshakeLimits::max_minimum_depth`]. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -/// -/// [`is_outbound`]: ChannelDetails::is_outbound -/// [`ChannelHandshakeConfig::minimum_depth`]: crate::util::config::ChannelHandshakeConfig::minimum_depth -/// [`ChannelHandshakeLimits::max_minimum_depth`]: crate::util::config::ChannelHandshakeLimits::max_minimum_depth -#[no_mangle] -pub extern "C" fn ChannelDetails_set_confirmations_required(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations_required = local_val; -} -/// The current number of confirmations on the funding transaction. -/// -/// This value will be `None` for objects serialized with LDK versions prior to 0.0.113. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_confirmations(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u32Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().confirmations; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The current number of confirmations on the funding transaction. -/// -/// This value will be `None` for objects serialized with LDK versions prior to 0.0.113. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_confirmations(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u32Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.confirmations = local_val; -} -/// The number of blocks (after our commitment transaction confirms) that we will need to wait -/// until we can claim our funds after we force-close the channel. During this time our -/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty -/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any -/// time to claim our non-HTLC-encumbered funds. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_force_close_spend_delay(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u16Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().force_close_spend_delay; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u16Z::None } else { crate::c_types::derived::COption_u16Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The number of blocks (after our commitment transaction confirms) that we will need to wait -/// until we can claim our funds after we force-close the channel. During this time our -/// counterparty is allowed to punish us if we broadcasted a stale state. If our counterparty -/// force-closes the channel and broadcasts a commitment transaction we do not have to wait any -/// time to claim our non-HTLC-encumbered funds. -/// -/// This value will be `None` for outbound channels until the counterparty accepts the channel. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_force_close_spend_delay(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u16Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_close_spend_delay = local_val; -} -/// True if the channel was initiated (and thus funded) by us. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_is_outbound(this_ptr: &ChannelDetails) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().is_outbound; - *inner_val -} -/// True if the channel was initiated (and thus funded) by us. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_is_outbound(this_ptr: &mut ChannelDetails, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_outbound = val; -} -/// True if the channel is confirmed, channel_ready messages have been exchanged, and the -/// channel is not currently being shut down. `channel_ready` message exchange implies the -/// required confirmation count has been reached (and we were connected to the peer at some -/// point after the funding transaction received enough confirmations). The required -/// confirmation count is provided in [`confirmations_required`]. -/// -/// [`confirmations_required`]: ChannelDetails::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_get_is_channel_ready(this_ptr: &ChannelDetails) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().is_channel_ready; - *inner_val -} -/// True if the channel is confirmed, channel_ready messages have been exchanged, and the -/// channel is not currently being shut down. `channel_ready` message exchange implies the -/// required confirmation count has been reached (and we were connected to the peer at some -/// point after the funding transaction received enough confirmations). The required -/// confirmation count is provided in [`confirmations_required`]. -/// -/// [`confirmations_required`]: ChannelDetails::confirmations_required -#[no_mangle] -pub extern "C" fn ChannelDetails_set_is_channel_ready(this_ptr: &mut ChannelDetails, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_channel_ready = val; -} -/// The stage of the channel's shutdown. -/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. -/// -/// Returns a copy of the field. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_channel_shutdown_state(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_ChannelShutdownStateZ { - let mut inner_val = this_ptr.get_native_mut_ref().channel_shutdown_state.clone(); - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ChannelShutdownStateZ::None } else { crate::c_types::derived::COption_ChannelShutdownStateZ::Some( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(inner_val.unwrap()) }) }; - local_inner_val -} -/// The stage of the channel's shutdown. -/// `None` for `ChannelDetails` serialized on LDK versions prior to 0.0.116. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_channel_shutdown_state(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_ChannelShutdownStateZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_shutdown_state = local_val; -} -/// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) -/// the peer is connected, and (c) the channel is not currently negotiating a shutdown. -/// -/// This is a strict superset of `is_channel_ready`. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_is_usable(this_ptr: &ChannelDetails) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().is_usable; - *inner_val -} -/// True if the channel is (a) confirmed and channel_ready messages have been exchanged, (b) -/// the peer is connected, and (c) the channel is not currently negotiating a shutdown. -/// -/// This is a strict superset of `is_channel_ready`. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_is_usable(this_ptr: &mut ChannelDetails, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_usable = val; -} -/// True if this channel is (or will be) publicly-announced. -#[no_mangle] -pub extern "C" fn ChannelDetails_get_is_public(this_ptr: &ChannelDetails) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().is_public; - *inner_val -} -/// True if this channel is (or will be) publicly-announced. -#[no_mangle] -pub extern "C" fn ChannelDetails_set_is_public(this_ptr: &mut ChannelDetails, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_public = val; -} -/// The smallest value HTLC (in msat) we will accept, for this channel. This field -/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 -#[no_mangle] -pub extern "C" fn ChannelDetails_get_inbound_htlc_minimum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_minimum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The smallest value HTLC (in msat) we will accept, for this channel. This field -/// is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.107 -#[no_mangle] -pub extern "C" fn ChannelDetails_set_inbound_htlc_minimum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_minimum_msat = local_val; + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The largest value HTLC (in msat) we currently will accept, for this channel. +/// The network for determining the `chain_hash` in Lightning messages. #[no_mangle] -pub extern "C" fn ChannelDetails_get_inbound_htlc_maximum_msat(this_ptr: &ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().inbound_htlc_maximum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val +pub extern "C" fn ChainParameters_get_network(this_ptr: &ChainParameters) -> crate::bitcoin::network::Network { + let mut inner_val = &mut this_ptr.get_native_mut_ref().network; + crate::bitcoin::network::Network::from_bitcoin(inner_val) } -/// The largest value HTLC (in msat) we currently will accept, for this channel. +/// The network for determining the `chain_hash` in Lightning messages. #[no_mangle] -pub extern "C" fn ChannelDetails_set_inbound_htlc_maximum_msat(this_ptr: &mut ChannelDetails, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.inbound_htlc_maximum_msat = local_val; +pub extern "C" fn ChainParameters_set_network(this_ptr: &mut ChainParameters, mut val: crate::bitcoin::network::Network) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.network = val.into_bitcoin(); } -/// Set of configurable parameters that affect channel operation. -/// -/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. +/// The hash and height of the latest block successfully connected. /// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. #[no_mangle] -pub extern "C" fn ChannelDetails_get_config(this_ptr: &ChannelDetails) -> crate::lightning::util::config::ChannelConfig { - let mut inner_val = &mut this_ptr.get_native_mut_ref().config; - let mut local_inner_val = crate::lightning::util::config::ChannelConfig { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::util::config::ChannelConfig<>) as *mut _ }, is_owned: false }; - local_inner_val +pub extern "C" fn ChainParameters_get_best_block(this_ptr: &ChainParameters) -> crate::lightning::chain::BestBlock { + let mut inner_val = &mut this_ptr.get_native_mut_ref().best_block; + crate::lightning::chain::BestBlock { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::chain::BestBlock<>) as *mut _) }, is_owned: false } } -/// Set of configurable parameters that affect channel operation. -/// -/// This field is only `None` for `ChannelDetails` objects serialized prior to LDK 0.0.109. +/// The hash and height of the latest block successfully connected. /// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Used to track on-chain channel funding outputs and send payments with reliable timelocks. #[no_mangle] -pub extern "C" fn ChannelDetails_set_config(this_ptr: &mut ChannelDetails, mut val: crate::lightning::util::config::ChannelConfig) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.config = local_val; +pub extern "C" fn ChainParameters_set_best_block(this_ptr: &mut ChainParameters, mut val: crate::lightning::chain::BestBlock) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.best_block = *unsafe { Box::from_raw(val.take_inner()) }; } -/// Constructs a new ChannelDetails given each field -/// -/// Note that funding_txo_arg (or a relevant inner pointer) may be NULL or all-0s to represent None -/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None -/// Note that config_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Constructs a new ChainParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelDetails_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut counterparty_arg: crate::lightning::ln::channelmanager::ChannelCounterparty, mut funding_txo_arg: crate::lightning::chain::transaction::OutPoint, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut short_channel_id_arg: crate::c_types::derived::COption_u64Z, mut outbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut inbound_scid_alias_arg: crate::c_types::derived::COption_u64Z, mut channel_value_satoshis_arg: u64, mut unspendable_punishment_reserve_arg: crate::c_types::derived::COption_u64Z, mut user_channel_id_arg: crate::c_types::U128, mut feerate_sat_per_1000_weight_arg: crate::c_types::derived::COption_u32Z, mut balance_msat_arg: u64, mut outbound_capacity_msat_arg: u64, mut next_outbound_htlc_limit_msat_arg: u64, mut next_outbound_htlc_minimum_msat_arg: u64, mut inbound_capacity_msat_arg: u64, mut confirmations_required_arg: crate::c_types::derived::COption_u32Z, mut confirmations_arg: crate::c_types::derived::COption_u32Z, mut force_close_spend_delay_arg: crate::c_types::derived::COption_u16Z, mut is_outbound_arg: bool, mut is_channel_ready_arg: bool, mut channel_shutdown_state_arg: crate::c_types::derived::COption_ChannelShutdownStateZ, mut is_usable_arg: bool, mut is_public_arg: bool, mut inbound_htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut inbound_htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z, mut config_arg: crate::lightning::util::config::ChannelConfig) -> ChannelDetails { - let mut local_funding_txo_arg = if funding_txo_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(funding_txo_arg.take_inner()) } }) }; - let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; - let mut local_short_channel_id_arg = if short_channel_id_arg.is_some() { Some( { short_channel_id_arg.take() }) } else { None }; - let mut local_outbound_scid_alias_arg = if outbound_scid_alias_arg.is_some() { Some( { outbound_scid_alias_arg.take() }) } else { None }; - let mut local_inbound_scid_alias_arg = if inbound_scid_alias_arg.is_some() { Some( { inbound_scid_alias_arg.take() }) } else { None }; - let mut local_unspendable_punishment_reserve_arg = if unspendable_punishment_reserve_arg.is_some() { Some( { unspendable_punishment_reserve_arg.take() }) } else { None }; - let mut local_feerate_sat_per_1000_weight_arg = if feerate_sat_per_1000_weight_arg.is_some() { Some( { feerate_sat_per_1000_weight_arg.take() }) } else { None }; - let mut local_confirmations_required_arg = if confirmations_required_arg.is_some() { Some( { confirmations_required_arg.take() }) } else { None }; - let mut local_confirmations_arg = if confirmations_arg.is_some() { Some( { confirmations_arg.take() }) } else { None }; - let mut local_force_close_spend_delay_arg = if force_close_spend_delay_arg.is_some() { Some( { force_close_spend_delay_arg.take() }) } else { None }; - let mut local_channel_shutdown_state_arg = { /*channel_shutdown_state_arg*/ let channel_shutdown_state_arg_opt = channel_shutdown_state_arg; if channel_shutdown_state_arg_opt.is_none() { None } else { Some({ { { channel_shutdown_state_arg_opt.take() }.into_native() }})} }; - let mut local_inbound_htlc_minimum_msat_arg = if inbound_htlc_minimum_msat_arg.is_some() { Some( { inbound_htlc_minimum_msat_arg.take() }) } else { None }; - let mut local_inbound_htlc_maximum_msat_arg = if inbound_htlc_maximum_msat_arg.is_some() { Some( { inbound_htlc_maximum_msat_arg.take() }) } else { None }; - let mut local_config_arg = if config_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(config_arg.take_inner()) } }) }; - ChannelDetails { inner: ObjOps::heap_alloc(nativeChannelDetails { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), - counterparty: *unsafe { Box::from_raw(counterparty_arg.take_inner()) }, - funding_txo: local_funding_txo_arg, - channel_type: local_channel_type_arg, - short_channel_id: local_short_channel_id_arg, - outbound_scid_alias: local_outbound_scid_alias_arg, - inbound_scid_alias: local_inbound_scid_alias_arg, - channel_value_satoshis: channel_value_satoshis_arg, - unspendable_punishment_reserve: local_unspendable_punishment_reserve_arg, - user_channel_id: user_channel_id_arg.into(), - feerate_sat_per_1000_weight: local_feerate_sat_per_1000_weight_arg, - balance_msat: balance_msat_arg, - outbound_capacity_msat: outbound_capacity_msat_arg, - next_outbound_htlc_limit_msat: next_outbound_htlc_limit_msat_arg, - next_outbound_htlc_minimum_msat: next_outbound_htlc_minimum_msat_arg, - inbound_capacity_msat: inbound_capacity_msat_arg, - confirmations_required: local_confirmations_required_arg, - confirmations: local_confirmations_arg, - force_close_spend_delay: local_force_close_spend_delay_arg, - is_outbound: is_outbound_arg, - is_channel_ready: is_channel_ready_arg, - channel_shutdown_state: local_channel_shutdown_state_arg, - is_usable: is_usable_arg, - is_public: is_public_arg, - inbound_htlc_minimum_msat: local_inbound_htlc_minimum_msat_arg, - inbound_htlc_maximum_msat: local_inbound_htlc_maximum_msat_arg, - config: local_config_arg, +pub extern "C" fn ChainParameters_new(mut network_arg: crate::bitcoin::network::Network, mut best_block_arg: crate::lightning::chain::BestBlock) -> ChainParameters { + ChainParameters { inner: ObjOps::heap_alloc(nativeChainParameters { + network: network_arg.into_bitcoin(), + best_block: *unsafe { Box::from_raw(best_block_arg.take_inner()) }, }), is_owned: true } } -impl Clone for ChannelDetails { +impl Clone for ChainParameters { fn clone(&self) -> Self { Self { - inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2152,158 +1880,38 @@ impl Clone for ChannelDetails { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelDetails)).clone() })) as *mut c_void +pub(crate) extern "C" fn ChainParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChainParameters)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the ChannelDetails -pub extern "C" fn ChannelDetails_clone(orig: &ChannelDetails) -> ChannelDetails { +/// Creates a copy of the ChainParameters +pub extern "C" fn ChainParameters_clone(orig: &ChainParameters) -> ChainParameters { orig.clone() } -/// Get a string which allows debug introspection of a ChannelDetails object -pub extern "C" fn ChannelDetails_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelDetails }).into()} -/// Gets the current SCID which should be used to identify this channel for inbound payments. -/// This should be used for providing invoice hints or in any other context where our -/// counterparty will forward a payment to us. +/// The amount of time in blocks we require our counterparty wait to claim their money (ie time +/// between when we, or our watchtower, must check for them having broadcast a theft transaction). /// -/// This is either the [`ChannelDetails::inbound_scid_alias`], if set, or the -/// [`ChannelDetails::short_channel_id`]. See those for more information. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelDetails_get_inbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_inbound_payment_scid(); - let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; - local_ret -} - -/// Gets the current SCID which should be used to identify this channel for outbound payments. -/// This should be used in [`Route`]s to describe the first hop or in other contexts where -/// we're sending or forwarding a payment outbound over this channel. +/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`] /// -/// This is either the [`ChannelDetails::short_channel_id`], if set, or the -/// [`ChannelDetails::outbound_scid_alias`]. See those for more information. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelDetails_get_outbound_payment_scid(this_arg: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::COption_u64Z { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_outbound_payment_scid(); - let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { ret.unwrap() }) }; - local_ret -} - -/// Further information on the details of the channel shutdown. -/// Upon channels being forced closed (i.e. commitment transaction confirmation detected -/// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or -/// the channel will be removed shortly. -/// Also note, that in normal operation, peers could disconnect at any of these states -/// and require peer re-connection before making progress onto other states -#[derive(Clone)] -#[must_use] -#[repr(C)] -pub enum ChannelShutdownState { - /// Channel has not sent or received a shutdown message. - NotShuttingDown, - /// Local node has sent a shutdown message for this channel. - ShutdownInitiated, - /// Shutdown message exchanges have concluded and the channels are in the midst of - /// resolving all existing open HTLCs before closing can continue. - ResolvingHTLCs, - /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. - NegotiatingClosingFee, - /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about - /// to drop the channel. - ShutdownComplete, -} -use lightning::ln::channelmanager::ChannelShutdownState as ChannelShutdownStateImport; -pub(crate) type nativeChannelShutdownState = ChannelShutdownStateImport; +/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay -impl ChannelShutdownState { - #[allow(unused)] - pub(crate) fn to_native(&self) -> nativeChannelShutdownState { - match self { - ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, - ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, - ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, - ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, - ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, - } - } - #[allow(unused)] - pub(crate) fn into_native(self) -> nativeChannelShutdownState { - match self { - ChannelShutdownState::NotShuttingDown => nativeChannelShutdownState::NotShuttingDown, - ChannelShutdownState::ShutdownInitiated => nativeChannelShutdownState::ShutdownInitiated, - ChannelShutdownState::ResolvingHTLCs => nativeChannelShutdownState::ResolvingHTLCs, - ChannelShutdownState::NegotiatingClosingFee => nativeChannelShutdownState::NegotiatingClosingFee, - ChannelShutdownState::ShutdownComplete => nativeChannelShutdownState::ShutdownComplete, - } - } - #[allow(unused)] - pub(crate) fn from_native(native: &ChannelShutdownStateImport) -> Self { - let native = unsafe { &*(native as *const _ as *const c_void as *const nativeChannelShutdownState) }; - match native { - nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, - nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, - nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, - nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, - nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, - } - } - #[allow(unused)] - pub(crate) fn native_into(native: nativeChannelShutdownState) -> Self { - match native { - nativeChannelShutdownState::NotShuttingDown => ChannelShutdownState::NotShuttingDown, - nativeChannelShutdownState::ShutdownInitiated => ChannelShutdownState::ShutdownInitiated, - nativeChannelShutdownState::ResolvingHTLCs => ChannelShutdownState::ResolvingHTLCs, - nativeChannelShutdownState::NegotiatingClosingFee => ChannelShutdownState::NegotiatingClosingFee, - nativeChannelShutdownState::ShutdownComplete => ChannelShutdownState::ShutdownComplete, - } - } -} -/// Creates a copy of the ChannelShutdownState -#[no_mangle] -pub extern "C" fn ChannelShutdownState_clone(orig: &ChannelShutdownState) -> ChannelShutdownState { - orig.clone() -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelShutdownState_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ChannelShutdownState)).clone() })) as *mut c_void -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelShutdownState_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut ChannelShutdownState) }; -} #[no_mangle] -/// Utility method to constructs a new NotShuttingDown-variant ChannelShutdownState -pub extern "C" fn ChannelShutdownState_not_shutting_down() -> ChannelShutdownState { - ChannelShutdownState::NotShuttingDown} -#[no_mangle] -/// Utility method to constructs a new ShutdownInitiated-variant ChannelShutdownState -pub extern "C" fn ChannelShutdownState_shutdown_initiated() -> ChannelShutdownState { - ChannelShutdownState::ShutdownInitiated} -#[no_mangle] -/// Utility method to constructs a new ResolvingHTLCs-variant ChannelShutdownState -pub extern "C" fn ChannelShutdownState_resolving_htlcs() -> ChannelShutdownState { - ChannelShutdownState::ResolvingHTLCs} -#[no_mangle] -/// Utility method to constructs a new NegotiatingClosingFee-variant ChannelShutdownState -pub extern "C" fn ChannelShutdownState_negotiating_closing_fee() -> ChannelShutdownState { - ChannelShutdownState::NegotiatingClosingFee} +pub static BREAKDOWN_TIMEOUT: u16 = lightning::ln::channelmanager::BREAKDOWN_TIMEOUT; +/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound +/// HTLC's CLTV. The current default represents roughly seven hours of blocks at six blocks/hour. +/// +/// This can be increased (but not decreased) through [`ChannelConfig::cltv_expiry_delta`] +/// +/// [`ChannelConfig::cltv_expiry_delta`]: crate::util::config::ChannelConfig::cltv_expiry_delta + #[no_mangle] -/// Utility method to constructs a new ShutdownComplete-variant ChannelShutdownState -pub extern "C" fn ChannelShutdownState_shutdown_complete() -> ChannelShutdownState { - ChannelShutdownState::ShutdownComplete} -/// Get a string which allows debug introspection of a ChannelShutdownState object -pub extern "C" fn ChannelShutdownState_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::channelmanager::ChannelShutdownState }).into()} -/// Checks if two ChannelShutdownStates contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. +pub static MIN_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA; +/// Minimum CLTV difference between the current block height and received inbound payments. +/// Invoices generated for payment to us must set their `min_final_cltv_expiry_delta` field to at least +/// this value. + #[no_mangle] -pub extern "C" fn ChannelShutdownState_eq(a: &ChannelShutdownState, b: &ChannelShutdownState) -> bool { - if &a.to_native() == &b.to_native() { true } else { false } -} +pub static MIN_FINAL_CLTV_EXPIRY_DELTA: u16 = lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA; /// Used by [`ChannelManager::list_recent_payments`] to express the status of recent payments. /// These include payments that have yet to find a successful path, or have unresolved HTLCs. #[derive(Clone)] @@ -2369,14 +1977,14 @@ impl RecentPaymentDetails { let mut total_msat_nonref = Clone::clone(total_msat); nativeRecentPaymentDetails::Pending { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), total_msat: total_msat_nonref, } }, RecentPaymentDetails::Fulfilled {ref payment_id, ref payment_hash, } => { let mut payment_id_nonref = Clone::clone(payment_id); let mut payment_hash_nonref = Clone::clone(payment_hash); - let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; + let mut local_payment_hash_nonref = { /*payment_hash_nonref*/ let payment_hash_nonref_opt = payment_hash_nonref; if payment_hash_nonref_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_nonref_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), payment_hash: local_payment_hash_nonref, @@ -2387,7 +1995,7 @@ impl RecentPaymentDetails { let mut payment_hash_nonref = Clone::clone(payment_hash); nativeRecentPaymentDetails::Abandoned { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id_nonref.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash_nonref.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_nonref.data), } }, } @@ -2403,12 +2011,12 @@ impl RecentPaymentDetails { RecentPaymentDetails::Pending {mut payment_id, mut payment_hash, mut total_msat, } => { nativeRecentPaymentDetails::Pending { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), total_msat: total_msat, } }, RecentPaymentDetails::Fulfilled {mut payment_id, mut payment_hash, } => { - let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; nativeRecentPaymentDetails::Fulfilled { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), payment_hash: local_payment_hash, @@ -2417,7 +2025,7 @@ impl RecentPaymentDetails { RecentPaymentDetails::Abandoned {mut payment_id, mut payment_hash, } => { nativeRecentPaymentDetails::Abandoned { payment_id: ::lightning::ln::channelmanager::PaymentId(payment_id.data), - payment_hash: ::lightning::ln::PaymentHash(payment_hash.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash.data), } }, } @@ -2567,6 +2175,12 @@ pub struct PhantomRouteHints { pub is_owned: bool, } +impl core::ops::Deref for PhantomRouteHints { + type Target = nativePhantomRouteHints; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PhantomRouteHints { } +unsafe impl core::marker::Sync for PhantomRouteHints { } impl Drop for PhantomRouteHints { fn drop(&mut self) { if self.is_owned && !<*mut nativePhantomRouteHints>::is_null(self.inner) { @@ -2597,12 +2211,15 @@ impl PhantomRouteHints { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The list of channels to be included in the invoice route hints. #[no_mangle] pub extern "C" fn PhantomRouteHints_get_channels(this_ptr: &PhantomRouteHints) -> crate::c_types::derived::CVec_ChannelDetailsZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().channels; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_inner_val.into() } /// The list of channels to be included in the invoice route hints. @@ -2730,14 +2347,15 @@ pub extern "C" fn ChannelManager_get_current_default_configuration(this_arg: &cr /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id /// +/// Note that temporary_channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None /// Note that override_config (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut temporary_channel_id: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_ThirtyTwoBytesAPIErrorZ { - let mut local_temporary_channel_id = { /*temporary_channel_id*/ let temporary_channel_id_opt = temporary_channel_id; if temporary_channel_id_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ temporary_channel_id_opt.take() }.data) }})} }; +pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut their_network_key: crate::c_types::PublicKey, mut channel_value_satoshis: u64, mut push_msat: u64, mut user_channel_id: crate::c_types::U128, mut temporary_channel_id: crate::lightning::ln::types::ChannelId, mut override_config: crate::lightning::util::config::UserConfig) -> crate::c_types::derived::CResult_ChannelIdAPIErrorZ { + let mut local_temporary_channel_id = if temporary_channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(temporary_channel_id.take_inner()) } }) }; let mut local_override_config = if override_config.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(override_config.take_inner()) } }) }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_channel(their_network_key.into_rust(), channel_value_satoshis, push_msat, user_channel_id.into(), local_temporary_channel_id, local_override_config); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -2747,7 +2365,7 @@ pub extern "C" fn ChannelManager_create_channel(this_arg: &crate::lightning::ln: #[no_mangle] pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -2761,7 +2379,7 @@ pub extern "C" fn ChannelManager_list_channels(this_arg: &crate::lightning::ln:: #[no_mangle] pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CVec_ChannelDetailsZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_usable_channels(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -2770,7 +2388,7 @@ pub extern "C" fn ChannelManager_list_usable_channels(this_arg: &crate::lightnin #[no_mangle] pub extern "C" fn ChannelManager_list_channels_with_counterparty(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CVec_ChannelDetailsZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_channels_with_counterparty(&counterparty_node_id.into_rust()); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -2815,8 +2433,8 @@ pub extern "C" fn ChannelManager_list_recent_payments(this_arg: &crate::lightnin /// [`SendShutdown`]: crate::events::MessageSendEvent::SendShutdown #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust()); +pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel(channel_id.get_native_ref(), &counterparty_node_id.into_rust()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -2854,56 +2472,74 @@ pub extern "C" fn ChannelManager_close_channel(this_arg: &crate::lightning::ln:: /// Note that shutdown_script (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ { +pub extern "C" fn ChannelManager_close_channel_with_feerate_and_script(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut target_feerate_sats_per_1000_weight: crate::c_types::derived::COption_u32Z, mut shutdown_script: crate::lightning::ln::script::ShutdownScript) -> crate::c_types::derived::CResult_NoneAPIErrorZ { let mut local_target_feerate_sats_per_1000_weight = if target_feerate_sats_per_1000_weight.is_some() { Some( { target_feerate_sats_per_1000_weight.take() }) } else { None }; let mut local_shutdown_script = if shutdown_script.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(shutdown_script.take_inner()) } }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.close_channel_with_feerate_and_script(channel_id.get_native_ref(), &counterparty_node_id.into_rust(), local_target_feerate_sats_per_1000_weight, local_shutdown_script); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } -/// Force closes a channel, immediately broadcasting the latest local transaction(s) and -/// rejecting new HTLCs on the given channel. Fails if `channel_id` is unknown to -/// the manager, or if the `counterparty_node_id` isn't the counterparty of the corresponding -/// channel. +/// Force closes a channel, immediately broadcasting the latest local transaction(s), +/// rejecting new HTLCs. +/// +/// The provided `error_message` is sent to connected peers for closing +/// channels and should be a human-readable description of what went wrong. +/// +/// Fails if `channel_id` is unknown to the manager, or if the `counterparty_node_id` +/// isn't the counterparty of the corresponding channel. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust()); +pub extern "C" fn ChannelManager_force_close_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut error_message: crate::c_types::Str) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_broadcasting_latest_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust(), error_message.into_string()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } /// Force closes a channel, rejecting new HTLCs on the given channel but skips broadcasting -/// the latest local transaction(s). Fails if `channel_id` is unknown to the manager, or if the -/// `counterparty_node_id` isn't the counterparty of the corresponding channel. +/// the latest local transaction(s). +/// +/// The provided `error_message` is sent to connected peers for closing channels and should +/// be a human-readable description of what went wrong. /// -/// You can always get the latest local transaction(s) to broadcast from -/// [`ChannelMonitor::get_latest_holder_commitment_txn`]. +/// Fails if `channel_id` is unknown to the manager, or if the +/// `counterparty_node_id` isn't the counterparty of the corresponding channel. +/// You can always broadcast the latest local transaction(s) via +/// [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(&::lightning::ln::ChannelId(unsafe { *channel_id }), &counterparty_node_id.into_rust()); +pub extern "C" fn ChannelManager_force_close_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut error_message: crate::c_types::Str) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_without_broadcasting_txn(channel_id.get_native_ref(), &counterparty_node_id.into_rust(), error_message.into_string()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } /// Force close all channels, immediately broadcasting the latest local commitment transaction /// for each to the chain and rejecting new HTLCs on each. +/// +/// The provided `error_message` is sent to connected peers for closing channels and should +/// be a human-readable description of what went wrong. #[no_mangle] -pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn() +pub extern "C" fn ChannelManager_force_close_all_channels_broadcasting_latest_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut error_message: crate::c_types::Str) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_broadcasting_latest_txn(error_message.into_string()) } /// Force close all channels rejecting new HTLCs on each but without broadcasting the latest /// local transaction(s). +/// +/// The provided `error_message` is sent to connected peers for closing channels and +/// should be a human-readable description of what went wrong. #[no_mangle] -pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn() +pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_txn(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut error_message: crate::c_types::Str) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.force_close_all_channels_without_broadcasting_txn(error_message.into_string()) } /// Sends a payment along a given route. /// +/// This method is *DEPRECATED*, use [`Self::send_payment`] instead. If you wish to fix the +/// route for a payment, do so by matching the [`PaymentId`] passed to +/// [`Router::find_route_with_id`]. +/// /// Value parameters are provided via the last hop in route, see documentation for [`RouteHop`] /// fields for more info. /// @@ -2955,8 +2591,8 @@ pub extern "C" fn ChannelManager_force_close_all_channels_without_broadcasting_t /// [`ChannelMonitorUpdateStatus::InProgress`]: crate::chain::ChannelMonitorUpdateStatus::InProgress #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(route.get_native_ref(), ::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); +pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut route: crate::lightning::routing::router::Route, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_NonePaymentSendFailureZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment_with_route(*unsafe { Box::from_raw(route.take_inner()) }, ::lightning::ln::types::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret } @@ -2966,7 +2602,7 @@ pub extern "C" fn ChannelManager_send_payment_with_route(this_arg: &crate::light #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_NoneRetryableSendFailureZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(::lightning::ln::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_payment(::lightning::ln::types::PaymentHash(payment_hash.data), *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret } @@ -2987,15 +2623,13 @@ pub extern "C" fn ChannelManager_send_payment(this_arg: &crate::lightning::ln::c /// # Requested Invoices /// /// In the case of paying a [`Bolt12Invoice`] via [`ChannelManager::pay_for_offer`], abandoning -/// the payment prior to receiving the invoice will result in an [`Event::InvoiceRequestFailed`] -/// and prevent any attempts at paying it once received. The other events may only be generated -/// once the invoice has been received. +/// the payment prior to receiving the invoice will result in an [`Event::PaymentFailed`] and +/// prevent any attempts at paying it once received. /// /// # Restart Behavior /// /// If an [`Event::PaymentFailed`] is generated and we restart without first persisting the -/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated; likewise for -/// [`Event::InvoiceRequestFailed`]. +/// [`ChannelManager`], another [`Event::PaymentFailed`] may be generated. /// /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[no_mangle] @@ -3019,7 +2653,7 @@ pub extern "C" fn ChannelManager_abandon_payment(this_arg: &crate::lightning::ln #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, route: &crate::lightning::routing::router::Route, mut payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_ThirtyTwoBytesPaymentSendFailureZ { - let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment(route.get_native_ref(), local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::PaymentSendFailure::native_into(e) }).into() }; local_ret @@ -3035,7 +2669,7 @@ pub extern "C" fn ChannelManager_send_spontaneous_payment(this_arg: &crate::ligh #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_send_spontaneous_payment_with_retry(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut recipient_onion: crate::lightning::ln::outbound_payment::RecipientOnionFields, mut payment_id: crate::c_types::ThirtyTwoBytes, mut route_params: crate::lightning::routing::router::RouteParameters, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CResult_ThirtyTwoBytesRetryableSendFailureZ { - let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; + let mut local_payment_preimage = { /*payment_preimage*/ let payment_preimage_opt = payment_preimage; if payment_preimage_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ payment_preimage_opt.take() }.data) }})} }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_spontaneous_payment_with_retry(local_payment_preimage, *unsafe { Box::from_raw(recipient_onion.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(route_params.take_inner()) }, retry_strategy.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(e) }).into() }; local_ret @@ -3120,8 +2754,43 @@ pub extern "C" fn ChannelManager_send_preflight_probes(this_arg: &crate::lightni /// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), funding_transaction.into_bitcoin()); +pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channel_id: crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.funding_transaction_generated(*unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id.into_rust(), funding_transaction.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; + local_ret +} + +/// **Unsafe**: This method does not validate the spent output. It is the caller's +/// responsibility to ensure the spent outputs are SegWit, as well as making sure the funding +/// transaction has a final absolute locktime, i.e., its locktime is lower than the next block height. +/// +/// For a safer method, please refer to [`ChannelManager::funding_transaction_generated`]. +/// +/// Call this in response to a [`Event::FundingGenerationReady`] event. +/// +/// Note that if this method is called successfully, the funding transaction won't be +/// broadcasted and you are expected to broadcast it manually when receiving the +/// [`Event::FundingTxBroadcastSafe`] event. +/// +/// Returns [`APIError::ChannelUnavailable`] if a funding transaction has already been provided +/// for the channel or if the channel has been closed as indicated by [`Event::ChannelClosed`]. +/// +/// May panic if the funding output is duplicative with some other channel (note that this +/// should be trivially prevented by using unique funding transaction keys per-channel). +/// +/// Note to keep the miner incentives aligned in moving the blockchain forward, we recommend +/// the wallet software generating the funding transaction to apply anti-fee sniping as +/// implemented by Bitcoin Core wallet. See for +/// more details. +/// +/// [`Event::FundingGenerationReady`]: crate::events::Event::FundingGenerationReady +/// [`Event::FundingTxBroadcastSafe`]: crate::events::Event::FundingTxBroadcastSafe +/// [`Event::ChannelClosed`]: crate::events::Event::ChannelClosed +/// [`ChannelManager::funding_transaction_generated`]: crate::ln::channelmanager::ChannelManager::funding_transaction_generated +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_unsafe_manual_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channel_id: crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut funding: crate::lightning::chain::transaction::OutPoint) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.unsafe_manual_funding_transaction_generated(*unsafe { Box::from_raw(temporary_channel_id.take_inner()) }, counterparty_node_id.into_rust(), *unsafe { Box::from_raw(funding.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -3138,8 +2807,8 @@ pub extern "C" fn ChannelManager_funding_transaction_generated(this_arg: &crate: /// If there is an error, all channels in the batch are to be considered closed. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_batch_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channels: crate::c_types::derived::CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut local_temporary_channels = Vec::new(); for mut item in temporary_channels.into_rust().drain(..) { local_temporary_channels.push( { let (mut orig_temporary_channels_0_0, mut orig_temporary_channels_0_1) = item.to_rust(); let mut local_temporary_channels_0 = (::lightning::ln::ChannelId(orig_temporary_channels_0_0.data), orig_temporary_channels_0_1.into_rust()); local_temporary_channels_0 }); }; +pub extern "C" fn ChannelManager_batch_funding_transaction_generated(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut temporary_channels: crate::c_types::derived::CVec_C2Tuple_ChannelIdPublicKeyZZ, mut funding_transaction: crate::c_types::Transaction) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_temporary_channels = Vec::new(); for mut item in temporary_channels.into_rust().drain(..) { local_temporary_channels.push( { let (mut orig_temporary_channels_0_0, mut orig_temporary_channels_0_1) = item.to_rust(); let mut local_temporary_channels_0 = (*unsafe { Box::from_raw(orig_temporary_channels_0_0.take_inner()) }, orig_temporary_channels_0_1.into_rust()); local_temporary_channels_0 }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.batch_funding_transaction_generated(&local_temporary_channels.iter().map(|(a, b)| (a, b)).collect::>()[..], funding_transaction.into_bitcoin()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret @@ -3169,8 +2838,8 @@ pub extern "C" fn ChannelManager_batch_funding_transaction_generated(this_arg: & /// [`APIMisuseError`]: APIError::APIMisuseError #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); }; +pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ChannelIdZ, config_update: &crate::lightning::util::config::ChannelConfigUpdate) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_partial_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config_update.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret @@ -3200,8 +2869,8 @@ pub extern "C" fn ChannelManager_update_partial_channel_config(this_arg: &crate: /// [`APIMisuseError`]: APIError::APIMisuseError #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ThirtyTwoBytesZ, config: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { ::lightning::ln::ChannelId(item.data) }); }; +pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut counterparty_node_id: crate::c_types::PublicKey, mut channel_ids: crate::c_types::derived::CVec_ChannelIdZ, config: &crate::lightning::util::config::ChannelConfig) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut local_channel_ids = Vec::new(); for mut item in channel_ids.into_rust().drain(..) { local_channel_ids.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.update_channel_config(&counterparty_node_id.into_rust(), local_channel_ids, config.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret @@ -3232,8 +2901,8 @@ pub extern "C" fn ChannelManager_update_channel_config(this_arg: &crate::lightni /// [`HTLCIntercepted::expected_outbound_amount_msat`]: events::Event::HTLCIntercepted::expected_outbound_amount_msat #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: *const [u8; 32], mut next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data), &::lightning::ln::ChannelId(unsafe { *next_hop_channel_id }), next_node_id.into_rust(), amt_to_forward_msat); +pub extern "C" fn ChannelManager_forward_intercepted_htlc(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut intercept_id: crate::c_types::ThirtyTwoBytes, next_hop_channel_id: &crate::lightning::ln::types::ChannelId, mut next_node_id: crate::c_types::PublicKey, mut amt_to_forward_msat: u64) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_intercepted_htlc(::lightning::ln::channelmanager::InterceptId(intercept_id.data), next_hop_channel_id.get_native_ref(), next_node_id.into_rust(), amt_to_forward_msat); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -3303,7 +2972,7 @@ pub extern "C" fn ChannelManager_timer_tick_occurred(this_arg: &crate::lightning /// startup during which time claims that were in-progress at shutdown may be replayed. #[no_mangle] pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, payment_hash: *const [u8; 32]) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards(&::lightning::ln::PaymentHash(unsafe { *payment_hash })) + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards(&::lightning::ln::types::PaymentHash(unsafe { *payment_hash })) } /// This is a variant of [`ChannelManager::fail_htlc_backwards`] that allows you to specify the @@ -3312,7 +2981,7 @@ pub extern "C" fn ChannelManager_fail_htlc_backwards(this_arg: &crate::lightning /// See [`FailureCode`] for valid failure codes. #[no_mangle] pub extern "C" fn ChannelManager_fail_htlc_backwards_with_reason(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, payment_hash: *const [u8; 32], mut failure_code: crate::lightning::ln::channelmanager::FailureCode) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards_with_reason(&::lightning::ln::PaymentHash(unsafe { *payment_hash }), failure_code.into_native()) + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fail_htlc_backwards_with_reason(&::lightning::ln::types::PaymentHash(unsafe { *payment_hash }), failure_code.into_native()) } /// Provides a payment preimage in response to [`Event::PaymentClaimable`], generating any @@ -3341,7 +3010,7 @@ pub extern "C" fn ChannelManager_fail_htlc_backwards_with_reason(this_arg: &crat /// [`claim_funds_with_known_custom_tlvs`]: Self::claim_funds_with_known_custom_tlvs #[no_mangle] pub extern "C" fn ChannelManager_claim_funds(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds(::lightning::ln::PaymentPreimage(payment_preimage.data)) + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds(::lightning::ln::types::PaymentPreimage(payment_preimage.data)) } /// This is a variant of [`claim_funds`] that allows accepting a payment with custom TLVs with @@ -3355,7 +3024,7 @@ pub extern "C" fn ChannelManager_claim_funds(this_arg: &crate::lightning::ln::ch /// [`claim_funds`]: Self::claim_funds #[no_mangle] pub extern "C" fn ChannelManager_claim_funds_with_known_custom_tlvs(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_preimage: crate::c_types::ThirtyTwoBytes) { - unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds_with_known_custom_tlvs(::lightning::ln::PaymentPreimage(payment_preimage.data)) + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.claim_funds_with_known_custom_tlvs(::lightning::ln::types::PaymentPreimage(payment_preimage.data)) } /// Gets the node_id held by this ChannelManager @@ -3384,8 +3053,8 @@ pub extern "C" fn ChannelManager_get_our_node_id(this_arg: &crate::lightning::ln /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), user_channel_id.into()); +pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel(temporary_channel_id.get_native_ref(), &counterparty_node_id.into_rust(), user_channel_id.into()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -3410,12 +3079,99 @@ pub extern "C" fn ChannelManager_accept_inbound_channel(this_arg: &crate::lightn /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: *const [u8; 32], mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel_from_trusted_peer_0conf(&::lightning::ln::ChannelId(unsafe { *temporary_channel_id }), &counterparty_node_id.into_rust(), user_channel_id.into()); +pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, temporary_channel_id: &crate::lightning::ln::types::ChannelId, mut counterparty_node_id: crate::c_types::PublicKey, mut user_channel_id: crate::c_types::U128) -> crate::c_types::derived::CResult_NoneAPIErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.accept_inbound_channel_from_trusted_peer_0conf(temporary_channel_id.get_native_ref(), &counterparty_node_id.into_rust(), user_channel_id.into()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } +/// Creates an [`OfferBuilder`] such that the [`Offer`] it builds is recognized by the +/// [`ChannelManager`] when handling [`InvoiceRequest`] messages for the offer. The offer's +/// expiration will be `absolute_expiry` if `Some`, otherwise it will not expire. +/// +/// # Privacy +/// +/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the offer based on the given +/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for +/// privacy implications as well as those of the parameterized [`Router`], which implements +/// [`MessageRouter`]. +/// +/// Also, uses a derived signing pubkey in the offer for recipient privacy. +/// +/// # Limitations +/// +/// Requires a direct connection to the introduction node in the responding [`InvoiceRequest`]'s +/// reply path. +/// +/// # Errors +/// +/// Errors if the parameterized [`Router`] is unable to create a blinded path for the offer. +/// +/// [`Offer`]: crate::offers::offer::Offer +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_create_offer_builder(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut absolute_expiry: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut local_absolute_expiry = { /*absolute_expiry*/ let absolute_expiry_opt = absolute_expiry; if absolute_expiry_opt.is_none() { None } else { Some({ { core::time::Duration::from_secs({ absolute_expiry_opt.take() }) }})} }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_offer_builder(local_absolute_expiry); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Creates a [`RefundBuilder`] such that the [`Refund`] it builds is recognized by the +/// [`ChannelManager`] when handling [`Bolt12Invoice`] messages for the refund. +/// +/// # Payment +/// +/// The provided `payment_id` is used to ensure that only one invoice is paid for the refund. +/// See [Avoiding Duplicate Payments] for other requirements once the payment has been sent. +/// +/// The builder will have the provided expiration set. Any changes to the expiration on the +/// returned builder will not be honored by [`ChannelManager`]. For `no-std`, the highest seen +/// block time minus two hours is used for the current time when determining if the refund has +/// expired. +/// +/// To revoke the refund, use [`ChannelManager::abandon_payment`] prior to receiving the +/// invoice. If abandoned, or an invoice isn't received before expiration, the payment will fail +/// with an [`Event::PaymentFailed`]. +/// +/// If `max_total_routing_fee_msat` is not specified, The default from +/// [`RouteParameters::from_payment_params_and_value`] is applied. +/// +/// # Privacy +/// +/// Uses [`MessageRouter`] to construct a [`BlindedMessagePath`] for the refund based on the given +/// `absolute_expiry` according to [`MAX_SHORT_LIVED_RELATIVE_EXPIRY`]. See those docs for +/// privacy implications as well as those of the parameterized [`Router`], which implements +/// [`MessageRouter`]. +/// +/// Also, uses a derived payer id in the refund for payer privacy. +/// +/// # Limitations +/// +/// Requires a direct connection to an introduction node in the responding +/// [`Bolt12Invoice::payment_paths`]. +/// +/// # Errors +/// +/// Errors if: +/// - a duplicate `payment_id` is provided given the caveats in the aforementioned link, +/// - `amount_msats` is invalid, or +/// - the parameterized [`Router`] is unable to create a blinded path for the refund. +/// +/// [`Refund`]: crate::offers::refund::Refund +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`Bolt12Invoice::payment_paths`]: crate::offers::invoice::Bolt12Invoice::payment_paths +/// [Avoiding Duplicate Payments]: #avoiding-duplicate-payments +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelManager_create_refund_builder(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut amount_msats: u64, mut absolute_expiry: u64, mut payment_id: crate::c_types::ThirtyTwoBytes, mut retry_strategy: crate::lightning::ln::outbound_payment::Retry, mut max_total_routing_fee_msat: crate::c_types::derived::COption_u64Z) -> crate::c_types::derived::CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut local_max_total_routing_fee_msat = if max_total_routing_fee_msat.is_some() { Some( { max_total_routing_fee_msat.take() }) } else { None }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_refund_builder(amount_msats, core::time::Duration::from_secs(absolute_expiry), ::lightning::ln::channelmanager::PaymentId(payment_id.data), retry_strategy.into_native(), local_max_total_routing_fee_msat); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + /// Pays for an [`Offer`] using the given parameters by creating an [`InvoiceRequest`] and /// enqueuing it to be sent via an onion message. [`ChannelManager`] will pay the actual /// [`Bolt12Invoice`] once it is received. @@ -3439,14 +3195,13 @@ pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf( /// /// To revoke the request, use [`ChannelManager::abandon_payment`] prior to receiving the /// invoice. If abandoned, or an invoice isn't received in a reasonable amount of time, the -/// payment will fail with an [`Event::InvoiceRequestFailed`]. +/// payment will fail with an [`Event::PaymentFailed`]. /// /// # Privacy /// -/// Uses a one-hop [`BlindedPath`] for the reply path with [`ChannelManager::get_our_node_id`] -/// as the introduction node and a derived payer id for payer privacy. As such, currently, the -/// node must be announced. Otherwise, there is no way to find a path to the introduction node -/// in order to send the [`Bolt12Invoice`]. +/// For payer privacy, uses a derived payer id and uses [`MessageRouter::create_blinded_paths`] +/// to construct a [`BlindedMessagePath`] for the reply path. For further privacy implications, see the +/// docs of the parameterized [`Router`], which implements [`MessageRouter`]. /// /// # Limitations /// @@ -3459,6 +3214,7 @@ pub extern "C" fn ChannelManager_accept_inbound_channel_from_trusted_peer_0conf( /// Errors if: /// - a duplicate `payment_id` is provided given the caveats in the aforementioned link, /// - the provided parameters are invalid for the offer, +/// - the offer is for an unsupported chain, or /// - the parameterized [`Router`] is unable to create a blinded reply path for the invoice /// request. /// @@ -3485,8 +3241,8 @@ pub extern "C" fn ChannelManager_pay_for_offer(this_arg: &crate::lightning::ln:: /// message. /// /// The resulting invoice uses a [`PaymentHash`] recognized by the [`ChannelManager`] and a -/// [`BlindedPath`] containing the [`PaymentSecret`] needed to reconstruct the corresponding -/// [`PaymentPreimage`]. +/// [`BlindedPaymentPath`] containing the [`PaymentSecret`] needed to reconstruct the +/// corresponding [`PaymentPreimage`]. It is returned purely for informational purposes. /// /// # Limitations /// @@ -3497,15 +3253,17 @@ pub extern "C" fn ChannelManager_pay_for_offer(this_arg: &crate::lightning::ln:: /// /// # Errors /// -/// Errors if the parameterized [`Router`] is unable to create a blinded payment path or reply -/// path for the invoice. +/// Errors if: +/// - the refund is for an unsupported chain, or +/// - the parameterized [`Router`] is unable to create a blinded payment path or reply path for +/// the invoice. /// /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_request_refund_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, refund: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { +pub extern "C" fn ChannelManager_request_refund_payment(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, refund: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CResult_Bolt12InvoiceBolt12SemanticErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_refund_payment(refund.get_native_ref()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -3515,10 +3273,9 @@ pub extern "C" fn ChannelManager_request_refund_payment(this_arg: &crate::lightn /// This differs from [`create_inbound_payment_for_hash`] only in that it generates the /// [`PaymentHash`] and [`PaymentPreimage`] for you. /// -/// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`], which -/// will have the [`PaymentClaimable::purpose`] be [`PaymentPurpose::InvoicePayment`] with -/// its [`PaymentPurpose::InvoicePayment::payment_preimage`] field filled in. That should then be -/// passed directly to [`claim_funds`]. +/// The [`PaymentPreimage`] will ultimately be returned to you in the [`PaymentClaimable`] event, which +/// will have the [`PaymentClaimable::purpose`] return `Some` for [`PaymentPurpose::preimage`]. That +/// should then be passed directly to [`claim_funds`]. /// /// See [`create_inbound_payment_for_hash`] for detailed documentation on behavior and requirements. /// @@ -3538,8 +3295,7 @@ pub extern "C" fn ChannelManager_request_refund_payment(this_arg: &crate::lightn /// [`claim_funds`]: Self::claim_funds /// [`PaymentClaimable`]: events::Event::PaymentClaimable /// [`PaymentClaimable::purpose`]: events::Event::PaymentClaimable::purpose -/// [`PaymentPurpose::InvoicePayment`]: events::PaymentPurpose::InvoicePayment -/// [`PaymentPurpose::InvoicePayment::payment_preimage`]: events::PaymentPurpose::InvoicePayment::payment_preimage +/// [`PaymentPurpose::preimage`]: events::PaymentPurpose::preimage /// [`create_inbound_payment_for_hash`]: Self::create_inbound_payment_for_hash #[must_use] #[no_mangle] @@ -3602,7 +3358,7 @@ pub extern "C" fn ChannelManager_create_inbound_payment(this_arg: &crate::lightn pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry = if min_final_cltv_expiry.is_some() { Some( { min_final_cltv_expiry.take() }) } else { None }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash(::lightning::ln::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs, local_min_final_cltv_expiry); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.create_inbound_payment_for_hash(::lightning::ln::types::PaymentHash(payment_hash.data), local_min_value_msat, invoice_expiry_delta_secs, local_min_final_cltv_expiry); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -3614,7 +3370,7 @@ pub extern "C" fn ChannelManager_create_inbound_payment_for_hash(this_arg: &crat #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_payment_preimage(this_arg: &crate::lightning::ln::channelmanager::ChannelManager, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_ThirtyTwoBytesAPIErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_payment_preimage(::lightning::ln::PaymentHash(payment_hash.data), ::lightning::ln::PaymentSecret(payment_secret.data)); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_payment_preimage(::lightning::ln::types::PaymentHash(payment_hash.data), ::lightning::ln::types::PaymentSecret(payment_secret.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_ret } @@ -3685,7 +3441,7 @@ pub extern "C" fn ChannelManager_as_MessageSendEventsProvider(this_arg: &Channel #[must_use] extern "C" fn ChannelManager_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut ret = ::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -3712,7 +3468,7 @@ pub extern "C" fn ChannelManager_as_EventsProvider(this_arg: &ChannelManager) -> } extern "C" fn ChannelManager_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { - >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler) + ::process_pending_events(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, handler) } impl From for crate::lightning::chain::Listen { @@ -3740,13 +3496,13 @@ pub extern "C" fn ChannelManager_as_Listen(this_arg: &ChannelManager) -> crate:: extern "C" fn ChannelManager_Listen_filtered_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - >::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) + ::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) } extern "C" fn ChannelManager_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { - >::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) + ::block_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) } extern "C" fn ChannelManager_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { - >::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) + ::block_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } impl From for crate::lightning::chain::Confirm { @@ -3775,17 +3531,17 @@ pub extern "C" fn ChannelManager_as_Confirm(this_arg: &ChannelManager) -> crate: extern "C" fn ChannelManager_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; - >::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) + ::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) } extern "C" fn ChannelManager_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) { - >::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) + ::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) } extern "C" fn ChannelManager_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { - >::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) + ::best_block_updated(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) } #[must_use] extern "C" fn ChannelManager_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { - let mut ret = >::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut ret = ::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_2.unwrap().as_ref() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); }; local_ret.into() } @@ -3806,6 +3562,9 @@ pub extern "C" fn ChannelManager_get_event_or_persistence_needed_future(this_arg } /// Returns true if this [`ChannelManager`] needs to be persisted. +/// +/// See [`Self::get_event_or_persistence_needed_future`] for retrieving a [`Future`] that +/// indicates this should be checked. #[must_use] #[no_mangle] pub extern "C" fn ChannelManager_get_and_clear_needs_persistence(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> bool { @@ -3826,36 +3585,36 @@ pub extern "C" fn ChannelManager_current_best_block(this_arg: &crate::lightning: /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn ChannelManager_node_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::NodeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.node_features(); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`ChannelFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn ChannelManager_channel_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::ChannelFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_features(); - crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`ChannelTypeFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn ChannelManager_channel_type_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Fetches the set of [`InitFeatures`] flags that are provided by or required by /// [`ChannelManager`]. #[must_use] #[no_mangle] -pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn ChannelManager_init_features(this_arg: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::lightning_types::features::InitFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.init_features(); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::ln::msgs::ChannelMessageHandler { @@ -3885,9 +3644,6 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana handle_shutdown: ChannelManager_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ChannelManager_ChannelMessageHandler_handle_closing_signed, handle_stfu: ChannelManager_ChannelMessageHandler_handle_stfu, - handle_splice: ChannelManager_ChannelMessageHandler_handle_splice, - handle_splice_ack: ChannelManager_ChannelMessageHandler_handle_splice_ack, - handle_splice_locked: ChannelManager_ChannelMessageHandler_handle_splice_locked, handle_tx_add_input: ChannelManager_ChannelMessageHandler_handle_tx_add_input, handle_tx_add_output: ChannelManager_ChannelMessageHandler_handle_tx_add_output, handle_tx_remove_input: ChannelManager_ChannelMessageHandler_handle_tx_remove_input, @@ -3922,126 +3678,117 @@ pub extern "C" fn ChannelManager_as_ChannelMessageHandler(this_arg: &ChannelMana } extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { - >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { - >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { - >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { - >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { - >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) { - >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) { - >::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown) { - >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { - >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_stfu(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu) { - >::handle_stfu(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice) { - >::handle_splice(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck) { - >::handle_splice_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ChannelManager_ChannelMessageHandler_handle_splice_locked(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked) { - >::handle_splice_locked(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_stfu(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { - >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { - >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { - >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { - >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { - >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { - >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { - >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { - >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { - >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { - >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) { - >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) { - >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) { - >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) { - >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) { - >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) { - >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) { - >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()) + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()) } #[must_use] extern "C" fn ChannelManager_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) { - >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) { - >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ChannelManager_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) { - >::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_error(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust(), msg.get_native_ref()) } #[must_use] -extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn ChannelManager_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn ChannelManager_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] extern "C" fn ChannelManager_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ { - let mut ret = >::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut ret = ::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) }; local_ret } @@ -4069,74 +3816,96 @@ pub extern "C" fn ChannelManager_as_OffersMessageHandler(this_arg: &ChannelManag } #[must_use] -extern "C" fn ChannelManager_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ { - let mut ret = >::handle_message(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, message.into_native()); - let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_OffersMessageZ::None } else { crate::c_types::derived::COption_OffersMessageZ::Some( { crate::lightning::onion_message::offers::OffersMessage::native_into(ret.unwrap()) }) }; +extern "C" fn ChannelManager_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage, mut context: crate::c_types::derived::COption_OffersContextZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::handle_message(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, message.into_native(), local_context, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; local_ret } #[must_use] -extern "C" fn ChannelManager_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - let mut ret = >::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).into(); local_ret_0 }); }; +extern "C" fn ChannelManager_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } -/// Fetches the set of [`InitFeatures`] flags that are provided by or required by -/// [`ChannelManager`]. -#[no_mangle] -pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning::ln::features::InitFeatures { - let mut ret = lightning::ln::channelmanager::provided_init_features(config.get_native_ref()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +impl From for crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + fn from(obj: nativeChannelManager) -> Self { + let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = ChannelManager_as_AsyncPaymentsMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(ChannelManager_free_void); + ret + } } - +/// Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is #[no_mangle] -/// Serialize the CounterpartyForwardingInfo object into a byte array which can be read by CounterpartyForwardingInfo_read -pub extern "C" fn CounterpartyForwardingInfo_write(obj: &crate::lightning::ln::channelmanager::CounterpartyForwardingInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn CounterpartyForwardingInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCounterpartyForwardingInfo) }) +pub extern "C" fn ChannelManager_as_AsyncPaymentsMessageHandler(this_arg: &ChannelManager) -> crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + held_htlc_available: ChannelManager_AsyncPaymentsMessageHandler_held_htlc_available, + release_held_htlc: ChannelManager_AsyncPaymentsMessageHandler_release_held_htlc, + release_pending_messages: ChannelManager_AsyncPaymentsMessageHandler_release_pending_messages, + } } -#[no_mangle] -/// Read a CounterpartyForwardingInfo from a byte array, created by CounterpartyForwardingInfo_write -pub extern "C" fn CounterpartyForwardingInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CounterpartyForwardingInfoDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res + +#[must_use] +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_held_htlc_available(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::held_htlc_available(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, *unsafe { Box::from_raw(message.take_inner()) }, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; + local_ret } -#[no_mangle] -/// Serialize the ChannelCounterparty object into a byte array which can be read by ChannelCounterparty_read -pub extern "C" fn ChannelCounterparty_write(obj: &crate::lightning::ln::channelmanager::ChannelCounterparty) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_release_held_htlc(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) { + ::release_held_htlc(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, *unsafe { Box::from_raw(message.take_inner()) }) } -#[allow(unused)] -pub(crate) extern "C" fn ChannelCounterparty_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelCounterparty) }) +#[must_use] +extern "C" fn ChannelManager_AsyncPaymentsMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; + local_ret.into() } -#[no_mangle] -/// Read a ChannelCounterparty from a byte array, created by ChannelCounterparty_write -pub extern "C" fn ChannelCounterparty_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelCounterpartyDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelCounterparty { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res + +impl From for crate::lightning::blinded_path::NodeIdLookUp { + fn from(obj: nativeChannelManager) -> Self { + let rust_obj = crate::lightning::ln::channelmanager::ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = ChannelManager_as_NodeIdLookUp(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(ChannelManager_free_void); + ret + } } +/// Constructs a new NodeIdLookUp which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned NodeIdLookUp must be freed before this_arg is #[no_mangle] -/// Serialize the ChannelDetails object into a byte array which can be read by ChannelDetails_read -pub extern "C" fn ChannelDetails_write(obj: &crate::lightning::ln::channelmanager::ChannelDetails) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +pub extern "C" fn ChannelManager_as_NodeIdLookUp(this_arg: &ChannelManager) -> crate::lightning::blinded_path::NodeIdLookUp { + crate::lightning::blinded_path::NodeIdLookUp { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + next_node_id: ChannelManager_NodeIdLookUp_next_node_id, + } } -#[allow(unused)] -pub(crate) extern "C" fn ChannelDetails_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDetails) }) + +#[must_use] +extern "C" fn ChannelManager_NodeIdLookUp_next_node_id(this_arg: *const c_void, mut short_channel_id: u64) -> crate::c_types::PublicKey { + let mut ret = ::next_node_id(unsafe { &mut *(this_arg as *mut nativeChannelManager) }, short_channel_id); + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } + +/// Fetches the set of [`InitFeatures`] flags that are provided by or required by +/// [`ChannelManager`]. #[no_mangle] -/// Read a ChannelDetails from a byte array, created by ChannelDetails_write -pub extern "C" fn ChannelDetails_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelDetailsDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res +pub extern "C" fn provided_init_features(config: &crate::lightning::util::config::UserConfig) -> crate::lightning_types::features::InitFeatures { + let mut ret = lightning::ln::channelmanager::provided_init_features(config.get_native_ref()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } + #[no_mangle] /// Serialize the PhantomRouteHints object into a byte array which can be read by PhantomRouteHints_read pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelmanager::PhantomRouteHints) -> crate::c_types::derived::CVec_u8Z { @@ -4144,7 +3913,7 @@ pub extern "C" fn PhantomRouteHints_write(obj: &crate::lightning::ln::channelman } #[allow(unused)] pub(crate) extern "C" fn PhantomRouteHints_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePhantomRouteHints) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativePhantomRouteHints) }) } #[no_mangle] /// Read a PhantomRouteHints from a byte array, created by PhantomRouteHints_write @@ -4160,7 +3929,7 @@ pub extern "C" fn BlindedForward_write(obj: &crate::lightning::ln::channelmanage } #[allow(unused)] pub(crate) extern "C" fn BlindedForward_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedForward) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativeBlindedForward) }) } #[no_mangle] /// Read a BlindedForward from a byte array, created by BlindedForward_write @@ -4192,7 +3961,7 @@ pub extern "C" fn PendingHTLCInfo_write(obj: &crate::lightning::ln::channelmanag } #[allow(unused)] pub(crate) extern "C" fn PendingHTLCInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePendingHTLCInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativePendingHTLCInfo) }) } #[no_mangle] /// Read a PendingHTLCInfo from a byte array, created by PendingHTLCInfo_write @@ -4224,27 +3993,11 @@ pub extern "C" fn ChannelManager_write(obj: &crate::lightning::ln::channelmanage } #[allow(unused)] pub(crate) extern "C" fn ChannelManager_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelManager) }) -} -#[no_mangle] -/// Serialize the ChannelShutdownState object into a byte array which can be read by ChannelShutdownState_read -pub extern "C" fn ChannelShutdownState_write(obj: &crate::lightning::ln::channelmanager::ChannelShutdownState) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) -} -#[allow(unused)] -pub(crate) extern "C" fn ChannelShutdownState_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - ChannelShutdownState_write(unsafe { &*(obj as *const ChannelShutdownState) }) -} -#[no_mangle] -/// Read a ChannelShutdownState from a byte array, created by ChannelShutdownState_write -pub extern "C" fn ChannelShutdownState_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelShutdownStateDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::ChannelShutdownState::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::channelmanager::nativeChannelManager) }) } use lightning::ln::channelmanager::ChannelManagerReadArgs as nativeChannelManagerReadArgsImport; -pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger>; +pub(crate) type nativeChannelManagerReadArgs = nativeChannelManagerReadArgsImport<'static, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, >; /// Arguments for the creation of a ChannelManager that are not deserialized. /// @@ -4293,6 +4046,12 @@ pub struct ChannelManagerReadArgs { pub is_owned: bool, } +impl core::ops::Deref for ChannelManagerReadArgs { + type Target = nativeChannelManagerReadArgs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelManagerReadArgs { } +unsafe impl core::marker::Sync for ChannelManagerReadArgs { } impl Drop for ChannelManagerReadArgs { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelManagerReadArgs>::is_null(self.inner) { @@ -4323,6 +4082,9 @@ impl ChannelManagerReadArgs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A cryptographically secure source of entropy. #[no_mangle] diff --git a/lightning-c-bindings/src/lightning/ln/features.rs b/lightning-c-bindings/src/lightning/ln/features.rs index fe78860..985db0d 100644 --- a/lightning-c-bindings/src/lightning/ln/features.rs +++ b/lightning-c-bindings/src/lightning/ln/features.rs @@ -8,82 +8,13 @@ //! Feature flag definitions for the Lightning protocol according to [BOLT #9]. //! -//! Lightning nodes advertise a supported set of operation through feature flags. Features are -//! applicable for a specific context as indicated in some [messages]. [`Features`] encapsulates -//! behavior for specifying and checking feature flags for a particular context. Each feature is -//! defined internally by a trait specifying the corresponding flags (i.e., even and odd bits). +//! See [`lightning_types::features`] for the list of features currently supported. //! -//! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas -//! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node -//! supports a feature if it advertises the feature (as either required or optional) to its peers. -//! And the implementation can interpret a feature if the feature is known to it. -//! -//! The following features are currently required in the LDK: -//! - `VariableLengthOnion` - requires/supports variable-length routing onion payloads -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). -//! - `StaticRemoteKey` - requires/supports static key for remote output -//! (see [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more information). -//! -//! The following features are currently supported in the LDK: -//! - `DataLossProtect` - requires/supports that a node which has somehow fallen behind, e.g., has been restored from an old backup, -//! can detect that it has fallen behind -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `InitialRoutingSync` - requires/supports that the sending node needs a complete routing information dump -//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#initial-sync) for more information). -//! - `UpfrontShutdownScript` - commits to a shutdown scriptpubkey when opening a channel -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). -//! - `GossipQueries` - requires/supports more sophisticated gossip control -//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md) for more information). -//! - `PaymentSecret` - requires/supports that a node supports payment_secret field -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). -//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information). -//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec. -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). -//! - `AnchorsZeroFeeHtlcTx` - requires/supports that commitment transactions include anchor outputs -//! and HTLC transactions are pre-signed with zero fee (see -//! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more -//! information). -//! - `RouteBlinding` - requires/supports that a node can relay payments over blinded paths -//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information). -//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown` -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `OnionMessages` - requires/supports forwarding onion messages -//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information). -//! - `ChannelType` - node supports the channel_type field in open/accept -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `SCIDPrivacy` - supply channel aliases for routing -//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). -//! - `PaymentMetadata` - include additional data in invoices which is passed to recipients in the -//! onion. -//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for -//! more). -//! - `ZeroConf` - supports accepting HTLCs and using channels prior to funding confirmation -//! (see -//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) -//! for more info). -//! - `Keysend` - send funds to a node without an invoice -//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information). -//! -//! LDK knows about the following features, but does not support them: -//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be -//! vulnerable (see this -//! [mailing list post](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html) -//! for more information). +//! Note that the use of types via this module is deprecated and will be removed in a future +//! version. Instead, use feature objects via [`lightning::types::features`]. //! +//! [`lightning::types::features`]: crate::types::features //! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md -//! [messages]: crate::ln::msgs - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -mod sealed { use alloc::str::FromStr; use alloc::string::String; @@ -94,3026 +25,115 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_data_loss_protect_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_data_loss_protect_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_data_loss_protect(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_data_loss_protect_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_data_loss_protect_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_data_loss_protect(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_data_loss_protect(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_data_loss_protect(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_initial_routing_sync_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_initial_routing_sync_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_initial_routing_sync_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_initial_routing_sync_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_initial_routing_sync(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.initial_routing_sync(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_upfront_shutdown_script_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_upfront_shutdown_script_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_gossip_queries_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_gossip_queries_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_gossip_queries(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_gossip_queries_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_gossip_queries_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_gossip_queries(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_gossip_queries(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_gossip_queries(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_variable_length_onion_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_variable_length_onion_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_variable_length_onion_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_variable_length_onion_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_static_remote_key_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_static_remote_key_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_static_remote_key(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_static_remote_key(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_payment_secret_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_payment_secret_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_payment_secret_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_payment_secret_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_wumbo_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_wumbo_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_wumbo_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_wumbo_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_wumbo(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_wumbo_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_wumbo_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_wumbo_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_wumbo_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_wumbo(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_wumbo(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_route_blinding_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_route_blinding_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_route_blinding_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_route_blinding(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_route_blinding_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_route_blinding_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_route_blinding_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_route_blinding(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_route_blinding(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_route_blinding(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_shutdown_any_segwit_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_shutdown_any_segwit_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_taproot_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_taproot_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_taproot_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_taproot_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_taproot_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_taproot_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_taproot_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_taproot_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_taproot(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_taproot(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_onion_messages_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_onion_messages_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_onion_messages_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_onion_messages_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_onion_messages_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_onion_messages_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_onion_messages(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_channel_type_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_channel_type_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_channel_type_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_channel_type_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_channel_type(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_channel_type_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_channel_type_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_channel_type_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_channel_type_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_channel_type(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_channel_type(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_channel_type(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_scid_privacy_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_scid_privacy_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_scid_privacy(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_metadata(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_metadata(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn InitFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn InitFeatures_set_zero_conf_required(this_arg: &mut crate::lightning::ln::features::InitFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_zero_conf_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_zero_conf_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_supports_zero_conf(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_zero_conf(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); - ret -} - -/// Set this feature as optional. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_keysend_optional(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_keysend_optional() -} - -/// Set this feature as required. -#[no_mangle] -pub extern "C" fn NodeFeatures_set_keysend_required(this_arg: &mut crate::lightning::ln::features::NodeFeatures) { - unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_keysend_required() -} - -/// Checks if this feature is supported. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_supports_keysend(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_keysend(); - ret -} - -/// Checks if this feature is required. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_keysend(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_keysend(); - ret -} - -} -/// Checks if two InitFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two NodeFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two ChannelFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two Bolt11InvoiceFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_eq(a: &Bolt11InvoiceFeatures, b: &Bolt11InvoiceFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two OfferFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn OfferFeatures_eq(a: &OfferFeatures, b: &OfferFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two InvoiceRequestFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_eq(a: &InvoiceRequestFeatures, b: &InvoiceRequestFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two Bolt12InvoiceFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_eq(a: &Bolt12InvoiceFeatures, b: &Bolt12InvoiceFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two BlindedHopFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_eq(a: &BlindedHopFeatures, b: &BlindedHopFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Checks if two ChannelTypeFeaturess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_eq(a: &ChannelTypeFeatures, b: &ChannelTypeFeatures) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -impl Clone for InitFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInitFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInitFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InitFeatures -pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { - orig.clone() -} -impl Clone for NodeFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the NodeFeatures -pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { - orig.clone() -} -impl Clone for ChannelFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelFeatures -pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { - orig.clone() -} -impl Clone for Bolt11InvoiceFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Bolt11InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Bolt11InvoiceFeatures -pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { - orig.clone() -} -impl Clone for OfferFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeOfferFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OfferFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the OfferFeatures -pub extern "C" fn OfferFeatures_clone(orig: &OfferFeatures) -> OfferFeatures { - orig.clone() -} -impl Clone for InvoiceRequestFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceRequestFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the InvoiceRequestFeatures -pub extern "C" fn InvoiceRequestFeatures_clone(orig: &InvoiceRequestFeatures) -> InvoiceRequestFeatures { - orig.clone() -} -impl Clone for Bolt12InvoiceFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Bolt12InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12InvoiceFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Bolt12InvoiceFeatures -pub extern "C" fn Bolt12InvoiceFeatures_clone(orig: &Bolt12InvoiceFeatures) -> Bolt12InvoiceFeatures { - orig.clone() -} -impl Clone for BlindedHopFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedHopFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedHopFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHopFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedHopFeatures -pub extern "C" fn BlindedHopFeatures_clone(orig: &BlindedHopFeatures) -> BlindedHopFeatures { - orig.clone() -} -impl Clone for ChannelTypeFeatures { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeChannelTypeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelTypeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelTypeFeatures)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the ChannelTypeFeatures -pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures { - orig.clone() -} -/// Generates a non-cryptographic 64-bit hash of the InitFeatures. -#[no_mangle] -pub extern "C" fn InitFeatures_hash(o: &InitFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the NodeFeatures. -#[no_mangle] -pub extern "C" fn NodeFeatures_hash(o: &NodeFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the ChannelFeatures. -#[no_mangle] -pub extern "C" fn ChannelFeatures_hash(o: &ChannelFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_hash(o: &Bolt11InvoiceFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the OfferFeatures. -#[no_mangle] -pub extern "C" fn OfferFeatures_hash(o: &OfferFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_hash(o: &InvoiceRequestFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_hash(o: &Bolt12InvoiceFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_hash(o: &BlindedHopFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_hash(o: &ChannelTypeFeatures) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Get a string which allows debug introspection of a InitFeatures object -pub extern "C" fn InitFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::InitFeatures }).into()} -/// Get a string which allows debug introspection of a NodeFeatures object -pub extern "C" fn NodeFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::NodeFeatures }).into()} -/// Get a string which allows debug introspection of a ChannelFeatures object -pub extern "C" fn ChannelFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::ChannelFeatures }).into()} -/// Get a string which allows debug introspection of a Bolt11InvoiceFeatures object -pub extern "C" fn Bolt11InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::Bolt11InvoiceFeatures }).into()} -/// Get a string which allows debug introspection of a OfferFeatures object -pub extern "C" fn OfferFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::OfferFeatures }).into()} -/// Get a string which allows debug introspection of a InvoiceRequestFeatures object -pub extern "C" fn InvoiceRequestFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::InvoiceRequestFeatures }).into()} -/// Get a string which allows debug introspection of a Bolt12InvoiceFeatures object -pub extern "C" fn Bolt12InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::Bolt12InvoiceFeatures }).into()} -/// Get a string which allows debug introspection of a BlindedHopFeatures object -pub extern "C" fn BlindedHopFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::BlindedHopFeatures }).into()} -/// Get a string which allows debug introspection of a ChannelTypeFeatures object -pub extern "C" fn ChannelTypeFeatures_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::features::ChannelTypeFeatures }).into()} - -use lightning::ln::features::InitFeatures as nativeInitFeaturesImport; -pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; - -/// Features used within an `init` message. -#[must_use] -#[repr(C)] -pub struct InitFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInitFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InitFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInitFeatures) }; -} -#[allow(unused)] -impl InitFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::NodeFeatures as nativeNodeFeaturesImport; -pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; - -/// Features used within a `node_announcement` message. -#[must_use] -#[repr(C)] -pub struct NodeFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeNodeFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for NodeFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeFeatures) }; -} -#[allow(unused)] -impl NodeFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::ChannelFeatures as nativeChannelFeaturesImport; -pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; - -/// Features used within a `channel_announcement` message. -#[must_use] -#[repr(C)] -pub struct ChannelFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeChannelFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelFeatures) }; -} -#[allow(unused)] -impl ChannelFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; -pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; - -/// Features used within an invoice. -#[must_use] -#[repr(C)] -pub struct Bolt11InvoiceFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeBolt11InvoiceFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Bolt11InvoiceFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_free(this_obj: Bolt11InvoiceFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; -} -#[allow(unused)] -impl Bolt11InvoiceFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::OfferFeatures as nativeOfferFeaturesImport; -pub(crate) type nativeOfferFeatures = nativeOfferFeaturesImport; - -/// Features used within an `offer`. -#[must_use] -#[repr(C)] -pub struct OfferFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeOfferFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for OfferFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeOfferFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn OfferFeatures_free(this_obj: OfferFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OfferFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferFeatures) }; -} -#[allow(unused)] -impl OfferFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeOfferFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeOfferFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::InvoiceRequestFeatures as nativeInvoiceRequestFeaturesImport; -pub(crate) type nativeInvoiceRequestFeatures = nativeInvoiceRequestFeaturesImport; - -/// Features used within an `invoice_request`. -#[must_use] -#[repr(C)] -pub struct InvoiceRequestFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeInvoiceRequestFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for InvoiceRequestFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_free(this_obj: InvoiceRequestFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn InvoiceRequestFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFeatures) }; -} -#[allow(unused)] -impl InvoiceRequestFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::Bolt12InvoiceFeatures as nativeBolt12InvoiceFeaturesImport; -pub(crate) type nativeBolt12InvoiceFeatures = nativeBolt12InvoiceFeaturesImport; - -/// Features used within an `invoice`. -#[must_use] -#[repr(C)] -pub struct Bolt12InvoiceFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeBolt12InvoiceFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for Bolt12InvoiceFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_free(this_obj: Bolt12InvoiceFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Bolt12InvoiceFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12InvoiceFeatures) }; -} -#[allow(unused)] -impl Bolt12InvoiceFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12InvoiceFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12InvoiceFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeBolt12InvoiceFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::BlindedHopFeatures as nativeBlindedHopFeaturesImport; -pub(crate) type nativeBlindedHopFeatures = nativeBlindedHopFeaturesImport; - -/// Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo -#[must_use] -#[repr(C)] -pub struct BlindedHopFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeBlindedHopFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for BlindedHopFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedHopFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_free(this_obj: BlindedHopFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedHopFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHopFeatures) }; -} -#[allow(unused)] -impl BlindedHopFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHopFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHopFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeBlindedHopFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} - -use lightning::ln::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport; -pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport; - -/// Features used within the channel_type field in an OpenChannel message. -/// -/// A channel is always of some known \"type\", describing the transaction formats used and the exact -/// semantics of our interaction with our peer. -/// -/// Note that because a channel is a specific type which is proposed by the opener and accepted by -/// the counterparty, only required features are allowed here. -/// -/// This is serialized differently from other feature types - it is not prefixed by a length, and -/// thus must only appear inside a TLV where its length is known in advance. -#[must_use] -#[repr(C)] -pub struct ChannelTypeFeatures { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeChannelTypeFeatures, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for ChannelTypeFeatures { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn ChannelTypeFeatures_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelTypeFeatures) }; -} -#[allow(unused)] -impl ChannelTypeFeatures { - pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeChannelTypeFeatures { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_empty() -> crate::lightning::ln::features::InitFeatures { - let mut ret = lightning::ln::features::InitFeatures::empty(); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InitFeatures, other: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InitFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn InitFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInitFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_empty() -> crate::lightning::ln::features::NodeFeatures { - let mut ret = lightning::ln::features::NodeFeatures::empty(); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::NodeFeatures, other: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::NodeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn NodeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeNodeFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_empty() -> crate::lightning::ln::features::ChannelFeatures { - let mut ret = lightning::ln::features::ChannelFeatures::empty(); - crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelFeatures, other: &crate::lightning::ln::features::ChannelFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::ChannelFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_empty() -> crate::lightning::ln::features::Bolt11InvoiceFeatures { - let mut ret = lightning::ln::features::Bolt11InvoiceFeatures::empty(); - crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures, other: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt11InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt11InvoiceFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_empty() -> crate::lightning::ln::features::OfferFeatures { - let mut ret = lightning::ln::features::OfferFeatures::empty(); - crate::lightning::ln::features::OfferFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::OfferFeatures, other: &crate::lightning::ln::features::OfferFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::OfferFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn OfferFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeOfferFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning::ln::features::InvoiceRequestFeatures { - let mut ret = lightning::ln::features::InvoiceRequestFeatures::empty(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::InvoiceRequestFeatures, other: &crate::lightning::ln::features::InvoiceRequestFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::InvoiceRequestFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn InvoiceRequestFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeInvoiceRequestFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning::ln::features::Bolt12InvoiceFeatures { - let mut ret = lightning::ln::features::Bolt12InvoiceFeatures::empty(); - crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures, other: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBolt12InvoiceFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning::ln::features::BlindedHopFeatures { - let mut ret = lightning::ln::features::BlindedHopFeatures::empty(); - crate::lightning::ln::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::BlindedHopFeatures, other: &crate::lightning::ln::features::BlindedHopFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::BlindedHopFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn BlindedHopFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeBlindedHopFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Create a blank Features with no features set -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut ret = lightning::ln::features::ChannelTypeFeatures::empty(); - crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } -} - -/// Returns true if this `Features` object contains required features unknown by `other`. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures, other: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); - ret -} - -/// Returns true if this `Features` object contains unknown feature flags which are set as -/// \"required\". -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::lightning::ln::features::ChannelTypeFeatures) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); - ret -} - -/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_required_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined -/// by [BOLT 9]. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_optional_feature_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will -/// be set instead (i.e., `bit - 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_required_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined -/// by [bLIP 2] or if it is a known `T` feature. -/// -/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be -/// set instead (i.e., `bit + 1`). -/// -/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelTypeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning::ln::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::ln::features::nativeChannelTypeFeatures)) }.set_optional_custom_bit(bit); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - #[no_mangle] /// Serialize the InitFeatures object into a byte array which can be read by InitFeatures_read -pub extern "C" fn InitFeatures_write(obj: &crate::lightning::ln::features::InitFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn InitFeatures_write(obj: &crate::lightning_types::features::InitFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn InitFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInitFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeInitFeatures) }) } #[no_mangle] /// Read a InitFeatures from a byte array, created by InitFeatures_write pub extern "C" fn InitFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InitFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the ChannelFeatures object into a byte array which can be read by ChannelFeatures_read -pub extern "C" fn ChannelFeatures_write(obj: &crate::lightning::ln::features::ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn ChannelFeatures_write(obj: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn ChannelFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeChannelFeatures) }) } #[no_mangle] /// Read a ChannelFeatures from a byte array, created by ChannelFeatures_write pub extern "C" fn ChannelFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::ChannelFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the NodeFeatures object into a byte array which can be read by NodeFeatures_read -pub extern "C" fn NodeFeatures_write(obj: &crate::lightning::ln::features::NodeFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn NodeFeatures_write(obj: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn NodeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeNodeFeatures) }) } #[no_mangle] /// Read a NodeFeatures from a byte array, created by NodeFeatures_write pub extern "C" fn NodeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the Bolt11InvoiceFeatures object into a byte array which can be read by Bolt11InvoiceFeatures_read -pub extern "C" fn Bolt11InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn Bolt11InvoiceFeatures_write(obj: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn Bolt11InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt11InvoiceFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeBolt11InvoiceFeatures) }) } #[no_mangle] /// Read a Bolt11InvoiceFeatures from a byte array, created by Bolt11InvoiceFeatures_write pub extern "C" fn Bolt11InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt11InvoiceFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the Bolt12InvoiceFeatures object into a byte array which can be read by Bolt12InvoiceFeatures_read -pub extern "C" fn Bolt12InvoiceFeatures_write(obj: &crate::lightning::ln::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn Bolt12InvoiceFeatures_write(obj: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn Bolt12InvoiceFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12InvoiceFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeBolt12InvoiceFeatures) }) } #[no_mangle] /// Read a Bolt12InvoiceFeatures from a byte array, created by Bolt12InvoiceFeatures_write pub extern "C" fn Bolt12InvoiceFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12InvoiceFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the BlindedHopFeatures object into a byte array which can be read by BlindedHopFeatures_read -pub extern "C" fn BlindedHopFeatures_write(obj: &crate::lightning::ln::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn BlindedHopFeatures_write(obj: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn BlindedHopFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedHopFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeBlindedHopFeatures) }) } #[no_mangle] /// Read a BlindedHopFeatures from a byte array, created by BlindedHopFeatures_write pub extern "C" fn BlindedHopFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedHopFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] /// Serialize the ChannelTypeFeatures object into a byte array which can be read by ChannelTypeFeatures_read -pub extern "C" fn ChannelTypeFeatures_write(obj: &crate::lightning::ln::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn ChannelTypeFeatures_write(obj: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn ChannelTypeFeatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelTypeFeatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::features::nativeChannelTypeFeatures) }) } #[no_mangle] /// Read a ChannelTypeFeatures from a byte array, created by ChannelTypeFeatures_write pub extern "C" fn ChannelTypeFeatures_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelTypeFeaturesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs index a1cea41..3d8972c 100644 --- a/lightning-c-bindings/src/lightning/ln/inbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/inbound_payment.rs @@ -40,6 +40,12 @@ pub struct ExpandedKey { pub is_owned: bool, } +impl core::ops::Deref for ExpandedKey { + type Target = nativeExpandedKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ExpandedKey { } +unsafe impl core::marker::Sync for ExpandedKey { } impl Drop for ExpandedKey { fn drop(&mut self) { if self.is_owned && !<*mut nativeExpandedKey>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl ExpandedKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Create a new [`ExpandedKey`] for generating an inbound payment hash and secret. /// @@ -100,7 +109,7 @@ pub extern "C" fn ExpandedKey_new(key_material: *const [u8; 32]) -> crate::light pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut invoice_expiry_delta_secs: u32, entropy_source: &crate::lightning::sign::EntropySource, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); + let mut ret = lightning::ln::inbound_payment::create::(keys.get_native_ref(), local_min_value_msat, invoice_expiry_delta_secs, entropy_source, current_time, local_min_final_cltv_expiry_delta); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::c_types::ThirtyTwoBytes { data: orig_ret_0_1.0 }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -119,7 +128,7 @@ pub extern "C" fn create(keys: &crate::lightning::ln::inbound_payment::ExpandedK pub extern "C" fn create_from_hash(keys: &crate::lightning::ln::inbound_payment::ExpandedKey, mut min_value_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut invoice_expiry_delta_secs: u32, mut current_time: u64, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { let mut local_min_value_msat = if min_value_msat.is_some() { Some( { min_value_msat.take() }) } else { None }; let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning::ln::inbound_payment::create_from_hash(keys.get_native_ref(), local_min_value_msat, ::lightning::ln::PaymentHash(payment_hash.data), invoice_expiry_delta_secs, current_time, local_min_final_cltv_expiry_delta); + let mut ret = lightning::ln::inbound_payment::create_from_hash(keys.get_native_ref(), local_min_value_msat, ::lightning::ln::types::PaymentHash(payment_hash.data), invoice_expiry_delta_secs, current_time, local_min_final_cltv_expiry_delta); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/ln/invoice_utils.rs b/lightning-c-bindings/src/lightning/ln/invoice_utils.rs new file mode 100644 index 0000000..b9835c8 --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/invoice_utils.rs @@ -0,0 +1,205 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Convenient utilities to create an invoice. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" +/// See [`PhantomKeysManager`] for more information on phantom node payments. +/// +/// `phantom_route_hints` parameter: +/// * Contains channel info for all nodes participating in the phantom invoice +/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each +/// participating node +/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is +/// updated when a channel becomes disabled or closes +/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice +/// may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared +/// down +/// +/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference +/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). +/// If `None` is provided for `payment_hash`, then one will be created. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// `duration_since_epoch` is the current time since epoch in seconds. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom +/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this +/// requirement). +/// +/// [`PhantomKeysManager`]: crate::sign::PhantomKeysManager +/// [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints +/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment +/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash +/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA +/// +/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not +/// available and the current time is supplied by the caller. +#[no_mangle] +pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; + let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" +/// See [`PhantomKeysManager`] for more information on phantom node payments. +/// +/// `phantom_route_hints` parameter: +/// * Contains channel info for all nodes participating in the phantom invoice +/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each +/// participating node +/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is +/// updated when a channel becomes disabled or closes +/// * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum +/// of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected +/// in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node +/// until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as +/// desired, but note that some nodes will be trimmed if more than 3 nodes are provided. +/// +/// `description_hash` is a SHA-256 hash of the description text +/// +/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference +/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). +/// If `None` is provided for `payment_hash`, then one will be created. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// `duration_since_epoch` is the current time since epoch in seconds. +/// +/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom +/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this +/// requirement). +/// +/// [`PhantomKeysManager`]: crate::sign::PhantomKeysManager +/// [`ChannelManager::get_phantom_route_hints`]: crate::ln::channelmanager::ChannelManager::get_phantom_route_hints +/// [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment +/// [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash +/// [`PhantomRouteHints::channels`]: crate::ln::channelmanager::PhantomRouteHints::channels +/// +/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not +/// available and the current time is supplied by the caller. +#[no_mangle] +pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_opt.take() }.data) }})} }; + let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// Utility to construct an invoice. Generally, unless you want to do something like a custom +/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this +/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user +/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify +/// that the payment secret is valid when the invoice is paid. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// Utility to construct an invoice. Generally, unless you want to do something like a custom +/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this +/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user +/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify +/// that the payment secret is valid when the invoice is paid. +/// Use this variant if you want to pass the `description_hash` to the invoice. +/// +/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for +/// in excess of the current time. +/// +/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to +/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block +/// confirmations during routing. +/// +/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: crate::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// See [`create_invoice_from_channelmanager_with_description_hash`] +/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not +/// available and the current time is supplied by the caller. +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// See [`create_invoice_from_channelmanager`] +/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not +/// available and the current time is supplied by the caller. +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + +/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`] +/// This version allows for providing a custom [`PaymentHash`] for the invoice. +/// This may be useful if you're building an on-chain swap or involving another protocol where +/// the payment hash is also involved outside the scope of lightning. +#[no_mangle] +pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { + let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; + let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; + let mut ret = lightning::ln::invoice_utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::types::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; + local_ret +} + diff --git a/lightning-c-bindings/src/lightning/ln/mod.rs b/lightning-c-bindings/src/lightning/ln/mod.rs index 4b76489..6029722 100644 --- a/lightning-c-bindings/src/lightning/ln/mod.rs +++ b/lightning-c-bindings/src/lightning/ln/mod.rs @@ -7,6 +7,12 @@ // source was automatically generated. //! Implementations of various parts of the Lightning protocol are in this module. +//! +//! Note that the re-exports of [`PaymentHash`], [`PaymentPreimage`], and [`PaymentSecret`] here +//! are deprecated and will be removed in a future version. Instead, use them via +//! [`lightning::types::payment`]. +//! +//! [`lightning::types::payment`]: crate::types::payment use alloc::str::FromStr; use alloc::string::String; @@ -20,15 +26,19 @@ use alloc::{vec::Vec, boxed::Box}; pub mod onion_payment; pub mod channelmanager; pub mod channel_keys; +pub mod channel_state; pub mod inbound_payment; pub mod msgs; pub mod peer_handler; pub mod chan_utils; pub mod features; pub mod script; +pub mod types; +pub mod invoice_utils; +pub mod bolt11_payment; pub mod outbound_payment; pub mod wire; -mod channel_id { +mod peer_channel_encryptor { use alloc::str::FromStr; use alloc::string::String; @@ -40,7 +50,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -mod peer_channel_encryptor { +mod channel { use alloc::str::FromStr; use alloc::string::String; @@ -51,8 +61,7 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -} -mod channel { +mod state_flags { use alloc::str::FromStr; use alloc::string::String; @@ -63,7 +72,9 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -mod state_flags { +} +} +mod onion_utils { use alloc::str::FromStr; use alloc::string::String; @@ -75,8 +86,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -} -mod onion_utils { +mod interactivetxs { use alloc::str::FromStr; use alloc::string::String; diff --git a/lightning-c-bindings/src/lightning/ln/msgs.rs b/lightning-c-bindings/src/lightning/ln/msgs.rs index 9332324..89c8181 100644 --- a/lightning-c-bindings/src/lightning/ln/msgs.rs +++ b/lightning-c-bindings/src/lightning/ln/msgs.rs @@ -58,6 +58,16 @@ pub enum DecodeError { crate::c_types::IOError), /// The message included zlib-compressed values, which we don't support. UnsupportedCompression, + /// Value is validly encoded but is dangerous to use. + /// + /// This is used for things like [`ChannelManager`] deserialization where we want to ensure + /// that we don't use a [`ChannelManager`] which is in out of sync with the [`ChannelMonitor`]. + /// This indicates that there is a critical implementation flaw in the storage implementation + /// and it's unsafe to continue. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager + /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + DangerousValue, } use lightning::ln::msgs::DecodeError as DecodeErrorImport; pub(crate) type nativeDecodeError = DecodeErrorImport; @@ -78,6 +88,7 @@ impl DecodeError { ) }, DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression, + DecodeError::DangerousValue => nativeDecodeError::DangerousValue, } } #[allow(unused)] @@ -94,6 +105,7 @@ impl DecodeError { ) }, DecodeError::UnsupportedCompression => nativeDecodeError::UnsupportedCompression, + DecodeError::DangerousValue => nativeDecodeError::DangerousValue, } } #[allow(unused)] @@ -112,6 +124,7 @@ impl DecodeError { ) }, nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression, + nativeDecodeError::DangerousValue => DecodeError::DangerousValue, } } #[allow(unused)] @@ -128,6 +141,7 @@ impl DecodeError { ) }, nativeDecodeError::UnsupportedCompression => DecodeError::UnsupportedCompression, + nativeDecodeError::DangerousValue => DecodeError::DangerousValue, } } } @@ -178,6 +192,10 @@ pub extern "C" fn DecodeError_io(a: crate::c_types::IOError) -> DecodeError { /// Utility method to constructs a new UnsupportedCompression-variant DecodeError pub extern "C" fn DecodeError_unsupported_compression() -> DecodeError { DecodeError::UnsupportedCompression} +#[no_mangle] +/// Utility method to constructs a new DangerousValue-variant DecodeError +pub extern "C" fn DecodeError_dangerous_value() -> DecodeError { + DecodeError::DangerousValue} /// Get a string which allows debug introspection of a DecodeError object pub extern "C" fn DecodeError_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::DecodeError }).into()} @@ -218,6 +236,12 @@ pub struct Init { pub is_owned: bool, } +impl core::ops::Deref for Init { + type Target = nativeInit; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Init { } +unsafe impl core::marker::Sync for Init { } impl Drop for Init { fn drop(&mut self) { if self.is_owned && !<*mut nativeInit>::is_null(self.inner) { @@ -248,16 +272,19 @@ impl Init { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The relevant features which the sender supports. #[no_mangle] -pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning::ln::features::InitFeatures { +pub extern "C" fn Init_get_features(this_ptr: &Init) -> crate::lightning_types::features::InitFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::InitFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } } /// The relevant features which the sender supports. #[no_mangle] -pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning::ln::features::InitFeatures) { +pub extern "C" fn Init_set_features(this_ptr: &mut Init, mut val: crate::lightning_types::features::InitFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Indicates chains the sender is interested in. @@ -276,7 +303,7 @@ pub extern "C" fn Init_get_networks(this_ptr: &Init) -> crate::c_types::derived: /// If there are no common chains, the connection will be closed. #[no_mangle] pub extern "C" fn Init_set_networks(this_ptr: &mut Init, mut val: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} }; + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { let mut local_val_0 = Vec::new(); for mut item in { val_opt.take() }.into_rust().drain(..) { local_val_0.push( { ::bitcoin::constants::ChainHash::from(&item.data) }); }; local_val_0 }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.networks = local_val; } /// The receipient's network address. @@ -305,8 +332,8 @@ pub extern "C" fn Init_set_remote_network_address(this_ptr: &mut Init, mut val: /// Constructs a new Init given each field #[must_use] #[no_mangle] -pub extern "C" fn Init_new(mut features_arg: crate::lightning::ln::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init { - let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_networks_arg_0 }})} }; +pub extern "C" fn Init_new(mut features_arg: crate::lightning_types::features::InitFeatures, mut networks_arg: crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ, mut remote_network_address_arg: crate::c_types::derived::COption_SocketAddressZ) -> Init { + let mut local_networks_arg = { /*networks_arg*/ let networks_arg_opt = networks_arg; if networks_arg_opt.is_none() { None } else { Some({ { let mut local_networks_arg_0 = Vec::new(); for mut item in { networks_arg_opt.take() }.into_rust().drain(..) { local_networks_arg_0.push( { ::bitcoin::constants::ChainHash::from(&item.data) }); }; local_networks_arg_0 }})} }; let mut local_remote_network_address_arg = { /*remote_network_address_arg*/ let remote_network_address_arg_opt = remote_network_address_arg; if remote_network_address_arg_opt.is_none() { None } else { Some({ { { remote_network_address_arg_opt.take() }.into_native() }})} }; Init { inner: ObjOps::heap_alloc(nativeInit { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, @@ -377,6 +404,12 @@ pub struct ErrorMessage { pub is_owned: bool, } +impl core::ops::Deref for ErrorMessage { + type Target = nativeErrorMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErrorMessage { } +unsafe impl core::marker::Sync for ErrorMessage { } impl Drop for ErrorMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeErrorMessage>::is_null(self.inner) { @@ -407,23 +440,26 @@ impl ErrorMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID involved in the error. /// /// All-0s indicates a general error unrelated to a specific channel, after which all channels /// with the sending peer should be closed. #[no_mangle] -pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> *const [u8; 32] { +pub extern "C" fn ErrorMessage_get_channel_id(this_ptr: &ErrorMessage) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID involved in the error. /// /// All-0s indicates a general error unrelated to a specific channel, after which all channels /// with the sending peer should be closed. #[no_mangle] -pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn ErrorMessage_set_channel_id(this_ptr: &mut ErrorMessage, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// A possibly human-readable error description. /// @@ -447,9 +483,9 @@ pub extern "C" fn ErrorMessage_set_data(this_ptr: &mut ErrorMessage, mut val: cr /// Constructs a new ErrorMessage given each field #[must_use] #[no_mangle] -pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> ErrorMessage { +pub extern "C" fn ErrorMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> ErrorMessage { ErrorMessage { inner: ObjOps::heap_alloc(nativeErrorMessage { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, data: data_arg.into_string(), }), is_owned: true } } @@ -516,6 +552,12 @@ pub struct WarningMessage { pub is_owned: bool, } +impl core::ops::Deref for WarningMessage { + type Target = nativeWarningMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for WarningMessage { } +unsafe impl core::marker::Sync for WarningMessage { } impl Drop for WarningMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeWarningMessage>::is_null(self.inner) { @@ -546,21 +588,24 @@ impl WarningMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID involved in the warning. /// /// All-0s indicates a warning unrelated to a specific channel. #[no_mangle] -pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> *const [u8; 32] { +pub extern "C" fn WarningMessage_get_channel_id(this_ptr: &WarningMessage) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID involved in the warning. /// /// All-0s indicates a warning unrelated to a specific channel. #[no_mangle] -pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn WarningMessage_set_channel_id(this_ptr: &mut WarningMessage, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// A possibly human-readable warning description. /// @@ -584,9 +629,9 @@ pub extern "C" fn WarningMessage_set_data(this_ptr: &mut WarningMessage, mut val /// Constructs a new WarningMessage given each field #[must_use] #[no_mangle] -pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::Str) -> WarningMessage { +pub extern "C" fn WarningMessage_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::Str) -> WarningMessage { WarningMessage { inner: ObjOps::heap_alloc(nativeWarningMessage { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, data: data_arg.into_string(), }), is_owned: true } } @@ -653,6 +698,12 @@ pub struct Ping { pub is_owned: bool, } +impl core::ops::Deref for Ping { + type Target = nativePing; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Ping { } +unsafe impl core::marker::Sync for Ping { } impl Drop for Ping { fn drop(&mut self) { if self.is_owned && !<*mut nativePing>::is_null(self.inner) { @@ -683,6 +734,9 @@ impl Ping { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The desired response length. #[no_mangle] @@ -782,6 +836,12 @@ pub struct Pong { pub is_owned: bool, } +impl core::ops::Deref for Pong { + type Target = nativePong; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Pong { } +unsafe impl core::marker::Sync for Pong { } impl Drop for Pong { fn drop(&mut self) { if self.is_owned && !<*mut nativePong>::is_null(self.inner) { @@ -812,6 +872,9 @@ impl Pong { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The pong packet size. /// @@ -878,22 +941,20 @@ pub extern "C" fn Pong_eq(a: &Pong, b: &Pong) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport; -pub(crate) type nativeOpenChannel = nativeOpenChannelImport; +use lightning::ln::msgs::CommonOpenChannelFields as nativeCommonOpenChannelFieldsImport; +pub(crate) type nativeCommonOpenChannelFields = nativeCommonOpenChannelFieldsImport; -/// An [`open_channel`] message to be sent to or received from a peer. -/// -/// Used in V1 channel establishment +/// Contains fields that are both common to [`open_channel`] and `open_channel2` messages. /// /// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message #[must_use] #[repr(C)] -pub struct OpenChannel { +pub struct CommonOpenChannelFields { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeOpenChannel, + pub inner: *mut nativeCommonOpenChannelFields, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -901,250 +962,249 @@ pub struct OpenChannel { pub is_owned: bool, } -impl Drop for OpenChannel { +impl core::ops::Deref for CommonOpenChannelFields { + type Target = nativeCommonOpenChannelFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommonOpenChannelFields { } +unsafe impl core::marker::Sync for CommonOpenChannelFields { } +impl Drop for CommonOpenChannelFields { fn drop(&mut self) { - if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) { + if self.is_owned && !<*mut nativeCommonOpenChannelFields>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the CommonOpenChannelFields, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { } +pub extern "C" fn CommonOpenChannelFields_free(this_obj: CommonOpenChannelFields) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) }; +pub(crate) extern "C" fn CommonOpenChannelFields_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonOpenChannelFields) }; } #[allow(unused)] -impl OpenChannel { - pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel { +impl CommonOpenChannelFields { + pub(crate) fn get_native_ref(&self) -> &'static nativeCommonOpenChannelFields { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonOpenChannelFields { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel { + pub(crate) fn take_inner(mut self) -> *mut nativeCommonOpenChannelFields { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] -pub extern "C" fn OpenChannel_get_chain_hash(this_ptr: &OpenChannel) -> *const [u8; 32] { +pub extern "C" fn CommonOpenChannelFields_get_chain_hash(this_ptr: &CommonOpenChannelFields) -> *const [u8; 32] { let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; inner_val.as_ref() } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] -pub extern "C" fn OpenChannel_set_chain_hash(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); +pub extern "C" fn CommonOpenChannelFields_set_chain_hash(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } -/// A temporary channel ID, until the funding outpoint is announced +/// A temporary channel ID +/// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint +/// For V1 channels: a temporary channel ID, until the funding outpoint is announced #[no_mangle] -pub extern "C" fn OpenChannel_get_temporary_channel_id(this_ptr: &OpenChannel) -> *const [u8; 32] { +pub extern "C" fn CommonOpenChannelFields_get_temporary_channel_id(this_ptr: &CommonOpenChannelFields) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } -/// A temporary channel ID, until the funding outpoint is announced +/// A temporary channel ID +/// For V2 channels: derived using a zeroed out value for the channel acceptor's revocation basepoint +/// For V1 channels: a temporary channel ID, until the funding outpoint is announced #[no_mangle] -pub extern "C" fn OpenChannel_set_temporary_channel_id(this_ptr: &mut OpenChannel, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn CommonOpenChannelFields_set_temporary_channel_id(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The channel value +/// For V1 channels: The channel value +/// For V2 channels: Part of the channel value contributed by the channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_get_funding_satoshis(this_ptr: &OpenChannel) -> u64 { +pub extern "C" fn CommonOpenChannelFields_get_funding_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; *inner_val } -/// The channel value +/// For V1 channels: The channel value +/// For V2 channels: Part of the channel value contributed by the channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_set_funding_satoshis(this_ptr: &mut OpenChannel, mut val: u64) { +pub extern "C" fn CommonOpenChannelFields_set_funding_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; } -/// The amount to push to the counterparty as part of the open, in milli-satoshi -#[no_mangle] -pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat; - *inner_val -} -/// The amount to push to the counterparty as part of the open, in milli-satoshi -#[no_mangle] -pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val; -} -/// The threshold below which outputs on transactions broadcast by sender will be omitted +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted #[no_mangle] -pub extern "C" fn OpenChannel_get_dust_limit_satoshis(this_ptr: &OpenChannel) -> u64 { +pub extern "C" fn CommonOpenChannelFields_get_dust_limit_satoshis(this_ptr: &CommonOpenChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; *inner_val } -/// The threshold below which outputs on transactions broadcast by sender will be omitted +/// The threshold below which outputs on transactions broadcast by the channel initiator will be +/// omitted #[no_mangle] -pub extern "C" fn OpenChannel_set_dust_limit_satoshis(this_ptr: &mut OpenChannel, mut val: u64) { +pub extern "C" fn CommonOpenChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonOpenChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; } -/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannel_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannel) -> u64 { +pub extern "C" fn CommonOpenChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonOpenChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; *inner_val } -/// The maximum inbound HTLC value in flight towards sender, in milli-satoshi +/// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannel, mut val: u64) { +pub extern "C" fn CommonOpenChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; } -/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel -#[no_mangle] -pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis; - *inner_val -} -/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel -#[no_mangle] -pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val; -} -/// The minimum HTLC size incoming to sender, in milli-satoshi +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannel_get_htlc_minimum_msat(this_ptr: &OpenChannel) -> u64 { +pub extern "C" fn CommonOpenChannelFields_get_htlc_minimum_msat(this_ptr: &CommonOpenChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; *inner_val } -/// The minimum HTLC size incoming to sender, in milli-satoshi +/// The minimum HTLC size incoming to channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannel_set_htlc_minimum_msat(this_ptr: &mut OpenChannel, mut val: u64) { +pub extern "C" fn CommonOpenChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonOpenChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; } -/// The feerate per 1000-weight of sender generated transactions, until updated by +/// The feerate for the commitment transaction set by the channel initiator until updated by /// [`UpdateFee`] #[no_mangle] -pub extern "C" fn OpenChannel_get_feerate_per_kw(this_ptr: &OpenChannel) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().feerate_per_kw; +pub extern "C" fn CommonOpenChannelFields_get_commitment_feerate_sat_per_1000_weight(this_ptr: &CommonOpenChannelFields) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight; *inner_val } -/// The feerate per 1000-weight of sender generated transactions, until updated by +/// The feerate for the commitment transaction set by the channel initiator until updated by /// [`UpdateFee`] #[no_mangle] -pub extern "C" fn OpenChannel_set_feerate_per_kw(this_ptr: &mut OpenChannel, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.feerate_per_kw = val; +pub extern "C" fn CommonOpenChannelFields_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut CommonOpenChannelFields, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if -/// they broadcast a commitment transaction +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction #[no_mangle] -pub extern "C" fn OpenChannel_get_to_self_delay(this_ptr: &OpenChannel) -> u16 { +pub extern "C" fn CommonOpenChannelFields_get_to_self_delay(this_ptr: &CommonOpenChannelFields) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; *inner_val } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if -/// they broadcast a commitment transaction +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction #[no_mangle] -pub extern "C" fn OpenChannel_set_to_self_delay(this_ptr: &mut OpenChannel, mut val: u16) { +pub extern "C" fn CommonOpenChannelFields_set_to_self_delay(this_ptr: &mut CommonOpenChannelFields, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; } -/// The maximum number of inbound HTLCs towards sender +/// The maximum number of inbound HTLCs towards channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_get_max_accepted_htlcs(this_ptr: &OpenChannel) -> u16 { +pub extern "C" fn CommonOpenChannelFields_get_max_accepted_htlcs(this_ptr: &CommonOpenChannelFields) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; *inner_val } -/// The maximum number of inbound HTLCs towards sender +/// The maximum number of inbound HTLCs towards channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_set_max_accepted_htlcs(this_ptr: &mut OpenChannel, mut val: u16) { +pub extern "C" fn CommonOpenChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonOpenChannelFields, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; } -/// The sender's key controlling the funding transaction +/// The channel initiator's key controlling the funding transaction #[no_mangle] -pub extern "C" fn OpenChannel_get_funding_pubkey(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonOpenChannelFields_get_funding_pubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The sender's key controlling the funding transaction +/// The channel initiator's key controlling the funding transaction #[no_mangle] -pub extern "C" fn OpenChannel_set_funding_pubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonOpenChannelFields_set_funding_pubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn OpenChannel_get_revocation_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonOpenChannelFields_get_revocation_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn OpenChannel_set_revocation_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonOpenChannelFields_set_revocation_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); } -/// A payment key to sender for transactions broadcast by counterparty +/// A payment key to channel initiator for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn OpenChannel_get_payment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point; +pub extern "C" fn CommonOpenChannelFields_get_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } -/// A payment key to sender for transactions broadcast by counterparty +/// A payment key to channel initiator for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn OpenChannel_set_payment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust(); +pub extern "C" fn CommonOpenChannelFields_set_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); } -/// Used to derive a payment key to sender for transactions broadcast by sender +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator #[no_mangle] -pub extern "C" fn OpenChannel_get_delayed_payment_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonOpenChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } -/// Used to derive a payment key to sender for transactions broadcast by sender +/// Used to derive a payment key to channel initiator for transactions broadcast by channel +/// initiator #[no_mangle] -pub extern "C" fn OpenChannel_set_delayed_payment_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonOpenChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); } -/// Used to derive an HTLC payment key to sender +/// Used to derive an HTLC payment key to channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_get_htlc_basepoint(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonOpenChannelFields_get_htlc_basepoint(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } -/// Used to derive an HTLC payment key to sender +/// Used to derive an HTLC payment key to channel initiator #[no_mangle] -pub extern "C" fn OpenChannel_set_htlc_basepoint(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonOpenChannelFields_set_htlc_basepoint(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); } -/// The first to-be-broadcast-by-sender transaction's per commitment point +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point #[no_mangle] -pub extern "C" fn OpenChannel_get_first_per_commitment_point(this_ptr: &OpenChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonOpenChannelFields_get_first_per_commitment_point(this_ptr: &CommonOpenChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The first to-be-broadcast-by-sender transaction's per commitment point +/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point #[no_mangle] -pub extern "C" fn OpenChannel_set_first_per_commitment_point(this_ptr: &mut OpenChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonOpenChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); } /// The channel flags to be used #[no_mangle] -pub extern "C" fn OpenChannel_get_channel_flags(this_ptr: &OpenChannel) -> u8 { +pub extern "C" fn CommonOpenChannelFields_get_channel_flags(this_ptr: &CommonOpenChannelFields) -> u8 { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; *inner_val } /// The channel flags to be used #[no_mangle] -pub extern "C" fn OpenChannel_set_channel_flags(this_ptr: &mut OpenChannel, mut val: u8) { +pub extern "C" fn CommonOpenChannelFields_set_channel_flags(this_ptr: &mut CommonOpenChannelFields, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } -/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close #[no_mangle] -pub extern "C" fn OpenChannel_get_shutdown_scriptpubkey(this_ptr: &OpenChannel) -> crate::c_types::derived::COption_CVec_u8ZZ { +pub extern "C" fn CommonOpenChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonOpenChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) }; local_inner_val } -/// A request to pre-set the to-sender output's `scriptPubkey` for when we collaboratively close +/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we +/// collaboratively close #[no_mangle] -pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; +pub extern "C" fn CommonOpenChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonOpenChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; } /// The channel type that this channel will represent @@ -1154,9 +1214,9 @@ pub extern "C" fn OpenChannel_set_shutdown_scriptpubkey(this_ptr: &mut OpenChann /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn CommonOpenChannelFields_get_channel_type(this_ptr: &CommonOpenChannelFields) -> crate::lightning_types::features::ChannelTypeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; - let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + let mut local_inner_val = crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; local_inner_val } /// The channel type that this channel will represent @@ -1166,33 +1226,31 @@ pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate: /// /// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn OpenChannel_set_channel_type(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { +pub extern "C" fn CommonOpenChannelFields_set_channel_type(this_ptr: &mut CommonOpenChannelFields, mut val: crate::lightning_types::features::ChannelTypeFeatures) { let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; } -/// Constructs a new OpenChannel given each field +/// Constructs a new CommonOpenChannelFields given each field /// /// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut push_msat_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut feerate_per_kw_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> OpenChannel { - let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; +pub extern "C" fn CommonOpenChannelFields_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning_types::features::ChannelTypeFeatures) -> CommonOpenChannelFields { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; - OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data), + CommonOpenChannelFields { inner: ObjOps::heap_alloc(nativeCommonOpenChannelFields { + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) }, funding_satoshis: funding_satoshis_arg, - push_msat: push_msat_arg, dust_limit_satoshis: dust_limit_satoshis_arg, max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, - channel_reserve_satoshis: channel_reserve_satoshis_arg, htlc_minimum_msat: htlc_minimum_msat_arg, - feerate_per_kw: feerate_per_kw_arg, + commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, to_self_delay: to_self_delay_arg, max_accepted_htlcs: max_accepted_htlcs_arg, funding_pubkey: funding_pubkey_arg.into_rust(), revocation_basepoint: revocation_basepoint_arg.into_rust(), - payment_point: payment_point_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), htlc_basepoint: htlc_basepoint_arg.into_rust(), first_per_commitment_point: first_per_commitment_point_arg.into_rust(), @@ -1201,10 +1259,10 @@ pub extern "C" fn OpenChannel_new(mut chain_hash_arg: crate::c_types::ThirtyTwoB channel_type: local_channel_type_arg, }), is_owned: true } } -impl Clone for OpenChannel { +impl Clone for CommonOpenChannelFields { fn clone(&self) -> Self { Self { - inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeCommonOpenChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1212,20 +1270,20 @@ impl Clone for OpenChannel { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void +pub(crate) extern "C" fn CommonOpenChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonOpenChannelFields)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the OpenChannel -pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel { +/// Creates a copy of the CommonOpenChannelFields +pub extern "C" fn CommonOpenChannelFields_clone(orig: &CommonOpenChannelFields) -> CommonOpenChannelFields { orig.clone() } -/// Get a string which allows debug introspection of a OpenChannel object -pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()} -/// Generates a non-cryptographic 64-bit hash of the OpenChannel. +/// Get a string which allows debug introspection of a CommonOpenChannelFields object +pub extern "C" fn CommonOpenChannelFields_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonOpenChannelFields }).into()} +/// Generates a non-cryptographic 64-bit hash of the CommonOpenChannelFields. #[no_mangle] -pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 { +pub extern "C" fn CommonOpenChannelFields_hash(o: &CommonOpenChannelFields) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -1233,31 +1291,37 @@ pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two OpenChannels contain equal inner contents. +/// Checks if two CommonOpenChannelFieldss contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool { +pub extern "C" fn CommonOpenChannelFields_eq(a: &CommonOpenChannelFields, b: &CommonOpenChannelFields) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// The [`ChannelParameters`] for this channel. +#[must_use] +#[no_mangle] +pub extern "C" fn CommonOpenChannelFields_channel_parameters(this_arg: &crate::lightning::ln::msgs::CommonOpenChannelFields) -> crate::lightning::ln::msgs::ChannelParameters { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_parameters(); + crate::lightning::ln::msgs::ChannelParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } +} -use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import; -pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import; -/// An open_channel2 message to be sent by or received from the channel initiator. -/// -/// Used in V2 channel establishment -/// +use lightning::ln::msgs::ChannelParameters as nativeChannelParametersImport; +pub(crate) type nativeChannelParameters = nativeChannelParametersImport; + +/// A subset of [`CommonOpenChannelFields`], containing various parameters which are set by the +/// channel initiator and which are not part of the channel funding transaction. #[must_use] #[repr(C)] -pub struct OpenChannelV2 { +pub struct ChannelParameters { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeOpenChannelV2, + pub inner: *mut nativeChannelParameters, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1265,287 +1329,426 @@ pub struct OpenChannelV2 { pub is_owned: bool, } -impl Drop for OpenChannelV2 { +impl core::ops::Deref for ChannelParameters { + type Target = nativeChannelParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelParameters { } +unsafe impl core::marker::Sync for ChannelParameters { } +impl Drop for ChannelParameters { fn drop(&mut self) { - if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) { + if self.is_owned && !<*mut nativeChannelParameters>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the ChannelParameters, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { } +pub extern "C" fn ChannelParameters_free(this_obj: ChannelParameters) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) }; +pub(crate) extern "C" fn ChannelParameters_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelParameters) }; } #[allow(unused)] -impl OpenChannelV2 { - pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 { +impl ChannelParameters { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelParameters { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelParameters { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 { + pub(crate) fn take_inner(mut self) -> *mut nativeChannelParameters { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } -} -/// The genesis hash of the blockchain where the channel is to be opened -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_chain_hash(this_ptr: &OpenChannelV2) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; - inner_val.as_ref() -} -/// The genesis hash of the blockchain where the channel is to be opened -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_chain_hash(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); -} -/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_temporary_channel_id(this_ptr: &OpenChannelV2) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; - &inner_val.0 -} -/// A temporary channel ID derived using a zeroed out value for the channel acceptor's revocation basepoint -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_temporary_channel_id(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data); -} -/// The feerate for the funding transaction set by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight; - *inner_val -} -/// The feerate for the funding transaction set by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val; -} -/// The feerate for the commitment transaction set by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight; - *inner_val -} -/// The feerate for the commitment transaction set by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; -} -/// Part of the channel value contributed by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_funding_satoshis(this_ptr: &OpenChannelV2) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_satoshis; - *inner_val -} -/// Part of the channel value contributed by the channel initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_funding_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The threshold below which outputs on transactions broadcast by the channel initiator will be -/// omitted +/// omitted. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_dust_limit_satoshis(this_ptr: &OpenChannelV2) -> u64 { +pub extern "C" fn ChannelParameters_get_dust_limit_satoshis(this_ptr: &ChannelParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; *inner_val } /// The threshold below which outputs on transactions broadcast by the channel initiator will be -/// omitted +/// omitted. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_dust_limit_satoshis(this_ptr: &mut OpenChannelV2, mut val: u64) { +pub extern "C" fn ChannelParameters_set_dust_limit_satoshis(this_ptr: &mut ChannelParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; } /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &OpenChannelV2) -> u64 { +pub extern "C" fn ChannelParameters_get_max_htlc_value_in_flight_msat(this_ptr: &ChannelParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; *inner_val } /// The maximum inbound HTLC value in flight towards channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { +pub extern "C" fn ChannelParameters_set_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; } -/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +/// The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_get_htlc_minimum_msat(this_ptr: &OpenChannelV2) -> u64 { +pub extern "C" fn ChannelParameters_get_htlc_minimum_msat(this_ptr: &ChannelParameters) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; *inner_val } -/// The minimum HTLC size incoming to channel initiator, in milli-satoshi +/// The minimum HTLC size for HTLCs towards the channel initiator, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_set_htlc_minimum_msat(this_ptr: &mut OpenChannelV2, mut val: u64) { +pub extern "C" fn ChannelParameters_set_htlc_minimum_msat(this_ptr: &mut ChannelParameters, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they -/// broadcast a commitment transaction +/// The feerate for the commitment transaction set by the channel initiator until updated by +/// [`UpdateFee`] #[no_mangle] -pub extern "C" fn OpenChannelV2_get_to_self_delay(this_ptr: &OpenChannelV2) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; +pub extern "C" fn ChannelParameters_get_commitment_feerate_sat_per_1000_weight(this_ptr: &ChannelParameters) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_feerate_sat_per_1000_weight; *inner_val } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they -/// broadcast a commitment transaction +/// The feerate for the commitment transaction set by the channel initiator until updated by +/// [`UpdateFee`] #[no_mangle] -pub extern "C" fn OpenChannelV2_set_to_self_delay(this_ptr: &mut OpenChannelV2, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; +pub extern "C" fn ChannelParameters_set_commitment_feerate_sat_per_1000_weight(this_ptr: &mut ChannelParameters, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_feerate_sat_per_1000_weight = val; } -/// The maximum number of inbound HTLCs towards channel initiator +/// The number of blocks which the non-channel-initator will have to wait to claim on-chain +/// funds if they broadcast a commitment transaction. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_max_accepted_htlcs(this_ptr: &OpenChannelV2) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; +pub extern "C" fn ChannelParameters_get_to_self_delay(this_ptr: &ChannelParameters) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; *inner_val } -/// The maximum number of inbound HTLCs towards channel initiator +/// The number of blocks which the non-channel-initator will have to wait to claim on-chain +/// funds if they broadcast a commitment transaction. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_max_accepted_htlcs(this_ptr: &mut OpenChannelV2, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; +pub extern "C" fn ChannelParameters_set_to_self_delay(this_ptr: &mut ChannelParameters, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; } -/// The locktime for the funding transaction +/// The maximum number of pending HTLCs towards the channel initiator. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; +pub extern "C" fn ChannelParameters_get_max_accepted_htlcs(this_ptr: &ChannelParameters) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; *inner_val } -/// The locktime for the funding transaction +/// The maximum number of pending HTLCs towards the channel initiator. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +pub extern "C" fn ChannelParameters_set_max_accepted_htlcs(this_ptr: &mut ChannelParameters, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; } -/// The channel initiator's key controlling the funding transaction +/// Constructs a new ChannelParameters given each field +#[must_use] #[no_mangle] -pub extern "C" fn OpenChannelV2_get_funding_pubkey(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) +pub extern "C" fn ChannelParameters_new(mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16) -> ChannelParameters { + ChannelParameters { inner: ObjOps::heap_alloc(nativeChannelParameters { + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + }), is_owned: true } } -/// The channel initiator's key controlling the funding transaction -#[no_mangle] -pub extern "C" fn OpenChannelV2_set_funding_pubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); +impl Clone for ChannelParameters { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelParameters>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } } -/// Used to derive a revocation key for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_revocation_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelParameters_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelParameters)).clone() })) as *mut c_void } -/// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn OpenChannelV2_set_revocation_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); +/// Creates a copy of the ChannelParameters +pub extern "C" fn ChannelParameters_clone(orig: &ChannelParameters) -> ChannelParameters { + orig.clone() } -/// A payment key to channel initiator for transactions broadcast by counterparty +/// Get a string which allows debug introspection of a ChannelParameters object +pub extern "C" fn ChannelParameters_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::ChannelParameters }).into()} +/// Generates a non-cryptographic 64-bit hash of the ChannelParameters. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) +pub extern "C" fn ChannelParameters_hash(o: &ChannelParameters) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) } -/// A payment key to channel initiator for transactions broadcast by counterparty +/// Checks if two ChannelParameterss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); +pub extern "C" fn ChannelParameters_eq(a: &ChannelParameters, b: &ChannelParameters) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Used to derive a payment key to channel initiator for transactions broadcast by channel -/// initiator -#[no_mangle] -pub extern "C" fn OpenChannelV2_get_delayed_payment_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) + +use lightning::ln::msgs::OpenChannel as nativeOpenChannelImport; +pub(crate) type nativeOpenChannel = nativeOpenChannelImport; + +/// An [`open_channel`] message to be sent to or received from a peer. +/// +/// Used in V1 channel establishment +/// +/// [`open_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message +#[must_use] +#[repr(C)] +pub struct OpenChannel { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOpenChannel, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, } -/// Used to derive a payment key to channel initiator for transactions broadcast by channel -/// initiator + +impl core::ops::Deref for OpenChannel { + type Target = nativeOpenChannel; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OpenChannel { } +unsafe impl core::marker::Sync for OpenChannel { } +impl Drop for OpenChannel { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOpenChannel>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OpenChannel, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_delayed_payment_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +pub extern "C" fn OpenChannel_free(this_obj: OpenChannel) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannel_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannel) }; } -/// Used to derive an HTLC payment key to channel initiator +#[allow(unused)] +impl OpenChannel { + pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannel { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannel { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Common fields of `open_channel(2)`-like messages #[no_mangle] -pub extern "C" fn OpenChannelV2_get_htlc_basepoint(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) +pub extern "C" fn OpenChannel_get_common_fields(this_ptr: &OpenChannel) -> crate::lightning::ln::msgs::CommonOpenChannelFields { + let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields; + crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false } } -/// Used to derive an HTLC payment key to channel initiator +/// Common fields of `open_channel(2)`-like messages #[no_mangle] -pub extern "C" fn OpenChannelV2_set_htlc_basepoint(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +pub extern "C" fn OpenChannel_set_common_fields(this_ptr: &mut OpenChannel, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +/// The amount to push to the counterparty as part of the open, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_get_first_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) +pub extern "C" fn OpenChannel_get_push_msat(this_ptr: &OpenChannel) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().push_msat; + *inner_val } -/// The first to-be-broadcast-by-channel-initiator transaction's per commitment point +/// The amount to push to the counterparty as part of the open, in milli-satoshi #[no_mangle] -pub extern "C" fn OpenChannelV2_set_first_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +pub extern "C" fn OpenChannel_set_push_msat(this_ptr: &mut OpenChannel, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.push_msat = val; } -/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] -pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) +pub extern "C" fn OpenChannel_get_channel_reserve_satoshis(this_ptr: &OpenChannel) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis; + *inner_val } -/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] -pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); +pub extern "C" fn OpenChannel_set_channel_reserve_satoshis(this_ptr: &mut OpenChannel, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val; } -/// Channel flags +/// Constructs a new OpenChannel given each field +#[must_use] #[no_mangle] -pub extern "C" fn OpenChannelV2_get_channel_flags(this_ptr: &OpenChannelV2) -> u8 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; - *inner_val +pub extern "C" fn OpenChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut push_msat_arg: u64, mut channel_reserve_satoshis_arg: u64) -> OpenChannel { + OpenChannel { inner: ObjOps::heap_alloc(nativeOpenChannel { + common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) }, + push_msat: push_msat_arg, + channel_reserve_satoshis: channel_reserve_satoshis_arg, + }), is_owned: true } +} +impl Clone for OpenChannel { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannel_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOpenChannel)).clone() })) as *mut c_void } -/// Channel flags #[no_mangle] -pub extern "C" fn OpenChannelV2_set_channel_flags(this_ptr: &mut OpenChannelV2, mut val: u8) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; +/// Creates a copy of the OpenChannel +pub extern "C" fn OpenChannel_clone(orig: &OpenChannel) -> OpenChannel { + orig.clone() } -/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we -/// collaboratively close +/// Get a string which allows debug introspection of a OpenChannel object +pub extern "C" fn OpenChannel_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OpenChannel }).into()} +/// Generates a non-cryptographic 64-bit hash of the OpenChannel. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_shutdown_scriptpubkey(this_ptr: &OpenChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) }; - local_inner_val +pub extern "C" fn OpenChannel_hash(o: &OpenChannel) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) } -/// Optionally, a request to pre-set the to-channel-initiator output's scriptPubkey for when we -/// collaboratively close +/// Checks if two OpenChannels contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn OpenChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +pub extern "C" fn OpenChannel_eq(a: &OpenChannel, b: &OpenChannel) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// The channel type that this channel will represent. If none is set, we derive the channel -/// type from the intersection of our feature bits with our counterparty's feature bits from -/// the Init message. + +use lightning::ln::msgs::OpenChannelV2 as nativeOpenChannelV2Import; +pub(crate) type nativeOpenChannelV2 = nativeOpenChannelV2Import; + +/// An open_channel2 message to be sent by or received from the channel initiator. /// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Used in V2 channel establishment +/// +#[must_use] +#[repr(C)] +pub struct OpenChannelV2 { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOpenChannelV2, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OpenChannelV2 { + type Target = nativeOpenChannelV2; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OpenChannelV2 { } +unsafe impl core::marker::Sync for OpenChannelV2 { } +impl Drop for OpenChannelV2 { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOpenChannelV2>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OpenChannelV2, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn OpenChannelV2_get_channel_type(this_ptr: &OpenChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; - let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; - local_inner_val +pub extern "C" fn OpenChannelV2_free(this_obj: OpenChannelV2) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OpenChannelV2_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOpenChannelV2) }; } -/// The channel type that this channel will represent. If none is set, we derive the channel -/// type from the intersection of our feature bits with our counterparty's feature bits from -/// the Init message. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[allow(unused)] +impl OpenChannelV2 { + pub(crate) fn get_native_ref(&self) -> &'static nativeOpenChannelV2 { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOpenChannelV2 { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannelV2 { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Common fields of `open_channel(2)`-like messages #[no_mangle] -pub extern "C" fn OpenChannelV2_set_channel_type(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +pub extern "C" fn OpenChannelV2_get_common_fields(this_ptr: &OpenChannelV2) -> crate::lightning::ln::msgs::CommonOpenChannelFields { + let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields; + crate::lightning::ln::msgs::CommonOpenChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonOpenChannelFields<>) as *mut _) }, is_owned: false } +} +/// Common fields of `open_channel(2)`-like messages +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_common_fields(this_ptr: &mut OpenChannelV2, mut val: crate::lightning::ln::msgs::CommonOpenChannelFields) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_funding_feerate_sat_per_1000_weight(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_sat_per_1000_weight; + *inner_val +} +/// The feerate for the funding transaction set by the channel initiator +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_funding_feerate_sat_per_1000_weight(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_sat_per_1000_weight = val; +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_locktime(this_ptr: &OpenChannelV2) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; + *inner_val +} +/// The locktime for the funding transaction +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_locktime(this_ptr: &mut OpenChannelV2, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_get_second_per_commitment_point(this_ptr: &OpenChannelV2) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-initiator transaction's per commitment point +#[no_mangle] +pub extern "C" fn OpenChannelV2_set_second_per_commitment_point(this_ptr: &mut OpenChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); } /// Optionally, a requirement that only confirmed inputs can be added #[no_mangle] @@ -1561,36 +1764,15 @@ pub extern "C" fn OpenChannelV2_set_require_confirmed_inputs(this_ptr: &mut Open unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; } /// Constructs a new OpenChannelV2 given each field -/// -/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn OpenChannelV2_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_feerate_sat_per_1000_weight_arg: u32, mut commitment_feerate_sat_per_1000_weight_arg: u32, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut channel_flags_arg: u8, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 { - let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; - let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; +pub extern "C" fn OpenChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonOpenChannelFields, mut funding_feerate_sat_per_1000_weight_arg: u32, mut locktime_arg: u32, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> OpenChannelV2 { let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; OpenChannelV2 { inner: ObjOps::heap_alloc(nativeOpenChannelV2 { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data), + common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) }, funding_feerate_sat_per_1000_weight: funding_feerate_sat_per_1000_weight_arg, - commitment_feerate_sat_per_1000_weight: commitment_feerate_sat_per_1000_weight_arg, - funding_satoshis: funding_satoshis_arg, - dust_limit_satoshis: dust_limit_satoshis_arg, - max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - to_self_delay: to_self_delay_arg, - max_accepted_htlcs: max_accepted_htlcs_arg, locktime: locktime_arg, - funding_pubkey: funding_pubkey_arg.into_rust(), - revocation_basepoint: revocation_basepoint_arg.into_rust(), - payment_basepoint: payment_basepoint_arg.into_rust(), - delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), - htlc_basepoint: htlc_basepoint_arg.into_rust(), - first_per_commitment_point: first_per_commitment_point_arg.into_rust(), second_per_commitment_point: second_per_commitment_point_arg.into_rust(), - channel_flags: channel_flags_arg, - shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, - channel_type: local_channel_type_arg, require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } @@ -1636,22 +1818,20 @@ pub extern "C" fn OpenChannelV2_eq(a: &OpenChannelV2, b: &OpenChannelV2) -> bool if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport; -pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport; +use lightning::ln::msgs::CommonAcceptChannelFields as nativeCommonAcceptChannelFieldsImport; +pub(crate) type nativeCommonAcceptChannelFields = nativeCommonAcceptChannelFieldsImport; -/// An [`accept_channel`] message to be sent to or received from a peer. -/// -/// Used in V1 channel establishment +/// Contains fields that are both common to [`accept_channel`] and `accept_channel2` messages. /// /// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message #[must_use] #[repr(C)] -pub struct AcceptChannel { +pub struct CommonAcceptChannelFields { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeAcceptChannel, + pub inner: *mut nativeCommonAcceptChannelFields, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1659,254 +1839,397 @@ pub struct AcceptChannel { pub is_owned: bool, } -impl Drop for AcceptChannel { +impl core::ops::Deref for CommonAcceptChannelFields { + type Target = nativeCommonAcceptChannelFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommonAcceptChannelFields { } +unsafe impl core::marker::Sync for CommonAcceptChannelFields { } +impl Drop for CommonAcceptChannelFields { fn drop(&mut self) { - if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) { + if self.is_owned && !<*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the CommonAcceptChannelFields, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { } +pub extern "C" fn CommonAcceptChannelFields_free(this_obj: CommonAcceptChannelFields) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) }; +pub(crate) extern "C" fn CommonAcceptChannelFields_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommonAcceptChannelFields) }; } #[allow(unused)] -impl AcceptChannel { - pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel { +impl CommonAcceptChannelFields { + pub(crate) fn get_native_ref(&self) -> &'static nativeCommonAcceptChannelFields { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommonAcceptChannelFields { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel { + pub(crate) fn take_inner(mut self) -> *mut nativeCommonAcceptChannelFields { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// A temporary channel ID, until the funding outpoint is announced +/// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. #[no_mangle] -pub extern "C" fn AcceptChannel_get_temporary_channel_id(this_ptr: &AcceptChannel) -> *const [u8; 32] { +pub extern "C" fn CommonAcceptChannelFields_get_temporary_channel_id(this_ptr: &CommonAcceptChannelFields) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } -/// A temporary channel ID, until the funding outpoint is announced +/// The same `temporary_channel_id` received from the initiator's `open_channel2` or `open_channel` message. #[no_mangle] -pub extern "C" fn AcceptChannel_set_temporary_channel_id(this_ptr: &mut AcceptChannel, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn CommonAcceptChannelFields_set_temporary_channel_id(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The threshold below which outputs on transactions broadcast by sender will be omitted +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted #[no_mangle] -pub extern "C" fn AcceptChannel_get_dust_limit_satoshis(this_ptr: &AcceptChannel) -> u64 { +pub extern "C" fn CommonAcceptChannelFields_get_dust_limit_satoshis(this_ptr: &CommonAcceptChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; *inner_val } -/// The threshold below which outputs on transactions broadcast by sender will be omitted +/// The threshold below which outputs on transactions broadcast by the channel acceptor will be +/// omitted #[no_mangle] -pub extern "C" fn AcceptChannel_set_dust_limit_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) { +pub extern "C" fn CommonAcceptChannelFields_set_dust_limit_satoshis(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] -pub extern "C" fn AcceptChannel_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannel) -> u64 { +pub extern "C" fn CommonAcceptChannelFields_get_max_htlc_value_in_flight_msat(this_ptr: &CommonAcceptChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; *inner_val } /// The maximum inbound HTLC value in flight towards sender, in milli-satoshi #[no_mangle] -pub extern "C" fn AcceptChannel_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannel, mut val: u64) { +pub extern "C" fn CommonAcceptChannelFields_set_max_htlc_value_in_flight_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; } -/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel -#[no_mangle] -pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis; - *inner_val -} -/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel -#[no_mangle] -pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val; -} -/// The minimum HTLC size incoming to sender, in milli-satoshi +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi #[no_mangle] -pub extern "C" fn AcceptChannel_get_htlc_minimum_msat(this_ptr: &AcceptChannel) -> u64 { +pub extern "C" fn CommonAcceptChannelFields_get_htlc_minimum_msat(this_ptr: &CommonAcceptChannelFields) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; *inner_val } -/// The minimum HTLC size incoming to sender, in milli-satoshi +/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi #[no_mangle] -pub extern "C" fn AcceptChannel_set_htlc_minimum_msat(this_ptr: &mut AcceptChannel, mut val: u64) { +pub extern "C" fn CommonAcceptChannelFields_set_htlc_minimum_msat(this_ptr: &mut CommonAcceptChannelFields, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; } /// Minimum depth of the funding transaction before the channel is considered open #[no_mangle] -pub extern "C" fn AcceptChannel_get_minimum_depth(this_ptr: &AcceptChannel) -> u32 { +pub extern "C" fn CommonAcceptChannelFields_get_minimum_depth(this_ptr: &CommonAcceptChannelFields) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth; *inner_val } /// Minimum depth of the funding transaction before the channel is considered open #[no_mangle] -pub extern "C" fn AcceptChannel_set_minimum_depth(this_ptr: &mut AcceptChannel, mut val: u32) { +pub extern "C" fn CommonAcceptChannelFields_set_minimum_depth(this_ptr: &mut CommonAcceptChannelFields, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val; } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction #[no_mangle] -pub extern "C" fn AcceptChannel_get_to_self_delay(this_ptr: &AcceptChannel) -> u16 { +pub extern "C" fn CommonAcceptChannelFields_get_to_self_delay(this_ptr: &CommonAcceptChannelFields) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; *inner_val } -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they broadcast a commitment transaction +/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they +/// broadcast a commitment transaction #[no_mangle] -pub extern "C" fn AcceptChannel_set_to_self_delay(this_ptr: &mut AcceptChannel, mut val: u16) { +pub extern "C" fn CommonAcceptChannelFields_set_to_self_delay(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; } -/// The maximum number of inbound HTLCs towards sender +/// The maximum number of inbound HTLCs towards channel acceptor #[no_mangle] -pub extern "C" fn AcceptChannel_get_max_accepted_htlcs(this_ptr: &AcceptChannel) -> u16 { +pub extern "C" fn CommonAcceptChannelFields_get_max_accepted_htlcs(this_ptr: &CommonAcceptChannelFields) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; *inner_val } -/// The maximum number of inbound HTLCs towards sender +/// The maximum number of inbound HTLCs towards channel acceptor #[no_mangle] -pub extern "C" fn AcceptChannel_set_max_accepted_htlcs(this_ptr: &mut AcceptChannel, mut val: u16) { +pub extern "C" fn CommonAcceptChannelFields_set_max_accepted_htlcs(this_ptr: &mut CommonAcceptChannelFields, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; } -/// The sender's key controlling the funding transaction +/// The channel acceptor's key controlling the funding transaction #[no_mangle] -pub extern "C" fn AcceptChannel_get_funding_pubkey(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonAcceptChannelFields_get_funding_pubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The sender's key controlling the funding transaction +/// The channel acceptor's key controlling the funding transaction #[no_mangle] -pub extern "C" fn AcceptChannel_set_funding_pubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonAcceptChannelFields_set_funding_pubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn AcceptChannel_get_revocation_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonAcceptChannelFields_get_revocation_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } /// Used to derive a revocation key for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn AcceptChannel_set_revocation_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { +pub extern "C" fn CommonAcceptChannelFields_set_revocation_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); } -/// A payment key to sender for transactions broadcast by counterparty +/// A payment key to channel acceptor for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn AcceptChannel_get_payment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_point; +pub extern "C" fn CommonAcceptChannelFields_get_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } -/// A payment key to sender for transactions broadcast by counterparty +/// A payment key to channel acceptor for transactions broadcast by counterparty #[no_mangle] -pub extern "C" fn AcceptChannel_set_payment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_point = val.into_rust(); +pub extern "C" fn CommonAcceptChannelFields_set_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); } -/// Used to derive a payment key to sender for transactions broadcast by sender +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor #[no_mangle] -pub extern "C" fn AcceptChannel_get_delayed_payment_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { +pub extern "C" fn CommonAcceptChannelFields_get_delayed_payment_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; crate::c_types::PublicKey::from_rust(&inner_val) } -/// Used to derive a payment key to sender for transactions broadcast by sender +/// Used to derive a payment key to channel acceptor for transactions broadcast by channel +/// acceptor +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_set_delayed_payment_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_get_htlc_basepoint(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_set_htlc_basepoint(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_get_first_per_commitment_point(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_set_first_per_commitment_point(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_get_shutdown_scriptpubkey(this_ptr: &CommonAcceptChannelFields) -> crate::c_types::derived::COption_CVec_u8ZZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) }; + local_inner_val +} +/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we +/// collaboratively close +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_set_shutdown_scriptpubkey(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s +/// [`CommonOpenChannelFields::channel_type`]. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_get_channel_type(this_ptr: &CommonAcceptChannelFields) -> crate::lightning_types::features::ChannelTypeFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; + let mut local_inner_val = crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel type that this channel will represent. If none is set, we derive the channel +/// type from the intersection of our feature bits with our counterparty's feature bits from +/// the Init message. +/// +/// This is required to match the equivalent field in [`OpenChannel`] or [`OpenChannelV2`]'s +/// [`CommonOpenChannelFields::channel_type`]. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_set_channel_type(this_ptr: &mut CommonAcceptChannelFields, mut val: crate::lightning_types::features::ChannelTypeFeatures) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +} +/// Constructs a new CommonAcceptChannelFields given each field +/// +/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning_types::features::ChannelTypeFeatures) -> CommonAcceptChannelFields { + let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; + let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; + CommonAcceptChannelFields { inner: ObjOps::heap_alloc(nativeCommonAcceptChannelFields { + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) }, + dust_limit_satoshis: dust_limit_satoshis_arg, + max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + htlc_minimum_msat: htlc_minimum_msat_arg, + minimum_depth: minimum_depth_arg, + to_self_delay: to_self_delay_arg, + max_accepted_htlcs: max_accepted_htlcs_arg, + funding_pubkey: funding_pubkey_arg.into_rust(), + revocation_basepoint: revocation_basepoint_arg.into_rust(), + payment_basepoint: payment_basepoint_arg.into_rust(), + delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), + htlc_basepoint: htlc_basepoint_arg.into_rust(), + first_per_commitment_point: first_per_commitment_point_arg.into_rust(), + shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, + channel_type: local_channel_type_arg, + }), is_owned: true } +} +impl Clone for CommonAcceptChannelFields { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeCommonAcceptChannelFields>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CommonAcceptChannelFields_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommonAcceptChannelFields)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the CommonAcceptChannelFields +pub extern "C" fn CommonAcceptChannelFields_clone(orig: &CommonAcceptChannelFields) -> CommonAcceptChannelFields { + orig.clone() +} +/// Get a string which allows debug introspection of a CommonAcceptChannelFields object +pub extern "C" fn CommonAcceptChannelFields_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommonAcceptChannelFields }).into()} +/// Generates a non-cryptographic 64-bit hash of the CommonAcceptChannelFields. +#[no_mangle] +pub extern "C" fn CommonAcceptChannelFields_hash(o: &CommonAcceptChannelFields) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two CommonAcceptChannelFieldss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn AcceptChannel_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); +pub extern "C" fn CommonAcceptChannelFields_eq(a: &CommonAcceptChannelFields, b: &CommonAcceptChannelFields) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } } -/// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannel_get_htlc_basepoint(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) + +use lightning::ln::msgs::AcceptChannel as nativeAcceptChannelImport; +pub(crate) type nativeAcceptChannel = nativeAcceptChannelImport; + +/// An [`accept_channel`] message to be sent to or received from a peer. +/// +/// Used in V1 channel establishment +/// +/// [`accept_channel`]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-accept_channel-message +#[must_use] +#[repr(C)] +pub struct AcceptChannel { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeAcceptChannel, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, } -/// Used to derive an HTLC payment key to sender for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannel_set_htlc_basepoint(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); + +impl core::ops::Deref for AcceptChannel { + type Target = nativeAcceptChannel; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } } -/// The first to-be-broadcast-by-sender transaction's per commitment point -#[no_mangle] -pub extern "C" fn AcceptChannel_get_first_per_commitment_point(this_ptr: &AcceptChannel) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) +unsafe impl core::marker::Send for AcceptChannel { } +unsafe impl core::marker::Sync for AcceptChannel { } +impl Drop for AcceptChannel { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeAcceptChannel>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } } -/// The first to-be-broadcast-by-sender transaction's per commitment point +/// Frees any resources used by the AcceptChannel, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn AcceptChannel_set_first_per_commitment_point(this_ptr: &mut AcceptChannel, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); +pub extern "C" fn AcceptChannel_free(this_obj: AcceptChannel) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AcceptChannel_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAcceptChannel) }; +} +#[allow(unused)] +impl AcceptChannel { + pub(crate) fn get_native_ref(&self) -> &'static nativeAcceptChannel { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAcceptChannel { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +/// Common fields of `accept_channel(2)`-like messages #[no_mangle] -pub extern "C" fn AcceptChannel_get_shutdown_scriptpubkey(this_ptr: &AcceptChannel) -> crate::c_types::derived::COption_CVec_u8ZZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) }; - local_inner_val +pub extern "C" fn AcceptChannel_get_common_fields(this_ptr: &AcceptChannel) -> crate::lightning::ln::msgs::CommonAcceptChannelFields { + let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields; + crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false } } -/// A request to pre-set the to-sender output's scriptPubkey for when we collaboratively close +/// Common fields of `accept_channel(2)`-like messages #[no_mangle] -pub extern "C" fn AcceptChannel_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannel, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; +pub extern "C" fn AcceptChannel_set_common_fields(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The channel type that this channel will represent. -/// -/// If this is `None`, we derive the channel type from the intersection of -/// our feature bits with our counterparty's feature bits from the [`Init`] message. -/// This is required to match the equivalent field in [`OpenChannel::channel_type`]. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] -pub extern "C" fn AcceptChannel_get_channel_type(this_ptr: &AcceptChannel) -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; - let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; - local_inner_val +pub extern "C" fn AcceptChannel_get_channel_reserve_satoshis(this_ptr: &AcceptChannel) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_reserve_satoshis; + *inner_val } -/// The channel type that this channel will represent. -/// -/// If this is `None`, we derive the channel type from the intersection of -/// our feature bits with our counterparty's feature bits from the [`Init`] message. -/// This is required to match the equivalent field in [`OpenChannel::channel_type`]. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +/// The minimum value unencumbered by HTLCs for the counterparty to keep in the channel #[no_mangle] -pub extern "C" fn AcceptChannel_set_channel_type(this_ptr: &mut AcceptChannel, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +pub extern "C" fn AcceptChannel_set_channel_reserve_satoshis(this_ptr: &mut AcceptChannel, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_reserve_satoshis = val; } /// Constructs a new AcceptChannel given each field -/// -/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn AcceptChannel_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut channel_reserve_satoshis_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_point_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures) -> AcceptChannel { - let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; - let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; +pub extern "C" fn AcceptChannel_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut channel_reserve_satoshis_arg: u64) -> AcceptChannel { AcceptChannel { inner: ObjOps::heap_alloc(nativeAcceptChannel { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data), - dust_limit_satoshis: dust_limit_satoshis_arg, - max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, + common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) }, channel_reserve_satoshis: channel_reserve_satoshis_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - minimum_depth: minimum_depth_arg, - to_self_delay: to_self_delay_arg, - max_accepted_htlcs: max_accepted_htlcs_arg, - funding_pubkey: funding_pubkey_arg.into_rust(), - revocation_basepoint: revocation_basepoint_arg.into_rust(), - payment_point: payment_point_arg.into_rust(), - delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), - htlc_basepoint: htlc_basepoint_arg.into_rust(), - first_per_commitment_point: first_per_commitment_point_arg.into_rust(), - shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, - channel_type: local_channel_type_arg, }), is_owned: true } } impl Clone for AcceptChannel { @@ -1973,6 +2296,12 @@ pub struct AcceptChannelV2 { pub is_owned: bool, } +impl core::ops::Deref for AcceptChannelV2 { + type Target = nativeAcceptChannelV2; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AcceptChannelV2 { } +unsafe impl core::marker::Sync for AcceptChannelV2 { } impl Drop for AcceptChannelV2 { fn drop(&mut self) { if self.is_owned && !<*mut nativeAcceptChannelV2>::is_null(self.inner) { @@ -2003,17 +2332,20 @@ impl AcceptChannelV2 { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +/// Common fields of `accept_channel(2)`-like messages #[no_mangle] -pub extern "C" fn AcceptChannelV2_get_temporary_channel_id(this_ptr: &AcceptChannelV2) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; - &inner_val.0 +pub extern "C" fn AcceptChannelV2_get_common_fields(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::msgs::CommonAcceptChannelFields { + let mut inner_val = &mut this_ptr.get_native_mut_ref().common_fields; + crate::lightning::ln::msgs::CommonAcceptChannelFields { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::msgs::CommonAcceptChannelFields<>) as *mut _) }, is_owned: false } } -/// The same `temporary_channel_id` received from the initiator's `open_channel2` message. +/// Common fields of `accept_channel(2)`-like messages #[no_mangle] -pub extern "C" fn AcceptChannelV2_set_temporary_channel_id(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn AcceptChannelV2_set_common_fields(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::msgs::CommonAcceptChannelFields) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.common_fields = *unsafe { Box::from_raw(val.take_inner()) }; } /// Part of the channel value contributed by the channel acceptor #[no_mangle] @@ -2026,194 +2358,16 @@ pub extern "C" fn AcceptChannelV2_get_funding_satoshis(this_ptr: &AcceptChannelV pub extern "C" fn AcceptChannelV2_set_funding_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_satoshis = val; } -/// The threshold below which outputs on transactions broadcast by the channel acceptor will be -/// omitted -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_dust_limit_satoshis(this_ptr: &AcceptChannelV2) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().dust_limit_satoshis; - *inner_val -} -/// The threshold below which outputs on transactions broadcast by the channel acceptor will be -/// omitted -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_dust_limit_satoshis(this_ptr: &mut AcceptChannelV2, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.dust_limit_satoshis = val; -} -/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_max_htlc_value_in_flight_msat(this_ptr: &AcceptChannelV2) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_value_in_flight_msat; - *inner_val -} -/// The maximum inbound HTLC value in flight towards channel acceptor, in milli-satoshi -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_max_htlc_value_in_flight_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_value_in_flight_msat = val; -} -/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_htlc_minimum_msat(this_ptr: &AcceptChannelV2) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; - *inner_val -} -/// The minimum HTLC size incoming to channel acceptor, in milli-satoshi -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_htlc_minimum_msat(this_ptr: &mut AcceptChannelV2, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; -} -/// Minimum depth of the funding transaction before the channel is considered open -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_minimum_depth(this_ptr: &AcceptChannelV2) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().minimum_depth; - *inner_val -} -/// Minimum depth of the funding transaction before the channel is considered open -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_minimum_depth(this_ptr: &mut AcceptChannelV2, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.minimum_depth = val; -} -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they -/// broadcast a commitment transaction -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_to_self_delay(this_ptr: &AcceptChannelV2) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().to_self_delay; - *inner_val -} -/// The number of blocks which the counterparty will have to wait to claim on-chain funds if they -/// broadcast a commitment transaction -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_to_self_delay(this_ptr: &mut AcceptChannelV2, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.to_self_delay = val; -} -/// The maximum number of inbound HTLCs towards channel acceptor -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_max_accepted_htlcs(this_ptr: &AcceptChannelV2) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().max_accepted_htlcs; - *inner_val -} -/// The maximum number of inbound HTLCs towards channel acceptor -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_max_accepted_htlcs(this_ptr: &mut AcceptChannelV2, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_accepted_htlcs = val; -} -/// The channel acceptor's key controlling the funding transaction -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_funding_pubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The channel acceptor's key controlling the funding transaction -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_funding_pubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); -} -/// Used to derive a revocation key for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_revocation_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().revocation_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Used to derive a revocation key for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_revocation_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.revocation_basepoint = val.into_rust(); -} -/// A payment key to channel acceptor for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// A payment key to channel acceptor for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_basepoint = val.into_rust(); -} -/// Used to derive a payment key to channel acceptor for transactions broadcast by channel -/// acceptor -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_delayed_payment_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().delayed_payment_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Used to derive a payment key to channel acceptor for transactions broadcast by channel -/// acceptor -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_delayed_payment_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.delayed_payment_basepoint = val.into_rust(); -} -/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_htlc_basepoint(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_basepoint; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// Used to derive an HTLC payment key to channel acceptor for transactions broadcast by counterparty -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_htlc_basepoint(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_basepoint = val.into_rust(); -} -/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_first_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().first_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The first to-be-broadcast-by-channel-acceptor transaction's per commitment point -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_first_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.first_per_commitment_point = val.into_rust(); -} /// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point #[no_mangle] pub extern "C" fn AcceptChannelV2_get_second_per_commitment_point(this_ptr: &AcceptChannelV2) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().second_per_commitment_point; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); -} -/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we -/// collaboratively close -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_shutdown_scriptpubkey(this_ptr: &AcceptChannelV2) -> crate::c_types::derived::COption_CVec_u8ZZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().shutdown_scriptpubkey; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { (*inner_val.as_ref().unwrap()).clone().to_bytes().into() }) }; - local_inner_val -} -/// Optionally, a request to pre-set the to-channel-acceptor output's scriptPubkey for when we -/// collaboratively close -#[no_mangle] -pub extern "C" fn AcceptChannelV2_set_shutdown_scriptpubkey(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::derived::COption_CVec_u8ZZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ val_opt.take() }.into_rust()) }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shutdown_scriptpubkey = local_val; -} -/// The channel type that this channel will represent. If none is set, we derive the channel -/// type from the intersection of our feature bits with our counterparty's feature bits from -/// the Init message. -/// -/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None -#[no_mangle] -pub extern "C" fn AcceptChannelV2_get_channel_type(this_ptr: &AcceptChannelV2) -> crate::lightning::ln::features::ChannelTypeFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type; - let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; - local_inner_val -} -/// The channel type that this channel will represent. If none is set, we derive the channel -/// type from the intersection of our feature bits with our counterparty's feature bits from -/// the Init message. -/// -/// This is required to match the equivalent field in [`OpenChannelV2::channel_type`]. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The second to-be-broadcast-by-channel-acceptor transaction's per commitment point #[no_mangle] -pub extern "C" fn AcceptChannelV2_set_channel_type(this_ptr: &mut AcceptChannelV2, mut val: crate::lightning::ln::features::ChannelTypeFeatures) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_type = local_val; +pub extern "C" fn AcceptChannelV2_set_second_per_commitment_point(this_ptr: &mut AcceptChannelV2, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.second_per_commitment_point = val.into_rust(); } /// Optionally, a requirement that only confirmed inputs can be added #[no_mangle] @@ -2229,32 +2383,14 @@ pub extern "C" fn AcceptChannelV2_set_require_confirmed_inputs(this_ptr: &mut Ac unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; } /// Constructs a new AcceptChannelV2 given each field -/// -/// Note that channel_type_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn AcceptChannelV2_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_satoshis_arg: u64, mut dust_limit_satoshis_arg: u64, mut max_htlc_value_in_flight_msat_arg: u64, mut htlc_minimum_msat_arg: u64, mut minimum_depth_arg: u32, mut to_self_delay_arg: u16, mut max_accepted_htlcs_arg: u16, mut funding_pubkey_arg: crate::c_types::PublicKey, mut revocation_basepoint_arg: crate::c_types::PublicKey, mut payment_basepoint_arg: crate::c_types::PublicKey, mut delayed_payment_basepoint_arg: crate::c_types::PublicKey, mut htlc_basepoint_arg: crate::c_types::PublicKey, mut first_per_commitment_point_arg: crate::c_types::PublicKey, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut shutdown_scriptpubkey_arg: crate::c_types::derived::COption_CVec_u8ZZ, mut channel_type_arg: crate::lightning::ln::features::ChannelTypeFeatures, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 { - let mut local_shutdown_scriptpubkey_arg = { /*shutdown_scriptpubkey_arg*/ let shutdown_scriptpubkey_arg_opt = shutdown_scriptpubkey_arg; if shutdown_scriptpubkey_arg_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::script::ScriptBuf::from({ shutdown_scriptpubkey_arg_opt.take() }.into_rust()) }})} }; - let mut local_channel_type_arg = if channel_type_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_type_arg.take_inner()) } }) }; +pub extern "C" fn AcceptChannelV2_new(mut common_fields_arg: crate::lightning::ln::msgs::CommonAcceptChannelFields, mut funding_satoshis_arg: u64, mut second_per_commitment_point_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> AcceptChannelV2 { let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; AcceptChannelV2 { inner: ObjOps::heap_alloc(nativeAcceptChannelV2 { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data), + common_fields: *unsafe { Box::from_raw(common_fields_arg.take_inner()) }, funding_satoshis: funding_satoshis_arg, - dust_limit_satoshis: dust_limit_satoshis_arg, - max_htlc_value_in_flight_msat: max_htlc_value_in_flight_msat_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - minimum_depth: minimum_depth_arg, - to_self_delay: to_self_delay_arg, - max_accepted_htlcs: max_accepted_htlcs_arg, - funding_pubkey: funding_pubkey_arg.into_rust(), - revocation_basepoint: revocation_basepoint_arg.into_rust(), - payment_basepoint: payment_basepoint_arg.into_rust(), - delayed_payment_basepoint: delayed_payment_basepoint_arg.into_rust(), - htlc_basepoint: htlc_basepoint_arg.into_rust(), - first_per_commitment_point: first_per_commitment_point_arg.into_rust(), second_per_commitment_point: second_per_commitment_point_arg.into_rust(), - shutdown_scriptpubkey: local_shutdown_scriptpubkey_arg, - channel_type: local_channel_type_arg, require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } @@ -2323,6 +2459,12 @@ pub struct FundingCreated { pub is_owned: bool, } +impl core::ops::Deref for FundingCreated { + type Target = nativeFundingCreated; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FundingCreated { } +unsafe impl core::marker::Sync for FundingCreated { } impl Drop for FundingCreated { fn drop(&mut self) { if self.is_owned && !<*mut nativeFundingCreated>::is_null(self.inner) { @@ -2353,17 +2495,20 @@ impl FundingCreated { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A temporary channel ID, until the funding is established #[no_mangle] -pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> *const [u8; 32] { +pub extern "C" fn FundingCreated_get_temporary_channel_id(this_ptr: &FundingCreated) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().temporary_channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// A temporary channel ID, until the funding is established #[no_mangle] -pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn FundingCreated_set_temporary_channel_id(this_ptr: &mut FundingCreated, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.temporary_channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The funding transaction ID #[no_mangle] @@ -2401,9 +2546,9 @@ pub extern "C" fn FundingCreated_set_signature(this_ptr: &mut FundingCreated, mu /// Constructs a new FundingCreated given each field #[must_use] #[no_mangle] -pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated { +pub extern "C" fn FundingCreated_new(mut temporary_channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_index_arg: u16, mut signature_arg: crate::c_types::ECDSASignature) -> FundingCreated { FundingCreated { inner: ObjOps::heap_alloc(nativeFundingCreated { - temporary_channel_id: ::lightning::ln::ChannelId(temporary_channel_id_arg.data), + temporary_channel_id: *unsafe { Box::from_raw(temporary_channel_id_arg.take_inner()) }, funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(), funding_output_index: funding_output_index_arg, signature: signature_arg.into_rust(), @@ -2474,6 +2619,12 @@ pub struct FundingSigned { pub is_owned: bool, } +impl core::ops::Deref for FundingSigned { + type Target = nativeFundingSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FundingSigned { } +unsafe impl core::marker::Sync for FundingSigned { } impl Drop for FundingSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeFundingSigned>::is_null(self.inner) { @@ -2504,17 +2655,20 @@ impl FundingSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> *const [u8; 32] { +pub extern "C" fn FundingSigned_get_channel_id(this_ptr: &FundingSigned) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn FundingSigned_set_channel_id(this_ptr: &mut FundingSigned, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The signature of the channel acceptor (fundee) on the initial commitment transaction #[no_mangle] @@ -2530,9 +2684,9 @@ pub extern "C" fn FundingSigned_set_signature(this_ptr: &mut FundingSigned, mut /// Constructs a new FundingSigned given each field #[must_use] #[no_mangle] -pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned { +pub extern "C" fn FundingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature) -> FundingSigned { FundingSigned { inner: ObjOps::heap_alloc(nativeFundingSigned { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, signature: signature_arg.into_rust(), }), is_owned: true } } @@ -2599,6 +2753,12 @@ pub struct ChannelReady { pub is_owned: bool, } +impl core::ops::Deref for ChannelReady { + type Target = nativeChannelReady; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelReady { } +unsafe impl core::marker::Sync for ChannelReady { } impl Drop for ChannelReady { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelReady>::is_null(self.inner) { @@ -2629,17 +2789,20 @@ impl ChannelReady { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> *const [u8; 32] { +pub extern "C" fn ChannelReady_get_channel_id(this_ptr: &ChannelReady) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn ChannelReady_set_channel_id(this_ptr: &mut ChannelReady, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The per-commitment point of the second commitment transaction #[no_mangle] @@ -2674,10 +2837,10 @@ pub extern "C" fn ChannelReady_set_short_channel_id_alias(this_ptr: &mut Channel /// Constructs a new ChannelReady given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady { +pub extern "C" fn ChannelReady_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_per_commitment_point_arg: crate::c_types::PublicKey, mut short_channel_id_alias_arg: crate::c_types::derived::COption_u64Z) -> ChannelReady { let mut local_short_channel_id_alias_arg = if short_channel_id_alias_arg.is_some() { Some( { short_channel_id_alias_arg.take() }) } else { None }; ChannelReady { inner: ObjOps::heap_alloc(nativeChannelReady { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, next_per_commitment_point: next_per_commitment_point_arg.into_rust(), short_channel_id_alias: local_short_channel_id_alias_arg, }), is_owned: true } @@ -2727,7 +2890,8 @@ pub extern "C" fn ChannelReady_eq(a: &ChannelReady, b: &ChannelReady) -> bool { use lightning::ln::msgs::Stfu as nativeStfuImport; pub(crate) type nativeStfu = nativeStfuImport; -/// An stfu (quiescence) message to be sent by or received from the stfu initiator. +/// An `stfu` (quiescence) message to be sent by or received from the stfu initiator. +/// #[must_use] #[repr(C)] pub struct Stfu { @@ -2743,6 +2907,12 @@ pub struct Stfu { pub is_owned: bool, } +impl core::ops::Deref for Stfu { + type Target = nativeStfu; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Stfu { } +unsafe impl core::marker::Sync for Stfu { } impl Drop for Stfu { fn drop(&mut self) { if self.is_owned && !<*mut nativeStfu>::is_null(self.inner) { @@ -2773,17 +2943,20 @@ impl Stfu { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where quiescence is intended #[no_mangle] -pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> *const [u8; 32] { +pub extern "C" fn Stfu_get_channel_id(this_ptr: &Stfu) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID where quiescence is intended #[no_mangle] -pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn Stfu_set_channel_id(this_ptr: &mut Stfu, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// Initiator flag, 1 if initiating, 0 if replying to an stfu. #[no_mangle] @@ -2799,9 +2972,9 @@ pub extern "C" fn Stfu_set_initiator(this_ptr: &mut Stfu, mut val: u8) { /// Constructs a new Stfu given each field #[must_use] #[no_mangle] -pub extern "C" fn Stfu_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut initiator_arg: u8) -> Stfu { +pub extern "C" fn Stfu_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut initiator_arg: u8) -> Stfu { Stfu { inner: ObjOps::heap_alloc(nativeStfu { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, initiator: initiator_arg, }), is_owned: true } } @@ -2837,18 +3010,19 @@ pub extern "C" fn Stfu_eq(a: &Stfu, b: &Stfu) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } -use lightning::ln::msgs::Splice as nativeSpliceImport; -pub(crate) type nativeSplice = nativeSpliceImport; +use lightning::ln::msgs::SpliceInit as nativeSpliceInitImport; +pub(crate) type nativeSpliceInit = nativeSpliceInitImport; -/// A splice message to be sent by or received from the stfu initiator (splice initiator). +/// A `splice_init` message to be sent by or received from the stfu initiator (splice initiator). +/// #[must_use] #[repr(C)] -pub struct Splice { +pub struct SpliceInit { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeSplice, + pub inner: *mut nativeSpliceInit, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -2856,122 +3030,134 @@ pub struct Splice { pub is_owned: bool, } -impl Drop for Splice { +impl core::ops::Deref for SpliceInit { + type Target = nativeSpliceInit; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceInit { } +unsafe impl core::marker::Sync for SpliceInit { } +impl Drop for SpliceInit { fn drop(&mut self) { - if self.is_owned && !<*mut nativeSplice>::is_null(self.inner) { + if self.is_owned && !<*mut nativeSpliceInit>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the Splice, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the SpliceInit, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn Splice_free(this_obj: Splice) { } +pub extern "C" fn SpliceInit_free(this_obj: SpliceInit) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Splice_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSplice) }; +pub(crate) extern "C" fn SpliceInit_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeSpliceInit) }; } #[allow(unused)] -impl Splice { - pub(crate) fn get_native_ref(&self) -> &'static nativeSplice { +impl SpliceInit { + pub(crate) fn get_native_ref(&self) -> &'static nativeSpliceInit { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSplice { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeSpliceInit { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeSplice { + pub(crate) fn take_inner(mut self) -> *mut nativeSpliceInit { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn Splice_get_channel_id(this_ptr: &Splice) -> *const [u8; 32] { +pub extern "C" fn SpliceInit_get_channel_id(this_ptr: &SpliceInit) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn Splice_set_channel_id(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); -} -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn Splice_get_chain_hash(this_ptr: &Splice) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; - inner_val.as_ref() -} -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn Splice_set_chain_hash(this_ptr: &mut Splice, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); +pub extern "C" fn SpliceInit_set_channel_id(this_ptr: &mut SpliceInit, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. +/// The amount the splice initiator is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn Splice_get_relative_satoshis(this_ptr: &Splice) -> i64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis; +pub extern "C" fn SpliceInit_get_funding_contribution_satoshis(this_ptr: &SpliceInit) -> i64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_contribution_satoshis; *inner_val } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice initiator) by splicing into/from the channel. +/// The amount the splice initiator is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn Splice_set_relative_satoshis(this_ptr: &mut Splice, mut val: i64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val; +pub extern "C" fn SpliceInit_set_funding_contribution_satoshis(this_ptr: &mut SpliceInit, mut val: i64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_contribution_satoshis = val; } /// The feerate for the new funding transaction, set by the splice initiator #[no_mangle] -pub extern "C" fn Splice_get_funding_feerate_perkw(this_ptr: &Splice) -> u32 { +pub extern "C" fn SpliceInit_get_funding_feerate_perkw(this_ptr: &SpliceInit) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_feerate_perkw; *inner_val } /// The feerate for the new funding transaction, set by the splice initiator #[no_mangle] -pub extern "C" fn Splice_set_funding_feerate_perkw(this_ptr: &mut Splice, mut val: u32) { +pub extern "C" fn SpliceInit_set_funding_feerate_perkw(this_ptr: &mut SpliceInit, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_feerate_perkw = val; } /// The locktime for the new funding transaction #[no_mangle] -pub extern "C" fn Splice_get_locktime(this_ptr: &Splice) -> u32 { +pub extern "C" fn SpliceInit_get_locktime(this_ptr: &SpliceInit) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().locktime; *inner_val } /// The locktime for the new funding transaction #[no_mangle] -pub extern "C" fn Splice_set_locktime(this_ptr: &mut Splice, mut val: u32) { +pub extern "C" fn SpliceInit_set_locktime(this_ptr: &mut SpliceInit, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.locktime = val; } /// The key of the sender (splice initiator) controlling the new funding transaction #[no_mangle] -pub extern "C" fn Splice_get_funding_pubkey(this_ptr: &Splice) -> crate::c_types::PublicKey { +pub extern "C" fn SpliceInit_get_funding_pubkey(this_ptr: &SpliceInit) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_pubkey; crate::c_types::PublicKey::from_rust(&inner_val) } /// The key of the sender (splice initiator) controlling the new funding transaction #[no_mangle] -pub extern "C" fn Splice_set_funding_pubkey(this_ptr: &mut Splice, mut val: crate::c_types::PublicKey) { +pub extern "C" fn SpliceInit_set_funding_pubkey(this_ptr: &mut SpliceInit, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } -/// Constructs a new Splice given each field +/// If set, only confirmed inputs added (by the splice acceptor) will be accepted +#[no_mangle] +pub extern "C" fn SpliceInit_get_require_confirmed_inputs(this_ptr: &SpliceInit) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// If set, only confirmed inputs added (by the splice acceptor) will be accepted +#[no_mangle] +pub extern "C" fn SpliceInit_set_require_confirmed_inputs(this_ptr: &mut SpliceInit, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} +/// Constructs a new SpliceInit given each field #[must_use] #[no_mangle] -pub extern "C" fn Splice_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey) -> Splice { - Splice { inner: ObjOps::heap_alloc(nativeSplice { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - relative_satoshis: relative_satoshis_arg, +pub extern "C" fn SpliceInit_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_contribution_satoshis_arg: i64, mut funding_feerate_perkw_arg: u32, mut locktime_arg: u32, mut funding_pubkey_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> SpliceInit { + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; + SpliceInit { inner: ObjOps::heap_alloc(nativeSpliceInit { + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + funding_contribution_satoshis: funding_contribution_satoshis_arg, funding_feerate_perkw: funding_feerate_perkw_arg, locktime: locktime_arg, funding_pubkey: funding_pubkey_arg.into_rust(), + require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } -impl Clone for Splice { +impl Clone for SpliceInit { fn clone(&self) -> Self { Self { - inner: if <*mut nativeSplice>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeSpliceInit>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -2979,22 +3165,22 @@ impl Clone for Splice { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Splice_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSplice)).clone() })) as *mut c_void +pub(crate) extern "C" fn SpliceInit_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeSpliceInit)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the Splice -pub extern "C" fn Splice_clone(orig: &Splice) -> Splice { +/// Creates a copy of the SpliceInit +pub extern "C" fn SpliceInit_clone(orig: &SpliceInit) -> SpliceInit { orig.clone() } -/// Get a string which allows debug introspection of a Splice object -pub extern "C" fn Splice_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::Splice }).into()} -/// Checks if two Splices contain equal inner contents. +/// Get a string which allows debug introspection of a SpliceInit object +pub extern "C" fn SpliceInit_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::SpliceInit }).into()} +/// Checks if two SpliceInits contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool { +pub extern "C" fn SpliceInit_eq(a: &SpliceInit, b: &SpliceInit) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -3003,7 +3189,7 @@ pub extern "C" fn Splice_eq(a: &Splice, b: &Splice) -> bool { use lightning::ln::msgs::SpliceAck as nativeSpliceAckImport; pub(crate) type nativeSpliceAck = nativeSpliceAckImport; -/// A splice_ack message to be received by or sent to the splice initiator. +/// A `splice_ack` message to be received by or sent to the splice initiator. /// #[must_use] #[repr(C)] @@ -3020,6 +3206,12 @@ pub struct SpliceAck { pub is_owned: bool, } +impl core::ops::Deref for SpliceAck { + type Target = nativeSpliceAck; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceAck { } +unsafe impl core::marker::Sync for SpliceAck { } impl Drop for SpliceAck { fn drop(&mut self) { if self.is_owned && !<*mut nativeSpliceAck>::is_null(self.inner) { @@ -3050,41 +3242,33 @@ impl SpliceAck { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> *const [u8; 32] { +pub extern "C" fn SpliceAck_get_channel_id(this_ptr: &SpliceAck) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID where splicing is intended #[no_mangle] -pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); -} -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn SpliceAck_get_chain_hash(this_ptr: &SpliceAck) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().chain_hash; - inner_val.as_ref() -} -/// The genesis hash of the blockchain where the channel is intended to be spliced -#[no_mangle] -pub extern "C" fn SpliceAck_set_chain_hash(this_ptr: &mut SpliceAck, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); +pub extern "C" fn SpliceAck_set_channel_id(this_ptr: &mut SpliceAck, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. +/// The amount the splice acceptor is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn SpliceAck_get_relative_satoshis(this_ptr: &SpliceAck) -> i64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().relative_satoshis; +pub extern "C" fn SpliceAck_get_funding_contribution_satoshis(this_ptr: &SpliceAck) -> i64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_contribution_satoshis; *inner_val } -/// The intended change in channel capacity: the amount to be added (positive value) -/// or removed (negative value) by the sender (splice acceptor) by splicing into/from the channel. +/// The amount the splice acceptor is intending to add to its channel balance (splice-in) +/// or remove from its channel balance (splice-out). #[no_mangle] -pub extern "C" fn SpliceAck_set_relative_satoshis(this_ptr: &mut SpliceAck, mut val: i64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.relative_satoshis = val; +pub extern "C" fn SpliceAck_set_funding_contribution_satoshis(this_ptr: &mut SpliceAck, mut val: i64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_contribution_satoshis = val; } /// The key of the sender (splice acceptor) controlling the new funding transaction #[no_mangle] @@ -3097,15 +3281,29 @@ pub extern "C" fn SpliceAck_get_funding_pubkey(this_ptr: &SpliceAck) -> crate::c pub extern "C" fn SpliceAck_set_funding_pubkey(this_ptr: &mut SpliceAck, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_pubkey = val.into_rust(); } +/// If set, only confirmed inputs added (by the splice initiator) will be accepted +#[no_mangle] +pub extern "C" fn SpliceAck_get_require_confirmed_inputs(this_ptr: &SpliceAck) -> crate::c_types::derived::COption_NoneZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().require_confirmed_inputs; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NoneZ::None } else { crate::c_types::derived::COption_NoneZ::Some /* { () /**/ } */ }; + local_inner_val +} +/// If set, only confirmed inputs added (by the splice initiator) will be accepted +#[no_mangle] +pub extern "C" fn SpliceAck_set_require_confirmed_inputs(this_ptr: &mut SpliceAck, mut val: crate::c_types::derived::COption_NoneZ) { + let mut local_val = if val.is_some() { Some( { () /*val.take()*/ }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.require_confirmed_inputs = local_val; +} /// Constructs a new SpliceAck given each field #[must_use] #[no_mangle] -pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut relative_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey) -> SpliceAck { +pub extern "C" fn SpliceAck_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_contribution_satoshis_arg: i64, mut funding_pubkey_arg: crate::c_types::PublicKey, mut require_confirmed_inputs_arg: crate::c_types::derived::COption_NoneZ) -> SpliceAck { + let mut local_require_confirmed_inputs_arg = if require_confirmed_inputs_arg.is_some() { Some( { () /*require_confirmed_inputs_arg.take()*/ }) } else { None }; SpliceAck { inner: ObjOps::heap_alloc(nativeSpliceAck { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), - relative_satoshis: relative_satoshis_arg, + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + funding_contribution_satoshis: funding_contribution_satoshis_arg, funding_pubkey: funding_pubkey_arg.into_rust(), + require_confirmed_inputs: local_require_confirmed_inputs_arg, }), is_owned: true } } impl Clone for SpliceAck { @@ -3143,7 +3341,7 @@ pub extern "C" fn SpliceAck_eq(a: &SpliceAck, b: &SpliceAck) -> bool { use lightning::ln::msgs::SpliceLocked as nativeSpliceLockedImport; pub(crate) type nativeSpliceLocked = nativeSpliceLockedImport; -/// A splice_locked message to be sent to or received from a peer. +/// A `splice_locked` message to be sent to or received from a peer. /// #[must_use] #[repr(C)] @@ -3160,6 +3358,12 @@ pub struct SpliceLocked { pub is_owned: bool, } +impl core::ops::Deref for SpliceLocked { + type Target = nativeSpliceLocked; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SpliceLocked { } +unsafe impl core::marker::Sync for SpliceLocked { } impl Drop for SpliceLocked { fn drop(&mut self) { if self.is_owned && !<*mut nativeSpliceLocked>::is_null(self.inner) { @@ -3190,24 +3394,39 @@ impl SpliceLocked { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> *const [u8; 32] { +pub extern "C" fn SpliceLocked_get_channel_id(this_ptr: &SpliceLocked) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn SpliceLocked_set_channel_id(this_ptr: &mut SpliceLocked, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The ID of the new funding transaction that has been locked +#[no_mangle] +pub extern "C" fn SpliceLocked_get_splice_txid(this_ptr: &SpliceLocked) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().splice_txid; + inner_val.as_ref() +} +/// The ID of the new funding transaction that has been locked +#[no_mangle] +pub extern "C" fn SpliceLocked_set_splice_txid(this_ptr: &mut SpliceLocked, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.splice_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); } /// Constructs a new SpliceLocked given each field #[must_use] #[no_mangle] -pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> SpliceLocked { +pub extern "C" fn SpliceLocked_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut splice_txid_arg: crate::c_types::ThirtyTwoBytes) -> SpliceLocked { SpliceLocked { inner: ObjOps::heap_alloc(nativeSpliceLocked { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + splice_txid: ::bitcoin::hash_types::Txid::from_slice(&splice_txid_arg.data[..]).unwrap(), }), is_owned: true } } impl Clone for SpliceLocked { @@ -3262,6 +3481,12 @@ pub struct TxAddInput { pub is_owned: bool, } +impl core::ops::Deref for TxAddInput { + type Target = nativeTxAddInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAddInput { } +unsafe impl core::marker::Sync for TxAddInput { } impl Drop for TxAddInput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAddInput>::is_null(self.inner) { @@ -3292,17 +3517,20 @@ impl TxAddInput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> *const [u8; 32] { +pub extern "C" fn TxAddInput_get_channel_id(this_ptr: &TxAddInput) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxAddInput_set_channel_id(this_ptr: &mut TxAddInput, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// A randomly chosen unique identifier for this input, which is even for initiators and odd for /// non-initiators. @@ -3352,16 +3580,31 @@ pub extern "C" fn TxAddInput_get_sequence(this_ptr: &TxAddInput) -> u32 { pub extern "C" fn TxAddInput_set_sequence(this_ptr: &mut TxAddInput, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.sequence = val; } +/// The ID of the previous funding transaction, when it is being added as an input during splicing +#[no_mangle] +pub extern "C" fn TxAddInput_get_shared_input_txid(this_ptr: &TxAddInput) -> crate::c_types::derived::COption_ThirtyTwoBytesZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shared_input_txid; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: *(*inner_val.as_ref().unwrap()).clone().as_ref() } }) }; + local_inner_val +} +/// The ID of the previous funding transaction, when it is being added as an input during splicing +#[no_mangle] +pub extern "C" fn TxAddInput_set_shared_input_txid(this_ptr: &mut TxAddInput, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ val_opt.take() }.data[..]).unwrap() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shared_input_txid = local_val; +} /// Constructs a new TxAddInput given each field #[must_use] #[no_mangle] -pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32) -> TxAddInput { +pub extern "C" fn TxAddInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut prevtx_arg: crate::lightning::util::ser::TransactionU16LenLimited, mut prevtx_out_arg: u32, mut sequence_arg: u32, mut shared_input_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> TxAddInput { + let mut local_shared_input_txid_arg = { /*shared_input_txid_arg*/ let shared_input_txid_arg_opt = shared_input_txid_arg; if shared_input_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ shared_input_txid_arg_opt.take() }.data[..]).unwrap() }})} }; TxAddInput { inner: ObjOps::heap_alloc(nativeTxAddInput { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, prevtx: *unsafe { Box::from_raw(prevtx_arg.take_inner()) }, prevtx_out: prevtx_out_arg, sequence: sequence_arg, + shared_input_txid: local_shared_input_txid_arg, }), is_owned: true } } impl Clone for TxAddInput { @@ -3426,6 +3669,12 @@ pub struct TxAddOutput { pub is_owned: bool, } +impl core::ops::Deref for TxAddOutput { + type Target = nativeTxAddOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAddOutput { } +unsafe impl core::marker::Sync for TxAddOutput { } impl Drop for TxAddOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAddOutput>::is_null(self.inner) { @@ -3456,17 +3705,20 @@ impl TxAddOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> *const [u8; 32] { +pub extern "C" fn TxAddOutput_get_channel_id(this_ptr: &TxAddOutput) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxAddOutput_set_channel_id(this_ptr: &mut TxAddOutput, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// A randomly chosen unique identifier for this output, which is even for initiators and odd for /// non-initiators. @@ -3501,17 +3753,17 @@ pub extern "C" fn TxAddOutput_get_script(this_ptr: &TxAddOutput) -> crate::c_typ /// The scriptPubKey for the output #[no_mangle] pub extern "C" fn TxAddOutput_set_script(this_ptr: &mut TxAddOutput, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new TxAddOutput given each field #[must_use] #[no_mangle] -pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput { +pub extern "C" fn TxAddOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64, mut sats_arg: u64, mut script_arg: crate::c_types::derived::CVec_u8Z) -> TxAddOutput { TxAddOutput { inner: ObjOps::heap_alloc(nativeTxAddOutput { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, sats: sats_arg, - script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()), + script: ::bitcoin::script::ScriptBuf::from(script_arg.into_rust()), }), is_owned: true } } impl Clone for TxAddOutput { @@ -3576,6 +3828,12 @@ pub struct TxRemoveInput { pub is_owned: bool, } +impl core::ops::Deref for TxRemoveInput { + type Target = nativeTxRemoveInput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxRemoveInput { } +unsafe impl core::marker::Sync for TxRemoveInput { } impl Drop for TxRemoveInput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxRemoveInput>::is_null(self.inner) { @@ -3606,17 +3864,20 @@ impl TxRemoveInput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> *const [u8; 32] { +pub extern "C" fn TxRemoveInput_get_channel_id(this_ptr: &TxRemoveInput) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxRemoveInput_set_channel_id(this_ptr: &mut TxRemoveInput, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The serial ID of the input to be removed #[no_mangle] @@ -3632,9 +3893,9 @@ pub extern "C" fn TxRemoveInput_set_serial_id(this_ptr: &mut TxRemoveInput, mut /// Constructs a new TxRemoveInput given each field #[must_use] #[no_mangle] -pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveInput { +pub extern "C" fn TxRemoveInput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveInput { TxRemoveInput { inner: ObjOps::heap_alloc(nativeTxRemoveInput { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, }), is_owned: true } } @@ -3700,6 +3961,12 @@ pub struct TxRemoveOutput { pub is_owned: bool, } +impl core::ops::Deref for TxRemoveOutput { + type Target = nativeTxRemoveOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxRemoveOutput { } +unsafe impl core::marker::Sync for TxRemoveOutput { } impl Drop for TxRemoveOutput { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxRemoveOutput>::is_null(self.inner) { @@ -3730,17 +3997,20 @@ impl TxRemoveOutput { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> *const [u8; 32] { +pub extern "C" fn TxRemoveOutput_get_channel_id(this_ptr: &TxRemoveOutput) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxRemoveOutput_set_channel_id(this_ptr: &mut TxRemoveOutput, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The serial ID of the output to be removed #[no_mangle] @@ -3756,9 +4026,9 @@ pub extern "C" fn TxRemoveOutput_set_serial_id(this_ptr: &mut TxRemoveOutput, mu /// Constructs a new TxRemoveOutput given each field #[must_use] #[no_mangle] -pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut serial_id_arg: u64) -> TxRemoveOutput { +pub extern "C" fn TxRemoveOutput_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut serial_id_arg: u64) -> TxRemoveOutput { TxRemoveOutput { inner: ObjOps::heap_alloc(nativeTxRemoveOutput { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, serial_id: serial_id_arg, }), is_owned: true } } @@ -3825,6 +4095,12 @@ pub struct TxComplete { pub is_owned: bool, } +impl core::ops::Deref for TxComplete { + type Target = nativeTxComplete; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxComplete { } +unsafe impl core::marker::Sync for TxComplete { } impl Drop for TxComplete { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxComplete>::is_null(self.inner) { @@ -3855,24 +4131,27 @@ impl TxComplete { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> *const [u8; 32] { +pub extern "C" fn TxComplete_get_channel_id(this_ptr: &TxComplete) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxComplete_set_channel_id(this_ptr: &mut TxComplete, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// Constructs a new TxComplete given each field #[must_use] #[no_mangle] -pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes) -> TxComplete { +pub extern "C" fn TxComplete_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId) -> TxComplete { TxComplete { inner: ObjOps::heap_alloc(nativeTxComplete { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, }), is_owned: true } } impl Clone for TxComplete { @@ -3938,6 +4217,12 @@ pub struct TxSignatures { pub is_owned: bool, } +impl core::ops::Deref for TxSignatures { + type Target = nativeTxSignatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxSignatures { } +unsafe impl core::marker::Sync for TxSignatures { } impl Drop for TxSignatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxSignatures>::is_null(self.inner) { @@ -3968,17 +4253,20 @@ impl TxSignatures { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> *const [u8; 32] { +pub extern "C" fn TxSignatures_get_channel_id(this_ptr: &TxSignatures) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxSignatures_set_channel_id(this_ptr: &mut TxSignatures, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The TXID #[no_mangle] @@ -4006,15 +4294,30 @@ pub extern "C" fn TxSignatures_set_witnesses(this_ptr: &mut TxSignatures, mut va let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_bitcoin() }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.witnesses = local_val; } +/// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers +#[no_mangle] +pub extern "C" fn TxSignatures_get_shared_input_signature(this_ptr: &TxSignatures) -> crate::c_types::derived::COption_ECDSASignatureZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().shared_input_signature; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ECDSASignatureZ::None } else { crate::c_types::derived::COption_ECDSASignatureZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ECDSASignature::from_rust(&(*inner_val.as_ref().unwrap()).clone()) }) }; + local_inner_val +} +/// Optional signature for the shared input -- the previous funding outpoint -- signed by both peers +#[no_mangle] +pub extern "C" fn TxSignatures_set_shared_input_signature(this_ptr: &mut TxSignatures, mut val: crate::c_types::derived::COption_ECDSASignatureZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_rust() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.shared_input_signature = local_val; +} /// Constructs a new TxSignatures given each field #[must_use] #[no_mangle] -pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ) -> TxSignatures { +pub extern "C" fn TxSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut tx_hash_arg: crate::c_types::ThirtyTwoBytes, mut witnesses_arg: crate::c_types::derived::CVec_WitnessZ, mut shared_input_signature_arg: crate::c_types::derived::COption_ECDSASignatureZ) -> TxSignatures { let mut local_witnesses_arg = Vec::new(); for mut item in witnesses_arg.into_rust().drain(..) { local_witnesses_arg.push( { item.into_bitcoin() }); }; + let mut local_shared_input_signature_arg = { /*shared_input_signature_arg*/ let shared_input_signature_arg_opt = shared_input_signature_arg; if shared_input_signature_arg_opt.is_none() { None } else { Some({ { { shared_input_signature_arg_opt.take() }.into_rust() }})} }; TxSignatures { inner: ObjOps::heap_alloc(nativeTxSignatures { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, tx_hash: ::bitcoin::hash_types::Txid::from_slice(&tx_hash_arg.data[..]).unwrap(), witnesses: local_witnesses_arg, + shared_input_signature: local_shared_input_signature_arg, }), is_owned: true } } impl Clone for TxSignatures { @@ -4080,6 +4383,12 @@ pub struct TxInitRbf { pub is_owned: bool, } +impl core::ops::Deref for TxInitRbf { + type Target = nativeTxInitRbf; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxInitRbf { } +unsafe impl core::marker::Sync for TxInitRbf { } impl Drop for TxInitRbf { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxInitRbf>::is_null(self.inner) { @@ -4110,17 +4419,20 @@ impl TxInitRbf { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> *const [u8; 32] { +pub extern "C" fn TxInitRbf_get_channel_id(this_ptr: &TxInitRbf) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxInitRbf_set_channel_id(this_ptr: &mut TxInitRbf, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The locktime of the transaction #[no_mangle] @@ -4162,10 +4474,10 @@ pub extern "C" fn TxInitRbf_set_funding_output_contribution(this_ptr: &mut TxIni /// Constructs a new TxInitRbf given each field #[must_use] #[no_mangle] -pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf { +pub extern "C" fn TxInitRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut locktime_arg: u32, mut feerate_sat_per_1000_weight_arg: u32, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxInitRbf { let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; TxInitRbf { inner: ObjOps::heap_alloc(nativeTxInitRbf { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, locktime: locktime_arg, feerate_sat_per_1000_weight: feerate_sat_per_1000_weight_arg, funding_output_contribution: local_funding_output_contribution_arg, @@ -4234,6 +4546,12 @@ pub struct TxAckRbf { pub is_owned: bool, } +impl core::ops::Deref for TxAckRbf { + type Target = nativeTxAckRbf; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAckRbf { } +unsafe impl core::marker::Sync for TxAckRbf { } impl Drop for TxAckRbf { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAckRbf>::is_null(self.inner) { @@ -4264,17 +4582,20 @@ impl TxAckRbf { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> *const [u8; 32] { +pub extern "C" fn TxAckRbf_get_channel_id(this_ptr: &TxAckRbf) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxAckRbf_set_channel_id(this_ptr: &mut TxAckRbf, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The number of satoshis the sender will contribute to or, if negative, remove from /// (e.g. splice-out) the funding output of the transaction @@ -4294,10 +4615,10 @@ pub extern "C" fn TxAckRbf_set_funding_output_contribution(this_ptr: &mut TxAckR /// Constructs a new TxAckRbf given each field #[must_use] #[no_mangle] -pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf { +pub extern "C" fn TxAckRbf_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut funding_output_contribution_arg: crate::c_types::derived::COption_i64Z) -> TxAckRbf { let mut local_funding_output_contribution_arg = if funding_output_contribution_arg.is_some() { Some( { funding_output_contribution_arg.take() }) } else { None }; TxAckRbf { inner: ObjOps::heap_alloc(nativeTxAckRbf { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, funding_output_contribution: local_funding_output_contribution_arg, }), is_owned: true } } @@ -4363,6 +4684,12 @@ pub struct TxAbort { pub is_owned: bool, } +impl core::ops::Deref for TxAbort { + type Target = nativeTxAbort; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TxAbort { } +unsafe impl core::marker::Sync for TxAbort { } impl Drop for TxAbort { fn drop(&mut self) { if self.is_owned && !<*mut nativeTxAbort>::is_null(self.inner) { @@ -4393,17 +4720,20 @@ impl TxAbort { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> *const [u8; 32] { +pub extern "C" fn TxAbort_get_channel_id(this_ptr: &TxAbort) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn TxAbort_set_channel_id(this_ptr: &mut TxAbort, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// Message data /// @@ -4423,10 +4753,10 @@ pub extern "C" fn TxAbort_set_data(this_ptr: &mut TxAbort, mut val: crate::c_typ /// Constructs a new TxAbort given each field #[must_use] #[no_mangle] -pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort { +pub extern "C" fn TxAbort_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut data_arg: crate::c_types::derived::CVec_u8Z) -> TxAbort { let mut local_data_arg = Vec::new(); for mut item in data_arg.into_rust().drain(..) { local_data_arg.push( { item }); }; TxAbort { inner: ObjOps::heap_alloc(nativeTxAbort { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, data: local_data_arg, }), is_owned: true } } @@ -4493,6 +4823,12 @@ pub struct Shutdown { pub is_owned: bool, } +impl core::ops::Deref for Shutdown { + type Target = nativeShutdown; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Shutdown { } +unsafe impl core::marker::Sync for Shutdown { } impl Drop for Shutdown { fn drop(&mut self) { if self.is_owned && !<*mut nativeShutdown>::is_null(self.inner) { @@ -4523,17 +4859,20 @@ impl Shutdown { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> *const [u8; 32] { +pub extern "C" fn Shutdown_get_channel_id(this_ptr: &Shutdown) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn Shutdown_set_channel_id(this_ptr: &mut Shutdown, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The destination of this peer's funds on closing. /// @@ -4548,15 +4887,15 @@ pub extern "C" fn Shutdown_get_scriptpubkey(this_ptr: &Shutdown) -> crate::c_typ /// Must be in one of these forms: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. #[no_mangle] pub extern "C" fn Shutdown_set_scriptpubkey(this_ptr: &mut Shutdown, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.scriptpubkey = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new Shutdown given each field #[must_use] #[no_mangle] -pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown { +pub extern "C" fn Shutdown_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut scriptpubkey_arg: crate::c_types::derived::CVec_u8Z) -> Shutdown { Shutdown { inner: ObjOps::heap_alloc(nativeShutdown { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), - scriptpubkey: ::bitcoin::blockdata::script::ScriptBuf::from(scriptpubkey_arg.into_rust()), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, + scriptpubkey: ::bitcoin::script::ScriptBuf::from(scriptpubkey_arg.into_rust()), }), is_owned: true } } impl Clone for Shutdown { @@ -4623,6 +4962,12 @@ pub struct ClosingSignedFeeRange { pub is_owned: bool, } +impl core::ops::Deref for ClosingSignedFeeRange { + type Target = nativeClosingSignedFeeRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingSignedFeeRange { } +unsafe impl core::marker::Sync for ClosingSignedFeeRange { } impl Drop for ClosingSignedFeeRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingSignedFeeRange>::is_null(self.inner) { @@ -4653,6 +4998,9 @@ impl ClosingSignedFeeRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The minimum absolute fee, in satoshis, which the sender is willing to place on the closing /// transaction. @@ -4752,6 +5100,12 @@ pub struct ClosingSigned { pub is_owned: bool, } +impl core::ops::Deref for ClosingSigned { + type Target = nativeClosingSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ClosingSigned { } +unsafe impl core::marker::Sync for ClosingSigned { } impl Drop for ClosingSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeClosingSigned>::is_null(self.inner) { @@ -4782,17 +5136,20 @@ impl ClosingSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> *const [u8; 32] { +pub extern "C" fn ClosingSigned_get_channel_id(this_ptr: &ClosingSigned) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn ClosingSigned_set_channel_id(this_ptr: &mut ClosingSigned, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The proposed total fee for the closing transaction #[no_mangle] @@ -4840,10 +5197,10 @@ pub extern "C" fn ClosingSigned_set_fee_range(this_ptr: &mut ClosingSigned, mut /// Note that fee_range_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned { +pub extern "C" fn ClosingSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut fee_satoshis_arg: u64, mut signature_arg: crate::c_types::ECDSASignature, mut fee_range_arg: crate::lightning::ln::msgs::ClosingSignedFeeRange) -> ClosingSigned { let mut local_fee_range_arg = if fee_range_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(fee_range_arg.take_inner()) } }) }; ClosingSigned { inner: ObjOps::heap_alloc(nativeClosingSigned { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, fee_satoshis: fee_satoshis_arg, signature: signature_arg.into_rust(), fee_range: local_fee_range_arg, @@ -4912,6 +5269,12 @@ pub struct UpdateAddHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateAddHTLC { + type Target = nativeUpdateAddHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateAddHTLC { } +unsafe impl core::marker::Sync for UpdateAddHTLC { } impl Drop for UpdateAddHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateAddHTLC>::is_null(self.inner) { @@ -4942,17 +5305,20 @@ impl UpdateAddHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> *const [u8; 32] { +pub extern "C" fn UpdateAddHTLC_get_channel_id(this_ptr: &UpdateAddHTLC) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn UpdateAddHTLC_set_channel_id(this_ptr: &mut UpdateAddHTLC, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The HTLC ID #[no_mangle] @@ -4985,7 +5351,7 @@ pub extern "C" fn UpdateAddHTLC_get_payment_hash(this_ptr: &UpdateAddHTLC) -> *c /// The payment hash, the pre-image of which controls HTLC redemption #[no_mangle] pub extern "C" fn UpdateAddHTLC_set_payment_hash(this_ptr: &mut UpdateAddHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::PaymentHash(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = ::lightning::ln::types::PaymentHash(val.data); } /// The expiry height of the HTLC #[no_mangle] @@ -5052,14 +5418,14 @@ pub extern "C" fn UpdateAddHTLC_set_blinding_point(this_ptr: &mut UpdateAddHTLC, /// Note that blinding_point_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC { +pub extern "C" fn UpdateAddHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut amount_msat_arg: u64, mut payment_hash_arg: crate::c_types::ThirtyTwoBytes, mut cltv_expiry_arg: u32, mut skimmed_fee_msat_arg: crate::c_types::derived::COption_u64Z, mut onion_routing_packet_arg: crate::lightning::ln::msgs::OnionPacket, mut blinding_point_arg: crate::c_types::PublicKey) -> UpdateAddHTLC { let mut local_skimmed_fee_msat_arg = if skimmed_fee_msat_arg.is_some() { Some( { skimmed_fee_msat_arg.take() }) } else { None }; let mut local_blinding_point_arg = if blinding_point_arg.is_null() { None } else { Some( { blinding_point_arg.into_rust() }) }; UpdateAddHTLC { inner: ObjOps::heap_alloc(nativeUpdateAddHTLC { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, htlc_id: htlc_id_arg, amount_msat: amount_msat_arg, - payment_hash: ::lightning::ln::PaymentHash(payment_hash_arg.data), + payment_hash: ::lightning::ln::types::PaymentHash(payment_hash_arg.data), cltv_expiry: cltv_expiry_arg, skimmed_fee_msat: local_skimmed_fee_msat_arg, onion_routing_packet: *unsafe { Box::from_raw(onion_routing_packet_arg.take_inner()) }, @@ -5128,6 +5494,12 @@ pub struct OnionMessage { pub is_owned: bool, } +impl core::ops::Deref for OnionMessage { + type Target = nativeOnionMessage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessage { } +unsafe impl core::marker::Sync for OnionMessage { } impl Drop for OnionMessage { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessage>::is_null(self.inner) { @@ -5158,6 +5530,9 @@ impl OnionMessage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Used in decrypting the onion packet's payload. #[no_mangle] @@ -5253,6 +5628,12 @@ pub struct UpdateFulfillHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFulfillHTLC { + type Target = nativeUpdateFulfillHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFulfillHTLC { } +unsafe impl core::marker::Sync for UpdateFulfillHTLC { } impl Drop for UpdateFulfillHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { @@ -5283,17 +5664,20 @@ impl UpdateFulfillHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> *const [u8; 32] { +pub extern "C" fn UpdateFulfillHTLC_get_channel_id(this_ptr: &UpdateFulfillHTLC) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn UpdateFulfillHTLC_set_channel_id(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The HTLC ID #[no_mangle] @@ -5315,16 +5699,16 @@ pub extern "C" fn UpdateFulfillHTLC_get_payment_preimage(this_ptr: &UpdateFulfil /// The pre-image of the payment hash, allowing HTLC redemption #[no_mangle] pub extern "C" fn UpdateFulfillHTLC_set_payment_preimage(this_ptr: &mut UpdateFulfillHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::PaymentPreimage(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_preimage = ::lightning::ln::types::PaymentPreimage(val.data); } /// Constructs a new UpdateFulfillHTLC given each field #[must_use] #[no_mangle] -pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC { +pub extern "C" fn UpdateFulfillHTLC_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut htlc_id_arg: u64, mut payment_preimage_arg: crate::c_types::ThirtyTwoBytes) -> UpdateFulfillHTLC { UpdateFulfillHTLC { inner: ObjOps::heap_alloc(nativeUpdateFulfillHTLC { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, htlc_id: htlc_id_arg, - payment_preimage: ::lightning::ln::PaymentPreimage(payment_preimage_arg.data), + payment_preimage: ::lightning::ln::types::PaymentPreimage(payment_preimage_arg.data), }), is_owned: true } } impl Clone for UpdateFulfillHTLC { @@ -5390,6 +5774,12 @@ pub struct UpdateFailHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFailHTLC { + type Target = nativeUpdateFailHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFailHTLC { } +unsafe impl core::marker::Sync for UpdateFailHTLC { } impl Drop for UpdateFailHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFailHTLC>::is_null(self.inner) { @@ -5420,17 +5810,20 @@ impl UpdateFailHTLC { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> *const [u8; 32] { +pub extern "C" fn UpdateFailHTLC_get_channel_id(this_ptr: &UpdateFailHTLC) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn UpdateFailHTLC_set_channel_id(this_ptr: &mut UpdateFailHTLC, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The HTLC ID #[no_mangle] @@ -5506,6 +5899,12 @@ pub struct UpdateFailMalformedHTLC { pub is_owned: bool, } +impl core::ops::Deref for UpdateFailMalformedHTLC { + type Target = nativeUpdateFailMalformedHTLC; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFailMalformedHTLC { } +unsafe impl core::marker::Sync for UpdateFailMalformedHTLC { } impl Drop for UpdateFailMalformedHTLC { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { @@ -5522,58 +5921,193 @@ pub(crate) extern "C" fn UpdateFailMalformedHTLC_free_void(this_ptr: *mut c_void let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUpdateFailMalformedHTLC) }; } #[allow(unused)] -impl UpdateFailMalformedHTLC { - pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC { +impl UpdateFailMalformedHTLC { + pub(crate) fn get_native_ref(&self) -> &'static nativeUpdateFailMalformedHTLC { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> crate::lightning::ln::types::ChannelId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } +} +/// The channel ID +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The HTLC ID +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id; + *inner_val +} +/// The HTLC ID +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val; +} +/// The failure code +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code; + *inner_val +} +/// The failure code +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val; +} +impl Clone for UpdateFailMalformedHTLC { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UpdateFailMalformedHTLC +pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC { + orig.clone() +} +/// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object +pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()} +/// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two UpdateFailMalformedHTLCs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning::ln::msgs::CommitmentSignedBatch as nativeCommitmentSignedBatchImport; +pub(crate) type nativeCommitmentSignedBatch = nativeCommitmentSignedBatchImport; + +/// Optional batch parameters for `commitment_signed` message. +#[must_use] +#[repr(C)] +pub struct CommitmentSignedBatch { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeCommitmentSignedBatch, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for CommitmentSignedBatch { + type Target = nativeCommitmentSignedBatch; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentSignedBatch { } +unsafe impl core::marker::Sync for CommitmentSignedBatch { } +impl Drop for CommitmentSignedBatch { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeCommitmentSignedBatch>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the CommitmentSignedBatch, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn CommitmentSignedBatch_free(this_obj: CommitmentSignedBatch) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn CommitmentSignedBatch_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeCommitmentSignedBatch) }; +} +#[allow(unused)] +impl CommitmentSignedBatch { + pub(crate) fn get_native_ref(&self) -> &'static nativeCommitmentSignedBatch { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUpdateFailMalformedHTLC { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeCommitmentSignedBatch { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC { + pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSignedBatch { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The channel ID -#[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_get_channel_id(this_ptr: &UpdateFailMalformedHTLC) -> *const [u8; 32] { - let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 -} -/// The channel ID +/// Batch size N: all N `commitment_signed` messages must be received before being processed #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_set_channel_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn CommitmentSignedBatch_get_batch_size(this_ptr: &CommitmentSignedBatch) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().batch_size; + *inner_val } -/// The HTLC ID +/// Batch size N: all N `commitment_signed` messages must be received before being processed #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_get_htlc_id(this_ptr: &UpdateFailMalformedHTLC) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_id; - *inner_val +pub extern "C" fn CommitmentSignedBatch_set_batch_size(this_ptr: &mut CommitmentSignedBatch, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.batch_size = val; } -/// The HTLC ID +/// The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_set_htlc_id(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_id = val; +pub extern "C" fn CommitmentSignedBatch_get_funding_txid(this_ptr: &CommitmentSignedBatch) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txid; + inner_val.as_ref() } -/// The failure code +/// The funding transaction, to discriminate among multiple pending funding transactions (e.g. in case of splicing) #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_get_failure_code(this_ptr: &UpdateFailMalformedHTLC) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().failure_code; - *inner_val +pub extern "C" fn CommitmentSignedBatch_set_funding_txid(this_ptr: &mut CommitmentSignedBatch, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.funding_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); } -/// The failure code +/// Constructs a new CommitmentSignedBatch given each field +#[must_use] #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_set_failure_code(this_ptr: &mut UpdateFailMalformedHTLC, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_code = val; +pub extern "C" fn CommitmentSignedBatch_new(mut batch_size_arg: u16, mut funding_txid_arg: crate::c_types::ThirtyTwoBytes) -> CommitmentSignedBatch { + CommitmentSignedBatch { inner: ObjOps::heap_alloc(nativeCommitmentSignedBatch { + batch_size: batch_size_arg, + funding_txid: ::bitcoin::hash_types::Txid::from_slice(&funding_txid_arg.data[..]).unwrap(), + }), is_owned: true } } -impl Clone for UpdateFailMalformedHTLC { +impl Clone for CommitmentSignedBatch { fn clone(&self) -> Self { Self { - inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeCommitmentSignedBatch>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -5581,20 +6115,20 @@ impl Clone for UpdateFailMalformedHTLC { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UpdateFailMalformedHTLC_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUpdateFailMalformedHTLC)).clone() })) as *mut c_void +pub(crate) extern "C" fn CommitmentSignedBatch_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeCommitmentSignedBatch)).clone() })) as *mut c_void } #[no_mangle] -/// Creates a copy of the UpdateFailMalformedHTLC -pub extern "C" fn UpdateFailMalformedHTLC_clone(orig: &UpdateFailMalformedHTLC) -> UpdateFailMalformedHTLC { +/// Creates a copy of the CommitmentSignedBatch +pub extern "C" fn CommitmentSignedBatch_clone(orig: &CommitmentSignedBatch) -> CommitmentSignedBatch { orig.clone() } -/// Get a string which allows debug introspection of a UpdateFailMalformedHTLC object -pub extern "C" fn UpdateFailMalformedHTLC_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::UpdateFailMalformedHTLC }).into()} -/// Generates a non-cryptographic 64-bit hash of the UpdateFailMalformedHTLC. +/// Get a string which allows debug introspection of a CommitmentSignedBatch object +pub extern "C" fn CommitmentSignedBatch_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::CommitmentSignedBatch }).into()} +/// Generates a non-cryptographic 64-bit hash of the CommitmentSignedBatch. #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u64 { +pub extern "C" fn CommitmentSignedBatch_hash(o: &CommitmentSignedBatch) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -5602,11 +6136,11 @@ pub extern "C" fn UpdateFailMalformedHTLC_hash(o: &UpdateFailMalformedHTLC) -> u core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two UpdateFailMalformedHTLCs contain equal inner contents. +/// Checks if two CommitmentSignedBatchs contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn UpdateFailMalformedHTLC_eq(a: &UpdateFailMalformedHTLC, b: &UpdateFailMalformedHTLC) -> bool { +pub extern "C" fn CommitmentSignedBatch_eq(a: &CommitmentSignedBatch, b: &CommitmentSignedBatch) -> bool { if a.inner == b.inner { return true; } if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } @@ -5633,6 +6167,12 @@ pub struct CommitmentSigned { pub is_owned: bool, } +impl core::ops::Deref for CommitmentSigned { + type Target = nativeCommitmentSigned; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentSigned { } +unsafe impl core::marker::Sync for CommitmentSigned { } impl Drop for CommitmentSigned { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentSigned>::is_null(self.inner) { @@ -5663,17 +6203,20 @@ impl CommitmentSigned { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> *const [u8; 32] { +pub extern "C" fn CommitmentSigned_get_channel_id(this_ptr: &CommitmentSigned) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn CommitmentSigned_set_channel_id(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// A signature on the commitment transaction #[no_mangle] @@ -5701,15 +6244,36 @@ pub extern "C" fn CommitmentSigned_set_htlc_signatures(this_ptr: &mut Commitment let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_rust() }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_signatures = local_val; } +/// Optional batch size and other parameters +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn CommitmentSigned_get_batch(this_ptr: &CommitmentSigned) -> crate::lightning::ln::msgs::CommitmentSignedBatch { + let mut inner_val = &mut this_ptr.get_native_mut_ref().batch; + let mut local_inner_val = crate::lightning::ln::msgs::CommitmentSignedBatch { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::CommitmentSignedBatch<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// Optional batch size and other parameters +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn CommitmentSigned_set_batch(this_ptr: &mut CommitmentSigned, mut val: crate::lightning::ln::msgs::CommitmentSignedBatch) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.batch = local_val; +} /// Constructs a new CommitmentSigned given each field +/// +/// Note that batch_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ) -> CommitmentSigned { +pub extern "C" fn CommitmentSigned_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut signature_arg: crate::c_types::ECDSASignature, mut htlc_signatures_arg: crate::c_types::derived::CVec_ECDSASignatureZ, mut batch_arg: crate::lightning::ln::msgs::CommitmentSignedBatch) -> CommitmentSigned { let mut local_htlc_signatures_arg = Vec::new(); for mut item in htlc_signatures_arg.into_rust().drain(..) { local_htlc_signatures_arg.push( { item.into_rust() }); }; + let mut local_batch_arg = if batch_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(batch_arg.take_inner()) } }) }; CommitmentSigned { inner: ObjOps::heap_alloc(nativeCommitmentSigned { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, signature: signature_arg.into_rust(), htlc_signatures: local_htlc_signatures_arg, + batch: local_batch_arg, }), is_owned: true } } impl Clone for CommitmentSigned { @@ -5775,6 +6339,12 @@ pub struct RevokeAndACK { pub is_owned: bool, } +impl core::ops::Deref for RevokeAndACK { + type Target = nativeRevokeAndACK; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RevokeAndACK { } +unsafe impl core::marker::Sync for RevokeAndACK { } impl Drop for RevokeAndACK { fn drop(&mut self) { if self.is_owned && !<*mut nativeRevokeAndACK>::is_null(self.inner) { @@ -5805,17 +6375,20 @@ impl RevokeAndACK { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> *const [u8; 32] { +pub extern "C" fn RevokeAndACK_get_channel_id(this_ptr: &RevokeAndACK) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn RevokeAndACK_set_channel_id(this_ptr: &mut RevokeAndACK, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The secret corresponding to the per-commitment point #[no_mangle] @@ -5842,9 +6415,9 @@ pub extern "C" fn RevokeAndACK_set_next_per_commitment_point(this_ptr: &mut Revo /// Constructs a new RevokeAndACK given each field #[must_use] #[no_mangle] -pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK { +pub extern "C" fn RevokeAndACK_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut next_per_commitment_point_arg: crate::c_types::PublicKey) -> RevokeAndACK { RevokeAndACK { inner: ObjOps::heap_alloc(nativeRevokeAndACK { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, per_commitment_secret: per_commitment_secret_arg.data, next_per_commitment_point: next_per_commitment_point_arg.into_rust(), }), is_owned: true } @@ -5912,6 +6485,12 @@ pub struct UpdateFee { pub is_owned: bool, } +impl core::ops::Deref for UpdateFee { + type Target = nativeUpdateFee; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UpdateFee { } +unsafe impl core::marker::Sync for UpdateFee { } impl Drop for UpdateFee { fn drop(&mut self) { if self.is_owned && !<*mut nativeUpdateFee>::is_null(self.inner) { @@ -5942,17 +6521,20 @@ impl UpdateFee { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> *const [u8; 32] { +pub extern "C" fn UpdateFee_get_channel_id(this_ptr: &UpdateFee) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn UpdateFee_set_channel_id(this_ptr: &mut UpdateFee, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// Fee rate per 1000-weight of the transaction #[no_mangle] @@ -5968,9 +6550,9 @@ pub extern "C" fn UpdateFee_set_feerate_per_kw(this_ptr: &mut UpdateFee, mut val /// Constructs a new UpdateFee given each field #[must_use] #[no_mangle] -pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut feerate_per_kw_arg: u32) -> UpdateFee { +pub extern "C" fn UpdateFee_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut feerate_per_kw_arg: u32) -> UpdateFee { UpdateFee { inner: ObjOps::heap_alloc(nativeUpdateFee { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, feerate_per_kw: feerate_per_kw_arg, }), is_owned: true } } @@ -6037,6 +6619,12 @@ pub struct ChannelReestablish { pub is_owned: bool, } +impl core::ops::Deref for ChannelReestablish { + type Target = nativeChannelReestablish; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelReestablish { } +unsafe impl core::marker::Sync for ChannelReestablish { } impl Drop for ChannelReestablish { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelReestablish>::is_null(self.inner) { @@ -6067,17 +6655,20 @@ impl ChannelReestablish { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> *const [u8; 32] { +pub extern "C" fn ChannelReestablish_get_channel_id(this_ptr: &ChannelReestablish) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn ChannelReestablish_set_channel_id(this_ptr: &mut ChannelReestablish, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The next commitment number for the sender #[no_mangle] @@ -6141,10 +6732,10 @@ pub extern "C" fn ChannelReestablish_set_next_funding_txid(this_ptr: &mut Channe /// Constructs a new ChannelReestablish given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish { +pub extern "C" fn ChannelReestablish_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut next_local_commitment_number_arg: u64, mut next_remote_commitment_number_arg: u64, mut your_last_per_commitment_secret_arg: crate::c_types::ThirtyTwoBytes, mut my_current_per_commitment_point_arg: crate::c_types::PublicKey, mut next_funding_txid_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> ChannelReestablish { let mut local_next_funding_txid_arg = { /*next_funding_txid_arg*/ let next_funding_txid_arg_opt = next_funding_txid_arg; if next_funding_txid_arg_opt.is_none() { None } else { Some({ { ::bitcoin::hash_types::Txid::from_slice(&{ next_funding_txid_arg_opt.take() }.data[..]).unwrap() }})} }; ChannelReestablish { inner: ObjOps::heap_alloc(nativeChannelReestablish { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, next_local_commitment_number: next_local_commitment_number_arg, next_remote_commitment_number: next_remote_commitment_number_arg, your_last_per_commitment_secret: your_last_per_commitment_secret_arg.data, @@ -6215,6 +6806,12 @@ pub struct AnnouncementSignatures { pub is_owned: bool, } +impl core::ops::Deref for AnnouncementSignatures { + type Target = nativeAnnouncementSignatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for AnnouncementSignatures { } +unsafe impl core::marker::Sync for AnnouncementSignatures { } impl Drop for AnnouncementSignatures { fn drop(&mut self) { if self.is_owned && !<*mut nativeAnnouncementSignatures>::is_null(self.inner) { @@ -6245,17 +6842,20 @@ impl AnnouncementSignatures { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The channel ID #[no_mangle] -pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> *const [u8; 32] { +pub extern "C" fn AnnouncementSignatures_get_channel_id(this_ptr: &AnnouncementSignatures) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - &inner_val.0 + crate::lightning::ln::types::ChannelId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::types::ChannelId<>) as *mut _) }, is_owned: false } } /// The channel ID #[no_mangle] -pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = ::lightning::ln::ChannelId(val.data); +pub extern "C" fn AnnouncementSignatures_set_channel_id(this_ptr: &mut AnnouncementSignatures, mut val: crate::lightning::ln::types::ChannelId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = *unsafe { Box::from_raw(val.take_inner()) }; } /// The short channel ID #[no_mangle] @@ -6293,9 +6893,9 @@ pub extern "C" fn AnnouncementSignatures_set_bitcoin_signature(this_ptr: &mut An /// Constructs a new AnnouncementSignatures given each field #[must_use] #[no_mangle] -pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures { +pub extern "C" fn AnnouncementSignatures_new(mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut short_channel_id_arg: u64, mut node_signature_arg: crate::c_types::ECDSASignature, mut bitcoin_signature_arg: crate::c_types::ECDSASignature) -> AnnouncementSignatures { AnnouncementSignatures { inner: ObjOps::heap_alloc(nativeAnnouncementSignatures { - channel_id: ::lightning::ln::ChannelId(channel_id_arg.data), + channel_id: *unsafe { Box::from_raw(channel_id_arg.take_inner()) }, short_channel_id: short_channel_id_arg, node_signature: node_signature_arg.into_rust(), bitcoin_signature: bitcoin_signature_arg.into_rust(), @@ -6757,6 +7357,11 @@ pub extern "C" fn SocketAddressParseError_hash(o: &SocketAddressParseError) -> u pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } +#[no_mangle] +/// Get the string representation of a SocketAddressParseError object +pub extern "C" fn SocketAddressParseError_to_str(o: &crate::lightning::ln::msgs::SocketAddressParseError) -> Str { + alloc::format!("{}", &o.to_native()).into() +} /// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`]. /// /// The host part must end with \".onion\". @@ -6959,6 +7564,12 @@ pub struct UnsignedNodeAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for UnsignedNodeAnnouncement { + type Target = nativeUnsignedNodeAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedNodeAnnouncement { } +unsafe impl core::marker::Sync for UnsignedNodeAnnouncement { } impl Drop for UnsignedNodeAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { @@ -6989,16 +7600,19 @@ impl UnsignedNodeAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The advertised features #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn UnsignedNodeAnnouncement_get_features(this_ptr: &UnsignedNodeAnnouncement) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// The advertised features #[no_mangle] -pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn UnsignedNodeAnnouncement_set_features(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// A strictly monotonic announcement counter, with gaps allowed @@ -7066,6 +7680,66 @@ pub extern "C" fn UnsignedNodeAnnouncement_set_addresses(this_ptr: &mut Unsigned let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val; } +/// Excess address data which was signed as a part of the message which we do not (yet) understand how +/// to decode. +/// +/// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_get_excess_address_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { + let mut inner_val = this_ptr.get_native_mut_ref().excess_address_data.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// Excess address data which was signed as a part of the message which we do not (yet) understand how +/// to decode. +/// +/// This is stored to ensure forward-compatibility as new address types are added to the lightning gossip protocol. +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_set_excess_address_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_address_data = local_val; +} +/// Excess data which was signed as a part of the message which we do not (yet) understand how +/// to decode. +/// +/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_get_excess_data(this_ptr: &UnsignedNodeAnnouncement) -> crate::c_types::derived::CVec_u8Z { + let mut inner_val = this_ptr.get_native_mut_ref().excess_data.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// Excess data which was signed as a part of the message which we do not (yet) understand how +/// to decode. +/// +/// This is stored to ensure forward-compatibility as new fields are added to the lightning gossip protocol. +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_set_excess_data(this_ptr: &mut UnsignedNodeAnnouncement, mut val: crate::c_types::derived::CVec_u8Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.excess_data = local_val; +} +/// Constructs a new UnsignedNodeAnnouncement given each field +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedNodeAnnouncement_new(mut features_arg: crate::lightning_types::features::NodeFeatures, mut timestamp_arg: u32, mut node_id_arg: crate::lightning::routing::gossip::NodeId, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ, mut excess_address_data_arg: crate::c_types::derived::CVec_u8Z, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedNodeAnnouncement { + let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; + let mut local_excess_address_data_arg = Vec::new(); for mut item in excess_address_data_arg.into_rust().drain(..) { local_excess_address_data_arg.push( { item }); }; + let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; + UnsignedNodeAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedNodeAnnouncement { + features: *unsafe { Box::from_raw(features_arg.take_inner()) }, + timestamp: timestamp_arg, + node_id: *unsafe { Box::from_raw(node_id_arg.take_inner()) }, + rgb: rgb_arg.data, + alias: *unsafe { Box::from_raw(alias_arg.take_inner()) }, + addresses: local_addresses_arg, + excess_address_data: local_excess_address_data_arg, + excess_data: local_excess_data_arg, + }), is_owned: true } +} impl Clone for UnsignedNodeAnnouncement { fn clone(&self) -> Self { Self { @@ -7129,6 +7803,12 @@ pub struct NodeAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for NodeAnnouncement { + type Target = nativeNodeAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAnnouncement { } +unsafe impl core::marker::Sync for NodeAnnouncement { } impl Drop for NodeAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeAnnouncement>::is_null(self.inner) { @@ -7159,6 +7839,9 @@ impl NodeAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The signature by the node key #[no_mangle] @@ -7254,6 +7937,12 @@ pub struct UnsignedChannelAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for UnsignedChannelAnnouncement { + type Target = nativeUnsignedChannelAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedChannelAnnouncement { } +unsafe impl core::marker::Sync for UnsignedChannelAnnouncement { } impl Drop for UnsignedChannelAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { @@ -7284,16 +7973,19 @@ impl UnsignedChannelAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The advertised channel features #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn UnsignedChannelAnnouncement_get_features(this_ptr: &UnsignedChannelAnnouncement) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// The advertised channel features #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn UnsignedChannelAnnouncement_set_features(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The genesis hash of the blockchain where the channel is to be opened @@ -7305,7 +7997,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_get_chain_hash(this_ptr: &Unsigned /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] pub extern "C" fn UnsignedChannelAnnouncement_set_chain_hash(this_ptr: &mut UnsignedChannelAnnouncement, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short channel ID #[no_mangle] @@ -7386,11 +8078,11 @@ pub extern "C" fn UnsignedChannelAnnouncement_set_excess_data(this_ptr: &mut Uns /// Constructs a new UnsignedChannelAnnouncement given each field #[must_use] #[no_mangle] -pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning::ln::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement { +pub extern "C" fn UnsignedChannelAnnouncement_new(mut features_arg: crate::lightning_types::features::ChannelFeatures, mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut node_id_1_arg: crate::lightning::routing::gossip::NodeId, mut node_id_2_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_1_arg: crate::lightning::routing::gossip::NodeId, mut bitcoin_key_2_arg: crate::lightning::routing::gossip::NodeId, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelAnnouncement { let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; UnsignedChannelAnnouncement { inner: ObjOps::heap_alloc(nativeUnsignedChannelAnnouncement { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_id: short_channel_id_arg, node_id_1: *unsafe { Box::from_raw(node_id_1_arg.take_inner()) }, node_id_2: *unsafe { Box::from_raw(node_id_2_arg.take_inner()) }, @@ -7462,6 +8154,12 @@ pub struct ChannelAnnouncement { pub is_owned: bool, } +impl core::ops::Deref for ChannelAnnouncement { + type Target = nativeChannelAnnouncement; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelAnnouncement { } +unsafe impl core::marker::Sync for ChannelAnnouncement { } impl Drop for ChannelAnnouncement { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelAnnouncement>::is_null(self.inner) { @@ -7492,6 +8190,9 @@ impl ChannelAnnouncement { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Authentication of the announcement by the first public node #[no_mangle] @@ -7623,6 +8324,12 @@ pub struct UnsignedChannelUpdate { pub is_owned: bool, } +impl core::ops::Deref for UnsignedChannelUpdate { + type Target = nativeUnsignedChannelUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedChannelUpdate { } +unsafe impl core::marker::Sync for UnsignedChannelUpdate { } impl Drop for UnsignedChannelUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { @@ -7653,6 +8360,9 @@ impl UnsignedChannelUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] @@ -7663,7 +8373,7 @@ pub extern "C" fn UnsignedChannelUpdate_get_chain_hash(this_ptr: &UnsignedChanne /// The genesis hash of the blockchain where the channel is to be opened #[no_mangle] pub extern "C" fn UnsignedChannelUpdate_set_chain_hash(this_ptr: &mut UnsignedChannelUpdate, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short channel ID #[no_mangle] @@ -7687,16 +8397,29 @@ pub extern "C" fn UnsignedChannelUpdate_get_timestamp(this_ptr: &UnsignedChannel pub extern "C" fn UnsignedChannelUpdate_set_timestamp(this_ptr: &mut UnsignedChannelUpdate, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.timestamp = val; } -/// Channel flags +/// Flags pertaining to this message. +#[no_mangle] +pub extern "C" fn UnsignedChannelUpdate_get_message_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().message_flags; + *inner_val +} +/// Flags pertaining to this message. #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_get_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().flags; +pub extern "C" fn UnsignedChannelUpdate_set_message_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.message_flags = val; +} +/// Flags pertaining to the channel, including to which direction in the channel this update +/// applies and whether the direction is currently able to forward HTLCs. +#[no_mangle] +pub extern "C" fn UnsignedChannelUpdate_get_channel_flags(this_ptr: &UnsignedChannelUpdate) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_flags; *inner_val } -/// Channel flags +/// Flags pertaining to the channel, including to which direction in the channel this update +/// applies and whether the direction is currently able to forward HTLCs. #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_set_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.flags = val; +pub extern "C" fn UnsignedChannelUpdate_set_channel_flags(this_ptr: &mut UnsignedChannelUpdate, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_flags = val; } /// The number of blocks such that if: /// `incoming_htlc.cltv_expiry < outgoing_htlc.cltv_expiry + cltv_expiry_delta` @@ -7795,13 +8518,14 @@ pub extern "C" fn UnsignedChannelUpdate_set_excess_data(this_ptr: &mut UnsignedC /// Constructs a new UnsignedChannelUpdate given each field #[must_use] #[no_mangle] -pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate { +pub extern "C" fn UnsignedChannelUpdate_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_id_arg: u64, mut timestamp_arg: u32, mut message_flags_arg: u8, mut channel_flags_arg: u8, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut excess_data_arg: crate::c_types::derived::CVec_u8Z) -> UnsignedChannelUpdate { let mut local_excess_data_arg = Vec::new(); for mut item in excess_data_arg.into_rust().drain(..) { local_excess_data_arg.push( { item }); }; UnsignedChannelUpdate { inner: ObjOps::heap_alloc(nativeUnsignedChannelUpdate { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_id: short_channel_id_arg, timestamp: timestamp_arg, - flags: flags_arg, + message_flags: message_flags_arg, + channel_flags: channel_flags_arg, cltv_expiry_delta: cltv_expiry_delta_arg, htlc_minimum_msat: htlc_minimum_msat_arg, htlc_maximum_msat: htlc_maximum_msat_arg, @@ -7873,6 +8597,12 @@ pub struct ChannelUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelUpdate { + type Target = nativeChannelUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUpdate { } +unsafe impl core::marker::Sync for ChannelUpdate { } impl Drop for ChannelUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUpdate>::is_null(self.inner) { @@ -7903,6 +8633,9 @@ impl ChannelUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A signature of the channel update #[no_mangle] @@ -8001,6 +8734,12 @@ pub struct QueryChannelRange { pub is_owned: bool, } +impl core::ops::Deref for QueryChannelRange { + type Target = nativeQueryChannelRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for QueryChannelRange { } +unsafe impl core::marker::Sync for QueryChannelRange { } impl Drop for QueryChannelRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeQueryChannelRange>::is_null(self.inner) { @@ -8031,6 +8770,9 @@ impl QueryChannelRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -8041,7 +8783,7 @@ pub extern "C" fn QueryChannelRange_get_chain_hash(this_ptr: &QueryChannelRange) /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn QueryChannelRange_set_chain_hash(this_ptr: &mut QueryChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The height of the first block for the channel UTXOs being queried #[no_mangle] @@ -8070,7 +8812,7 @@ pub extern "C" fn QueryChannelRange_set_number_of_blocks(this_ptr: &mut QueryCha #[no_mangle] pub extern "C" fn QueryChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32) -> QueryChannelRange { QueryChannelRange { inner: ObjOps::heap_alloc(nativeQueryChannelRange { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_blocknum: first_blocknum_arg, number_of_blocks: number_of_blocks_arg, }), is_owned: true } @@ -8146,6 +8888,12 @@ pub struct ReplyChannelRange { pub is_owned: bool, } +impl core::ops::Deref for ReplyChannelRange { + type Target = nativeReplyChannelRange; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplyChannelRange { } +unsafe impl core::marker::Sync for ReplyChannelRange { } impl Drop for ReplyChannelRange { fn drop(&mut self) { if self.is_owned && !<*mut nativeReplyChannelRange>::is_null(self.inner) { @@ -8176,6 +8924,9 @@ impl ReplyChannelRange { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -8186,7 +8937,7 @@ pub extern "C" fn ReplyChannelRange_get_chain_hash(this_ptr: &ReplyChannelRange) /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn ReplyChannelRange_set_chain_hash(this_ptr: &mut ReplyChannelRange, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The height of the first block in the range of the reply #[no_mangle] @@ -8242,7 +8993,7 @@ pub extern "C" fn ReplyChannelRange_set_short_channel_ids(this_ptr: &mut ReplyCh pub extern "C" fn ReplyChannelRange_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_blocknum_arg: u32, mut number_of_blocks_arg: u32, mut sync_complete_arg: bool, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> ReplyChannelRange { let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; ReplyChannelRange { inner: ObjOps::heap_alloc(nativeReplyChannelRange { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_blocknum: first_blocknum_arg, number_of_blocks: number_of_blocks_arg, sync_complete: sync_complete_arg, @@ -8320,6 +9071,12 @@ pub struct QueryShortChannelIds { pub is_owned: bool, } +impl core::ops::Deref for QueryShortChannelIds { + type Target = nativeQueryShortChannelIds; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for QueryShortChannelIds { } +unsafe impl core::marker::Sync for QueryShortChannelIds { } impl Drop for QueryShortChannelIds { fn drop(&mut self) { if self.is_owned && !<*mut nativeQueryShortChannelIds>::is_null(self.inner) { @@ -8350,6 +9107,9 @@ impl QueryShortChannelIds { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain being queried #[no_mangle] @@ -8360,7 +9120,7 @@ pub extern "C" fn QueryShortChannelIds_get_chain_hash(this_ptr: &QueryShortChann /// The genesis hash of the blockchain being queried #[no_mangle] pub extern "C" fn QueryShortChannelIds_set_chain_hash(this_ptr: &mut QueryShortChannelIds, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The short_channel_ids that are being queried /// @@ -8383,7 +9143,7 @@ pub extern "C" fn QueryShortChannelIds_set_short_channel_ids(this_ptr: &mut Quer pub extern "C" fn QueryShortChannelIds_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut short_channel_ids_arg: crate::c_types::derived::CVec_u64Z) -> QueryShortChannelIds { let mut local_short_channel_ids_arg = Vec::new(); for mut item in short_channel_ids_arg.into_rust().drain(..) { local_short_channel_ids_arg.push( { item }); }; QueryShortChannelIds { inner: ObjOps::heap_alloc(nativeQueryShortChannelIds { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), short_channel_ids: local_short_channel_ids_arg, }), is_owned: true } } @@ -8453,6 +9213,12 @@ pub struct ReplyShortChannelIdsEnd { pub is_owned: bool, } +impl core::ops::Deref for ReplyShortChannelIdsEnd { + type Target = nativeReplyShortChannelIdsEnd; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReplyShortChannelIdsEnd { } +unsafe impl core::marker::Sync for ReplyShortChannelIdsEnd { } impl Drop for ReplyShortChannelIdsEnd { fn drop(&mut self) { if self.is_owned && !<*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { @@ -8483,6 +9249,9 @@ impl ReplyShortChannelIdsEnd { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain that was queried #[no_mangle] @@ -8493,7 +9262,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_get_chain_hash(this_ptr: &ReplyShortCh /// The genesis hash of the blockchain that was queried #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_set_chain_hash(this_ptr: &mut ReplyShortChannelIdsEnd, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// Indicates if the query recipient maintains up-to-date channel /// information for the `chain_hash` @@ -8513,7 +9282,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_set_full_information(this_ptr: &mut Re #[no_mangle] pub extern "C" fn ReplyShortChannelIdsEnd_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut full_information_arg: bool) -> ReplyShortChannelIdsEnd { ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(nativeReplyShortChannelIdsEnd { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), full_information: full_information_arg, }), is_owned: true } } @@ -8582,6 +9351,12 @@ pub struct GossipTimestampFilter { pub is_owned: bool, } +impl core::ops::Deref for GossipTimestampFilter { + type Target = nativeGossipTimestampFilter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for GossipTimestampFilter { } +unsafe impl core::marker::Sync for GossipTimestampFilter { } impl Drop for GossipTimestampFilter { fn drop(&mut self) { if self.is_owned && !<*mut nativeGossipTimestampFilter>::is_null(self.inner) { @@ -8612,6 +9387,9 @@ impl GossipTimestampFilter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The genesis hash of the blockchain for channel and node information #[no_mangle] @@ -8622,7 +9400,7 @@ pub extern "C" fn GossipTimestampFilter_get_chain_hash(this_ptr: &GossipTimestam /// The genesis hash of the blockchain for channel and node information #[no_mangle] pub extern "C" fn GossipTimestampFilter_set_chain_hash(this_ptr: &mut GossipTimestampFilter, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::blockdata::constants::ChainHash::from(&val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.chain_hash = ::bitcoin::constants::ChainHash::from(&val.data); } /// The starting unix timestamp #[no_mangle] @@ -8651,7 +9429,7 @@ pub extern "C" fn GossipTimestampFilter_set_timestamp_range(this_ptr: &mut Gossi #[no_mangle] pub extern "C" fn GossipTimestampFilter_new(mut chain_hash_arg: crate::c_types::ThirtyTwoBytes, mut first_timestamp_arg: u32, mut timestamp_range_arg: u32) -> GossipTimestampFilter { GossipTimestampFilter { inner: ObjOps::heap_alloc(nativeGossipTimestampFilter { - chain_hash: ::bitcoin::blockdata::constants::ChainHash::from(&chain_hash_arg.data), + chain_hash: ::bitcoin::constants::ChainHash::from(&chain_hash_arg.data), first_timestamp: first_timestamp_arg, timestamp_range: timestamp_range_arg, }), is_owned: true } @@ -8985,6 +9763,12 @@ pub struct LightningError { pub is_owned: bool, } +impl core::ops::Deref for LightningError { + type Target = nativeLightningError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for LightningError { } +unsafe impl core::marker::Sync for LightningError { } impl Drop for LightningError { fn drop(&mut self) { if self.is_owned && !<*mut nativeLightningError>::is_null(self.inner) { @@ -9015,6 +9799,9 @@ impl LightningError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A human-readable message describing the error #[no_mangle] @@ -9090,6 +9877,12 @@ pub struct CommitmentUpdate { pub is_owned: bool, } +impl core::ops::Deref for CommitmentUpdate { + type Target = nativeCommitmentUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for CommitmentUpdate { } +unsafe impl core::marker::Sync for CommitmentUpdate { } impl Drop for CommitmentUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeCommitmentUpdate>::is_null(self.inner) { @@ -9120,6 +9913,9 @@ impl CommitmentUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// `update_add_htlc` messages which should be sent #[no_mangle] @@ -9291,12 +10087,6 @@ pub struct ChannelMessageHandler { pub handle_closing_signed: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned), /// Handle an incoming `stfu` message from the given peer. pub handle_stfu: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu), - /// Handle an incoming `splice` message from the given peer. - pub handle_splice: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice), - /// Handle an incoming `splice_ack` message from the given peer. - pub handle_splice_ack: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck), - /// Handle an incoming `splice_locked` message from the given peer. - pub handle_splice_locked: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked), /// Handle an incoming `tx_add_input message` from the given peer. pub handle_tx_add_input: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput), /// Handle an incoming `tx_add_output` message from the given peer. @@ -9348,13 +10138,13 @@ pub struct ChannelMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Gets the chain hashes for this `ChannelMessageHandler` indicating which chains it supports. /// /// If it's `None`, then no particular network chain hash compatibility will be enforced when @@ -9382,9 +10172,6 @@ pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) - handle_shutdown: Clone::clone(&orig.handle_shutdown), handle_closing_signed: Clone::clone(&orig.handle_closing_signed), handle_stfu: Clone::clone(&orig.handle_stfu), - handle_splice: Clone::clone(&orig.handle_splice), - handle_splice_ack: Clone::clone(&orig.handle_splice_ack), - handle_splice_locked: Clone::clone(&orig.handle_splice_locked), handle_tx_add_input: Clone::clone(&orig.handle_tx_add_input), handle_tx_add_output: Clone::clone(&orig.handle_tx_add_output), handle_tx_remove_input: Clone::clone(&orig.handle_tx_remove_input), @@ -9413,135 +10200,248 @@ pub(crate) fn ChannelMessageHandler_clone_fields(orig: &ChannelMessageHandler) - MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider_clone_fields(&orig.MessageSendEventsProvider), free: Clone::clone(&orig.free), } -} -impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler { - fn get_and_clear_pending_msg_events(&self) -> Vec { - let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; +} +impl lightning::events::MessageSendEventsProvider for ChannelMessageHandler { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.MessageSendEventsProvider.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} +impl lightning::events::MessageSendEventsProvider for ChannelMessageHandlerRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.0.MessageSendEventsProvider.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} + +use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler; +impl rustChannelMessageHandler for ChannelMessageHandler { + fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) { + (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) + } + fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) { + (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false }) + } + fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) { + (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) + } + fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) { + (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false }) + } + fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { + (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) + } + fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) { + (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false }) + } + fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) { + (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false }) + } + fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) { + (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false }) + } + fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { + (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) + } + fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) { + (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) { + (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) { + (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) { + (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) { + (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) { + (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) { + (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) { + (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) { + (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false }) + } + fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) { + (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false }) + } + fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { + (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) { + (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) { + (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { + (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false }) + } + fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) { + (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }) + } + fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) { + (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false }) + } + fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) { + (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false }) + } + fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) { + (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false }) + } + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) { + (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false }) + } + fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) { + (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }) + } + fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { + (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.provided_node_features)(self.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn get_chain_hashes(&self) -> Option> { + let mut ret = (self.get_chain_hashes)(self.this_arg); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} }; local_ret } } -use lightning::ln::msgs::ChannelMessageHandler as rustChannelMessageHandler; -impl rustChannelMessageHandler for ChannelMessageHandler { +pub struct ChannelMessageHandlerRef(ChannelMessageHandler); +impl rustChannelMessageHandler for ChannelMessageHandlerRef { fn handle_open_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannel) { - (self.handle_open_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) + (self.0.handle_open_channel)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannel<>) as *mut _) }, is_owned: false }) } fn handle_open_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OpenChannelV2) { - (self.handle_open_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false }) + (self.0.handle_open_channel_v2)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::OpenChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OpenChannelV2<>) as *mut _) }, is_owned: false }) } fn handle_accept_channel(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannel) { - (self.handle_accept_channel)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) + (self.0.handle_accept_channel)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannel { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannel<>) as *mut _) }, is_owned: false }) } fn handle_accept_channel_v2(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AcceptChannelV2) { - (self.handle_accept_channel_v2)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false }) + (self.0.handle_accept_channel_v2)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AcceptChannelV2 { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AcceptChannelV2<>) as *mut _) }, is_owned: false }) } fn handle_funding_created(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingCreated) { - (self.handle_funding_created)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) + (self.0.handle_funding_created)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingCreated { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingCreated<>) as *mut _) }, is_owned: false }) } fn handle_funding_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::FundingSigned) { - (self.handle_funding_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false }) + (self.0.handle_funding_signed)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::FundingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::FundingSigned<>) as *mut _) }, is_owned: false }) } fn handle_channel_ready(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReady) { - (self.handle_channel_ready)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false }) + (self.0.handle_channel_ready)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReady { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReady<>) as *mut _) }, is_owned: false }) } fn handle_shutdown(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Shutdown) { - (self.handle_shutdown)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false }) + (self.0.handle_shutdown)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Shutdown { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Shutdown<>) as *mut _) }, is_owned: false }) } fn handle_closing_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ClosingSigned) { - (self.handle_closing_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) + (self.0.handle_closing_signed)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ClosingSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ClosingSigned<>) as *mut _) }, is_owned: false }) } fn handle_stfu(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Stfu) { - (self.handle_stfu)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false }) - } - fn handle_splice(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Splice) { - (self.handle_splice)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Splice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Splice<>) as *mut _) }, is_owned: false }) - } - fn handle_splice_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceAck) { - (self.handle_splice_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceAck { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceAck<>) as *mut _) }, is_owned: false }) - } - fn handle_splice_locked(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::SpliceLocked) { - (self.handle_splice_locked)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::SpliceLocked { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::SpliceLocked<>) as *mut _) }, is_owned: false }) + (self.0.handle_stfu)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Stfu { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Stfu<>) as *mut _) }, is_owned: false }) } fn handle_tx_add_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddInput) { - (self.handle_tx_add_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_add_input)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddInput<>) as *mut _) }, is_owned: false }) } fn handle_tx_add_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAddOutput) { - (self.handle_tx_add_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_add_output)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAddOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAddOutput<>) as *mut _) }, is_owned: false }) } fn handle_tx_remove_input(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveInput) { - (self.handle_tx_remove_input)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_remove_input)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveInput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveInput<>) as *mut _) }, is_owned: false }) } fn handle_tx_remove_output(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxRemoveOutput) { - (self.handle_tx_remove_output)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_remove_output)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxRemoveOutput { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxRemoveOutput<>) as *mut _) }, is_owned: false }) } fn handle_tx_complete(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxComplete) { - (self.handle_tx_complete)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_complete)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxComplete { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxComplete<>) as *mut _) }, is_owned: false }) } fn handle_tx_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxSignatures) { - (self.handle_tx_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_signatures)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxSignatures<>) as *mut _) }, is_owned: false }) } fn handle_tx_init_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxInitRbf) { - (self.handle_tx_init_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_init_rbf)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxInitRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxInitRbf<>) as *mut _) }, is_owned: false }) } fn handle_tx_ack_rbf(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAckRbf) { - (self.handle_tx_ack_rbf)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_ack_rbf)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAckRbf { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAckRbf<>) as *mut _) }, is_owned: false }) } fn handle_tx_abort(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::TxAbort) { - (self.handle_tx_abort)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false }) + (self.0.handle_tx_abort)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::TxAbort { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::TxAbort<>) as *mut _) }, is_owned: false }) } fn handle_update_add_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateAddHTLC) { - (self.handle_update_add_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) + (self.0.handle_update_add_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateAddHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateAddHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fulfill_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFulfillHTLC) { - (self.handle_update_fulfill_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false }) + (self.0.handle_update_fulfill_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFulfillHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFulfillHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fail_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailHTLC) { - (self.handle_update_fail_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false }) + (self.0.handle_update_fail_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailHTLC<>) as *mut _) }, is_owned: false }) } fn handle_update_fail_malformed_htlc(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFailMalformedHTLC) { - (self.handle_update_fail_malformed_htlc)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false }) + (self.0.handle_update_fail_malformed_htlc)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFailMalformedHTLC { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFailMalformedHTLC<>) as *mut _) }, is_owned: false }) } fn handle_commitment_signed(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::CommitmentSigned) { - (self.handle_commitment_signed)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }) + (self.0.handle_commitment_signed)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::CommitmentSigned { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::CommitmentSigned<>) as *mut _) }, is_owned: false }) } fn handle_revoke_and_ack(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::RevokeAndACK) { - (self.handle_revoke_and_ack)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false }) + (self.0.handle_revoke_and_ack)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::RevokeAndACK { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::RevokeAndACK<>) as *mut _) }, is_owned: false }) } fn handle_update_fee(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::UpdateFee) { - (self.handle_update_fee)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false }) + (self.0.handle_update_fee)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::UpdateFee { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UpdateFee<>) as *mut _) }, is_owned: false }) } fn handle_announcement_signatures(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::AnnouncementSignatures) { - (self.handle_announcement_signatures)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false }) + (self.0.handle_announcement_signatures)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::AnnouncementSignatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::AnnouncementSignatures<>) as *mut _) }, is_owned: false }) } fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { - (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) } fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { - let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn handle_channel_reestablish(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelReestablish) { - (self.handle_channel_reestablish)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false }) + (self.0.handle_channel_reestablish)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelReestablish { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelReestablish<>) as *mut _) }, is_owned: false }) } fn handle_channel_update(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ChannelUpdate) { - (self.handle_channel_update)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }) + (self.0.handle_channel_update)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }) } fn handle_error(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::ErrorMessage) { - (self.handle_error)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) + (self.0.handle_error)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::ErrorMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ErrorMessage<>) as *mut _) }, is_owned: false }) } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { - let mut ret = (self.provided_node_features)(self.this_arg); + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); *unsafe { Box::from_raw(ret.take_inner()) } } - fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { - let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } - fn get_chain_hashes(&self) -> Option> { - let mut ret = (self.get_chain_hashes)(self.this_arg); - let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::blockdata::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} }; + fn get_chain_hashes(&self) -> Option> { + let mut ret = (self.0.get_chain_hashes)(self.0.this_arg); + let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { let mut local_ret_0 = Vec::new(); for mut item in { ret_opt.take() }.into_rust().drain(..) { local_ret_0.push( { ::bitcoin::constants::ChainHash::from(&item.data) }); }; local_ret_0 }})} }; local_ret } } @@ -9549,14 +10449,14 @@ impl rustChannelMessageHandler for ChannelMessageHandler { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for ChannelMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ChannelMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChannelMessageHandlerRef) } } } impl core::ops::DerefMut for ChannelMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ChannelMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut ChannelMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9633,13 +10533,13 @@ pub struct RoutingMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Implementation of MessageSendEventsProvider for this object. pub MessageSendEventsProvider: crate::lightning::events::MessageSendEventsProvider, /// Frees any resources associated with this object given its this_arg pointer. @@ -9676,6 +10576,13 @@ impl lightning::events::MessageSendEventsProvider for RoutingMessageHandler { local_ret } } +impl lightning::events::MessageSendEventsProvider for RoutingMessageHandlerRef { + fn get_and_clear_pending_msg_events(&self) -> Vec { + let mut ret = (self.0.MessageSendEventsProvider.get_and_clear_pending_msg_events)(self.0.MessageSendEventsProvider.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { item.into_native() }); }; + local_ret + } +} use lightning::ln::msgs::RoutingMessageHandler as rustRoutingMessageHandler; impl rustRoutingMessageHandler for RoutingMessageHandler { @@ -9734,27 +10641,94 @@ impl rustRoutingMessageHandler for RoutingMessageHandler { let mut ret = (self.processing_queue_high)(self.this_arg); ret } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { let mut ret = (self.provided_node_features)(self.this_arg); *unsafe { Box::from_raw(ret.take_inner()) } } - fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } } +pub struct RoutingMessageHandlerRef(RoutingMessageHandler); +impl rustRoutingMessageHandler for RoutingMessageHandlerRef { + fn handle_node_announcement(&self, mut msg: &lightning::ln::msgs::NodeAnnouncement) -> Result { + let mut ret = (self.0.handle_node_announcement)(self.0.this_arg, &crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_announcement(&self, mut msg: &lightning::ln::msgs::ChannelAnnouncement) -> Result { + let mut ret = (self.0.handle_channel_announcement)(self.0.this_arg, &crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_channel_update(&self, mut msg: &lightning::ln::msgs::ChannelUpdate) -> Result { + let mut ret = (self.0.handle_channel_update)(self.0.this_arg, &crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn get_next_channel_announcement(&self, mut starting_point: u64) -> Option<(lightning::ln::msgs::ChannelAnnouncement, Option, Option)> { + let mut ret = (self.0.get_next_channel_announcement)(self.0.this_arg, starting_point); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = ret.take().to_rust(); let mut local_orig_ret_0_1 = if orig_ret_0_1.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) } }) }; let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, local_orig_ret_0_1, local_orig_ret_0_2); local_ret_0 }) } else { None }; + local_ret + } + fn get_next_node_announcement(&self, mut starting_point: Option<&lightning::routing::gossip::NodeId>) -> Option { + let mut local_starting_point = crate::lightning::routing::gossip::NodeId { inner: unsafe { (if starting_point.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (starting_point.unwrap()) }) } as *const lightning::routing::gossip::NodeId<>) as *mut _ }, is_owned: false }; + let mut ret = (self.0.get_next_node_announcement)(self.0.this_arg, local_starting_point); + let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; + local_ret + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn handle_reply_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_reply_channel_range)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_reply_short_channel_ids_end(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::ReplyShortChannelIdsEnd) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_reply_short_channel_ids_end)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::ReplyShortChannelIdsEnd { inner: ObjOps::heap_alloc(msg), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_channel_range(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryChannelRange) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_query_channel_range)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryChannelRange { inner: ObjOps::heap_alloc(msg), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn handle_query_short_channel_ids(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: lightning::ln::msgs::QueryShortChannelIds) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_query_short_channel_ids)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), crate::lightning::ln::msgs::QueryShortChannelIds { inner: ObjOps::heap_alloc(msg), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn processing_queue_high(&self) -> bool { + let mut ret = (self.0.processing_queue_high)(self.0.this_arg); + ret + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for RoutingMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = RoutingMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const RoutingMessageHandlerRef) } } } impl core::ops::DerefMut for RoutingMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut RoutingMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut RoutingMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9773,14 +10747,6 @@ pub struct OnionMessageHandler { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, - /// Because much of the lightning network does not yet support forwarding onion messages, we - /// may need to directly connect to a node which will forward a message for us. In such a case, - /// this method will return the set of nodes which need connection by node_id and the - /// corresponding socket addresses where they may accept incoming connections. - /// - /// Thus, this method should be polled regularly to detect messages await such a direct - /// connection. - pub get_and_clear_connections_needed: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ, /// Handle an incoming `onion_message` message from the given peer. pub handle_onion_message: extern "C" fn (this_arg: *const c_void, peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage), /// Returns the next pending onion message for the peer with the given node id. @@ -9803,13 +10769,13 @@ pub struct OnionMessageHandler { /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// Note that this method is called before [`Self::peer_connected`]. - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -9820,7 +10786,6 @@ unsafe impl Sync for OnionMessageHandler {} pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> OnionMessageHandler { OnionMessageHandler { this_arg: orig.this_arg, - get_and_clear_connections_needed: Clone::clone(&orig.get_and_clear_connections_needed), handle_onion_message: Clone::clone(&orig.handle_onion_message), next_onion_message_for_peer: Clone::clone(&orig.next_onion_message_for_peer), peer_connected: Clone::clone(&orig.peer_connected), @@ -9834,11 +10799,6 @@ pub(crate) fn OnionMessageHandler_clone_fields(orig: &OnionMessageHandler) -> On use lightning::ln::msgs::OnionMessageHandler as rustOnionMessageHandler; impl rustOnionMessageHandler for OnionMessageHandler { - fn get_and_clear_connections_needed(&self) -> Vec<(bitcoin::secp256k1::PublicKey, Vec)> { - let mut ret = (self.get_and_clear_connections_needed)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_native() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }); }; - local_ret - } fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) { (self.handle_onion_message)(self.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false }) } @@ -9858,27 +10818,58 @@ impl rustOnionMessageHandler for OnionMessageHandler { fn timer_tick_occurred(&self) { (self.timer_tick_occurred)(self.this_arg) } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { let mut ret = (self.provided_node_features)(self.this_arg); *unsafe { Box::from_raw(ret.take_inner()) } } - fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } } +pub struct OnionMessageHandlerRef(OnionMessageHandler); +impl rustOnionMessageHandler for OnionMessageHandlerRef { + fn handle_onion_message(&self, mut peer_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::OnionMessage) { + (self.0.handle_onion_message)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id), &crate::lightning::ln::msgs::OnionMessage { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::OnionMessage<>) as *mut _) }, is_owned: false }) + } + fn next_onion_message_for_peer(&self, mut peer_node_id: bitcoin::secp256k1::PublicKey) -> Option { + let mut ret = (self.0.next_onion_message_for_peer)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&peer_node_id)); + let mut local_ret = if ret.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(ret.take_inner()) } }) }; + local_ret + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut init: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((init as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn timer_tick_occurred(&self) { + (self.0.timer_tick_occurred)(self.0.this_arg) + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for OnionMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OnionMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OnionMessageHandlerRef) } } } impl core::ops::DerefMut for OnionMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OnionMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut OnionMessageHandlerRef) } } } /// Calls the free function if one is set @@ -9912,6 +10903,12 @@ pub struct FinalOnionHopData { pub is_owned: bool, } +impl core::ops::Deref for FinalOnionHopData { + type Target = nativeFinalOnionHopData; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FinalOnionHopData { } +unsafe impl core::marker::Sync for FinalOnionHopData { } impl Drop for FinalOnionHopData { fn drop(&mut self) { if self.is_owned && !<*mut nativeFinalOnionHopData>::is_null(self.inner) { @@ -9942,6 +10939,9 @@ impl FinalOnionHopData { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs. /// Because it is generated by the recipient and included in the invoice, it also provides @@ -9956,7 +10956,7 @@ pub extern "C" fn FinalOnionHopData_get_payment_secret(this_ptr: &FinalOnionHopD /// proof to the recipient that the payment was sent by someone with the generated invoice. #[no_mangle] pub extern "C" fn FinalOnionHopData_set_payment_secret(this_ptr: &mut FinalOnionHopData, mut val: crate::c_types::ThirtyTwoBytes) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::PaymentSecret(val.data); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = ::lightning::ln::types::PaymentSecret(val.data); } /// The intended total amount that this payment is for. /// @@ -9978,7 +10978,7 @@ pub extern "C" fn FinalOnionHopData_set_total_msat(this_ptr: &mut FinalOnionHopD #[no_mangle] pub extern "C" fn FinalOnionHopData_new(mut payment_secret_arg: crate::c_types::ThirtyTwoBytes, mut total_msat_arg: u64) -> FinalOnionHopData { FinalOnionHopData { inner: ObjOps::heap_alloc(nativeFinalOnionHopData { - payment_secret: ::lightning::ln::PaymentSecret(payment_secret_arg.data), + payment_secret: ::lightning::ln::types::PaymentSecret(payment_secret_arg.data), total_msat: total_msat_arg, }), is_owned: true } } @@ -10033,6 +11033,12 @@ pub struct OnionPacket { pub is_owned: bool, } +impl core::ops::Deref for OnionPacket { + type Target = nativeOnionPacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionPacket { } +unsafe impl core::marker::Sync for OnionPacket { } impl Drop for OnionPacket { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionPacket>::is_null(self.inner) { @@ -10063,6 +11069,9 @@ impl OnionPacket { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// BOLT 4 version number. #[no_mangle] @@ -10150,6 +11159,181 @@ pub extern "C" fn OnionPacket_eq(a: &OnionPacket, b: &OnionPacket) -> bool { /// Get a string which allows debug introspection of a OnionPacket object pub extern "C" fn OnionPacket_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::OnionPacket }).into()} + +use lightning::ln::msgs::TrampolineOnionPacket as nativeTrampolineOnionPacketImport; +pub(crate) type nativeTrampolineOnionPacket = nativeTrampolineOnionPacketImport; + +/// BOLT 4 onion packet including hop data for the next peer. +#[must_use] +#[repr(C)] +pub struct TrampolineOnionPacket { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTrampolineOnionPacket, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for TrampolineOnionPacket { + type Target = nativeTrampolineOnionPacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrampolineOnionPacket { } +unsafe impl core::marker::Sync for TrampolineOnionPacket { } +impl Drop for TrampolineOnionPacket { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTrampolineOnionPacket>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TrampolineOnionPacket, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_free(this_obj: TrampolineOnionPacket) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TrampolineOnionPacket_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrampolineOnionPacket) }; +} +#[allow(unused)] +impl TrampolineOnionPacket { + pub(crate) fn get_native_ref(&self) -> &'static nativeTrampolineOnionPacket { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrampolineOnionPacket { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTrampolineOnionPacket { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Bolt 04 version number +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_get_version(this_ptr: &TrampolineOnionPacket) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().version; + *inner_val +} +/// Bolt 04 version number +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_set_version(this_ptr: &mut TrampolineOnionPacket, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.version = val; +} +/// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_get_public_key(this_ptr: &TrampolineOnionPacket) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().public_key; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A random sepc256k1 point, used to build the ECDH shared secret to decrypt hop_data +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_set_public_key(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.public_key = val.into_rust(); +} +/// Encrypted payload for the next hop +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_get_hop_data(this_ptr: &TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z { + let mut inner_val = this_ptr.get_native_mut_ref().hop_data.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { item }); }; + local_inner_val.into() +} +/// Encrypted payload for the next hop +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_set_hop_data(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::derived::CVec_u8Z) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hop_data = local_val; +} +/// HMAC to verify the integrity of hop_data +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_get_hmac(this_ptr: &TrampolineOnionPacket) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().hmac; + inner_val +} +/// HMAC to verify the integrity of hop_data +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_set_hmac(this_ptr: &mut TrampolineOnionPacket, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hmac = val.data; +} +/// Constructs a new TrampolineOnionPacket given each field +#[must_use] +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_new(mut version_arg: u8, mut public_key_arg: crate::c_types::PublicKey, mut hop_data_arg: crate::c_types::derived::CVec_u8Z, mut hmac_arg: crate::c_types::ThirtyTwoBytes) -> TrampolineOnionPacket { + let mut local_hop_data_arg = Vec::new(); for mut item in hop_data_arg.into_rust().drain(..) { local_hop_data_arg.push( { item }); }; + TrampolineOnionPacket { inner: ObjOps::heap_alloc(nativeTrampolineOnionPacket { + version: version_arg, + public_key: public_key_arg.into_rust(), + hop_data: local_hop_data_arg, + hmac: hmac_arg.data, + }), is_owned: true } +} +impl Clone for TrampolineOnionPacket { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTrampolineOnionPacket>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TrampolineOnionPacket_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrampolineOnionPacket)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TrampolineOnionPacket +pub extern "C" fn TrampolineOnionPacket_clone(orig: &TrampolineOnionPacket) -> TrampolineOnionPacket { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the TrampolineOnionPacket. +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_hash(o: &TrampolineOnionPacket) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two TrampolineOnionPackets contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TrampolineOnionPacket_eq(a: &TrampolineOnionPacket, b: &TrampolineOnionPacket) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the TrampolineOnionPacket object into a byte array which can be read by TrampolineOnionPacket_read +pub extern "C" fn TrampolineOnionPacket_write(obj: &crate::lightning::ln::msgs::TrampolineOnionPacket) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn TrampolineOnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTrampolineOnionPacket) }) +} +/// Get a string which allows debug introspection of a TrampolineOnionPacket object +pub extern "C" fn TrampolineOnionPacket_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::msgs::TrampolineOnionPacket }).into()} +#[no_mangle] +/// Get the string representation of a DecodeError object +pub extern "C" fn DecodeError_to_str(o: &crate::lightning::ln::msgs::DecodeError) -> Str { + alloc::format!("{}", &o.to_native()).into() +} #[no_mangle] /// Serialize the AcceptChannel object into a byte array which can be read by AcceptChannel_read pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptChannel) -> crate::c_types::derived::CVec_u8Z { @@ -10157,7 +11341,7 @@ pub extern "C" fn AcceptChannel_write(obj: &crate::lightning::ln::msgs::AcceptCh } #[allow(unused)] pub(crate) extern "C" fn AcceptChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannel) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAcceptChannel) }) } #[no_mangle] /// Read a AcceptChannel from a byte array, created by AcceptChannel_write @@ -10173,7 +11357,7 @@ pub extern "C" fn AcceptChannelV2_write(obj: &crate::lightning::ln::msgs::Accept } #[allow(unused)] pub(crate) extern "C" fn AcceptChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAcceptChannelV2) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAcceptChannelV2) }) } #[no_mangle] /// Read a AcceptChannelV2 from a byte array, created by AcceptChannelV2_write @@ -10189,7 +11373,7 @@ pub extern "C" fn Stfu_write(obj: &crate::lightning::ln::msgs::Stfu) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Stfu_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStfu) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeStfu) }) } #[no_mangle] /// Read a Stfu from a byte array, created by Stfu_write @@ -10199,19 +11383,19 @@ pub extern "C" fn Stfu_read(ser: crate::c_types::u8slice) -> crate::c_types::der local_res } #[no_mangle] -/// Serialize the Splice object into a byte array which can be read by Splice_read -pub extern "C" fn Splice_write(obj: &crate::lightning::ln::msgs::Splice) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the SpliceInit object into a byte array which can be read by SpliceInit_read +pub extern "C" fn SpliceInit_write(obj: &crate::lightning::ln::msgs::SpliceInit) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] -pub(crate) extern "C" fn Splice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSplice) }) +pub(crate) extern "C" fn SpliceInit_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceInit) }) } #[no_mangle] -/// Read a Splice from a byte array, created by Splice_write -pub extern "C" fn Splice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::Splice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; +/// Read a SpliceInit from a byte array, created by SpliceInit_write +pub extern "C" fn SpliceInit_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_SpliceInitDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SpliceInit { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } #[no_mangle] @@ -10221,7 +11405,7 @@ pub extern "C" fn SpliceAck_write(obj: &crate::lightning::ln::msgs::SpliceAck) - } #[allow(unused)] pub(crate) extern "C" fn SpliceAck_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceAck) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceAck) }) } #[no_mangle] /// Read a SpliceAck from a byte array, created by SpliceAck_write @@ -10237,7 +11421,7 @@ pub extern "C" fn SpliceLocked_write(obj: &crate::lightning::ln::msgs::SpliceLoc } #[allow(unused)] pub(crate) extern "C" fn SpliceLocked_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeSpliceLocked) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeSpliceLocked) }) } #[no_mangle] /// Read a SpliceLocked from a byte array, created by SpliceLocked_write @@ -10253,7 +11437,7 @@ pub extern "C" fn TxAddInput_write(obj: &crate::lightning::ln::msgs::TxAddInput) } #[allow(unused)] pub(crate) extern "C" fn TxAddInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddInput) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAddInput) }) } #[no_mangle] /// Read a TxAddInput from a byte array, created by TxAddInput_write @@ -10269,7 +11453,7 @@ pub extern "C" fn TxAddOutput_write(obj: &crate::lightning::ln::msgs::TxAddOutpu } #[allow(unused)] pub(crate) extern "C" fn TxAddOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAddOutput) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAddOutput) }) } #[no_mangle] /// Read a TxAddOutput from a byte array, created by TxAddOutput_write @@ -10285,7 +11469,7 @@ pub extern "C" fn TxRemoveInput_write(obj: &crate::lightning::ln::msgs::TxRemove } #[allow(unused)] pub(crate) extern "C" fn TxRemoveInput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveInput) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxRemoveInput) }) } #[no_mangle] /// Read a TxRemoveInput from a byte array, created by TxRemoveInput_write @@ -10301,7 +11485,7 @@ pub extern "C" fn TxRemoveOutput_write(obj: &crate::lightning::ln::msgs::TxRemov } #[allow(unused)] pub(crate) extern "C" fn TxRemoveOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxRemoveOutput) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxRemoveOutput) }) } #[no_mangle] /// Read a TxRemoveOutput from a byte array, created by TxRemoveOutput_write @@ -10317,7 +11501,7 @@ pub extern "C" fn TxComplete_write(obj: &crate::lightning::ln::msgs::TxComplete) } #[allow(unused)] pub(crate) extern "C" fn TxComplete_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxComplete) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxComplete) }) } #[no_mangle] /// Read a TxComplete from a byte array, created by TxComplete_write @@ -10333,7 +11517,7 @@ pub extern "C" fn TxSignatures_write(obj: &crate::lightning::ln::msgs::TxSignatu } #[allow(unused)] pub(crate) extern "C" fn TxSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxSignatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxSignatures) }) } #[no_mangle] /// Read a TxSignatures from a byte array, created by TxSignatures_write @@ -10349,7 +11533,7 @@ pub extern "C" fn TxInitRbf_write(obj: &crate::lightning::ln::msgs::TxInitRbf) - } #[allow(unused)] pub(crate) extern "C" fn TxInitRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxInitRbf) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxInitRbf) }) } #[no_mangle] /// Read a TxInitRbf from a byte array, created by TxInitRbf_write @@ -10365,7 +11549,7 @@ pub extern "C" fn TxAckRbf_write(obj: &crate::lightning::ln::msgs::TxAckRbf) -> } #[allow(unused)] pub(crate) extern "C" fn TxAckRbf_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAckRbf) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAckRbf) }) } #[no_mangle] /// Read a TxAckRbf from a byte array, created by TxAckRbf_write @@ -10381,7 +11565,7 @@ pub extern "C" fn TxAbort_write(obj: &crate::lightning::ln::msgs::TxAbort) -> cr } #[allow(unused)] pub(crate) extern "C" fn TxAbort_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTxAbort) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeTxAbort) }) } #[no_mangle] /// Read a TxAbort from a byte array, created by TxAbort_write @@ -10397,7 +11581,7 @@ pub extern "C" fn AnnouncementSignatures_write(obj: &crate::lightning::ln::msgs: } #[allow(unused)] pub(crate) extern "C" fn AnnouncementSignatures_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeAnnouncementSignatures) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeAnnouncementSignatures) }) } #[no_mangle] /// Read a AnnouncementSignatures from a byte array, created by AnnouncementSignatures_write @@ -10413,7 +11597,7 @@ pub extern "C" fn ChannelReestablish_write(obj: &crate::lightning::ln::msgs::Cha } #[allow(unused)] pub(crate) extern "C" fn ChannelReestablish_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReestablish) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelReestablish) }) } #[no_mangle] /// Read a ChannelReestablish from a byte array, created by ChannelReestablish_write @@ -10429,7 +11613,7 @@ pub extern "C" fn ClosingSigned_write(obj: &crate::lightning::ln::msgs::ClosingS } #[allow(unused)] pub(crate) extern "C" fn ClosingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeClosingSigned) }) } #[no_mangle] /// Read a ClosingSigned from a byte array, created by ClosingSigned_write @@ -10445,7 +11629,7 @@ pub extern "C" fn ClosingSignedFeeRange_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn ClosingSignedFeeRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeClosingSignedFeeRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeClosingSignedFeeRange) }) } #[no_mangle] /// Read a ClosingSignedFeeRange from a byte array, created by ClosingSignedFeeRange_write @@ -10455,13 +11639,29 @@ pub extern "C" fn ClosingSignedFeeRange_read(ser: crate::c_types::u8slice) -> cr local_res } #[no_mangle] +/// Serialize the CommitmentSignedBatch object into a byte array which can be read by CommitmentSignedBatch_read +pub extern "C" fn CommitmentSignedBatch_write(obj: &crate::lightning::ln::msgs::CommitmentSignedBatch) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn CommitmentSignedBatch_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeCommitmentSignedBatch) }) +} +#[no_mangle] +/// Read a CommitmentSignedBatch from a byte array, created by CommitmentSignedBatch_write +pub extern "C" fn CommitmentSignedBatch_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_CommitmentSignedBatchDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::CommitmentSignedBatch { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] /// Serialize the CommitmentSigned object into a byte array which can be read by CommitmentSigned_read pub extern "C" fn CommitmentSigned_write(obj: &crate::lightning::ln::msgs::CommitmentSigned) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn CommitmentSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeCommitmentSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeCommitmentSigned) }) } #[no_mangle] /// Read a CommitmentSigned from a byte array, created by CommitmentSigned_write @@ -10477,7 +11677,7 @@ pub extern "C" fn FundingCreated_write(obj: &crate::lightning::ln::msgs::Funding } #[allow(unused)] pub(crate) extern "C" fn FundingCreated_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingCreated) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFundingCreated) }) } #[no_mangle] /// Read a FundingCreated from a byte array, created by FundingCreated_write @@ -10493,7 +11693,7 @@ pub extern "C" fn FundingSigned_write(obj: &crate::lightning::ln::msgs::FundingS } #[allow(unused)] pub(crate) extern "C" fn FundingSigned_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFundingSigned) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFundingSigned) }) } #[no_mangle] /// Read a FundingSigned from a byte array, created by FundingSigned_write @@ -10509,7 +11709,7 @@ pub extern "C" fn ChannelReady_write(obj: &crate::lightning::ln::msgs::ChannelRe } #[allow(unused)] pub(crate) extern "C" fn ChannelReady_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelReady) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelReady) }) } #[no_mangle] /// Read a ChannelReady from a byte array, created by ChannelReady_write @@ -10525,7 +11725,7 @@ pub extern "C" fn Init_write(obj: &crate::lightning::ln::msgs::Init) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Init_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInit) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeInit) }) } #[no_mangle] /// Read a Init from a byte array, created by Init_write @@ -10541,7 +11741,7 @@ pub extern "C" fn OpenChannel_write(obj: &crate::lightning::ln::msgs::OpenChanne } #[allow(unused)] pub(crate) extern "C" fn OpenChannel_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannel) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOpenChannel) }) } #[no_mangle] /// Read a OpenChannel from a byte array, created by OpenChannel_write @@ -10557,7 +11757,7 @@ pub extern "C" fn OpenChannelV2_write(obj: &crate::lightning::ln::msgs::OpenChan } #[allow(unused)] pub(crate) extern "C" fn OpenChannelV2_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOpenChannelV2) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOpenChannelV2) }) } #[no_mangle] /// Read a OpenChannelV2 from a byte array, created by OpenChannelV2_write @@ -10573,7 +11773,7 @@ pub extern "C" fn RevokeAndACK_write(obj: &crate::lightning::ln::msgs::RevokeAnd } #[allow(unused)] pub(crate) extern "C" fn RevokeAndACK_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRevokeAndACK) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeRevokeAndACK) }) } #[no_mangle] /// Read a RevokeAndACK from a byte array, created by RevokeAndACK_write @@ -10589,7 +11789,7 @@ pub extern "C" fn Shutdown_write(obj: &crate::lightning::ln::msgs::Shutdown) -> } #[allow(unused)] pub(crate) extern "C" fn Shutdown_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdown) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeShutdown) }) } #[no_mangle] /// Read a Shutdown from a byte array, created by Shutdown_write @@ -10605,7 +11805,7 @@ pub extern "C" fn UpdateFailHTLC_write(obj: &crate::lightning::ln::msgs::UpdateF } #[allow(unused)] pub(crate) extern "C" fn UpdateFailHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFailHTLC) }) } #[no_mangle] /// Read a UpdateFailHTLC from a byte array, created by UpdateFailHTLC_write @@ -10621,7 +11821,7 @@ pub extern "C" fn UpdateFailMalformedHTLC_write(obj: &crate::lightning::ln::msgs } #[allow(unused)] pub(crate) extern "C" fn UpdateFailMalformedHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFailMalformedHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFailMalformedHTLC) }) } #[no_mangle] /// Read a UpdateFailMalformedHTLC from a byte array, created by UpdateFailMalformedHTLC_write @@ -10637,7 +11837,7 @@ pub extern "C" fn UpdateFee_write(obj: &crate::lightning::ln::msgs::UpdateFee) - } #[allow(unused)] pub(crate) extern "C" fn UpdateFee_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFee) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFee) }) } #[no_mangle] /// Read a UpdateFee from a byte array, created by UpdateFee_write @@ -10653,7 +11853,7 @@ pub extern "C" fn UpdateFulfillHTLC_write(obj: &crate::lightning::ln::msgs::Upda } #[allow(unused)] pub(crate) extern "C" fn UpdateFulfillHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateFulfillHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateFulfillHTLC) }) } #[no_mangle] /// Read a UpdateFulfillHTLC from a byte array, created by UpdateFulfillHTLC_write @@ -10669,7 +11869,7 @@ pub extern "C" fn OnionPacket_write(obj: &crate::lightning::ln::msgs::OnionPacke } #[allow(unused)] pub(crate) extern "C" fn OnionPacket_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionPacket) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOnionPacket) }) } #[no_mangle] /// Read a OnionPacket from a byte array, created by OnionPacket_write @@ -10685,7 +11885,7 @@ pub extern "C" fn UpdateAddHTLC_write(obj: &crate::lightning::ln::msgs::UpdateAd } #[allow(unused)] pub(crate) extern "C" fn UpdateAddHTLC_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUpdateAddHTLC) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUpdateAddHTLC) }) } #[no_mangle] /// Read a UpdateAddHTLC from a byte array, created by UpdateAddHTLC_write @@ -10708,7 +11908,7 @@ pub extern "C" fn OnionMessage_write(obj: &crate::lightning::ln::msgs::OnionMess } #[allow(unused)] pub(crate) extern "C" fn OnionMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOnionMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeOnionMessage) }) } #[no_mangle] /// Serialize the FinalOnionHopData object into a byte array which can be read by FinalOnionHopData_read @@ -10717,7 +11917,7 @@ pub extern "C" fn FinalOnionHopData_write(obj: &crate::lightning::ln::msgs::Fina } #[allow(unused)] pub(crate) extern "C" fn FinalOnionHopData_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFinalOnionHopData) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeFinalOnionHopData) }) } #[no_mangle] /// Read a FinalOnionHopData from a byte array, created by FinalOnionHopData_write @@ -10733,7 +11933,7 @@ pub extern "C" fn Ping_write(obj: &crate::lightning::ln::msgs::Ping) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Ping_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePing) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativePing) }) } #[no_mangle] /// Read a Ping from a byte array, created by Ping_write @@ -10749,7 +11949,7 @@ pub extern "C" fn Pong_write(obj: &crate::lightning::ln::msgs::Pong) -> crate::c } #[allow(unused)] pub(crate) extern "C" fn Pong_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePong) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativePong) }) } #[no_mangle] /// Read a Pong from a byte array, created by Pong_write @@ -10765,7 +11965,7 @@ pub extern "C" fn UnsignedChannelAnnouncement_write(obj: &crate::lightning::ln:: } #[allow(unused)] pub(crate) extern "C" fn UnsignedChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedChannelAnnouncement) }) } #[no_mangle] /// Read a UnsignedChannelAnnouncement from a byte array, created by UnsignedChannelAnnouncement_write @@ -10781,7 +11981,7 @@ pub extern "C" fn ChannelAnnouncement_write(obj: &crate::lightning::ln::msgs::Ch } #[allow(unused)] pub(crate) extern "C" fn ChannelAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelAnnouncement) }) } #[no_mangle] /// Read a ChannelAnnouncement from a byte array, created by ChannelAnnouncement_write @@ -10797,7 +11997,7 @@ pub extern "C" fn UnsignedChannelUpdate_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn UnsignedChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedChannelUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedChannelUpdate) }) } #[no_mangle] /// Read a UnsignedChannelUpdate from a byte array, created by UnsignedChannelUpdate_write @@ -10813,7 +12013,7 @@ pub extern "C" fn ChannelUpdate_write(obj: &crate::lightning::ln::msgs::ChannelU } #[allow(unused)] pub(crate) extern "C" fn ChannelUpdate_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdate) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeChannelUpdate) }) } #[no_mangle] /// Read a ChannelUpdate from a byte array, created by ChannelUpdate_write @@ -10829,7 +12029,7 @@ pub extern "C" fn ErrorMessage_write(obj: &crate::lightning::ln::msgs::ErrorMess } #[allow(unused)] pub(crate) extern "C" fn ErrorMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeErrorMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeErrorMessage) }) } #[no_mangle] /// Read a ErrorMessage from a byte array, created by ErrorMessage_write @@ -10845,7 +12045,7 @@ pub extern "C" fn WarningMessage_write(obj: &crate::lightning::ln::msgs::Warning } #[allow(unused)] pub(crate) extern "C" fn WarningMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeWarningMessage) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeWarningMessage) }) } #[no_mangle] /// Read a WarningMessage from a byte array, created by WarningMessage_write @@ -10861,7 +12061,7 @@ pub extern "C" fn UnsignedNodeAnnouncement_write(obj: &crate::lightning::ln::msg } #[allow(unused)] pub(crate) extern "C" fn UnsignedNodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedNodeAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeUnsignedNodeAnnouncement) }) } #[no_mangle] /// Read a UnsignedNodeAnnouncement from a byte array, created by UnsignedNodeAnnouncement_write @@ -10877,7 +12077,7 @@ pub extern "C" fn NodeAnnouncement_write(obj: &crate::lightning::ln::msgs::NodeA } #[allow(unused)] pub(crate) extern "C" fn NodeAnnouncement_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncement) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeNodeAnnouncement) }) } #[no_mangle] /// Read a NodeAnnouncement from a byte array, created by NodeAnnouncement_write @@ -10900,7 +12100,7 @@ pub extern "C" fn QueryShortChannelIds_write(obj: &crate::lightning::ln::msgs::Q } #[allow(unused)] pub(crate) extern "C" fn QueryShortChannelIds_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryShortChannelIds) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeQueryShortChannelIds) }) } #[no_mangle] /// Serialize the ReplyShortChannelIdsEnd object into a byte array which can be read by ReplyShortChannelIdsEnd_read @@ -10909,7 +12109,7 @@ pub extern "C" fn ReplyShortChannelIdsEnd_write(obj: &crate::lightning::ln::msgs } #[allow(unused)] pub(crate) extern "C" fn ReplyShortChannelIdsEnd_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyShortChannelIdsEnd) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeReplyShortChannelIdsEnd) }) } #[no_mangle] /// Read a ReplyShortChannelIdsEnd from a byte array, created by ReplyShortChannelIdsEnd_write @@ -10935,7 +12135,7 @@ pub extern "C" fn QueryChannelRange_write(obj: &crate::lightning::ln::msgs::Quer } #[allow(unused)] pub(crate) extern "C" fn QueryChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeQueryChannelRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeQueryChannelRange) }) } #[no_mangle] /// Read a QueryChannelRange from a byte array, created by QueryChannelRange_write @@ -10958,7 +12158,7 @@ pub extern "C" fn ReplyChannelRange_write(obj: &crate::lightning::ln::msgs::Repl } #[allow(unused)] pub(crate) extern "C" fn ReplyChannelRange_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeReplyChannelRange) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeReplyChannelRange) }) } #[no_mangle] /// Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read @@ -10967,7 +12167,7 @@ pub extern "C" fn GossipTimestampFilter_write(obj: &crate::lightning::ln::msgs:: } #[allow(unused)] pub(crate) extern "C" fn GossipTimestampFilter_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeGossipTimestampFilter) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::msgs::nativeGossipTimestampFilter) }) } #[no_mangle] /// Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write diff --git a/lightning-c-bindings/src/lightning/ln/onion_payment.rs b/lightning-c-bindings/src/lightning/ln/onion_payment.rs index ddfd561..2ff175b 100644 --- a/lightning-c-bindings/src/lightning/ln/onion_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/onion_payment.rs @@ -40,6 +40,12 @@ pub struct InboundHTLCErr { pub is_owned: bool, } +impl core::ops::Deref for InboundHTLCErr { + type Target = nativeInboundHTLCErr; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InboundHTLCErr { } +unsafe impl core::marker::Sync for InboundHTLCErr { } impl Drop for InboundHTLCErr { fn drop(&mut self) { if self.is_owned && !<*mut nativeInboundHTLCErr>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl InboundHTLCErr { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// BOLT 4 error code. #[no_mangle] @@ -119,9 +128,47 @@ pub extern "C" fn InboundHTLCErr_new(mut err_code_arg: u16, mut err_data_arg: cr msg: msg_arg.into_str(), }), is_owned: true } } +impl Clone for InboundHTLCErr { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInboundHTLCErr>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InboundHTLCErr_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInboundHTLCErr)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InboundHTLCErr +pub extern "C" fn InboundHTLCErr_clone(orig: &InboundHTLCErr) -> InboundHTLCErr { + orig.clone() +} /// Get a string which allows debug introspection of a InboundHTLCErr object pub extern "C" fn InboundHTLCErr_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::onion_payment::InboundHTLCErr }).into()} +/// Generates a non-cryptographic 64-bit hash of the InboundHTLCErr. +#[no_mangle] +pub extern "C" fn InboundHTLCErr_hash(o: &InboundHTLCErr) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two InboundHTLCErrs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn InboundHTLCErr_eq(a: &InboundHTLCErr, b: &InboundHTLCErr) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} /// Peel one layer off an incoming onion, returning a [`PendingHTLCInfo`] that contains information /// about the intended next-hop for the HTLC. /// @@ -132,7 +179,7 @@ pub extern "C" fn InboundHTLCErr_debug_str_void(o: *const c_void) -> Str { /// /// [`Event::PaymentClaimable`]: crate::events::Event::PaymentClaimable #[no_mangle] -pub extern "C" fn peel_payment_onion(msg: &crate::lightning::ln::msgs::UpdateAddHTLC, node_signer: &crate::lightning::sign::NodeSigner, logger: &crate::lightning::util::logger::Logger, mut cur_height: u32, mut accept_mpp_keysend: bool, mut allow_skimmed_fees: bool) -> crate::c_types::derived::CResult_PendingHTLCInfoInboundHTLCErrZ { +pub extern "C" fn peel_payment_onion(msg: &crate::lightning::ln::msgs::UpdateAddHTLC, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut cur_height: u32, mut accept_mpp_keysend: bool, mut allow_skimmed_fees: bool) -> crate::c_types::derived::CResult_PendingHTLCInfoInboundHTLCErrZ { let mut ret = lightning::ln::onion_payment::peel_payment_onion(msg.get_native_ref(), node_signer, logger, secp256k1::global::SECP256K1, cur_height, accept_mpp_keysend, allow_skimmed_fees); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::channelmanager::PendingHTLCInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::onion_payment::InboundHTLCErr { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index 0648ae3..c54bbee 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -192,6 +192,12 @@ pub enum RetryableSendFailure { /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed DuplicatePayment, + /// The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs`], or + /// [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion + /// packet size of 1300 bytes. + /// + /// [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath + OnionPacketSizeExceeded, } use lightning::ln::outbound_payment::RetryableSendFailure as RetryableSendFailureImport; pub(crate) type nativeRetryableSendFailure = RetryableSendFailureImport; @@ -203,6 +209,7 @@ impl RetryableSendFailure { RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired, RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound, RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment, + RetryableSendFailure::OnionPacketSizeExceeded => nativeRetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -211,6 +218,7 @@ impl RetryableSendFailure { RetryableSendFailure::PaymentExpired => nativeRetryableSendFailure::PaymentExpired, RetryableSendFailure::RouteNotFound => nativeRetryableSendFailure::RouteNotFound, RetryableSendFailure::DuplicatePayment => nativeRetryableSendFailure::DuplicatePayment, + RetryableSendFailure::OnionPacketSizeExceeded => nativeRetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -220,6 +228,7 @@ impl RetryableSendFailure { nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired, nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound, nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment, + nativeRetryableSendFailure::OnionPacketSizeExceeded => RetryableSendFailure::OnionPacketSizeExceeded, } } #[allow(unused)] @@ -228,6 +237,7 @@ impl RetryableSendFailure { nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired, nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound, nativeRetryableSendFailure::DuplicatePayment => RetryableSendFailure::DuplicatePayment, + nativeRetryableSendFailure::OnionPacketSizeExceeded => RetryableSendFailure::OnionPacketSizeExceeded, } } } @@ -258,6 +268,10 @@ pub extern "C" fn RetryableSendFailure_route_not_found() -> RetryableSendFailure /// Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure pub extern "C" fn RetryableSendFailure_duplicate_payment() -> RetryableSendFailure { RetryableSendFailure::DuplicatePayment} +#[no_mangle] +/// Utility method to constructs a new OnionPacketSizeExceeded-variant RetryableSendFailure +pub extern "C" fn RetryableSendFailure_onion_packet_size_exceeded() -> RetryableSendFailure { + RetryableSendFailure::OnionPacketSizeExceeded} /// Get a string which allows debug introspection of a RetryableSendFailure object pub extern "C" fn RetryableSendFailure_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::RetryableSendFailure }).into()} @@ -544,6 +558,125 @@ pub extern "C" fn PaymentSendFailure_debug_str_void(o: *const c_void) -> Str { pub extern "C" fn PaymentSendFailure_eq(a: &PaymentSendFailure, b: &PaymentSendFailure) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } +/// An error when attempting to pay a [`Bolt12Invoice`]. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum Bolt12PaymentError { + /// The invoice was not requested. + UnexpectedInvoice, + /// Payment for an invoice with the corresponding [`PaymentId`] was already initiated. + DuplicateInvoice, + /// The invoice was valid for the corresponding [`PaymentId`], but required unknown features. + UnknownRequiredFeatures, + /// The invoice was valid for the corresponding [`PaymentId`], but sending the payment failed. + SendingFailed( + crate::lightning::ln::outbound_payment::RetryableSendFailure), +} +use lightning::ln::outbound_payment::Bolt12PaymentError as Bolt12PaymentErrorImport; +pub(crate) type nativeBolt12PaymentError = Bolt12PaymentErrorImport; + +impl Bolt12PaymentError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeBolt12PaymentError { + match self { + Bolt12PaymentError::UnexpectedInvoice => nativeBolt12PaymentError::UnexpectedInvoice, + Bolt12PaymentError::DuplicateInvoice => nativeBolt12PaymentError::DuplicateInvoice, + Bolt12PaymentError::UnknownRequiredFeatures => nativeBolt12PaymentError::UnknownRequiredFeatures, + Bolt12PaymentError::SendingFailed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeBolt12PaymentError::SendingFailed ( + a_nonref.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeBolt12PaymentError { + match self { + Bolt12PaymentError::UnexpectedInvoice => nativeBolt12PaymentError::UnexpectedInvoice, + Bolt12PaymentError::DuplicateInvoice => nativeBolt12PaymentError::DuplicateInvoice, + Bolt12PaymentError::UnknownRequiredFeatures => nativeBolt12PaymentError::UnknownRequiredFeatures, + Bolt12PaymentError::SendingFailed (mut a, ) => { + nativeBolt12PaymentError::SendingFailed ( + a.into_native(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &Bolt12PaymentErrorImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBolt12PaymentError) }; + match native { + nativeBolt12PaymentError::UnexpectedInvoice => Bolt12PaymentError::UnexpectedInvoice, + nativeBolt12PaymentError::DuplicateInvoice => Bolt12PaymentError::DuplicateInvoice, + nativeBolt12PaymentError::UnknownRequiredFeatures => Bolt12PaymentError::UnknownRequiredFeatures, + nativeBolt12PaymentError::SendingFailed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + Bolt12PaymentError::SendingFailed ( + crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeBolt12PaymentError) -> Self { + match native { + nativeBolt12PaymentError::UnexpectedInvoice => Bolt12PaymentError::UnexpectedInvoice, + nativeBolt12PaymentError::DuplicateInvoice => Bolt12PaymentError::DuplicateInvoice, + nativeBolt12PaymentError::UnknownRequiredFeatures => Bolt12PaymentError::UnknownRequiredFeatures, + nativeBolt12PaymentError::SendingFailed (mut a, ) => { + Bolt12PaymentError::SendingFailed ( + crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a), + ) + }, + } + } +} +/// Frees any resources used by the Bolt12PaymentError +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_free(this_ptr: Bolt12PaymentError) { } +/// Creates a copy of the Bolt12PaymentError +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_clone(orig: &Bolt12PaymentError) -> Bolt12PaymentError { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12PaymentError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Bolt12PaymentError)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12PaymentError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Bolt12PaymentError) }; +} +#[no_mangle] +/// Utility method to constructs a new UnexpectedInvoice-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_unexpected_invoice() -> Bolt12PaymentError { + Bolt12PaymentError::UnexpectedInvoice} +#[no_mangle] +/// Utility method to constructs a new DuplicateInvoice-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_duplicate_invoice() -> Bolt12PaymentError { + Bolt12PaymentError::DuplicateInvoice} +#[no_mangle] +/// Utility method to constructs a new UnknownRequiredFeatures-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_unknown_required_features() -> Bolt12PaymentError { + Bolt12PaymentError::UnknownRequiredFeatures} +#[no_mangle] +/// Utility method to constructs a new SendingFailed-variant Bolt12PaymentError +pub extern "C" fn Bolt12PaymentError_sending_failed(a: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> Bolt12PaymentError { + Bolt12PaymentError::SendingFailed(a, ) +} +/// Get a string which allows debug introspection of a Bolt12PaymentError object +pub extern "C" fn Bolt12PaymentError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::Bolt12PaymentError }).into()} +/// Checks if two Bolt12PaymentErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Bolt12PaymentError_eq(a: &Bolt12PaymentError, b: &Bolt12PaymentError) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} /// Indicates that we failed to send a payment probe. Further errors may be surfaced later via /// [`Event::ProbeFailed`]. /// @@ -669,6 +802,12 @@ pub struct RecipientOnionFields { pub is_owned: bool, } +impl core::ops::Deref for RecipientOnionFields { + type Target = nativeRecipientOnionFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RecipientOnionFields { } +unsafe impl core::marker::Sync for RecipientOnionFields { } impl Drop for RecipientOnionFields { fn drop(&mut self) { if self.is_owned && !<*mut nativeRecipientOnionFields>::is_null(self.inner) { @@ -699,6 +838,9 @@ impl RecipientOnionFields { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The [`PaymentSecret`] is an arbitrary 32 bytes provided by the recipient for us to repeat /// in the onion. It is unrelated to `payment_hash` (or [`PaymentPreimage`]) and exists to @@ -730,7 +872,7 @@ pub extern "C" fn RecipientOnionFields_get_payment_secret(this_ptr: &RecipientOn /// recipient will not reject it. #[no_mangle] pub extern "C" fn RecipientOnionFields_set_payment_secret(this_ptr: &mut RecipientOnionFields, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentSecret({ val_opt.take() }.data) }})} }; + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentSecret({ val_opt.take() }.data) }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_secret = local_val; } /// The payment metadata serves a similar purpose as [`Self::payment_secret`] but is of @@ -808,7 +950,7 @@ pub extern "C" fn RecipientOnionFields_write(obj: &crate::lightning::ln::outboun } #[allow(unused)] pub(crate) extern "C" fn RecipientOnionFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRecipientOnionFields) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::outbound_payment::nativeRecipientOnionFields) }) } #[no_mangle] /// Read a RecipientOnionFields from a byte array, created by RecipientOnionFields_write @@ -823,7 +965,7 @@ pub extern "C" fn RecipientOnionFields_read(ser: crate::c_types::u8slice) -> cra #[must_use] #[no_mangle] pub extern "C" fn RecipientOnionFields_secret_only(mut payment_secret: crate::c_types::ThirtyTwoBytes) -> crate::lightning::ln::outbound_payment::RecipientOnionFields { - let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::secret_only(::lightning::ln::PaymentSecret(payment_secret.data)); + let mut ret = lightning::ln::outbound_payment::RecipientOnionFields::secret_only(::lightning::ln::types::PaymentSecret(payment_secret.data)); crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning/ln/peer_handler.rs b/lightning-c-bindings/src/lightning/ln/peer_handler.rs index 20aac90..672610e 100644 --- a/lightning-c-bindings/src/lightning/ln/peer_handler.rs +++ b/lightning-c-bindings/src/lightning/ln/peer_handler.rs @@ -44,18 +44,26 @@ pub struct CustomMessageHandler { /// in the process. Each message is paired with the node id of the intended recipient. If no /// connection to the node exists, then the message is simply not sent. pub get_and_clear_pending_msg: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ, + /// Indicates a peer disconnected. + pub peer_disconnected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey), + /// Handle a peer connecting. + /// + /// May return an `Err(())` if the features the peer supports are not sufficient to communicate + /// with us. Implementors should be somewhat conservative about doing so, however, as other + /// message handlers may still wish to communicate with this peer. + pub peer_connected: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ, /// Gets the node feature flags which this handler itself supports. All available handlers are /// queried similarly and their feature flags are OR'd together to form the [`NodeFeatures`] /// which are broadcasted in our [`NodeAnnouncement`] message. /// /// [`NodeAnnouncement`]: crate::ln::msgs::NodeAnnouncement - pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures, + pub provided_node_features: extern "C" fn (this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures, /// Gets the init feature flags which should be sent to the given peer. All available handlers /// are queried similarly and their feature flags are OR'd together to form the [`InitFeatures`] /// which are sent in our [`Init`] message. /// /// [`Init`]: crate::ln::msgs::Init - pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures, + pub provided_init_features: extern "C" fn (this_arg: *const c_void, their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures, /// Implementation of CustomMessageReader for this object. pub CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader, /// Frees any resources associated with this object given its this_arg pointer. @@ -70,6 +78,8 @@ pub(crate) fn CustomMessageHandler_clone_fields(orig: &CustomMessageHandler) -> this_arg: orig.this_arg, handle_custom_message: Clone::clone(&orig.handle_custom_message), get_and_clear_pending_msg: Clone::clone(&orig.get_and_clear_pending_msg), + peer_disconnected: Clone::clone(&orig.peer_disconnected), + peer_connected: Clone::clone(&orig.peer_connected), provided_node_features: Clone::clone(&orig.provided_node_features), provided_init_features: Clone::clone(&orig.provided_init_features), CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader_clone_fields(&orig.CustomMessageReader), @@ -84,6 +94,14 @@ impl lightning::ln::wire::CustomMessageReader for CustomMessageHandler { local_ret } } +impl lightning::ln::wire::CustomMessageReader for CustomMessageHandlerRef { + type CustomMessage = crate::lightning::ln::wire::Type; + fn read(&self, mut message_type: u16, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.CustomMessageReader.read)(self.0.CustomMessageReader.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } +} use lightning::ln::peer_handler::CustomMessageHandler as rustCustomMessageHandler; impl rustCustomMessageHandler for CustomMessageHandler { @@ -97,27 +115,65 @@ impl rustCustomMessageHandler for CustomMessageHandler { let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1); local_ret_0 }); }; local_ret } - fn provided_node_features(&self) -> lightning::ln::features::NodeFeatures { + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.peer_disconnected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.peer_connected)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { let mut ret = (self.provided_node_features)(self.this_arg); *unsafe { Box::from_raw(ret.take_inner()) } } - fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning::ln::features::InitFeatures { + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { let mut ret = (self.provided_init_features)(self.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); *unsafe { Box::from_raw(ret.take_inner()) } } } +pub struct CustomMessageHandlerRef(CustomMessageHandler); +impl rustCustomMessageHandler for CustomMessageHandlerRef { + fn handle_custom_message(&self, mut msg: crate::lightning::ln::wire::Type, mut sender_node_id: &bitcoin::secp256k1::PublicKey) -> Result<(), lightning::ln::msgs::LightningError> { + let mut ret = (self.0.handle_custom_message)(self.0.this_arg, Into::into(msg), crate::c_types::PublicKey::from_rust(&sender_node_id)); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn get_and_clear_pending_msg(&self) -> Vec<(bitcoin::secp256k1::PublicKey, crate::lightning::ln::wire::Type)> { + let mut ret = (self.0.get_and_clear_pending_msg)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_rust(), orig_ret_0_1); local_ret_0 }); }; + local_ret + } + fn peer_disconnected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) { + (self.0.peer_disconnected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)) + } + fn peer_connected(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey, mut msg: &lightning::ln::msgs::Init, mut inbound: bool) -> Result<(), ()> { + let mut ret = (self.0.peer_connected)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id), &crate::lightning::ln::msgs::Init { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::Init<>) as *mut _) }, is_owned: false }, inbound); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn provided_node_features(&self) -> lightning_types::features::NodeFeatures { + let mut ret = (self.0.provided_node_features)(self.0.this_arg); + *unsafe { Box::from_raw(ret.take_inner()) } + } + fn provided_init_features(&self, mut their_node_id: &bitcoin::secp256k1::PublicKey) -> lightning_types::features::InitFeatures { + let mut ret = (self.0.provided_init_features)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&their_node_id)); + *unsafe { Box::from_raw(ret.take_inner()) } + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for CustomMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomMessageHandlerRef) } } } impl core::ops::DerefMut for CustomMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut CustomMessageHandlerRef) } } } /// Calls the free function if one is set @@ -151,6 +207,12 @@ pub struct IgnoringMessageHandler { pub is_owned: bool, } +impl core::ops::Deref for IgnoringMessageHandler { + type Target = nativeIgnoringMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for IgnoringMessageHandler { } +unsafe impl core::marker::Sync for IgnoringMessageHandler { } impl Drop for IgnoringMessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeIgnoringMessageHandler>::is_null(self.inner) { @@ -181,6 +243,9 @@ impl IgnoringMessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new IgnoringMessageHandler given each field #[must_use] @@ -189,31 +254,6 @@ pub extern "C" fn IgnoringMessageHandler_new() -> IgnoringMessageHandler { IgnoringMessageHandler { inner: ObjOps::heap_alloc(nativeIgnoringMessageHandler { }), is_owned: true } } -impl From for crate::lightning::events::EventsProvider { - fn from(obj: nativeIgnoringMessageHandler) -> Self { - let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = IgnoringMessageHandler_as_EventsProvider(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn - core::mem::forget(rust_obj); - ret.free = Some(IgnoringMessageHandler_free_void); - ret - } -} -/// Constructs a new EventsProvider which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is -#[no_mangle] -pub extern "C" fn IgnoringMessageHandler_as_EventsProvider(this_arg: &IgnoringMessageHandler) -> crate::lightning::events::EventsProvider { - crate::lightning::events::EventsProvider { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - process_pending_events: IgnoringMessageHandler_EventsProvider_process_pending_events, - } -} - -extern "C" fn IgnoringMessageHandler_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { - >::process_pending_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, handler) -} - impl From for crate::lightning::events::MessageSendEventsProvider { fn from(obj: nativeIgnoringMessageHandler) -> Self { let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -237,7 +277,7 @@ pub extern "C" fn IgnoringMessageHandler_as_MessageSendEventsProvider(this_arg: #[must_use] extern "C" fn IgnoringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut ret = ::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -282,79 +322,79 @@ pub extern "C" fn IgnoringMessageHandler_as_RoutingMessageHandler(this_arg: &Ign #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); + let mut ret = ::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); + let mut ret = ::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); + let mut ret = ::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcement(this_arg: *const c_void, mut starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - let mut ret = >::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, starting_point); + let mut ret = ::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, starting_point); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None } else { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = (ret.unwrap()); let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }) }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_node_announcement(this_arg: *const c_void, mut starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement { let mut local_starting_point = if starting_point.inner.is_null() { None } else { Some( { starting_point.get_native_ref() }) }; - let mut ret = >::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local_starting_point); + let mut ret = ::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, local_starting_point); let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_processing_queue_high(this_arg: *const c_void) -> bool { - let mut ret = >::processing_queue_high(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut ret = ::processing_queue_high(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); ret } #[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::ln::msgs::OnionMessageHandler { @@ -374,7 +414,6 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &Ignor crate::lightning::ln::msgs::OnionMessageHandler { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, - get_and_clear_connections_needed: IgnoringMessageHandler_OnionMessageHandler_get_and_clear_connections_needed, handle_onion_message: IgnoringMessageHandler_OnionMessageHandler_handle_onion_message, next_onion_message_for_peer: IgnoringMessageHandler_OnionMessageHandler_next_onion_message_for_peer, peer_connected: IgnoringMessageHandler_OnionMessageHandler_peer_connected, @@ -385,42 +424,36 @@ pub extern "C" fn IgnoringMessageHandler_as_OnionMessageHandler(this_arg: &Ignor } } -#[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_get_and_clear_connections_needed(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - let mut ret = >::get_and_clear_connections_needed(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} extern "C" fn IgnoringMessageHandler_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) { - >::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &peer_node_id.into_rust(), msg.get_native_ref()) + ::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &peer_node_id.into_rust(), msg.get_native_ref()) } #[must_use] extern "C" fn IgnoringMessageHandler_OnionMessageHandler_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage { - let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, peer_node_id.into_rust()); + let mut ret = ::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, peer_node_id.into_rust()); let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } #[must_use] extern "C" fn IgnoringMessageHandler_OnionMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } extern "C" fn IgnoringMessageHandler_OnionMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()) + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()) } extern "C" fn IgnoringMessageHandler_OnionMessageHandler_timer_tick_occurred(this_arg: *const c_void) { - >::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ) + ::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ) } #[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::onion_message::offers::OffersMessageHandler { @@ -446,15 +479,57 @@ pub extern "C" fn IgnoringMessageHandler_as_OffersMessageHandler(this_arg: &Igno } #[must_use] -extern "C" fn IgnoringMessageHandler_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ { - let mut ret = >::handle_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message.into_native()); - let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_OffersMessageZ::None } else { crate::c_types::derived::COption_OffersMessageZ::Some( { crate::lightning::onion_message::offers::OffersMessage::native_into(ret.unwrap()) }) }; +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_handle_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::offers::OffersMessage, mut context: crate::c_types::derived::COption_OffersContextZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ { + let mut local_context = { /*context*/ let context_opt = context; if context_opt.is_none() { None } else { Some({ { { context_opt.take() }.into_native() }})} }; + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::handle_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message.into_native(), local_context, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; local_ret } #[must_use] -extern "C" fn IgnoringMessageHandler_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ { - let mut ret = >::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).into(); local_ret_0 }); }; +extern "C" fn IgnoringMessageHandler_OffersMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::lightning::onion_message::offers::OffersMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; + local_ret.into() +} + +impl From for crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + fn from(obj: nativeIgnoringMessageHandler) -> Self { + let rust_obj = crate::lightning::ln::peer_handler::IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(IgnoringMessageHandler_free_void); + ret + } +} +/// Constructs a new AsyncPaymentsMessageHandler which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned AsyncPaymentsMessageHandler must be freed before this_arg is +#[no_mangle] +pub extern "C" fn IgnoringMessageHandler_as_AsyncPaymentsMessageHandler(this_arg: &IgnoringMessageHandler) -> crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + held_htlc_available: IgnoringMessageHandler_AsyncPaymentsMessageHandler_held_htlc_available, + release_held_htlc: IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_held_htlc, + release_pending_messages: IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_pending_messages, + } +} + +#[must_use] +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_held_htlc_available(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ { + let mut local_responder = if responder.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(responder.take_inner()) } }) }; + let mut ret = ::held_htlc_available(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, *unsafe { Box::from_raw(message.take_inner()) }, local_responder); + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::None } else { crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (ret.unwrap()); let mut local_ret_0 = (crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }) }; + local_ret +} +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_held_htlc(this_arg: *const c_void, mut message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) { + ::release_held_htlc(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, *unsafe { Box::from_raw(message.take_inner()) }) +} +#[must_use] +extern "C" fn IgnoringMessageHandler_AsyncPaymentsMessageHandler_release_pending_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ { + let mut ret = ::release_pending_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } @@ -482,19 +557,19 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomOnionMessageHandler(this_arg: } #[must_use] -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut msg: crate::lightning::onion_message::packet::OnionMessageContents) -> crate::c_types::derived::COption_OnionMessageContentsZ { +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_handle_custom_message(this_arg: *const c_void, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: crate::c_types::derived::COption_CVec_u8ZZ, mut responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ { unreachable!(); } #[must_use] extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_read_custom_message(this_arg: *const c_void, mut message_type: u64, mut buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_OnionMessageContentsZDecodeErrorZ { - let mut ret = >::read_custom_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message_type, &mut buffer.to_reader()); + let mut ret = ::read_custom_message(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message_type, &mut buffer.to_reader()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = if o.is_none() { crate::c_types::derived::COption_OnionMessageContentsZ::None } else { crate::c_types::derived::COption_OnionMessageContentsZ::Some( { Into::into(o.unwrap()) }) }; local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_ret } #[must_use] -extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_release_pending_custom_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ { - let mut ret = >::release_pending_custom_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = crate::lightning::blinded_path::BlindedPath { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (Into::into(orig_ret_0_0), crate::lightning::onion_message::messenger::Destination::native_into(orig_ret_0_1), local_orig_ret_0_2).into(); local_ret_0 }); }; +extern "C" fn IgnoringMessageHandler_CustomOnionMessageHandler_release_pending_custom_messages(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ { + let mut ret = ::release_pending_custom_messages(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (Into::into(orig_ret_0_0), crate::lightning::onion_message::messenger::MessageSendInstructions::native_into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } @@ -531,7 +606,7 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomMessageReader(this_arg: &Ignor #[must_use] extern "C" fn IgnoringMessageHandler_CustomMessageReader_read(this_arg: *const c_void, mut message_type: u16, mut buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_TypeZDecodeErrorZ { - let mut ret = >::read(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message_type, &mut buffer.to_reader()); + let mut ret = ::read(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, message_type, &mut buffer.to_reader()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = if o.is_none() { crate::c_types::derived::COption_TypeZ::None } else { crate::c_types::derived::COption_TypeZ::Some( { Into::into(o.unwrap()) }) }; local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_ret } @@ -555,6 +630,8 @@ pub extern "C" fn IgnoringMessageHandler_as_CustomMessageHandler(this_arg: &Igno free: None, handle_custom_message: IgnoringMessageHandler_CustomMessageHandler_handle_custom_message, get_and_clear_pending_msg: IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_msg, + peer_disconnected: IgnoringMessageHandler_CustomMessageHandler_peer_disconnected, + peer_connected: IgnoringMessageHandler_CustomMessageHandler_peer_connected, provided_node_features: IgnoringMessageHandler_CustomMessageHandler_provided_node_features, provided_init_features: IgnoringMessageHandler_CustomMessageHandler_provided_init_features, CustomMessageReader: crate::lightning::ln::wire::CustomMessageReader { @@ -571,19 +648,28 @@ extern "C" fn IgnoringMessageHandler_CustomMessageHandler_handle_custom_message( } #[must_use] extern "C" fn IgnoringMessageHandler_CustomMessageHandler_get_and_clear_pending_msg(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyTypeZZ { - let mut ret = >::get_and_clear_pending_msg(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + let mut ret = ::get_and_clear_pending_msg(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), Into::into(orig_ret_0_1)).into(); local_ret_0 }); }; local_ret.into() } +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()) +} #[must_use] -extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn IgnoringMessageHandler_CustomMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -607,6 +693,12 @@ pub struct ErroringMessageHandler { pub is_owned: bool, } +impl core::ops::Deref for ErroringMessageHandler { + type Target = nativeErroringMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErroringMessageHandler { } +unsafe impl core::marker::Sync for ErroringMessageHandler { } impl Drop for ErroringMessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeErroringMessageHandler>::is_null(self.inner) { @@ -637,6 +729,9 @@ impl ErroringMessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new ErroringMessageHandler #[must_use] @@ -669,7 +764,7 @@ pub extern "C" fn ErroringMessageHandler_as_MessageSendEventsProvider(this_arg: #[must_use] extern "C" fn ErroringMessageHandler_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut ret = ::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -701,9 +796,6 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err handle_shutdown: ErroringMessageHandler_ChannelMessageHandler_handle_shutdown, handle_closing_signed: ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed, handle_stfu: ErroringMessageHandler_ChannelMessageHandler_handle_stfu, - handle_splice: ErroringMessageHandler_ChannelMessageHandler_handle_splice, - handle_splice_ack: ErroringMessageHandler_ChannelMessageHandler_handle_splice_ack, - handle_splice_locked: ErroringMessageHandler_ChannelMessageHandler_handle_splice_locked, handle_tx_add_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input, handle_tx_add_output: ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output, handle_tx_remove_input: ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input, @@ -738,133 +830,124 @@ pub extern "C" fn ErroringMessageHandler_as_ChannelMessageHandler(this_arg: &Err } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannel) { - >::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_open_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_open_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OpenChannelV2) { - >::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_open_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannel) { - >::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_accept_channel(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_accept_channel_v2(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AcceptChannelV2) { - >::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_accept_channel_v2(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_created(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingCreated) { - >::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_funding_created(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_funding_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::FundingSigned) { - >::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_funding_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_ready(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReady) { - >::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_ready(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_shutdown(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Shutdown) { - >::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_shutdown(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_closing_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ClosingSigned) { - >::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_closing_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_stfu(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Stfu) { - >::handle_stfu(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_splice(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Splice) { - >::handle_splice(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_splice_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceAck) { - >::handle_splice_ack(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) -} -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_splice_locked(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::SpliceLocked) { - >::handle_splice_locked(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_stfu(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddInput) { - >::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_add_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_add_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAddOutput) { - >::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_add_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_input(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveInput) { - >::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_remove_input(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_remove_output(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxRemoveOutput) { - >::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_remove_output(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_complete(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxComplete) { - >::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_complete(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxSignatures) { - >::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_init_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxInitRbf) { - >::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_init_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_ack_rbf(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAckRbf) { - >::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_ack_rbf(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_tx_abort(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::TxAbort) { - >::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_tx_abort(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_add_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateAddHTLC) { - >::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_add_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fulfill_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFulfillHTLC) { - >::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fulfill_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailHTLC) { - >::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fail_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fail_malformed_htlc(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFailMalformedHTLC) { - >::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fail_malformed_htlc(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_commitment_signed(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::CommitmentSigned) { - >::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_commitment_signed(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_revoke_and_ack(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::RevokeAndACK) { - >::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_revoke_and_ack(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_update_fee(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::UpdateFee) { - >::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_update_fee(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_announcement_signatures(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::AnnouncementSignatures) { - >::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_announcement_signatures(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()) + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()) } #[must_use] extern "C" fn ErroringMessageHandler_ChannelMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_reestablish(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelReestablish) { - >::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_reestablish(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_channel_update(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ChannelUpdate) { - >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } extern "C" fn ErroringMessageHandler_ChannelMessageHandler_handle_error(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::ErrorMessage) { - >::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) + ::handle_error(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust(), msg.get_native_ref()) } #[must_use] -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn ErroringMessageHandler_ChannelMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] extern "C" fn ErroringMessageHandler_ChannelMessageHandler_get_chain_hashes(this_arg: *const c_void) -> crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ { - let mut ret = >::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); + let mut ret = ::get_chain_hashes(unsafe { &mut *(this_arg as *mut nativeErroringMessageHandler) }, ); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::None } else { crate::c_types::derived::COption_CVec_ThirtyTwoBytesZZ::Some( { let mut local_ret_0 = Vec::new(); for mut item in ret.unwrap().drain(..) { local_ret_0.push( { crate::c_types::ThirtyTwoBytes { data: *item.as_ref() } }); }; local_ret_0.into() }) }; local_ret } use lightning::ln::peer_handler::MessageHandler as nativeMessageHandlerImport; -pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; +pub(crate) type nativeMessageHandler = nativeMessageHandlerImport; /// Provides references to trait impls which handle different types of messages. #[must_use] @@ -882,6 +965,12 @@ pub struct MessageHandler { pub is_owned: bool, } +impl core::ops::Deref for MessageHandler { + type Target = nativeMessageHandler; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MessageHandler { } +unsafe impl core::marker::Sync for MessageHandler { } impl Drop for MessageHandler { fn drop(&mut self) { if self.is_owned && !<*mut nativeMessageHandler>::is_null(self.inner) { @@ -912,6 +1001,9 @@ impl MessageHandler { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A message handler which handles messages specific to channels. Usually this is just a /// [`ChannelManager`] object or an [`ErroringMessageHandler`]. @@ -1059,9 +1151,16 @@ impl core::cmp::Eq for SocketDescriptor {} impl core::cmp::PartialEq for SocketDescriptor { fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o) } } +impl core::cmp::Eq for SocketDescriptorRef {} +impl core::cmp::PartialEq for SocketDescriptorRef { + fn eq(&self, o: &Self) -> bool { (self.0.eq)(self.0.this_arg, &o.0) } +} impl core::hash::Hash for SocketDescriptor { fn hash(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) } } +impl core::hash::Hash for SocketDescriptorRef { + fn hash(&self, hasher: &mut H) { hasher.write_u64((self.0.hash)(self.0.this_arg)) } +} #[no_mangle] /// Creates a copy of a SocketDescriptor pub extern "C" fn SocketDescriptor_clone(orig: &SocketDescriptor) -> SocketDescriptor { @@ -1074,6 +1173,11 @@ impl Clone for SocketDescriptor { SocketDescriptor_clone(self) } } +impl Clone for SocketDescriptorRef { + fn clone(&self) -> Self { + Self(SocketDescriptor_clone(&self.0)) + } +} use lightning::ln::peer_handler::SocketDescriptor as rustSocketDescriptor; impl rustSocketDescriptor for SocketDescriptor { @@ -1087,17 +1191,29 @@ impl rustSocketDescriptor for SocketDescriptor { } } +pub struct SocketDescriptorRef(SocketDescriptor); +impl rustSocketDescriptor for SocketDescriptorRef { + fn send_data(&mut self, mut data: &[u8], mut resume_read: bool) -> usize { + let mut local_data = crate::c_types::u8slice::from_slice(data); + let mut ret = (self.0.send_data)(self.0.this_arg, local_data, resume_read); + ret + } + fn disconnect_socket(&mut self) { + (self.0.disconnect_socket)(self.0.this_arg) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for SocketDescriptor { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = SocketDescriptorRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SocketDescriptorRef) } } } impl core::ops::DerefMut for SocketDescriptor { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SocketDescriptorRef { + unsafe { &mut *(self as *mut _ as *mut SocketDescriptorRef) } } } /// Calls the free function if one is set @@ -1111,6 +1227,142 @@ impl Drop for SocketDescriptor { } } +use lightning::ln::peer_handler::PeerDetails as nativePeerDetailsImport; +pub(crate) type nativePeerDetails = nativePeerDetailsImport; + +/// Details of a connected peer as returned by [`PeerManager::list_peers`]. +#[must_use] +#[repr(C)] +pub struct PeerDetails { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePeerDetails, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for PeerDetails { + type Target = nativePeerDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerDetails { } +unsafe impl core::marker::Sync for PeerDetails { } +impl Drop for PeerDetails { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePeerDetails>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PeerDetails, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PeerDetails_free(this_obj: PeerDetails) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PeerDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePeerDetails) }; +} +#[allow(unused)] +impl PeerDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativePeerDetails { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePeerDetails { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativePeerDetails { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The node id of the peer. +/// +/// For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter +/// passed in to [`PeerManager::new_outbound_connection`]. +#[no_mangle] +pub extern "C" fn PeerDetails_get_counterparty_node_id(this_ptr: &PeerDetails) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The node id of the peer. +/// +/// For outbound connections, this [`PublicKey`] will be the same as the `their_node_id` parameter +/// passed in to [`PeerManager::new_outbound_connection`]. +#[no_mangle] +pub extern "C" fn PeerDetails_set_counterparty_node_id(this_ptr: &mut PeerDetails, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_node_id = val.into_rust(); +} +/// The socket address the peer provided in the initial handshake. +/// +/// Will only be `Some` if an address had been previously provided to +/// [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. +/// +/// Returns a copy of the field. +#[no_mangle] +pub extern "C" fn PeerDetails_get_socket_address(this_ptr: &PeerDetails) -> crate::c_types::derived::COption_SocketAddressZ { + let mut inner_val = this_ptr.get_native_mut_ref().socket_address.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some( { crate::lightning::ln::msgs::SocketAddress::native_into(inner_val.unwrap()) }) }; + local_inner_val +} +/// The socket address the peer provided in the initial handshake. +/// +/// Will only be `Some` if an address had been previously provided to +/// [`PeerManager::new_outbound_connection`] or [`PeerManager::new_inbound_connection`]. +#[no_mangle] +pub extern "C" fn PeerDetails_set_socket_address(this_ptr: &mut PeerDetails, mut val: crate::c_types::derived::COption_SocketAddressZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.socket_address = local_val; +} +/// The features the peer provided in the initial handshake. +#[no_mangle] +pub extern "C" fn PeerDetails_get_init_features(this_ptr: &PeerDetails) -> crate::lightning_types::features::InitFeatures { + let mut inner_val = &mut this_ptr.get_native_mut_ref().init_features; + crate::lightning_types::features::InitFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::InitFeatures<>) as *mut _) }, is_owned: false } +} +/// The features the peer provided in the initial handshake. +#[no_mangle] +pub extern "C" fn PeerDetails_set_init_features(this_ptr: &mut PeerDetails, mut val: crate::lightning_types::features::InitFeatures) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.init_features = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// Indicates the direction of the peer connection. +/// +/// Will be `true` for inbound connections, and `false` for outbound connections. +#[no_mangle] +pub extern "C" fn PeerDetails_get_is_inbound_connection(this_ptr: &PeerDetails) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().is_inbound_connection; + *inner_val +} +/// Indicates the direction of the peer connection. +/// +/// Will be `true` for inbound connections, and `false` for outbound connections. +#[no_mangle] +pub extern "C" fn PeerDetails_set_is_inbound_connection(this_ptr: &mut PeerDetails, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.is_inbound_connection = val; +} +/// Constructs a new PeerDetails given each field +#[must_use] +#[no_mangle] +pub extern "C" fn PeerDetails_new(mut counterparty_node_id_arg: crate::c_types::PublicKey, mut socket_address_arg: crate::c_types::derived::COption_SocketAddressZ, mut init_features_arg: crate::lightning_types::features::InitFeatures, mut is_inbound_connection_arg: bool) -> PeerDetails { + let mut local_socket_address_arg = { /*socket_address_arg*/ let socket_address_arg_opt = socket_address_arg; if socket_address_arg_opt.is_none() { None } else { Some({ { { socket_address_arg_opt.take() }.into_native() }})} }; + PeerDetails { inner: ObjOps::heap_alloc(nativePeerDetails { + counterparty_node_id: counterparty_node_id_arg.into_rust(), + socket_address: local_socket_address_arg, + init_features: *unsafe { Box::from_raw(init_features_arg.take_inner()) }, + is_inbound_connection: is_inbound_connection_arg, + }), is_owned: true } +} + use lightning::ln::peer_handler::PeerHandleError as nativePeerHandleErrorImport; pub(crate) type nativePeerHandleError = nativePeerHandleErrorImport; @@ -1132,6 +1384,12 @@ pub struct PeerHandleError { pub is_owned: bool, } +impl core::ops::Deref for PeerHandleError { + type Target = nativePeerHandleError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerHandleError { } +unsafe impl core::marker::Sync for PeerHandleError { } impl Drop for PeerHandleError { fn drop(&mut self) { if self.is_owned && !<*mut nativePeerHandleError>::is_null(self.inner) { @@ -1162,6 +1420,9 @@ impl PeerHandleError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new PeerHandleError given each field #[must_use] @@ -1192,9 +1453,14 @@ pub extern "C" fn PeerHandleError_clone(orig: &PeerHandleError) -> PeerHandleErr /// Get a string which allows debug introspection of a PeerHandleError object pub extern "C" fn PeerHandleError_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::peer_handler::PeerHandleError }).into()} +#[no_mangle] +/// Get the string representation of a PeerHandleError object +pub extern "C" fn PeerHandleError_to_str(o: &crate::lightning::ln::peer_handler::PeerHandleError) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} use lightning::ln::peer_handler::PeerManager as nativePeerManagerImport; -pub(crate) type nativePeerManager = nativePeerManagerImport; +pub(crate) type nativePeerManager = nativePeerManagerImport; /// A PeerManager manages a set of peers, described by their [`SocketDescriptor`] and marshalls /// socket events into messages which it passes on to its [`MessageHandler`]. @@ -1230,6 +1496,12 @@ pub struct PeerManager { pub is_owned: bool, } +impl core::ops::Deref for PeerManager { + type Target = nativePeerManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PeerManager { } +unsafe impl core::marker::Sync for PeerManager { } impl Drop for PeerManager { fn drop(&mut self) { if self.is_owned && !<*mut nativePeerManager>::is_null(self.inner) { @@ -1260,6 +1532,9 @@ impl PeerManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new `PeerManager` with the given message handlers. /// @@ -1277,22 +1552,27 @@ pub extern "C" fn PeerManager_new(mut message_handler: crate::lightning::ln::pee crate::lightning::ln::peer_handler::PeerManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Get a list of tuples mapping from node id to network addresses for peers which have -/// completed the initial handshake. +/// Returns a list of [`PeerDetails`] for connected peers that have completed the initial +/// handshake. +#[must_use] +#[no_mangle] +pub extern "C" fn PeerManager_list_peers(this_arg: &crate::lightning::ln::peer_handler::PeerManager) -> crate::c_types::derived::CVec_PeerDetailsZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.list_peers(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::peer_handler::PeerDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Returns the [`PeerDetails`] of a connected peer that has completed the initial handshake. /// -/// For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter -/// passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial -/// handshake has completed and we are sure the remote peer has the private key for the given -/// [`PublicKey`]. +/// Will return `None` if the peer is unknown or it hasn't completed the initial handshake. /// -/// The returned `Option`s will only be `Some` if an address had been previously given via -/// [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`]. +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn PeerManager_get_peer_node_ids(this_arg: &crate::lightning::ln::peer_handler::PeerManager) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_peer_node_ids(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = if orig_ret_0_1.is_none() { crate::c_types::derived::COption_SocketAddressZ::None } else { crate::c_types::derived::COption_SocketAddressZ::Some( { crate::lightning::ln::msgs::SocketAddress::native_into(orig_ret_0_1.unwrap()) }) }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), local_orig_ret_0_1).into(); local_ret_0 }); }; - local_ret.into() +pub extern "C" fn PeerManager_peer_by_node_id(this_arg: &crate::lightning::ln::peer_handler::PeerManager, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::peer_handler::PeerDetails { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.peer_by_node_id(&their_node_id.into_rust()); + let mut local_ret = crate::lightning::ln::peer_handler::PeerDetails { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Indicates a new outbound connection has been established to a node with the given `node_id` diff --git a/lightning-c-bindings/src/lightning/ln/script.rs b/lightning-c-bindings/src/lightning/ln/script.rs index 9be5498..9d21f8a 100644 --- a/lightning-c-bindings/src/lightning/ln/script.rs +++ b/lightning-c-bindings/src/lightning/ln/script.rs @@ -39,6 +39,12 @@ pub struct ShutdownScript { pub is_owned: bool, } +impl core::ops::Deref for ShutdownScript { + type Target = nativeShutdownScript; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ShutdownScript { } +unsafe impl core::marker::Sync for ShutdownScript { } impl Drop for ShutdownScript { fn drop(&mut self) { if self.is_owned && !<*mut nativeShutdownScript>::is_null(self.inner) { @@ -69,6 +75,9 @@ impl ShutdownScript { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ShutdownScript { fn clone(&self) -> Self { @@ -118,6 +127,12 @@ pub struct InvalidShutdownScript { pub is_owned: bool, } +impl core::ops::Deref for InvalidShutdownScript { + type Target = nativeInvalidShutdownScript; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvalidShutdownScript { } +unsafe impl core::marker::Sync for InvalidShutdownScript { } impl Drop for InvalidShutdownScript { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvalidShutdownScript>::is_null(self.inner) { @@ -148,6 +163,9 @@ impl InvalidShutdownScript { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The script that did not meet the requirements from [BOLT #2]. /// @@ -162,14 +180,14 @@ pub extern "C" fn InvalidShutdownScript_get_script(this_ptr: &InvalidShutdownScr /// [BOLT #2]: https://github.com/lightning/bolts/blob/master/02-peer-protocol.md #[no_mangle] pub extern "C" fn InvalidShutdownScript_set_script(this_ptr: &mut InvalidShutdownScript, mut val: crate::c_types::derived::CVec_u8Z) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::blockdata::script::ScriptBuf::from(val.into_rust()); + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.script = ::bitcoin::script::ScriptBuf::from(val.into_rust()); } /// Constructs a new InvalidShutdownScript given each field #[must_use] #[no_mangle] pub extern "C" fn InvalidShutdownScript_new(mut script_arg: crate::c_types::derived::CVec_u8Z) -> InvalidShutdownScript { InvalidShutdownScript { inner: ObjOps::heap_alloc(nativeInvalidShutdownScript { - script: ::bitcoin::blockdata::script::ScriptBuf::from(script_arg.into_rust()), + script: ::bitcoin::script::ScriptBuf::from(script_arg.into_rust()), }), is_owned: true } } impl Clone for InvalidShutdownScript { @@ -201,7 +219,7 @@ pub extern "C" fn ShutdownScript_write(obj: &crate::lightning::ln::script::Shutd } #[allow(unused)] pub(crate) extern "C" fn ShutdownScript_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeShutdownScript) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::script::nativeShutdownScript) }) } #[no_mangle] /// Read a ShutdownScript from a byte array, created by ShutdownScript_write @@ -214,7 +232,7 @@ pub extern "C" fn ShutdownScript_read(ser: crate::c_types::u8slice) -> crate::c_ #[must_use] #[no_mangle] pub extern "C" fn ShutdownScript_new_p2wpkh(pubkey_hash: *const [u8; 20]) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2wpkh(&bitcoin::hash_types::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + let mut ret = lightning::ln::script::ShutdownScript::new_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -222,7 +240,7 @@ pub extern "C" fn ShutdownScript_new_p2wpkh(pubkey_hash: *const [u8; 20]) -> cra #[must_use] #[no_mangle] pub extern "C" fn ShutdownScript_new_p2wsh(script_hash: *const [u8; 32]) -> crate::lightning::ln::script::ShutdownScript { - let mut ret = lightning::ln::script::ShutdownScript::new_p2wsh(&bitcoin::hash_types::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + let mut ret = lightning::ln::script::ShutdownScript::new_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -266,8 +284,13 @@ pub extern "C" fn ShutdownScript_as_legacy_pubkey(this_arg: &crate::lightning::l /// Specifically, checks for compliance with feature `option_shutdown_anysegwit`. #[must_use] #[no_mangle] -pub extern "C" fn ShutdownScript_is_compatible(this_arg: &crate::lightning::ln::script::ShutdownScript, features: &crate::lightning::ln::features::InitFeatures) -> bool { +pub extern "C" fn ShutdownScript_is_compatible(this_arg: &crate::lightning::ln::script::ShutdownScript, features: &crate::lightning_types::features::InitFeatures) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_compatible(features.get_native_ref()); ret } +#[no_mangle] +/// Get the string representation of a ShutdownScript object +pub extern "C" fn ShutdownScript_to_str(o: &crate::lightning::ln::script::ShutdownScript) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} diff --git a/lightning-c-bindings/src/lightning/ln/types.rs b/lightning-c-bindings/src/lightning/ln/types.rs new file mode 100644 index 0000000..dfccfda --- /dev/null +++ b/lightning-c-bindings/src/lightning/ln/types.rs @@ -0,0 +1,239 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Various wrapper types (most around 32-byte arrays) for use in lightning. +//! +//! Note that the re-exports of [`PaymentHash`], [`PaymentPreimage`], and [`PaymentSecret`] here +//! are deprecated and will be removed in a future version. Instead, use them via +//! [`lightning::types::payment`]. +//! +//! [`lightning::types::payment`]: crate::types::payment + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::ln::types::ChannelId as nativeChannelIdImport; +pub(crate) type nativeChannelId = nativeChannelIdImport; + +/// A unique 32-byte identifier for a channel. +/// Depending on how the ID is generated, several varieties are distinguished +/// (but all are stored as 32 bytes): +/// _v1_ and _temporary_. +/// A _v1_ channel ID is generated based on funding tx outpoint (txid & index). +/// A _temporary_ ID is generated randomly. +/// (Later revocation-point-based _v2_ is a possibility.) +/// The variety (context) is not stored, it is relevant only at creation. +#[must_use] +#[repr(C)] +pub struct ChannelId { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelId, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ChannelId { + type Target = nativeChannelId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelId { } +unsafe impl core::marker::Sync for ChannelId { } +impl Drop for ChannelId { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelId>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelId, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelId_free(this_obj: ChannelId) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelId_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelId) }; +} +#[allow(unused)] +impl ChannelId { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelId { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelId { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelId { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn ChannelId_get_a(this_ptr: &ChannelId) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val +} +#[no_mangle] +pub extern "C" fn ChannelId_set_a(this_ptr: &mut ChannelId, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.data; +} +/// Constructs a new ChannelId given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_new(mut a_arg: crate::c_types::ThirtyTwoBytes) -> ChannelId { + ChannelId { inner: ObjOps::heap_alloc(lightning::ln::types::ChannelId ( + a_arg.data, + )), is_owned: true } +} +impl Clone for ChannelId { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelId>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelId_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelId)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelId +pub extern "C" fn ChannelId_clone(orig: &ChannelId) -> ChannelId { + orig.clone() +} +/// Get a string which allows debug introspection of a ChannelId object +pub extern "C" fn ChannelId_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::types::ChannelId }).into()} +/// Checks if two ChannelIds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelId_eq(a: &ChannelId, b: &ChannelId) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Generates a non-cryptographic 64-bit hash of the ChannelId. +#[no_mangle] +pub extern "C" fn ChannelId_hash(o: &ChannelId) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Create _v1_ channel ID based on a funding TX ID and output index +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_v1_from_funding_txid(txid: *const [u8; 32], mut output_index: u16) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::v1_from_funding_txid(unsafe { &*txid}, output_index); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create _v1_ channel ID from a funding tx outpoint +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_v1_from_funding_outpoint(mut outpoint: crate::lightning::chain::transaction::OutPoint) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::v1_from_funding_outpoint(*unsafe { Box::from_raw(outpoint.take_inner()) }); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create a _temporary_ channel ID randomly, based on an entropy source. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_temporary_from_entropy_source(entropy_source: &crate::lightning::sign::EntropySource) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::temporary_from_entropy_source(entropy_source); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Generic constructor; create a new channel ID from the provided data. +/// Use a more specific `*_from_*` constructor when possible. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_from_bytes(mut data: crate::c_types::ThirtyTwoBytes) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::from_bytes(data.data); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create a channel ID consisting of all-zeros data (e.g. when uninitialized or a placeholder). +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_new_zero() -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::new_zero(); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Check whether ID is consisting of all zeros (uninitialized) +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_is_zero(this_arg: &crate::lightning::ln::types::ChannelId) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_zero(); + ret +} + +/// Create _v2_ channel ID by concatenating the holder revocation basepoint with the counterparty +/// revocation basepoint and hashing the result. The basepoints will be concatenated in increasing +/// sorted order. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_v2_from_revocation_basepoints(ours: &crate::lightning::ln::channel_keys::RevocationBasepoint, theirs: &crate::lightning::ln::channel_keys::RevocationBasepoint) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::v2_from_revocation_basepoints(ours.get_native_ref(), theirs.get_native_ref()); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create temporary _v2_ channel ID by concatenating a zeroed out basepoint with the holder +/// revocation basepoint and hashing the result. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelId_temporary_v2_from_revocation_basepoint(our_revocation_basepoint: &crate::lightning::ln::channel_keys::RevocationBasepoint) -> crate::lightning::ln::types::ChannelId { + let mut ret = lightning::ln::types::ChannelId::temporary_v2_from_revocation_basepoint(our_revocation_basepoint.get_native_ref()); + crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +#[no_mangle] +/// Serialize the ChannelId object into a byte array which can be read by ChannelId_read +pub extern "C" fn ChannelId_write(obj: &crate::lightning::ln::types::ChannelId) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn ChannelId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::ln::types::nativeChannelId) }) +} +#[no_mangle] +/// Read a ChannelId from a byte array, created by ChannelId_write +pub extern "C" fn ChannelId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ChannelIdDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::types::ChannelId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Get the string representation of a ChannelId object +pub extern "C" fn ChannelId_to_str(o: &crate::lightning::ln::types::ChannelId) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} diff --git a/lightning-c-bindings/src/lightning/ln/wire.rs b/lightning-c-bindings/src/lightning/ln/wire.rs index 39a696a..e5747f6 100644 --- a/lightning-c-bindings/src/lightning/ln/wire.rs +++ b/lightning-c-bindings/src/lightning/ln/wire.rs @@ -57,17 +57,27 @@ impl rustCustomMessageReader for CustomMessageReader { } } +pub struct CustomMessageReaderRef(CustomMessageReader); +impl rustCustomMessageReader for CustomMessageReaderRef { + type CustomMessage = crate::lightning::ln::wire::Type; + fn read(&self, mut message_type: u16, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.read)(self.0.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for CustomMessageReader { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomMessageReaderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomMessageReaderRef) } } } impl core::ops::DerefMut for CustomMessageReader { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomMessageReaderRef { + unsafe { &mut *(self as *mut _ as *mut CustomMessageReaderRef) } } } /// Calls the free function if one is set @@ -132,12 +142,23 @@ impl core::fmt::Debug for Type { f.write_str((self.debug_str)(self.this_arg).into_str()) } } +impl core::fmt::Debug for TypeRef { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.write_str((self.0.debug_str)(self.0.this_arg).into_str()) + } +} impl lightning::util::ser::Writeable for Type { fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { let vec = (self.write)(self.this_arg); w.write_all(vec.as_slice()) } } +impl lightning::util::ser::Writeable for TypeRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} #[no_mangle] /// Creates a copy of a Type pub extern "C" fn Type_clone(orig: &Type) -> Type { @@ -150,6 +171,11 @@ impl Clone for Type { Type_clone(self) } } +impl Clone for TypeRef { + fn clone(&self) -> Self { + Self(Type_clone(&self.0)) + } +} use lightning::ln::wire::Type as rustType; impl rustType for Type { @@ -159,17 +185,25 @@ impl rustType for Type { } } +pub struct TypeRef(Type); +impl rustType for TypeRef { + fn type_id(&self) -> u16 { + let mut ret = (self.0.type_id)(self.0.this_arg); + ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Type { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = TypeRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const TypeRef) } } } impl core::ops::DerefMut for Type { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut TypeRef { + unsafe { &mut *(self as *mut _ as *mut TypeRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/mod.rs b/lightning-c-bindings/src/lightning/mod.rs index 52eca2d..6b19d5f 100644 --- a/lightning-c-bindings/src/lightning/mod.rs +++ b/lightning-c-bindings/src/lightning/mod.rs @@ -53,6 +53,7 @@ pub mod sign; pub mod onion_message; pub mod blinded_path; pub mod events; +pub mod io; mod crypto { use alloc::str::FromStr; @@ -148,18 +149,6 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -} -mod io_extras { - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - } mod prelude { diff --git a/lightning-c-bindings/src/lightning/offers/invoice.rs b/lightning-c-bindings/src/lightning/offers/invoice.rs index f4c5b5a..61f2bdb 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice.rs @@ -13,46 +13,49 @@ //! then sends the invoice to the intended payer, who will then pay it. //! //! The payment recipient must include a [`PaymentHash`], so as to reveal the preimage upon payment -//! receipt, and one or more [`BlindedPath`]s for the payer to use when sending the payment. +//! receipt, and one or more [`BlindedPaymentPath`]s for the payer to use when sending the payment. //! //! ``` //! extern crate bitcoin; //! extern crate lightning; //! //! use bitcoin::hashes::Hash; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; -//! use core::convert::{Infallible, TryFrom}; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; +//! use core::convert::TryFrom; +//! use lightning::offers::invoice::UnsignedBolt12Invoice; //! use lightning::offers::invoice_request::InvoiceRequest; //! use lightning::offers::refund::Refund; //! use lightning::util::ser::Writeable; //! -//! # use lightning::ln::PaymentHash; -//! # use lightning::offers::invoice::BlindedPayInfo; -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::ln::types::PaymentHash; +//! # use lightning::offers::invoice::{ExplicitSigningPubkey, InvoiceBuilder}; +//! # use lightning::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath}; //! # -//! # fn create_payment_paths() -> Vec<(BlindedPayInfo, BlindedPath)> { unimplemented!() } +//! # fn create_payment_paths() -> Vec { unimplemented!() } //! # fn create_payment_hash() -> PaymentHash { unimplemented!() } //! # //! # fn parse_invoice_request(bytes: Vec) -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let payment_paths = create_payment_paths(); //! let payment_hash = create_payment_hash(); //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); //! let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); //! let mut buffer = Vec::new(); //! //! // Invoice for the \"offer to be paid\" flow. +//! # >::from( //! InvoiceRequest::try_from(bytes)? //! //! .respond_with(payment_paths, payment_hash)? //! +//! # ) //! .relative_expiry(3600) //! .allow_mpp() //! .fallback_v0_p2wpkh(&wpubkey_hash) //! .build()? -//! .sign::<_, Infallible>( -//! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) +//! .sign(|message: &UnsignedBolt12Invoice| +//! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) //! ) //! .expect(\"failed verifying signature\") //! .write(&mut buffer) @@ -64,23 +67,25 @@ //! # let payment_paths = create_payment_paths(); //! # let payment_hash = create_payment_hash(); //! # let secp_ctx = Secp256k1::new(); -//! # let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! # let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! # let pubkey = PublicKey::from(keys); //! # let wpubkey_hash = bitcoin::key::PublicKey::new(pubkey).wpubkey_hash().unwrap(); //! # let mut buffer = Vec::new(); //! //! // Invoice for the \"offer for money\" flow. +//! # >::from( //! \"lnr1qcp4256ypq\" //! .parse::()? //! //! .respond_with(payment_paths, payment_hash, pubkey)? //! +//! # ) //! .relative_expiry(3600) //! .allow_mpp() //! .fallback_v0_p2wpkh(&wpubkey_hash) //! .build()? -//! .sign::<_, Infallible>( -//! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) +//! .sign(|message: &UnsignedBolt12Invoice| +//! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) //! ) //! .expect(\"failed verifying signature\") //! .write(&mut buffer) @@ -100,6 +105,271 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; +use lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder as nativeInvoiceWithExplicitSigningPubkeyBuilderImport; +pub(crate) type nativeInvoiceWithExplicitSigningPubkeyBuilder = nativeInvoiceWithExplicitSigningPubkeyBuilderImport<'static, >; + +/// Builds a [`Bolt12Invoice`] from either: +/// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or +/// - a [`Refund`] for the \"offer for money\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Refund`]: crate::offers::refund::Refund +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct InvoiceWithExplicitSigningPubkeyBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceWithExplicitSigningPubkeyBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceWithExplicitSigningPubkeyBuilder { + type Target = nativeInvoiceWithExplicitSigningPubkeyBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceWithExplicitSigningPubkeyBuilder { } +unsafe impl core::marker::Sync for InvoiceWithExplicitSigningPubkeyBuilder { } +impl Drop for InvoiceWithExplicitSigningPubkeyBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceWithExplicitSigningPubkeyBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceWithExplicitSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free(this_obj: InvoiceWithExplicitSigningPubkeyBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithExplicitSigningPubkeyBuilder) }; +} +#[allow(unused)] +impl InvoiceWithExplicitSigningPubkeyBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithExplicitSigningPubkeyBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithExplicitSigningPubkeyBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithExplicitSigningPubkeyBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder as nativeInvoiceWithDerivedSigningPubkeyBuilderImport; +pub(crate) type nativeInvoiceWithDerivedSigningPubkeyBuilder = nativeInvoiceWithDerivedSigningPubkeyBuilderImport<'static, >; + +/// Builds a [`Bolt12Invoice`] from either: +/// - an [`InvoiceRequest`] for the \"offer to be paid\" flow or +/// - a [`Refund`] for the \"offer for money\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +/// [`Refund`]: crate::offers::refund::Refund +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct InvoiceWithDerivedSigningPubkeyBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceWithDerivedSigningPubkeyBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceWithDerivedSigningPubkeyBuilder { + type Target = nativeInvoiceWithDerivedSigningPubkeyBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceWithDerivedSigningPubkeyBuilder { } +unsafe impl core::marker::Sync for InvoiceWithDerivedSigningPubkeyBuilder { } +impl Drop for InvoiceWithDerivedSigningPubkeyBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceWithDerivedSigningPubkeyBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceWithDerivedSigningPubkeyBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free(this_obj: InvoiceWithDerivedSigningPubkeyBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceWithDerivedSigningPubkeyBuilder) }; +} +#[allow(unused)] +impl InvoiceWithDerivedSigningPubkeyBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceWithDerivedSigningPubkeyBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceWithDerivedSigningPubkeyBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceWithDerivedSigningPubkeyBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Builds an unsigned [`Bolt12Invoice`] after checking for valid semantics. It can be signed by +/// [`UnsignedBolt12Invoice::sign`]. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_build(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) -> crate::c_types::derived::CResult_UnsignedBolt12InvoiceBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +///Sets the [`Bolt12Invoice::relative_expiry`] +///as seconds since [`Bolt12Invoice::created_at`]. +///Any expiry that has already passed is valid and can be checked for using +///[`Bolt12Invoice::is_expired`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut relative_expiry_secs: u32) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs); + () /*ret*/ +} + +///Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, script_hash: *const [u8; 32]) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + () /*ret*/ +} + +///Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + () /*ret*/ +} + +///Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2TR addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust()); + () /*ret*/ +} + +///Sets [`Bolt12Invoice::invoice_features`] +///to indicate MPP may be used. Otherwise, MPP is disallowed. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithExplicitSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp(); + () /*ret*/ +} + +/// Builds a signed [`Bolt12Invoice`] after checking for valid semantics. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_build_and_sign(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) -> crate::c_types::derived::CResult_Bolt12InvoiceBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build_and_sign(secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +///Sets the [`Bolt12Invoice::relative_expiry`] +///as seconds since [`Bolt12Invoice::created_at`]. +///Any expiry that has already passed is valid and can be checked for using +///[`Bolt12Invoice::is_expired`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_relative_expiry(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut relative_expiry_secs: u32) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).relative_expiry(relative_expiry_secs); + () /*ret*/ +} + +///Adds a P2WSH address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2WSH addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wsh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, script_hash: *const [u8; 32]) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wsh(&bitcoin::WScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *script_hash }.clone()))); + () /*ret*/ +} + +///Adds a P2WPKH address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2WPKH addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v0_p2wpkh(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, pubkey_hash: *const [u8; 20]) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v0_p2wpkh(&bitcoin::WPubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(unsafe { *pubkey_hash }.clone()))); + () /*ret*/ +} + +///Adds a P2TR address to [`Bolt12Invoice::fallbacks`]. +/// +/// Successive calls to this method will add another address. Caller is responsible for not +/// adding duplicate addresses and only calling if capable of receiving to P2TR addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_fallback_v1_p2tr_tweaked(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder, mut output_key: crate::c_types::TweakedPublicKey) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).fallback_v1_p2tr_tweaked(&output_key.into_rust()); + () /*ret*/ +} + +///Sets [`Bolt12Invoice::invoice_features`] +///to indicate MPP may be used. Otherwise, MPP is disallowed. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceWithDerivedSigningPubkeyBuilder_allow_mpp(mut this_arg: crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).allow_mpp(); + () /*ret*/ +} + + use lightning::offers::invoice::UnsignedBolt12Invoice as nativeUnsignedBolt12InvoiceImport; pub(crate) type nativeUnsignedBolt12Invoice = nativeUnsignedBolt12InvoiceImport; @@ -124,6 +394,12 @@ pub struct UnsignedBolt12Invoice { pub is_owned: bool, } +impl core::ops::Deref for UnsignedBolt12Invoice { + type Target = nativeUnsignedBolt12Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedBolt12Invoice { } +unsafe impl core::marker::Sync for UnsignedBolt12Invoice { } impl Drop for UnsignedBolt12Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { @@ -154,6 +430,92 @@ impl UnsignedBolt12Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for UnsignedBolt12Invoice { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnsignedBolt12Invoice>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnsignedBolt12Invoice_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedBolt12Invoice)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UnsignedBolt12Invoice +pub extern "C" fn UnsignedBolt12Invoice_clone(orig: &UnsignedBolt12Invoice) -> UnsignedBolt12Invoice { + orig.clone() +} +/// A function for signing an [`UnsignedBolt12Invoice`]. +#[repr(C)] +pub struct SignBolt12InvoiceFn { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + pub sign_invoice: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for SignBolt12InvoiceFn {} +unsafe impl Sync for SignBolt12InvoiceFn {} +#[allow(unused)] +pub(crate) fn SignBolt12InvoiceFn_clone_fields(orig: &SignBolt12InvoiceFn) -> SignBolt12InvoiceFn { + SignBolt12InvoiceFn { + this_arg: orig.this_arg, + sign_invoice: Clone::clone(&orig.sign_invoice), + free: Clone::clone(&orig.free), + } +} + +use lightning::offers::invoice::SignBolt12InvoiceFn as rustSignBolt12InvoiceFn; +impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFn { + fn sign_invoice(&self, mut message: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result { + let mut ret = (self.sign_invoice)(self.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct SignBolt12InvoiceFnRef(SignBolt12InvoiceFn); +impl rustSignBolt12InvoiceFn for SignBolt12InvoiceFnRef { + fn sign_invoice(&self, mut message: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result { + let mut ret = (self.0.sign_invoice)(self.0.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for SignBolt12InvoiceFn { + type Target = SignBolt12InvoiceFnRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignBolt12InvoiceFnRef) } + } +} +impl core::ops::DerefMut for SignBolt12InvoiceFn { + fn deref_mut(&mut self) -> &mut SignBolt12InvoiceFnRef { + unsafe { &mut *(self as *mut _ as *mut SignBolt12InvoiceFnRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn SignBolt12InvoiceFn_free(this_ptr: SignBolt12InvoiceFn) { } +impl Drop for SignBolt12InvoiceFn { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } } /// Returns the [`TaggedHash`] of the invoice to sign. #[must_use] @@ -190,6 +552,12 @@ pub struct Bolt12Invoice { pub is_owned: bool, } +impl core::ops::Deref for Bolt12Invoice { + type Target = nativeBolt12Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12Invoice { } +unsafe impl core::marker::Sync for Bolt12Invoice { } impl Drop for Bolt12Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12Invoice>::is_null(self.inner) { @@ -220,6 +588,9 @@ impl Bolt12Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Bolt12Invoice { fn clone(&self) -> Self { @@ -243,6 +614,58 @@ pub extern "C" fn Bolt12Invoice_clone(orig: &Bolt12Invoice) -> Bolt12Invoice { /// Get a string which allows debug introspection of a Bolt12Invoice object pub extern "C" fn Bolt12Invoice_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::Bolt12Invoice }).into()} +/// Duration since the Unix epoch when the invoice was created. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at(); + ret.as_secs() +} + +/// Duration since +///[`Bolt12Invoice::created_at`] +/// when the invoice has expired and therefore should no longer be paid. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry(); + ret.as_secs() +} + +/// Whether the invoice has expired. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); + ret +} + +/// Fallback addresses for paying the invoice on-chain, in order of most-preferred to +/// least-preferred. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_StrZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + local_ret.into() +} + +/// Features pertaining to paying an invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::Bolt12InvoiceFeatures { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features(); + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } +} + +/// The public key corresponding to the key used to sign the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); + crate::c_types::PublicKey::from_rust(&ret) +} + /// The chains that may be used when paying a requested invoice. /// /// From [`Offer::chains`]; `None` if the invoice was created in response to a [`Refund`]. @@ -292,13 +715,11 @@ pub extern "C" fn UnsignedBolt12Invoice_metadata(this_arg: &crate::lightning::of /// /// [`Offer`]: crate::offers::offer::Offer /// [`Offer::amount`]: crate::offers::offer::Offer::amount -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } @@ -313,9 +734,9 @@ pub extern "C" fn UnsignedBolt12Invoice_amount(this_arg: &crate::lightning::offe /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::OfferFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -324,11 +745,14 @@ pub extern "C" fn UnsignedBolt12Invoice_offer_features(this_arg: &crate::lightni /// From [`Offer::description`] or [`Refund::description`]. /// /// [`Offer::description`]: crate::offers::offer::Offer::description +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -353,9 +777,9 @@ pub extern "C" fn UnsignedBolt12Invoice_absolute_expiry(this_arg: &crate::lightn /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -366,9 +790,9 @@ pub extern "C" fn UnsignedBolt12Invoice_issuer(this_arg: &crate::lightning::offe /// [`Offer::paths`]: crate::offers::offer::Offer::paths #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -378,13 +802,11 @@ pub extern "C" fn UnsignedBolt12Invoice_message_paths(this_arg: &crate::lightnin /// [`Refund`]. /// /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::offers::offer::Quantity { +pub extern "C" fn UnsignedBolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::COption_QuantityZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - let mut local_ret = crate::lightning::offers::offer::Quantity { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) }; local_ret } @@ -404,9 +826,9 @@ pub extern "C" fn UnsignedBolt12Invoice_payer_metadata(this_arg: &crate::lightni /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn UnsignedBolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of items requested or refunded for. @@ -438,25 +860,42 @@ pub extern "C" fn UnsignedBolt12Invoice_payer_id(this_arg: &crate::lightning::of /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedBolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } +/// SHA256 hash of the payment preimage that will be given in return for paying the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); + crate::c_types::ThirtyTwoBytes { data: ret.0 } +} + +/// The minimum amount required for a successful payment of the invoice. +#[must_use] +#[no_mangle] +pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); + ret +} + /// Duration since the Unix epoch when the invoice was created. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { +pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at(); ret.as_secs() } -/// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore -/// should no longer be paid. +/// Duration since +///[`Bolt12Invoice::created_at`] +/// when the invoice has expired and therefore should no longer be paid. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { +pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry(); ret.as_secs() } @@ -464,39 +903,33 @@ pub extern "C" fn UnsignedBolt12Invoice_relative_expiry(this_arg: &crate::lightn /// Whether the invoice has expired. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> bool { +pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); ret } -/// SHA256 hash of the payment preimage that will be given in return for paying the invoice. +/// Fallback addresses for paying the invoice on-chain, in order of most-preferred to +/// least-preferred. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_payment_hash(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::ThirtyTwoBytes { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash(); - crate::c_types::ThirtyTwoBytes { data: ret.0 } -} - -/// The minimum amount required for a successful payment of the invoice. -#[must_use] -#[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_amount_msats(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> u64 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount_msats(); - ret +pub extern "C" fn Bolt12Invoice_fallbacks(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_StrZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.fallbacks(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { alloc::string::ToString::to_string(&item).into() }); }; + local_ret.into() } /// Features pertaining to paying an invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { +pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::Bolt12InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features(); - crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } } /// The public key corresponding to the key used to sign the invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedBolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::PublicKey { +pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); crate::c_types::PublicKey::from_rust(&ret) } @@ -550,13 +983,11 @@ pub extern "C" fn Bolt12Invoice_metadata(this_arg: &crate::lightning::offers::in /// /// [`Offer`]: crate::offers::offer::Offer /// [`Offer::amount`]: crate::offers::offer::Offer::amount -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } @@ -571,9 +1002,9 @@ pub extern "C" fn Bolt12Invoice_amount(this_arg: &crate::lightning::offers::invo /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - let mut local_ret = crate::lightning::ln::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::OfferFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::OfferFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::OfferFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -582,11 +1013,14 @@ pub extern "C" fn Bolt12Invoice_offer_features(this_arg: &crate::lightning::offe /// From [`Offer::description`] or [`Refund::description`]. /// /// [`Offer::description`]: crate::offers::offer::Offer::description +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_description(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -611,9 +1045,9 @@ pub extern "C" fn Bolt12Invoice_absolute_expiry(this_arg: &crate::lightning::off /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -624,9 +1058,9 @@ pub extern "C" fn Bolt12Invoice_issuer(this_arg: &crate::lightning::offers::invo /// [`Offer::paths`]: crate::offers::offer::Offer::paths #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.message_paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -636,13 +1070,11 @@ pub extern "C" fn Bolt12Invoice_message_paths(this_arg: &crate::lightning::offer /// [`Refund`]. /// /// [`Offer::supported_quantity`]: crate::offers::offer::Offer::supported_quantity -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::offers::offer::Quantity { +pub extern "C" fn Bolt12Invoice_supported_quantity(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::COption_QuantityZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - let mut local_ret = crate::lightning::offers::offer::Quantity { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_QuantityZ::None } else { crate::c_types::derived::COption_QuantityZ::Some( { crate::lightning::offers::offer::Quantity::native_into(ret.unwrap()) }) }; local_ret } @@ -662,9 +1094,9 @@ pub extern "C" fn Bolt12Invoice_payer_metadata(this_arg: &crate::lightning::offe /// From [`InvoiceRequest::invoice_request_features`] or [`Refund::features`]. #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn Bolt12Invoice_invoice_request_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of items requested or refunded for. @@ -696,37 +1128,12 @@ pub extern "C" fn Bolt12Invoice_payer_id(this_arg: &crate::lightning::offers::in /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Bolt12Invoice_payer_note(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } -/// Duration since the Unix epoch when the invoice was created. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_created_at(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.created_at(); - ret.as_secs() -} - -/// Duration since [`Bolt12Invoice::created_at`] when the invoice has expired and therefore -/// should no longer be paid. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_relative_expiry(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> u64 { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.relative_expiry(); - ret.as_secs() -} - -/// Whether the invoice has expired. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_is_expired(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_expired(); - ret -} - /// SHA256 hash of the payment preimage that will be given in return for paying the invoice. #[must_use] #[no_mangle] @@ -743,22 +1150,6 @@ pub extern "C" fn Bolt12Invoice_amount_msats(this_arg: &crate::lightning::offers ret } -/// Features pertaining to paying an invoice. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_invoice_features(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::lightning::ln::features::Bolt12InvoiceFeatures { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_features(); - crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::Bolt12InvoiceFeatures<>) as *mut _) }, is_owned: false } -} - -/// The public key corresponding to the key used to sign the invoice. -#[must_use] -#[no_mangle] -pub extern "C" fn Bolt12Invoice_signing_pubkey(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::PublicKey { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); - crate::c_types::PublicKey::from_rust(&ret) -} - /// Signature of the invoice verified using [`Bolt12Invoice::signing_pubkey`]. #[must_use] #[no_mangle] @@ -775,203 +1166,32 @@ pub extern "C" fn Bolt12Invoice_signable_hash(this_arg: &crate::lightning::offer crate::c_types::ThirtyTwoBytes { data: ret } } -/// Verifies that the invoice was for a request or refund created using the given key. Returns -/// the associated [`PaymentId`] to use when sending the payment. +/// Verifies that the invoice was for a request or refund created using the given key by +/// checking the payer metadata from the invoice request. +/// +/// Returns the associated [`PaymentId`] to use when sending the payment. #[must_use] #[no_mangle] -pub extern "C" fn Bolt12Invoice_verify(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify(key.get_native_ref(), secp256k1::global::SECP256K1); +pub extern "C" fn Bolt12Invoice_verify_using_metadata(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify_using_metadata(key.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } -#[no_mangle] -/// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read -pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedBolt12Invoice) }) -} -#[no_mangle] -/// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read -pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBolt12Invoice) }) -} - -use lightning::offers::invoice::BlindedPayInfo as nativeBlindedPayInfoImport; -pub(crate) type nativeBlindedPayInfo = nativeBlindedPayInfoImport; - -/// Information needed to route a payment across a [`BlindedPath`]. -#[must_use] -#[repr(C)] -pub struct BlindedPayInfo { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeBlindedPayInfo, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for BlindedPayInfo { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeBlindedPayInfo>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the BlindedPayInfo, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_free(this_obj: BlindedPayInfo) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPayInfo_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedPayInfo) }; -} -#[allow(unused)] -impl BlindedPayInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedPayInfo { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedPayInfo { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeBlindedPayInfo { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Base fee charged (in millisatoshi) for the entire blinded path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_fee_base_msat(this_ptr: &BlindedPayInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_base_msat; - *inner_val -} -/// Base fee charged (in millisatoshi) for the entire blinded path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_fee_base_msat(this_ptr: &mut BlindedPayInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_base_msat = val; -} -/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path -/// (i.e., 10,000 is 1%). -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_fee_proportional_millionths(this_ptr: &BlindedPayInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_proportional_millionths; - *inner_val -} -/// Liquidity fee charged (in millionths of the amount transferred) for the entire blinded path -/// (i.e., 10,000 is 1%). -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_fee_proportional_millionths(this_ptr: &mut BlindedPayInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_proportional_millionths = val; -} -/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded -/// path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_cltv_expiry_delta(this_ptr: &BlindedPayInfo) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// Number of blocks subtracted from an incoming HTLC's `cltv_expiry` for the entire blinded -/// path. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_cltv_expiry_delta(this_ptr: &mut BlindedPayInfo, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; -} -/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the -/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as -/// seen by the recipient. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_htlc_minimum_msat(this_ptr: &BlindedPayInfo) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; - *inner_val -} -/// The minimum HTLC value (in millisatoshi) that is acceptable to all channel peers on the -/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as -/// seen by the recipient. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_htlc_minimum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = val; -} -/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the -/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as -/// seen by the recipient. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_htlc_maximum_msat(this_ptr: &BlindedPayInfo) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; - *inner_val -} -/// The maximum HTLC value (in millisatoshi) that is acceptable to all channel peers on the -/// blinded path from the introduction node to the recipient, accounting for any fees, i.e., as -/// seen by the recipient. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_htlc_maximum_msat(this_ptr: &mut BlindedPayInfo, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = val; -} -/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an -/// onion payload. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_get_features(this_ptr: &BlindedPayInfo) -> crate::lightning::ln::features::BlindedHopFeatures { - let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::BlindedHopFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::BlindedHopFeatures<>) as *mut _) }, is_owned: false } -} -/// Features set in `encrypted_data_tlv` for the `encrypted_recipient_data` TLV record in an -/// onion payload. -#[no_mangle] -pub extern "C" fn BlindedPayInfo_set_features(this_ptr: &mut BlindedPayInfo, mut val: crate::lightning::ln::features::BlindedHopFeatures) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// Constructs a new BlindedPayInfo given each field +/// Verifies that the invoice was for a request or refund created using the given key by +/// checking a payment id and nonce included with the [`BlindedMessagePath`] for which the invoice was +/// sent through. #[must_use] #[no_mangle] -pub extern "C" fn BlindedPayInfo_new(mut fee_base_msat_arg: u32, mut fee_proportional_millionths_arg: u32, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut features_arg: crate::lightning::ln::features::BlindedHopFeatures) -> BlindedPayInfo { - BlindedPayInfo { inner: ObjOps::heap_alloc(nativeBlindedPayInfo { - fee_base_msat: fee_base_msat_arg, - fee_proportional_millionths: fee_proportional_millionths_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: htlc_minimum_msat_arg, - htlc_maximum_msat: htlc_maximum_msat_arg, - features: *unsafe { Box::from_raw(features_arg.take_inner()) }, - }), is_owned: true } -} -impl Clone for BlindedPayInfo { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeBlindedPayInfo>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn BlindedPayInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedPayInfo)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the BlindedPayInfo -pub extern "C" fn BlindedPayInfo_clone(orig: &BlindedPayInfo) -> BlindedPayInfo { - orig.clone() +pub extern "C" fn Bolt12Invoice_verify_using_payer_data(this_arg: &crate::lightning::offers::invoice::Bolt12Invoice, mut payment_id: crate::c_types::ThirtyTwoBytes, mut nonce: crate::lightning::offers::nonce::Nonce, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.verify_using_payer_data(::lightning::ln::channelmanager::PaymentId(payment_id.data), *unsafe { Box::from_raw(nonce.take_inner()) }, key.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.0 } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret } -/// Get a string which allows debug introspection of a BlindedPayInfo object -pub extern "C" fn BlindedPayInfo_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice::BlindedPayInfo }).into()} -/// Generates a non-cryptographic 64-bit hash of the BlindedPayInfo. + +/// Generates a non-cryptographic 64-bit hash of the Bolt12Invoice. #[no_mangle] -pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 { +pub extern "C" fn Bolt12Invoice_hash(o: &Bolt12Invoice) -> u64 { if o.inner.is_null() { return 0; } // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core #[allow(deprecated)] @@ -979,28 +1199,28 @@ pub extern "C" fn BlindedPayInfo_hash(o: &BlindedPayInfo) -> u64 { core::hash::Hash::hash(o.get_native_ref(), &mut hasher); core::hash::Hasher::finish(&hasher) } -/// Checks if two BlindedPayInfos contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] -pub extern "C" fn BlindedPayInfo_eq(a: &BlindedPayInfo, b: &BlindedPayInfo) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } +/// Serialize the UnsignedBolt12Invoice object into a byte array which can be read by UnsignedBolt12Invoice_read +pub extern "C" fn UnsignedBolt12Invoice_write(obj: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn UnsignedBolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice::nativeUnsignedBolt12Invoice) }) } #[no_mangle] -/// Serialize the BlindedPayInfo object into a byte array which can be read by BlindedPayInfo_read -pub extern "C" fn BlindedPayInfo_write(obj: &crate::lightning::offers::invoice::BlindedPayInfo) -> crate::c_types::derived::CVec_u8Z { +/// Serialize the Bolt12Invoice object into a byte array which can be read by Bolt12Invoice_read +pub extern "C" fn Bolt12Invoice_write(obj: &crate::lightning::offers::invoice::Bolt12Invoice) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] -pub(crate) extern "C" fn BlindedPayInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedPayInfo) }) +pub(crate) extern "C" fn Bolt12Invoice_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice::nativeBolt12Invoice) }) } #[no_mangle] -/// Read a BlindedPayInfo from a byte array, created by BlindedPayInfo_write -pub extern "C" fn BlindedPayInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_BlindedPayInfoDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; +/// Read a Bolt12Invoice from a byte array, created by Bolt12Invoice_write +pub extern "C" fn Bolt12Invoice_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_Bolt12InvoiceDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::Bolt12Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } diff --git a/lightning-c-bindings/src/lightning/offers/invoice_error.rs b/lightning-c-bindings/src/lightning/offers/invoice_error.rs index 68a64cb..7557481 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_error.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_error.rs @@ -40,6 +40,12 @@ pub struct InvoiceError { pub is_owned: bool, } +impl core::ops::Deref for InvoiceError { + type Target = nativeInvoiceError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceError { } +unsafe impl core::marker::Sync for InvoiceError { } impl Drop for InvoiceError { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceError>::is_null(self.inner) { @@ -70,6 +76,9 @@ impl InvoiceError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The field in the [`InvoiceRequest`] or the [`Bolt12Invoice`] that contained an error. /// @@ -96,13 +105,13 @@ pub extern "C" fn InvoiceError_set_erroneous_field(this_ptr: &mut InvoiceError, } /// An explanation of the error. #[no_mangle] -pub extern "C" fn InvoiceError_get_message(this_ptr: &InvoiceError) -> crate::lightning::util::string::UntrustedString { +pub extern "C" fn InvoiceError_get_message(this_ptr: &InvoiceError) -> crate::lightning_types::string::UntrustedString { let mut inner_val = &mut this_ptr.get_native_mut_ref().message; - crate::lightning::util::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::util::string::UntrustedString<>) as *mut _) }, is_owned: false } + crate::lightning_types::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::string::UntrustedString<>) as *mut _) }, is_owned: false } } /// An explanation of the error. #[no_mangle] -pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: crate::lightning::util::string::UntrustedString) { +pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: crate::lightning_types::string::UntrustedString) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.message = *unsafe { Box::from_raw(val.take_inner()) }; } /// Constructs a new InvoiceError given each field @@ -110,7 +119,7 @@ pub extern "C" fn InvoiceError_set_message(this_ptr: &mut InvoiceError, mut val: /// Note that erroneous_field_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceError_new(mut erroneous_field_arg: crate::lightning::offers::invoice_error::ErroneousField, mut message_arg: crate::lightning::util::string::UntrustedString) -> InvoiceError { +pub extern "C" fn InvoiceError_new(mut erroneous_field_arg: crate::lightning::offers::invoice_error::ErroneousField, mut message_arg: crate::lightning_types::string::UntrustedString) -> InvoiceError { let mut local_erroneous_field_arg = if erroneous_field_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(erroneous_field_arg.take_inner()) } }) }; InvoiceError { inner: ObjOps::heap_alloc(nativeInvoiceError { erroneous_field: local_erroneous_field_arg, @@ -162,6 +171,12 @@ pub struct ErroneousField { pub is_owned: bool, } +impl core::ops::Deref for ErroneousField { + type Target = nativeErroneousField; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ErroneousField { } +unsafe impl core::marker::Sync for ErroneousField { } impl Drop for ErroneousField { fn drop(&mut self) { if self.is_owned && !<*mut nativeErroneousField>::is_null(self.inner) { @@ -192,6 +207,9 @@ impl ErroneousField { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The type number of the TLV field containing the error. #[no_mangle] @@ -259,6 +277,11 @@ pub extern "C" fn InvoiceError_from_string(mut s: crate::c_types::Str) -> crate: crate::lightning::offers::invoice_error::InvoiceError { inner: ObjOps::heap_alloc(ret), is_owned: true } } +#[no_mangle] +/// Get the string representation of a InvoiceError object +pub extern "C" fn InvoiceError_to_str(o: &crate::lightning::offers::invoice_error::InvoiceError) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} #[no_mangle] /// Serialize the InvoiceError object into a byte array which can be read by InvoiceError_read pub extern "C" fn InvoiceError_write(obj: &crate::lightning::offers::invoice_error::InvoiceError) -> crate::c_types::derived::CVec_u8Z { @@ -266,7 +289,7 @@ pub extern "C" fn InvoiceError_write(obj: &crate::lightning::offers::invoice_err } #[allow(unused)] pub(crate) extern "C" fn InvoiceError_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceError) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_error::nativeInvoiceError) }) } #[no_mangle] /// Read a InvoiceError from a byte array, created by InvoiceError_write diff --git a/lightning-c-bindings/src/lightning/offers/invoice_request.rs b/lightning-c-bindings/src/lightning/offers/invoice_request.rs index d5db8ed..9f8565d 100644 --- a/lightning-c-bindings/src/lightning/offers/invoice_request.rs +++ b/lightning-c-bindings/src/lightning/offers/invoice_request.rs @@ -22,29 +22,32 @@ //! extern crate bitcoin; //! extern crate lightning; //! -//! use bitcoin::network::constants::Network; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; -//! use core::convert::Infallible; +//! use bitcoin::network::Network; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::ln::features::OfferFeatures; +//! use lightning::offers::invoice_request::UnsignedInvoiceRequest; //! use lightning::offers::offer::Offer; //! use lightning::util::ser::Writeable; //! //! # fn parse() -> Result<(), lightning::offers::parse::Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32])?); //! let pubkey = PublicKey::from(keys); //! let mut buffer = Vec::new(); //! +//! # use lightning::offers::invoice_request::{ExplicitPayerId, InvoiceRequestBuilder}; +//! # >::from( //! \"lno1qcp4256ypq\" //! .parse::()? //! .request_invoice(vec![42; 64], pubkey)? +//! # ) //! .chain(Network::Testnet)? //! .amount_msats(1000)? //! .quantity(5)? //! .payer_note(\"foo\".to_string()) //! .build()? -//! .sign::<_, Infallible>( -//! |message| Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) +//! .sign(|message: &UnsignedInvoiceRequest| +//! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys)) //! ) //! .expect(\"failed verifying signature\") //! .write(&mut buffer) @@ -63,6 +66,251 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; +use lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder as nativeInvoiceRequestWithExplicitPayerIdBuilderImport; +pub(crate) type nativeInvoiceRequestWithExplicitPayerIdBuilder = nativeInvoiceRequestWithExplicitPayerIdBuilderImport<'static, 'static, >; + +/// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct InvoiceRequestWithExplicitPayerIdBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceRequestWithExplicitPayerIdBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceRequestWithExplicitPayerIdBuilder { + type Target = nativeInvoiceRequestWithExplicitPayerIdBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestWithExplicitPayerIdBuilder { } +unsafe impl core::marker::Sync for InvoiceRequestWithExplicitPayerIdBuilder { } +impl Drop for InvoiceRequestWithExplicitPayerIdBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequestWithExplicitPayerIdBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequestWithExplicitPayerIdBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_free(this_obj: InvoiceRequestWithExplicitPayerIdBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestWithExplicitPayerIdBuilder) }; +} +#[allow(unused)] +impl InvoiceRequestWithExplicitPayerIdBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithExplicitPayerIdBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithExplicitPayerIdBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestWithExplicitPayerIdBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder as nativeInvoiceRequestWithDerivedPayerIdBuilderImport; +pub(crate) type nativeInvoiceRequestWithDerivedPayerIdBuilder = nativeInvoiceRequestWithDerivedPayerIdBuilderImport<'static, 'static, >; + +/// Builds an [`InvoiceRequest`] from an [`Offer`] for the \"offer to be paid\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct InvoiceRequestWithDerivedPayerIdBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceRequestWithDerivedPayerIdBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceRequestWithDerivedPayerIdBuilder { + type Target = nativeInvoiceRequestWithDerivedPayerIdBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestWithDerivedPayerIdBuilder { } +unsafe impl core::marker::Sync for InvoiceRequestWithDerivedPayerIdBuilder { } +impl Drop for InvoiceRequestWithDerivedPayerIdBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequestWithDerivedPayerIdBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequestWithDerivedPayerIdBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_free(this_obj: InvoiceRequestWithDerivedPayerIdBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestWithDerivedPayerIdBuilder) }; +} +#[allow(unused)] +impl InvoiceRequestWithDerivedPayerIdBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestWithDerivedPayerIdBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestWithDerivedPayerIdBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestWithDerivedPayerIdBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Builds an unsigned [`InvoiceRequest`] after checking for valid semantics. It can be signed +/// by [`UnsignedInvoiceRequest::sign`]. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_build(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder) -> crate::c_types::derived::CResult_UnsignedInvoiceRequestBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not +/// called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported +/// by the offer. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_chain(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut network: crate::bitcoin::network::Network) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is +/// not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). +/// +/// Successive calls to this method will override the previous setting. +/// +/// [`quantity`]: Self::quantity +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_amount_msats(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut amount_msats: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` +/// does not conform to [`Offer::is_valid_quantity`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_quantity(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut quantity: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).quantity(quantity); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::payer_note`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithExplicitPayerIdBuilder_payer_note(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder, mut payer_note: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).payer_note(payer_note.into_string()); + () /*ret*/ +} + +/// Builds a signed [`InvoiceRequest`] after checking for valid semantics. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder) -> crate::c_types::derived::CResult_InvoiceRequestBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build_and_sign(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not +/// called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported +/// by the offer. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_chain(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut network: crate::bitcoin::network::Network) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is +/// not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]). +/// +/// Successive calls to this method will override the previous setting. +/// +/// [`quantity`]: Self::quantity +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut amount_msats: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity` +/// does not conform to [`Offer::is_valid_quantity`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_quantity(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut quantity: u64) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).quantity(quantity); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`InvoiceRequest::payer_note`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestWithDerivedPayerIdBuilder_payer_note(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder, mut payer_note: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).payer_note(payer_note.into_string()); + () /*ret*/ +} + + use lightning::offers::invoice_request::UnsignedInvoiceRequest as nativeUnsignedInvoiceRequestImport; pub(crate) type nativeUnsignedInvoiceRequest = nativeUnsignedInvoiceRequestImport; @@ -87,6 +335,12 @@ pub struct UnsignedInvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for UnsignedInvoiceRequest { + type Target = nativeUnsignedInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UnsignedInvoiceRequest { } +unsafe impl core::marker::Sync for UnsignedInvoiceRequest { } impl Drop for UnsignedInvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { @@ -117,6 +371,92 @@ impl UnsignedInvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for UnsignedInvoiceRequest { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUnsignedInvoiceRequest>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UnsignedInvoiceRequest_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUnsignedInvoiceRequest)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UnsignedInvoiceRequest +pub extern "C" fn UnsignedInvoiceRequest_clone(orig: &UnsignedInvoiceRequest) -> UnsignedInvoiceRequest { + orig.clone() +} +/// A function for signing an [`UnsignedInvoiceRequest`]. +#[repr(C)] +pub struct SignInvoiceRequestFn { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream. + pub sign_invoice_request: extern "C" fn (this_arg: *const c_void, message: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for SignInvoiceRequestFn {} +unsafe impl Sync for SignInvoiceRequestFn {} +#[allow(unused)] +pub(crate) fn SignInvoiceRequestFn_clone_fields(orig: &SignInvoiceRequestFn) -> SignInvoiceRequestFn { + SignInvoiceRequestFn { + this_arg: orig.this_arg, + sign_invoice_request: Clone::clone(&orig.sign_invoice_request), + free: Clone::clone(&orig.free), + } +} + +use lightning::offers::invoice_request::SignInvoiceRequestFn as rustSignInvoiceRequestFn; +impl rustSignInvoiceRequestFn for SignInvoiceRequestFn { + fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result { + let mut ret = (self.sign_invoice_request)(self.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct SignInvoiceRequestFnRef(SignInvoiceRequestFn); +impl rustSignInvoiceRequestFn for SignInvoiceRequestFnRef { + fn sign_invoice_request(&self, mut message: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result { + let mut ret = (self.0.sign_invoice_request)(self.0.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((message as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for SignInvoiceRequestFn { + type Target = SignInvoiceRequestFnRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignInvoiceRequestFnRef) } + } +} +impl core::ops::DerefMut for SignInvoiceRequestFn { + fn deref_mut(&mut self) -> &mut SignInvoiceRequestFnRef { + unsafe { &mut *(self as *mut _ as *mut SignInvoiceRequestFnRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn SignInvoiceRequestFn_free(this_ptr: SignInvoiceRequestFn) { } +impl Drop for SignInvoiceRequestFn { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } } /// Returns the [`TaggedHash`] of the invoice to sign. #[must_use] @@ -152,6 +492,12 @@ pub struct InvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for InvoiceRequest { + type Target = nativeInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequest { } +unsafe impl core::marker::Sync for InvoiceRequest { } impl Drop for InvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeInvoiceRequest>::is_null(self.inner) { @@ -182,6 +528,9 @@ impl InvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for InvoiceRequest { fn clone(&self) -> Self { @@ -209,8 +558,9 @@ pub extern "C" fn InvoiceRequest_debug_str_void(o: *const c_void) -> Str { use lightning::offers::invoice_request::VerifiedInvoiceRequest as nativeVerifiedInvoiceRequestImport; pub(crate) type nativeVerifiedInvoiceRequest = nativeVerifiedInvoiceRequestImport; -/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify`] and exposes different -/// ways to respond depending on whether the signing keys were derived. +/// An [`InvoiceRequest`] that has been verified by [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and exposes different ways to respond depending +/// on whether the signing keys were derived. #[must_use] #[repr(C)] pub struct VerifiedInvoiceRequest { @@ -226,6 +576,12 @@ pub struct VerifiedInvoiceRequest { pub is_owned: bool, } +impl core::ops::Deref for VerifiedInvoiceRequest { + type Target = nativeVerifiedInvoiceRequest; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for VerifiedInvoiceRequest { } +unsafe impl core::marker::Sync for VerifiedInvoiceRequest { } impl Drop for VerifiedInvoiceRequest { fn drop(&mut self) { if self.is_owned && !<*mut nativeVerifiedInvoiceRequest>::is_null(self.inner) { @@ -256,33 +612,20 @@ impl VerifiedInvoiceRequest { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// Keys used for signing a [`Bolt12Invoice`] if they can be derived. -/// -/// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call -/// [`respond_with`]. -/// -/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice -/// [`respond_using_derived_keys`]: Self::respond_using_derived_keys -/// [`respond_with`]: Self::respond_with +/// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_get_keys(this_ptr: &VerifiedInvoiceRequest) -> crate::c_types::derived::COption_SecretKeyZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().keys; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_SecretKeyZ::None } else { crate::c_types::derived::COption_SecretKeyZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::SecretKey::from_rust((*inner_val.as_ref().unwrap()).clone().secret_key()) }) }; - local_inner_val +pub extern "C" fn VerifiedInvoiceRequest_get_offer_id(this_ptr: &VerifiedInvoiceRequest) -> crate::lightning::offers::offer::OfferId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().offer_id; + crate::lightning::offers::offer::OfferId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::offers::offer::OfferId<>) as *mut _) }, is_owned: false } } -/// Keys used for signing a [`Bolt12Invoice`] if they can be derived. -/// -/// If `Some`, must call [`respond_using_derived_keys`] when responding. Otherwise, call -/// [`respond_with`]. -/// -/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice -/// [`respond_using_derived_keys`]: Self::respond_using_derived_keys -/// [`respond_with`]: Self::respond_with +/// The identifier of the [`Offer`] for which the [`InvoiceRequest`] was made. #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_set_keys(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::c_types::derived::COption_SecretKeyZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::bitcoin::secp256k1::KeyPair::from_secret_key(&secp256k1::global::SECP256K1, &{ val_opt.take() }.into_rust()) }})} }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.keys = local_val; +pub extern "C" fn VerifiedInvoiceRequest_set_offer_id(this_ptr: &mut VerifiedInvoiceRequest, mut val: crate::lightning::offers::offer::OfferId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.offer_id = *unsafe { Box::from_raw(val.take_inner()) }; } impl Clone for VerifiedInvoiceRequest { fn clone(&self) -> Self { @@ -328,31 +671,32 @@ pub extern "C" fn UnsignedInvoiceRequest_metadata(this_arg: &crate::lightning::o } /// The minimum amount required for a successful payment of a single item. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn UnsignedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } /// A complete description of the purpose of the payment. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn UnsignedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -372,9 +716,9 @@ pub extern "C" fn UnsignedInvoiceRequest_absolute_expiry(this_arg: &crate::light /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -382,9 +726,9 @@ pub extern "C" fn UnsignedInvoiceRequest_issuer(this_arg: &crate::lightning::off /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -393,15 +737,18 @@ pub extern "C" fn UnsignedInvoiceRequest_paths(this_arg: &crate::lightning::offe #[no_mangle] pub extern "C" fn UnsignedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::offers::offer::Quantity { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning::offers::offer::Quantity::native_into(ret) } /// The public key used by the recipient to sign invoices. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn UnsignedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); - crate::c_types::PublicKey::from_rust(&ret) + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } /// An unpredictable series of bytes, typically containing information about the derivation of @@ -439,9 +786,9 @@ pub extern "C" fn UnsignedInvoiceRequest_amount_msats(this_arg: &crate::lightnin /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn UnsignedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -467,9 +814,9 @@ pub extern "C" fn UnsignedInvoiceRequest_payer_id(this_arg: &crate::lightning::o /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn UnsignedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -495,31 +842,32 @@ pub extern "C" fn InvoiceRequest_metadata(this_arg: &crate::lightning::offers::i } /// The minimum amount required for a successful payment of a single item. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn InvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } /// A complete description of the purpose of the payment. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn InvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -539,9 +887,9 @@ pub extern "C" fn InvoiceRequest_absolute_expiry(this_arg: &crate::lightning::of /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -549,9 +897,9 @@ pub extern "C" fn InvoiceRequest_issuer(this_arg: &crate::lightning::offers::inv /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -560,15 +908,18 @@ pub extern "C" fn InvoiceRequest_paths(this_arg: &crate::lightning::offers::invo #[no_mangle] pub extern "C" fn InvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::offers::offer::Quantity { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning::offers::offer::Quantity::native_into(ret) } /// The public key used by the recipient to sign invoices. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn InvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); - crate::c_types::PublicKey::from_rust(&ret) + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } /// An unpredictable series of bytes, typically containing information about the derivation of @@ -606,9 +957,9 @@ pub extern "C" fn InvoiceRequest_amount_msats(this_arg: &crate::lightning::offer /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn InvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -634,35 +985,102 @@ pub extern "C" fn InvoiceRequest_payer_id(this_arg: &crate::lightning::offers::i /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn InvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } -/// Signature of the invoice request using [`payer_id`]. +/// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the +/// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. /// -/// [`payer_id`]: Self::payer_id +/// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned +/// creation time is used for the `created_at` parameter. +/// +/// [`Duration`]: core::time::Duration #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature(); - crate::c_types::SchnorrSignature::from_rust(&ret) +pub extern "C" fn InvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret } -/// Verifies that the request was for an offer created using the given key. Returns the verified -/// request which contains the derived keys needed to sign a [`Bolt12Invoice`] for the request -/// if they could be extracted from the metadata. +/// Creates an [`InvoiceBuilder`] for the request with the given required fields. +/// +/// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after +/// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds +/// where [`std::time::SystemTime`] is not available. +/// +/// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment +/// for the invoice. +/// +/// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It +/// must contain one or more elements ordered from most-preferred to least-preferred, if there's +/// a preference. Note, however, that any privacy is lost if a public node id was used for +/// [`Offer::signing_pubkey`]. +/// +/// Errors if the request contains unknown required features. +/// +/// # Note +/// +/// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], +/// then first use [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods +/// instead. +/// +/// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at +/// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Verifies that the request was for an offer created using the given key by checking the +/// metadata from the offer. +/// +/// Returns the verified request which contains the derived keys needed to sign a +/// [`Bolt12Invoice`] for the request if they could be extracted from the metadata. /// /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice #[must_use] #[no_mangle] -pub extern "C" fn InvoiceRequest_verify(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify(key.get_native_ref(), secp256k1::global::SECP256K1); +pub extern "C" fn InvoiceRequest_verify_using_metadata(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify_using_metadata(key.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } +/// Verifies that the request was for an offer created using the given key by checking a nonce +/// included with the [`BlindedMessagePath`] for which the request was sent through. +/// +/// Returns the verified request which contains the derived keys needed to sign a +/// [`Bolt12Invoice`] for the request if they could be extracted from the metadata. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_verify_using_recipient_data(mut this_arg: crate::lightning::offers::invoice_request::InvoiceRequest, mut nonce: crate::lightning::offers::nonce::Nonce, key: &crate::lightning::ln::inbound_payment::ExpandedKey) -> crate::c_types::derived::CResult_VerifiedInvoiceRequestNoneZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).verify_using_recipient_data(*unsafe { Box::from_raw(nonce.take_inner()) }, key.get_native_ref(), secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::VerifiedInvoiceRequest { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Signature of the invoice request using [`payer_id`]. +/// +/// [`payer_id`]: Self::payer_id +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequest_signature(this_arg: &crate::lightning::offers::invoice_request::InvoiceRequest) -> crate::c_types::SchnorrSignature { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signature(); + crate::c_types::SchnorrSignature::from_rust(&ret) +} + /// The chains that may be used when paying a requested invoice (e.g., bitcoin mainnet). /// Payments must be denominated in units of the minimal lightning-payable unit (e.g., msats) /// for the selected chain. @@ -685,31 +1103,32 @@ pub extern "C" fn VerifiedInvoiceRequest_metadata(this_arg: &crate::lightning::o } /// The minimum amount required for a successful payment of a single item. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn VerifiedInvoiceRequest_amount(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } /// A complete description of the purpose of the payment. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_description(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn VerifiedInvoiceRequest_offer_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -729,9 +1148,9 @@ pub extern "C" fn VerifiedInvoiceRequest_absolute_expiry(this_arg: &crate::light /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -739,9 +1158,9 @@ pub extern "C" fn VerifiedInvoiceRequest_issuer(this_arg: &crate::lightning::off /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -750,15 +1169,18 @@ pub extern "C" fn VerifiedInvoiceRequest_paths(this_arg: &crate::lightning::offe #[no_mangle] pub extern "C" fn VerifiedInvoiceRequest_supported_quantity(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::offers::offer::Quantity { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning::offers::offer::Quantity::native_into(ret) } /// The public key used by the recipient to sign invoices. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn VerifiedInvoiceRequest_signing_pubkey(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); - crate::c_types::PublicKey::from_rust(&ret) + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } /// An unpredictable series of bytes, typically containing information about the derivation of @@ -796,9 +1218,9 @@ pub extern "C" fn VerifiedInvoiceRequest_amount_msats(this_arg: &crate::lightnin /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn VerifiedInvoiceRequest_invoice_request_features(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.invoice_request_features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. @@ -824,9 +1246,91 @@ pub extern "C" fn VerifiedInvoiceRequest_payer_id(this_arg: &crate::lightning::o /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn VerifiedInvoiceRequest_payer_note(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret +} + +/// Creates an [`InvoiceBuilder`] for the request with the given required fields and using the +/// [`Duration`] since [`std::time::SystemTime::UNIX_EPOCH`] as the creation time. +/// +/// See [`InvoiceRequest::respond_with_no_std`] for further details where the aforementioned +/// creation time is used for the `created_at` parameter. +/// +/// [`Duration`]: core::time::Duration +#[must_use] +#[no_mangle] +pub extern "C" fn VerifiedInvoiceRequest_respond_with(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Creates an [`InvoiceBuilder`] for the request with the given required fields. +/// +/// Unless [`InvoiceBuilder::relative_expiry`] is set, the invoice will expire two hours after +/// `created_at`, which is used to set [`Bolt12Invoice::created_at`]. Useful for `no-std` builds +/// where [`std::time::SystemTime`] is not available. +/// +/// The caller is expected to remember the preimage of `payment_hash` in order to claim a payment +/// for the invoice. +/// +/// The `payment_paths` parameter is useful for maintaining the payment recipient's privacy. It +/// must contain one or more elements ordered from most-preferred to least-preferred, if there's +/// a preference. Note, however, that any privacy is lost if a public node id was used for +/// [`Offer::signing_pubkey`]. +/// +/// Errors if the request contains unknown required features. +/// +/// # Note +/// +/// If the originating [`Offer`] was created using [`OfferBuilder::deriving_signing_pubkey`], +/// then first use [`InvoiceRequest::verify_using_metadata`] or +/// [`InvoiceRequest::verify_using_recipient_data`] and then [`VerifiedInvoiceRequest`] methods +/// instead. +/// +/// [`Bolt12Invoice::created_at`]: crate::offers::invoice::Bolt12Invoice::created_at +/// [`OfferBuilder::deriving_signing_pubkey`]: crate::offers::offer::OfferBuilder::deriving_signing_pubkey +#[must_use] +#[no_mangle] +pub extern "C" fn VerifiedInvoiceRequest_respond_with_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_with_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithExplicitSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses +/// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use +/// the same [`ExpandedKey`] as the one used to create the offer. +/// +/// See [`InvoiceRequest::respond_with`] for further details. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[no_mangle] +pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Creates an [`InvoiceBuilder`] for the request using the given required fields and that uses +/// derived signing keys from the originating [`Offer`] to sign the [`Bolt12Invoice`]. Must use +/// the same [`ExpandedKey`] as the one used to create the offer. +/// +/// See [`InvoiceRequest::respond_with_no_std`] for further details. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +#[must_use] +#[no_mangle] +pub extern "C" fn VerifiedInvoiceRequest_respond_using_derived_keys_no_std(this_arg: &crate::lightning::offers::invoice_request::VerifiedInvoiceRequest, mut payment_paths: crate::c_types::derived::CVec_BlindedPaymentPathZ, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut created_at: u64) -> crate::c_types::derived::CResult_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ { + let mut local_payment_paths = Vec::new(); for mut item in payment_paths.into_rust().drain(..) { local_payment_paths.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.respond_using_derived_keys_no_std(local_payment_paths, ::lightning::ln::types::PaymentHash(payment_hash.data), core::time::Duration::from_secs(created_at)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice::InvoiceWithDerivedSigningPubkeyBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; local_ret } @@ -837,7 +1341,7 @@ pub extern "C" fn UnsignedInvoiceRequest_write(obj: &crate::lightning::offers::i } #[allow(unused)] pub(crate) extern "C" fn UnsignedInvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUnsignedInvoiceRequest) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeUnsignedInvoiceRequest) }) } #[no_mangle] /// Serialize the InvoiceRequest object into a byte array which can be read by InvoiceRequest_read @@ -846,5 +1350,175 @@ pub extern "C" fn InvoiceRequest_write(obj: &crate::lightning::offers::invoice_r } #[allow(unused)] pub(crate) extern "C" fn InvoiceRequest_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInvoiceRequest) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeInvoiceRequest) }) +} + +use lightning::offers::invoice_request::InvoiceRequestFields as nativeInvoiceRequestFieldsImport; +pub(crate) type nativeInvoiceRequestFields = nativeInvoiceRequestFieldsImport; + +/// Fields sent in an [`InvoiceRequest`] message to include in [`PaymentContext::Bolt12Offer`]. +/// +/// [`PaymentContext::Bolt12Offer`]: crate::blinded_path::payment::PaymentContext::Bolt12Offer +#[must_use] +#[repr(C)] +pub struct InvoiceRequestFields { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceRequestFields, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceRequestFields { + type Target = nativeInvoiceRequestFields; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestFields { } +unsafe impl core::marker::Sync for InvoiceRequestFields { } +impl Drop for InvoiceRequestFields { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequestFields>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequestFields, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_free(this_obj: InvoiceRequestFields) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestFields_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFields) }; +} +#[allow(unused)] +impl InvoiceRequestFields { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFields { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFields { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFields { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// A possibly transient pubkey used to sign the invoice request. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_get_payer_id(this_ptr: &InvoiceRequestFields) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// A possibly transient pubkey used to sign the invoice request. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_set_payer_id(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_id = val.into_rust(); +} +/// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_get_quantity(this_ptr: &InvoiceRequestFields) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().quantity; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The quantity of the offer's item conforming to [`Offer::is_valid_quantity`]. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_set_quantity(this_ptr: &mut InvoiceRequestFields, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.quantity = local_val; +} +/// A payer-provided note which will be seen by the recipient and reflected back in the invoice +/// response. Truncated to [`PAYER_NOTE_LIMIT`] characters. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_get_payer_note_truncated(this_ptr: &InvoiceRequestFields) -> crate::lightning_types::string::UntrustedString { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payer_note_truncated; + let mut local_inner_val = crate::lightning_types::string::UntrustedString { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning_types::string::UntrustedString<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// A payer-provided note which will be seen by the recipient and reflected back in the invoice +/// response. Truncated to [`PAYER_NOTE_LIMIT`] characters. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_set_payer_note_truncated(this_ptr: &mut InvoiceRequestFields, mut val: crate::lightning_types::string::UntrustedString) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payer_note_truncated = local_val; +} +/// Constructs a new InvoiceRequestFields given each field +/// +/// Note that payer_note_truncated_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_new(mut payer_id_arg: crate::c_types::PublicKey, mut quantity_arg: crate::c_types::derived::COption_u64Z, mut payer_note_truncated_arg: crate::lightning_types::string::UntrustedString) -> InvoiceRequestFields { + let mut local_quantity_arg = if quantity_arg.is_some() { Some( { quantity_arg.take() }) } else { None }; + let mut local_payer_note_truncated_arg = if payer_note_truncated_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(payer_note_truncated_arg.take_inner()) } }) }; + InvoiceRequestFields { inner: ObjOps::heap_alloc(nativeInvoiceRequestFields { + payer_id: payer_id_arg.into_rust(), + quantity: local_quantity_arg, + payer_note_truncated: local_payer_note_truncated_arg, + }), is_owned: true } +} +impl Clone for InvoiceRequestFields { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceRequestFields>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestFields_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFields)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceRequestFields +pub extern "C" fn InvoiceRequestFields_clone(orig: &InvoiceRequestFields) -> InvoiceRequestFields { + orig.clone() +} +/// Get a string which allows debug introspection of a InvoiceRequestFields object +pub extern "C" fn InvoiceRequestFields_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::invoice_request::InvoiceRequestFields }).into()} +/// Checks if two InvoiceRequestFieldss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn InvoiceRequestFields_eq(a: &InvoiceRequestFields, b: &InvoiceRequestFields) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// The maximum number of characters included in [`InvoiceRequestFields::payer_note_truncated`]. + +#[no_mangle] +pub static PAYER_NOTE_LIMIT: usize = lightning::offers::invoice_request::PAYER_NOTE_LIMIT; +#[no_mangle] +/// Serialize the InvoiceRequestFields object into a byte array which can be read by InvoiceRequestFields_read +pub extern "C" fn InvoiceRequestFields_write(obj: &crate::lightning::offers::invoice_request::InvoiceRequestFields) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn InvoiceRequestFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::invoice_request::nativeInvoiceRequestFields) }) +} +#[no_mangle] +/// Read a InvoiceRequestFields from a byte array, created by InvoiceRequestFields_write +pub extern "C" fn InvoiceRequestFields_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_InvoiceRequestFieldsDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestFields { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res } diff --git a/lightning-c-bindings/src/lightning/offers/merkle.rs b/lightning-c-bindings/src/lightning/offers/merkle.rs index 24e0ec3..72c8014 100644 --- a/lightning-c-bindings/src/lightning/offers/merkle.rs +++ b/lightning-c-bindings/src/lightning/offers/merkle.rs @@ -41,6 +41,12 @@ pub struct TaggedHash { pub is_owned: bool, } +impl core::ops::Deref for TaggedHash { + type Target = nativeTaggedHash; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TaggedHash { } +unsafe impl core::marker::Sync for TaggedHash { } impl Drop for TaggedHash { fn drop(&mut self) { if self.is_owned && !<*mut nativeTaggedHash>::is_null(self.inner) { @@ -71,6 +77,9 @@ impl TaggedHash { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for TaggedHash { fn clone(&self) -> Self { @@ -118,3 +127,96 @@ pub extern "C" fn TaggedHash_merkle_root(this_arg: &crate::lightning::offers::me crate::c_types::ThirtyTwoBytes { data: *ret.as_ref() } } +/// Error when signing messages. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum SignError { + /// User-defined error when signing the message. + Signing, + /// Error when verifying the produced signature using the given pubkey. + Verification( + crate::c_types::Secp256k1Error), +} +use lightning::offers::merkle::SignError as SignErrorImport; +pub(crate) type nativeSignError = SignErrorImport; + +impl SignError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeSignError { + match self { + SignError::Signing => nativeSignError::Signing, + SignError::Verification (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeSignError::Verification ( + a_nonref.into_rust(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeSignError { + match self { + SignError::Signing => nativeSignError::Signing, + SignError::Verification (mut a, ) => { + nativeSignError::Verification ( + a.into_rust(), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &SignErrorImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSignError) }; + match native { + nativeSignError::Signing => SignError::Signing, + nativeSignError::Verification (ref a, ) => { + let mut a_nonref = Clone::clone(a); + SignError::Verification ( + crate::c_types::Secp256k1Error::from_rust(a_nonref), + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSignError) -> Self { + match native { + nativeSignError::Signing => SignError::Signing, + nativeSignError::Verification (mut a, ) => { + SignError::Verification ( + crate::c_types::Secp256k1Error::from_rust(a), + ) + }, + } + } +} +/// Frees any resources used by the SignError +#[no_mangle] +pub extern "C" fn SignError_free(this_ptr: SignError) { } +/// Creates a copy of the SignError +#[no_mangle] +pub extern "C" fn SignError_clone(orig: &SignError) -> SignError { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn SignError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SignError)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn SignError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut SignError) }; +} +#[no_mangle] +/// Utility method to constructs a new Signing-variant SignError +pub extern "C" fn SignError_signing() -> SignError { + SignError::Signing} +#[no_mangle] +/// Utility method to constructs a new Verification-variant SignError +pub extern "C" fn SignError_verification(a: crate::c_types::Secp256k1Error) -> SignError { + SignError::Verification(a, ) +} +/// Get a string which allows debug introspection of a SignError object +pub extern "C" fn SignError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::merkle::SignError }).into()} diff --git a/lightning-c-bindings/src/lightning/offers/mod.rs b/lightning-c-bindings/src/lightning/offers/mod.rs index 68d2175..9d8e1f2 100644 --- a/lightning-c-bindings/src/lightning/offers/mod.rs +++ b/lightning-c-bindings/src/lightning/offers/mod.rs @@ -25,8 +25,21 @@ pub mod invoice; pub mod invoice_error; pub mod invoice_request; pub mod merkle; +pub mod nonce; pub mod parse; pub mod refund; +mod invoice_macros { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} mod payer { use alloc::str::FromStr; diff --git a/lightning-c-bindings/src/lightning/offers/nonce.rs b/lightning-c-bindings/src/lightning/offers/nonce.rs new file mode 100644 index 0000000..aad51df --- /dev/null +++ b/lightning-c-bindings/src/lightning/offers/nonce.rs @@ -0,0 +1,150 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! A number used only once. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::offers::nonce::Nonce as nativeNonceImport; +pub(crate) type nativeNonce = nativeNonceImport; + +/// A 128-bit number used only once. +/// +/// Needed when constructing [`Offer::metadata`] and deriving [`Offer::signing_pubkey`] from +/// [`ExpandedKey`]. Must not be reused for any other derivation without first hashing. +/// +/// [`Offer::metadata`]: crate::offers::offer::Offer::metadata +/// [`Offer::signing_pubkey`]: crate::offers::offer::Offer::signing_pubkey +/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey +#[must_use] +#[repr(C)] +pub struct Nonce { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeNonce, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Nonce { + type Target = nativeNonce; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Nonce { } +unsafe impl core::marker::Sync for Nonce { } +impl Drop for Nonce { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNonce>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Nonce, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Nonce_free(this_obj: Nonce) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Nonce_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNonce) }; +} +#[allow(unused)] +impl Nonce { + pub(crate) fn get_native_ref(&self) -> &'static nativeNonce { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNonce { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeNonce { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for Nonce { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNonce>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Nonce_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNonce)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Nonce +pub extern "C" fn Nonce_clone(orig: &Nonce) -> Nonce { + orig.clone() +} +/// Get a string which allows debug introspection of a Nonce object +pub extern "C" fn Nonce_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::nonce::Nonce }).into()} +/// Checks if two Nonces contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Nonce_eq(a: &Nonce, b: &Nonce) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Creates a `Nonce` from the given [`EntropySource`]. +#[must_use] +#[no_mangle] +pub extern "C" fn Nonce_from_entropy_source(mut entropy_source: crate::lightning::sign::EntropySource) -> crate::lightning::offers::nonce::Nonce { + let mut ret = lightning::offers::nonce::Nonce::from_entropy_source(entropy_source); + crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns a slice of the underlying bytes of size [`Nonce::LENGTH`]. +#[must_use] +#[no_mangle] +pub extern "C" fn Nonce_as_slice(this_arg: &crate::lightning::offers::nonce::Nonce) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_slice(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +#[no_mangle] +/// Serialize the Nonce object into a byte array which can be read by Nonce_read +pub extern "C" fn Nonce_write(obj: &crate::lightning::offers::nonce::Nonce) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Nonce_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::nonce::nativeNonce) }) +} +#[no_mangle] +/// Read a Nonce from a byte array, created by Nonce_write +pub extern "C" fn Nonce_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NonceDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::nonce::Nonce { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/offers/offer.rs b/lightning-c-bindings/src/lightning/offers/offer.rs index bc2bcb4..a8520bd 100644 --- a/lightning-c-bindings/src/lightning/offers/offer.rs +++ b/lightning-c-bindings/src/lightning/offers/offer.rs @@ -23,26 +23,27 @@ //! use core::num::NonZeroU64; //! use core::time::Duration; //! -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::offer::{Offer, OfferBuilder, Quantity}; //! use lightning::offers::parse::Bolt12ParseError; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = \"std\")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] //! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); //! //! let expiration = SystemTime::now() + Duration::from_secs(24 * 60 * 60); -//! let offer = OfferBuilder::new(\"coffee, large\".to_string(), pubkey) +//! let offer = OfferBuilder::new(pubkey) +//! .description(\"coffee, large\".to_string()) //! .amount_msats(20_000) //! .supported_quantity(Quantity::Unbounded) //! .absolute_expiry(expiration.duration_since(SystemTime::UNIX_EPOCH).unwrap()) @@ -85,6 +86,520 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; +use lightning::offers::offer::OfferId as nativeOfferIdImport; +pub(crate) type nativeOfferId = nativeOfferIdImport; + +/// An identifier for an [`Offer`] built using [`DerivedMetadata`]. +#[must_use] +#[repr(C)] +pub struct OfferId { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOfferId, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OfferId { + type Target = nativeOfferId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferId { } +unsafe impl core::marker::Sync for OfferId { } +impl Drop for OfferId { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOfferId>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OfferId, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OfferId_free(this_obj: OfferId) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferId_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferId) }; +} +#[allow(unused)] +impl OfferId { + pub(crate) fn get_native_ref(&self) -> &'static nativeOfferId { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferId { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOfferId { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn OfferId_get_a(this_ptr: &OfferId) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val +} +#[no_mangle] +pub extern "C" fn OfferId_set_a(this_ptr: &mut OfferId, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.data; +} +/// Constructs a new OfferId given each field +#[must_use] +#[no_mangle] +pub extern "C" fn OfferId_new(mut a_arg: crate::c_types::ThirtyTwoBytes) -> OfferId { + OfferId { inner: ObjOps::heap_alloc(lightning::offers::offer::OfferId ( + a_arg.data, + )), is_owned: true } +} +impl Clone for OfferId { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOfferId>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferId_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferId)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OfferId +pub extern "C" fn OfferId_clone(orig: &OfferId) -> OfferId { + orig.clone() +} +/// Get a string which allows debug introspection of a OfferId object +pub extern "C" fn OfferId_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::OfferId }).into()} +/// Checks if two OfferIds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn OfferId_eq(a: &OfferId, b: &OfferId) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the OfferId object into a byte array which can be read by OfferId_read +pub extern "C" fn OfferId_write(obj: &crate::lightning::offers::offer::OfferId) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn OfferId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::offer::nativeOfferId) }) +} +#[no_mangle] +/// Read a OfferId from a byte array, created by OfferId_write +pub extern "C" fn OfferId_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OfferIdDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::OfferId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::offers::offer::OfferWithExplicitMetadataBuilder as nativeOfferWithExplicitMetadataBuilderImport; +pub(crate) type nativeOfferWithExplicitMetadataBuilder = nativeOfferWithExplicitMetadataBuilderImport<'static, >; + +/// Builds an [`Offer`] for the \"offer to be paid\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct OfferWithExplicitMetadataBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOfferWithExplicitMetadataBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OfferWithExplicitMetadataBuilder { + type Target = nativeOfferWithExplicitMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferWithExplicitMetadataBuilder { } +unsafe impl core::marker::Sync for OfferWithExplicitMetadataBuilder { } +impl Drop for OfferWithExplicitMetadataBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOfferWithExplicitMetadataBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OfferWithExplicitMetadataBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_free(this_obj: OfferWithExplicitMetadataBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferWithExplicitMetadataBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferWithExplicitMetadataBuilder) }; +} +#[allow(unused)] +impl OfferWithExplicitMetadataBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeOfferWithExplicitMetadataBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferWithExplicitMetadataBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOfferWithExplicitMetadataBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for OfferWithExplicitMetadataBuilder { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOfferWithExplicitMetadataBuilder>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferWithExplicitMetadataBuilder_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferWithExplicitMetadataBuilder)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OfferWithExplicitMetadataBuilder +pub extern "C" fn OfferWithExplicitMetadataBuilder_clone(orig: &OfferWithExplicitMetadataBuilder) -> OfferWithExplicitMetadataBuilder { + orig.clone() +} + +use lightning::offers::offer::OfferWithDerivedMetadataBuilder as nativeOfferWithDerivedMetadataBuilderImport; +pub(crate) type nativeOfferWithDerivedMetadataBuilder = nativeOfferWithDerivedMetadataBuilderImport<'static, >; + +/// Builds an [`Offer`] for the \"offer to be paid\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct OfferWithDerivedMetadataBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOfferWithDerivedMetadataBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OfferWithDerivedMetadataBuilder { + type Target = nativeOfferWithDerivedMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferWithDerivedMetadataBuilder { } +unsafe impl core::marker::Sync for OfferWithDerivedMetadataBuilder { } +impl Drop for OfferWithDerivedMetadataBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOfferWithDerivedMetadataBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OfferWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_free(this_obj: OfferWithDerivedMetadataBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferWithDerivedMetadataBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferWithDerivedMetadataBuilder) }; +} +#[allow(unused)] +impl OfferWithDerivedMetadataBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeOfferWithDerivedMetadataBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferWithDerivedMetadataBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOfferWithDerivedMetadataBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for OfferWithDerivedMetadataBuilder { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOfferWithDerivedMetadataBuilder>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferWithDerivedMetadataBuilder_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferWithDerivedMetadataBuilder)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OfferWithDerivedMetadataBuilder +pub extern "C" fn OfferWithDerivedMetadataBuilder_clone(orig: &OfferWithDerivedMetadataBuilder) -> OfferWithDerivedMetadataBuilder { + orig.clone() +} +/// Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices. +/// The associated secret key must be remembered while the offer is valid. +/// +/// Use a different pubkey per offer to avoid correlating offers. +/// +/// # Note +/// +/// If constructing an [`Offer`] for use with a [`ChannelManager`], use +/// [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`]. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_new(mut signing_pubkey: crate::c_types::PublicKey) -> crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder { + let mut ret = lightning::offers::offer::OfferWithExplicitMetadataBuilder::new(signing_pubkey.into_rust()); + crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Sets the [`Offer::metadata`] to the given bytes. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_metadata(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut metadata: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_NoneBolt12SemanticErrorZ { + let mut local_metadata = Vec::new(); for mut item in metadata.into_rust().drain(..) { local_metadata.push( { item }); }; + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).metadata(local_metadata); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, +/// the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. +/// +/// See [`Offer::chains`] on how this relates to the payment currency. +/// +/// Successive calls to this method will add another chain hash. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_chain(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut network: crate::bitcoin::network::Network) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin()); + () /*ret*/ +} + +/// Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_amount_msats(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut amount_msats: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats); + () /*ret*/ +} + +/// Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has +/// already passed is valid and can be checked for using [`Offer::is_expired`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_absolute_expiry(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut absolute_expiry: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).absolute_expiry(core::time::Duration::from_secs(absolute_expiry)); + () /*ret*/ +} + +/// Sets the [`Offer::description`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_description(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut description: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).description(description.into_string()); + () /*ret*/ +} + +/// Sets the [`Offer::issuer`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_issuer(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut issuer: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).issuer(issuer.into_string()); + () /*ret*/ +} + +/// Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by +/// private channels or if [`Offer::signing_pubkey`] is not a public node id. +/// +/// Successive calls to this method will add another blinded path. Caller is responsible for not +/// adding duplicate paths. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); + () /*ret*/ +} + +/// Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to +/// [`Quantity::One`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_supported_quantity(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder, mut quantity: crate::lightning::offers::offer::Quantity) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).supported_quantity(quantity.into_native()); + () /*ret*/ +} + +/// Builds an [`Offer`] from the builder's settings. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithExplicitMetadataBuilder_build(mut this_arg: crate::lightning::offers::offer::OfferWithExplicitMetadataBuilder) -> crate::c_types::derived::CResult_OfferBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::Offer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing +/// pubkey is derived from the given [`ExpandedKey`] and [`Nonce`]. This provides recipient +/// privacy by using a different signing pubkey for each offer. Otherwise, the provided +/// `node_id` is used for the signing pubkey. +/// +/// Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by +/// [`InvoiceRequest::verify_using_metadata`] to determine if the request was produced for the +/// offer given an [`ExpandedKey`]. However, if [`OfferBuilder::path`] is called, then the +/// metadata will not be set and must be included in each [`BlindedMessagePath`] instead. In this case, +/// use [`InvoiceRequest::verify_using_recipient_data`]. +/// +/// [`InvoiceRequest::verify_using_metadata`]: crate::offers::invoice_request::InvoiceRequest::verify_using_metadata +/// [`InvoiceRequest::verify_using_recipient_data`]: crate::offers::invoice_request::InvoiceRequest::verify_using_recipient_data +/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce) -> crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { + let mut ret = lightning::offers::offer::OfferWithDerivedMetadataBuilder::deriving_signing_pubkey(node_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1); + crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called, +/// the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported. +/// +/// See [`Offer::chains`] on how this relates to the payment currency. +/// +/// Successive calls to this method will add another chain hash. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_chain(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut network: crate::bitcoin::network::Network) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin()); + () /*ret*/ +} + +/// Sets the [`Offer::amount`] as an [`Amount::Bitcoin`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_amount_msats(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut amount_msats: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).amount_msats(amount_msats); + () /*ret*/ +} + +/// Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has +/// already passed is valid and can be checked for using [`Offer::is_expired`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_absolute_expiry(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut absolute_expiry: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).absolute_expiry(core::time::Duration::from_secs(absolute_expiry)); + () /*ret*/ +} + +/// Sets the [`Offer::description`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_description(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut description: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).description(description.into_string()); + () /*ret*/ +} + +/// Sets the [`Offer::issuer`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_issuer(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut issuer: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).issuer(issuer.into_string()); + () /*ret*/ +} + +/// Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by +/// private channels or if [`Offer::signing_pubkey`] is not a public node id. +/// +/// Successive calls to this method will add another blinded path. Caller is responsible for not +/// adding duplicate paths. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); + () /*ret*/ +} + +/// Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to +/// [`Quantity::One`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_supported_quantity(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder, mut quantity: crate::lightning::offers::offer::Quantity) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).supported_quantity(quantity.into_native()); + () /*ret*/ +} + +/// Builds an [`Offer`] from the builder's settings. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferWithDerivedMetadataBuilder_build(mut this_arg: crate::lightning::offers::offer::OfferWithDerivedMetadataBuilder) -> crate::c_types::derived::CResult_OfferBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::Offer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + + use lightning::offers::offer::Offer as nativeOfferImport; pub(crate) type nativeOffer = nativeOfferImport; @@ -97,7 +612,7 @@ pub(crate) type nativeOffer = nativeOfferImport; /// Offers may be denominated in currency other than bitcoin but are ultimately paid using the /// latter. /// -/// Through the use of [`BlindedPath`]s, offers provide recipient privacy. +/// Through the use of [`BlindedMessagePath`]s, offers provide recipient privacy. /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest /// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice @@ -116,6 +631,12 @@ pub struct Offer { pub is_owned: bool, } +impl core::ops::Deref for Offer { + type Target = nativeOffer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Offer { } +unsafe impl core::marker::Sync for Offer { } impl Drop for Offer { fn drop(&mut self) { if self.is_owned && !<*mut nativeOffer>::is_null(self.inner) { @@ -146,6 +667,9 @@ impl Offer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Offer { fn clone(&self) -> Self { @@ -191,31 +715,32 @@ pub extern "C" fn Offer_metadata(this_arg: &crate::lightning::offers::offer::Off } /// The minimum amount required for a successful payment of a single item. -/// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Offer_amount(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::offers::offer::Amount { +pub extern "C" fn Offer_amount(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::COption_AmountZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.amount(); - let mut local_ret = crate::lightning::offers::offer::Amount { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::offers::offer::Amount<>) as *mut _ }, is_owned: false }; + let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_AmountZ::None } else { crate::c_types::derived::COption_AmountZ::Some( { crate::lightning::offers::offer::Amount::native_into(ret.unwrap()) }) }; local_ret } /// A complete description of the purpose of the payment. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Offer_description(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Offer_description(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret } /// Features pertaining to the offer. #[must_use] #[no_mangle] -pub extern "C" fn Offer_offer_features(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::ln::features::OfferFeatures { +pub extern "C" fn Offer_offer_features(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::features::OfferFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.offer_features(); - crate::lightning::ln::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::OfferFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::OfferFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::OfferFeatures<>) as *mut _) }, is_owned: false } } /// Duration since the Unix epoch when an invoice should no longer be requested. @@ -235,9 +760,9 @@ pub extern "C" fn Offer_absolute_expiry(this_arg: &crate::lightning::offers::off /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -245,9 +770,9 @@ pub extern "C" fn Offer_issuer(this_arg: &crate::lightning::offers::offer::Offer /// recipient privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn Offer_paths(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Offer_paths(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -256,22 +781,33 @@ pub extern "C" fn Offer_paths(this_arg: &crate::lightning::offers::offer::Offer) #[no_mangle] pub extern "C" fn Offer_supported_quantity(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::offers::offer::Quantity { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supported_quantity(); - crate::lightning::offers::offer::Quantity { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning::offers::offer::Quantity::native_into(ret) } /// The public key used by the recipient to sign invoices. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn Offer_signing_pubkey(this_arg: &crate::lightning::offers::offer::Offer) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.signing_pubkey(); - crate::c_types::PublicKey::from_rust(&ret) + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret +} + +/// Returns the id of the offer. +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_id(this_arg: &crate::lightning::offers::offer::Offer) -> crate::lightning::offers::offer::OfferId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.id(); + crate::lightning::offers::offer::OfferId { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Returns whether the given chain is supported by the offer. #[must_use] #[no_mangle] pub extern "C" fn Offer_supports_chain(this_arg: &crate::lightning::offers::offer::Offer, mut chain: crate::c_types::ThirtyTwoBytes) -> bool { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::blockdata::constants::ChainHash::from(&chain.data)); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_chain(::bitcoin::constants::ChainHash::from(&chain.data)); ret } @@ -309,6 +845,83 @@ pub extern "C" fn Offer_expects_quantity(this_arg: &crate::lightning::offers::of ret } +/// Similar to [`Offer::request_invoice`] except it: +/// - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each +/// request, +/// - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called +/// such that it can be used by [`Bolt12Invoice::verify_using_metadata`] to determine if the +/// invoice was requested using a base [`ExpandedKey`] from which the payer id was derived, +/// and +/// - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can +/// be used when sending the payment for the requested invoice. +/// +/// Useful to protect the sender's privacy. +/// +/// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id +/// [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata +/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata +/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_request_invoice_deriving_payer_id(this_arg: &crate::lightning::offers::offer::Offer, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_payer_id(expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestWithDerivedPayerIdBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Similar to [`Offer::request_invoice_deriving_payer_id`] except uses `payer_id` for the +/// [`InvoiceRequest::payer_id`] instead of deriving a different key for each request. +/// +/// Useful for recurring payments using the same `payer_id` with different invoices. +/// +/// [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_request_invoice_deriving_metadata(this_arg: &crate::lightning::offers::offer::Offer, mut payer_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice_deriving_metadata(payer_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Creates an [`InvoiceRequestBuilder`] for the offer with the given `metadata` and `payer_id`, +/// which will be reflected in the `Bolt12Invoice` response. +/// +/// The `metadata` is useful for including information about the derivation of `payer_id` such +/// that invoice response handling can be stateless. Also serves as payer-provided entropy while +/// hashing in the signature calculation. +/// +/// This should not leak any information such as by using a simple BIP-32 derivation path. +/// Otherwise, payments may be correlated. +/// +/// Errors if the offer contains unknown required features. +/// +/// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest +#[must_use] +#[no_mangle] +pub extern "C" fn Offer_request_invoice(this_arg: &crate::lightning::offers::offer::Offer, mut metadata: crate::c_types::derived::CVec_u8Z, mut payer_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ { + let mut local_metadata = Vec::new(); for mut item in metadata.into_rust().drain(..) { local_metadata.push( { item }); }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.request_invoice(local_metadata, payer_id.into_rust()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::invoice_request::InvoiceRequestWithExplicitPayerIdBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Generates a non-cryptographic 64-bit hash of the Offer. +#[no_mangle] +pub extern "C" fn Offer_hash(o: &Offer) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +#[no_mangle] +/// Read a Offer from a byte array, created by Offer_write +pub extern "C" fn Offer_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OfferDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::offer::Offer { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} #[no_mangle] /// Serialize the Offer object into a byte array which can be read by Offer_read pub extern "C" fn Offer_write(obj: &crate::lightning::offers::offer::Offer) -> crate::c_types::derived::CVec_u8Z { @@ -316,152 +929,243 @@ pub extern "C" fn Offer_write(obj: &crate::lightning::offers::offer::Offer) -> c } #[allow(unused)] pub(crate) extern "C" fn Offer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeOffer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::offer::nativeOffer) }) } - -use lightning::offers::offer::Amount as nativeAmountImport; -pub(crate) type nativeAmount = nativeAmountImport; - /// The minimum amount required for an item in an [`Offer`], denominated in either bitcoin or /// another currency. +#[derive(Clone)] #[must_use] #[repr(C)] -pub struct Amount { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeAmount, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, +pub enum Amount { + /// An amount of bitcoin. + Bitcoin { + /// The amount in millisatoshi. + amount_msats: u64, + }, + /// An amount of currency specified using ISO 4712. + Currency { + /// The currency that the amount is denominated in. + iso4217_code: crate::c_types::ThreeBytes, + /// The amount in the currency unit adjusted by the ISO 4712 exponent (e.g., USD cents). + amount: u64, + }, } +use lightning::offers::offer::Amount as AmountImport; +pub(crate) type nativeAmount = AmountImport; -impl Drop for Amount { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeAmount>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the Amount, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Amount_free(this_obj: Amount) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Amount_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeAmount) }; -} -#[allow(unused)] impl Amount { - pub(crate) fn get_native_ref(&self) -> &'static nativeAmount { - unsafe { &*ObjOps::untweak_ptr(self.inner) } + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeAmount { + match self { + Amount::Bitcoin {ref amount_msats, } => { + let mut amount_msats_nonref = Clone::clone(amount_msats); + nativeAmount::Bitcoin { + amount_msats: amount_msats_nonref, + } + }, + Amount::Currency {ref iso4217_code, ref amount, } => { + let mut iso4217_code_nonref = Clone::clone(iso4217_code); + let mut amount_nonref = Clone::clone(amount); + nativeAmount::Currency { + iso4217_code: iso4217_code_nonref.data, + amount: amount_nonref, + } + }, + } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeAmount { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeAmount { + match self { + Amount::Bitcoin {mut amount_msats, } => { + nativeAmount::Bitcoin { + amount_msats: amount_msats, + } + }, + Amount::Currency {mut iso4217_code, mut amount, } => { + nativeAmount::Currency { + iso4217_code: iso4217_code.data, + amount: amount, + } + }, + } } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeAmount { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret + #[allow(unused)] + pub(crate) fn from_native(native: &AmountImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeAmount) }; + match native { + nativeAmount::Bitcoin {ref amount_msats, } => { + let mut amount_msats_nonref = Clone::clone(amount_msats); + Amount::Bitcoin { + amount_msats: amount_msats_nonref, + } + }, + nativeAmount::Currency {ref iso4217_code, ref amount, } => { + let mut iso4217_code_nonref = Clone::clone(iso4217_code); + let mut amount_nonref = Clone::clone(amount); + Amount::Currency { + iso4217_code: crate::c_types::ThreeBytes { data: iso4217_code_nonref }, + amount: amount_nonref, + } + }, + } } -} -impl Clone for Amount { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeAmount>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, + #[allow(unused)] + pub(crate) fn native_into(native: nativeAmount) -> Self { + match native { + nativeAmount::Bitcoin {mut amount_msats, } => { + Amount::Bitcoin { + amount_msats: amount_msats, + } + }, + nativeAmount::Currency {mut iso4217_code, mut amount, } => { + Amount::Currency { + iso4217_code: crate::c_types::ThreeBytes { data: iso4217_code }, + amount: amount, + } + }, } } } +/// Frees any resources used by the Amount +#[no_mangle] +pub extern "C" fn Amount_free(this_ptr: Amount) { } +/// Creates a copy of the Amount +#[no_mangle] +pub extern "C" fn Amount_clone(orig: &Amount) -> Amount { + orig.clone() +} #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method pub(crate) extern "C" fn Amount_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeAmount)).clone() })) as *mut c_void + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Amount)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Amount_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Amount) }; } #[no_mangle] -/// Creates a copy of the Amount -pub extern "C" fn Amount_clone(orig: &Amount) -> Amount { - orig.clone() +/// Utility method to constructs a new Bitcoin-variant Amount +pub extern "C" fn Amount_bitcoin(amount_msats: u64) -> Amount { + Amount::Bitcoin { + amount_msats, + } +} +#[no_mangle] +/// Utility method to constructs a new Currency-variant Amount +pub extern "C" fn Amount_currency(iso4217_code: crate::c_types::ThreeBytes, amount: u64) -> Amount { + Amount::Currency { + iso4217_code, + amount, + } } /// Get a string which allows debug introspection of a Amount object pub extern "C" fn Amount_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::Amount }).into()} - -use lightning::offers::offer::Quantity as nativeQuantityImport; -pub(crate) type nativeQuantity = nativeQuantityImport; - /// Quantity of items supported by an [`Offer`]. +#[derive(Clone)] #[must_use] #[repr(C)] -pub struct Quantity { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeQuantity, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, +pub enum Quantity { + /// Up to a specific number of items (inclusive). Use when more than one item can be requested + /// but is limited (e.g., because of per customer or inventory limits). + /// + /// May be used with `NonZeroU64::new(1)` but prefer to use [`Quantity::One`] if only one item + /// is supported. + Bounded( + u64), + /// One or more items. Use when more than one item can be requested without any limit. + Unbounded, + /// Only one item. Use when only a single item can be requested. + One, } +use lightning::offers::offer::Quantity as QuantityImport; +pub(crate) type nativeQuantity = QuantityImport; -impl Drop for Quantity { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeQuantity>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the Quantity, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn Quantity_free(this_obj: Quantity) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Quantity_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeQuantity) }; -} -#[allow(unused)] impl Quantity { - pub(crate) fn get_native_ref(&self) -> &'static nativeQuantity { - unsafe { &*ObjOps::untweak_ptr(self.inner) } + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeQuantity { + match self { + Quantity::Bounded (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeQuantity::Bounded ( + core::num::NonZeroU64::new(a_nonref).expect("Value must be non-zero"), + ) + }, + Quantity::Unbounded => nativeQuantity::Unbounded, + Quantity::One => nativeQuantity::One, + } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeQuantity { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeQuantity { + match self { + Quantity::Bounded (mut a, ) => { + nativeQuantity::Bounded ( + core::num::NonZeroU64::new(a).expect("Value must be non-zero"), + ) + }, + Quantity::Unbounded => nativeQuantity::Unbounded, + Quantity::One => nativeQuantity::One, + } } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeQuantity { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret + #[allow(unused)] + pub(crate) fn from_native(native: &QuantityImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeQuantity) }; + match native { + nativeQuantity::Bounded (ref a, ) => { + let mut a_nonref = Clone::clone(a); + Quantity::Bounded ( + a_nonref.into(), + ) + }, + nativeQuantity::Unbounded => Quantity::Unbounded, + nativeQuantity::One => Quantity::One, + } } -} -impl Clone for Quantity { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeQuantity>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, + #[allow(unused)] + pub(crate) fn native_into(native: nativeQuantity) -> Self { + match native { + nativeQuantity::Bounded (mut a, ) => { + Quantity::Bounded ( + a.into(), + ) + }, + nativeQuantity::Unbounded => Quantity::Unbounded, + nativeQuantity::One => Quantity::One, } } } +/// Frees any resources used by the Quantity +#[no_mangle] +pub extern "C" fn Quantity_free(this_ptr: Quantity) { } +/// Creates a copy of the Quantity +#[no_mangle] +pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity { + orig.clone() +} #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method pub(crate) extern "C" fn Quantity_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeQuantity)).clone() })) as *mut c_void + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Quantity)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Quantity_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Quantity) }; } #[no_mangle] -/// Creates a copy of the Quantity -pub extern "C" fn Quantity_clone(orig: &Quantity) -> Quantity { - orig.clone() +/// Utility method to constructs a new Bounded-variant Quantity +pub extern "C" fn Quantity_bounded(a: u64) -> Quantity { + Quantity::Bounded(a, ) } +#[no_mangle] +/// Utility method to constructs a new Unbounded-variant Quantity +pub extern "C" fn Quantity_unbounded() -> Quantity { + Quantity::Unbounded} +#[no_mangle] +/// Utility method to constructs a new One-variant Quantity +pub extern "C" fn Quantity_one() -> Quantity { + Quantity::One} /// Get a string which allows debug introspection of a Quantity object pub extern "C" fn Quantity_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::offer::Quantity }).into()} @@ -481,3 +1185,8 @@ pub extern "C" fn Offer_from_str(s: crate::c_types::Str) -> crate::c_types::deri }, }.into() } +#[no_mangle] +/// Get the string representation of a Offer object +pub extern "C" fn Offer_to_str(o: &crate::lightning::offers::offer::Offer) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs index ccdc70c..f7b438c 100644 --- a/lightning-c-bindings/src/lightning/offers/parse.rs +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -49,6 +49,12 @@ pub struct Bolt12ParseError { pub is_owned: bool, } +impl core::ops::Deref for Bolt12ParseError { + type Target = nativeBolt12ParseError; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12ParseError { } +unsafe impl core::marker::Sync for Bolt12ParseError { } impl Drop for Bolt12ParseError { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt12ParseError>::is_null(self.inner) { @@ -79,6 +85,9 @@ impl Bolt12ParseError { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Bolt12ParseError { fn clone(&self) -> Self { @@ -153,12 +162,16 @@ 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. MissingCreationTime, /// An invoice payment hash was expected but was missing. MissingPaymentHash, + /// An invoice payment hash was provided but was not expected. + UnexpectedPaymentHash, /// A signature was expected but was missing. MissingSignature, } @@ -192,9 +205,11 @@ 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, + Bolt12SemanticError::UnexpectedPaymentHash => nativeBolt12SemanticError::UnexpectedPaymentHash, Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, } } @@ -224,9 +239,11 @@ 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, + Bolt12SemanticError::UnexpectedPaymentHash => nativeBolt12SemanticError::UnexpectedPaymentHash, Bolt12SemanticError::MissingSignature => nativeBolt12SemanticError::MissingSignature, } } @@ -257,9 +274,11 @@ 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, + nativeBolt12SemanticError::UnexpectedPaymentHash => Bolt12SemanticError::UnexpectedPaymentHash, nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, } } @@ -289,9 +308,11 @@ 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, + nativeBolt12SemanticError::UnexpectedPaymentHash => Bolt12SemanticError::UnexpectedPaymentHash, nativeBolt12SemanticError::MissingSignature => Bolt12SemanticError::MissingSignature, } } @@ -404,6 +425,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} @@ -416,6 +441,10 @@ pub extern "C" fn Bolt12SemanticError_missing_creation_time() -> Bolt12SemanticE pub extern "C" fn Bolt12SemanticError_missing_payment_hash() -> Bolt12SemanticError { Bolt12SemanticError::MissingPaymentHash} #[no_mangle] +/// Utility method to constructs a new UnexpectedPaymentHash-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_payment_hash() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedPaymentHash} +#[no_mangle] /// Utility method to constructs a new MissingSignature-variant Bolt12SemanticError pub extern "C" fn Bolt12SemanticError_missing_signature() -> Bolt12SemanticError { Bolt12SemanticError::MissingSignature} diff --git a/lightning-c-bindings/src/lightning/offers/refund.rs b/lightning-c-bindings/src/lightning/offers/refund.rs index c55fc20..011aa19 100644 --- a/lightning-c-bindings/src/lightning/offers/refund.rs +++ b/lightning-c-bindings/src/lightning/offers/refund.rs @@ -27,27 +27,28 @@ //! use core::convert::TryFrom; //! use core::time::Duration; //! -//! use bitcoin::network::constants::Network; -//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey}; +//! use bitcoin::network::Network; +//! use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, SecretKey}; //! use lightning::offers::parse::Bolt12ParseError; //! use lightning::offers::refund::{Refund, RefundBuilder}; //! use lightning::util::ser::{Readable, Writeable}; //! -//! # use lightning::blinded_path::BlindedPath; +//! # use lightning::blinded_path::message::BlindedMessagePath; //! # #[cfg(feature = \"std\")] //! # use std::time::SystemTime; //! # -//! # fn create_blinded_path() -> BlindedPath { unimplemented!() } -//! # fn create_another_blinded_path() -> BlindedPath { unimplemented!() } +//! # fn create_blinded_path() -> BlindedMessagePath { unimplemented!() } +//! # fn create_another_blinded_path() -> BlindedMessagePath { unimplemented!() } //! # //! # #[cfg(feature = \"std\")] //! # fn build() -> Result<(), Bolt12ParseError> { //! let secp_ctx = Secp256k1::new(); -//! let keys = KeyPair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); +//! let keys = Keypair::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap()); //! let pubkey = PublicKey::from(keys); //! //! let expiration = SystemTime::now() + Duration::from_secs(24 * 60 * 60); -//! let refund = RefundBuilder::new(\"coffee, large\".to_string(), vec![1; 32], pubkey, 20_000)? +//! let refund = RefundBuilder::new(vec![1; 32], pubkey, 20_000)? +//! .description(\"coffee, large\".to_string()) //! .absolute_expiry(expiration.duration_since(SystemTime::UNIX_EPOCH).unwrap()) //! .issuer(\"Foo Bar\".to_string()) //! .path(create_blinded_path()) @@ -90,6 +91,225 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; +use lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder as nativeRefundMaybeWithDerivedMetadataBuilderImport; +pub(crate) type nativeRefundMaybeWithDerivedMetadataBuilder = nativeRefundMaybeWithDerivedMetadataBuilderImport<'static, >; + +/// Builds a [`Refund`] for the \"offer for money\" flow. +/// +/// See [module-level documentation] for usage. +/// +/// [module-level documentation]: self +#[must_use] +#[repr(C)] +pub struct RefundMaybeWithDerivedMetadataBuilder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRefundMaybeWithDerivedMetadataBuilder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RefundMaybeWithDerivedMetadataBuilder { + type Target = nativeRefundMaybeWithDerivedMetadataBuilder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RefundMaybeWithDerivedMetadataBuilder { } +unsafe impl core::marker::Sync for RefundMaybeWithDerivedMetadataBuilder { } +impl Drop for RefundMaybeWithDerivedMetadataBuilder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRefundMaybeWithDerivedMetadataBuilder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RefundMaybeWithDerivedMetadataBuilder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_free(this_obj: RefundMaybeWithDerivedMetadataBuilder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RefundMaybeWithDerivedMetadataBuilder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRefundMaybeWithDerivedMetadataBuilder) }; +} +#[allow(unused)] +impl RefundMaybeWithDerivedMetadataBuilder { + pub(crate) fn get_native_ref(&self) -> &'static nativeRefundMaybeWithDerivedMetadataBuilder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRefundMaybeWithDerivedMetadataBuilder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRefundMaybeWithDerivedMetadataBuilder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for RefundMaybeWithDerivedMetadataBuilder { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRefundMaybeWithDerivedMetadataBuilder>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RefundMaybeWithDerivedMetadataBuilder_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRefundMaybeWithDerivedMetadataBuilder)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RefundMaybeWithDerivedMetadataBuilder +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_clone(orig: &RefundMaybeWithDerivedMetadataBuilder) -> RefundMaybeWithDerivedMetadataBuilder { + orig.clone() +} +/// Creates a new builder for a refund using the [`Refund::payer_id`] for the public node id to +/// send to if no [`Refund::paths`] are set. Otherwise, it may be a transient pubkey. +/// +/// Additionally, sets the required (empty) [`Refund::description`], [`Refund::payer_metadata`], +/// and [`Refund::amount_msats`]. +/// +/// # Note +/// +/// If constructing a [`Refund`] for use with a [`ChannelManager`], use +/// [`ChannelManager::create_refund_builder`] instead of [`RefundBuilder::new`]. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager +/// [`ChannelManager::create_refund_builder`]: crate::ln::channelmanager::ChannelManager::create_refund_builder +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_new(mut metadata: crate::c_types::derived::CVec_u8Z, mut payer_id: crate::c_types::PublicKey, mut amount_msats: u64) -> crate::c_types::derived::CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut local_metadata = Vec::new(); for mut item in metadata.into_rust().drain(..) { local_metadata.push( { item }); }; + let mut ret = lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder::new(local_metadata, payer_id.into_rust(), amount_msats); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Similar to [`RefundBuilder::new`] except, if [`RefundBuilder::path`] is called, the payer id +/// is derived from the given [`ExpandedKey`] and nonce. This provides sender privacy by using a +/// different payer id for each refund, assuming a different nonce is used. Otherwise, the +/// provided `node_id` is used for the payer id. +/// +/// Also, sets the metadata when [`RefundBuilder::build`] is called such that it can be used by +/// [`Bolt12Invoice::verify_using_metadata`] to determine if the invoice was produced for the +/// refund given an [`ExpandedKey`]. However, if [`RefundBuilder::path`] is called, then the +/// metadata must be included in each [`BlindedMessagePath`] instead. In this case, use +/// [`Bolt12Invoice::verify_using_payer_data`]. +/// +/// The `payment_id` is encrypted in the metadata and should be unique. This ensures that only +/// one invoice will be paid for the refund and that payments can be uniquely identified. +/// +/// [`Bolt12Invoice::verify_using_metadata`]: crate::offers::invoice::Bolt12Invoice::verify_using_metadata +/// [`Bolt12Invoice::verify_using_payer_data`]: crate::offers::invoice::Bolt12Invoice::verify_using_payer_data +/// [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_deriving_payer_id(mut node_id: crate::c_types::PublicKey, expanded_key: &crate::lightning::ln::inbound_payment::ExpandedKey, mut nonce: crate::lightning::offers::nonce::Nonce, mut amount_msats: u64, mut payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ { + let mut ret = lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder::deriving_payer_id(node_id.into_rust(), expanded_key.get_native_ref(), *unsafe { Box::from_raw(nonce.take_inner()) }, secp256k1::global::SECP256K1, amount_msats, ::lightning::ln::channelmanager::PaymentId(payment_id.data)); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + +/// Sets the [`Refund::description`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_description(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut description: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).description(description.into_string()); + () /*ret*/ +} + +/// Sets the [`Refund::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has +/// already passed is valid and can be checked for using [`Refund::is_expired`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_absolute_expiry(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut absolute_expiry: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).absolute_expiry(core::time::Duration::from_secs(absolute_expiry)); + () /*ret*/ +} + +/// Sets the [`Refund::issuer`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_issuer(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut issuer: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).issuer(issuer.into_string()); + () /*ret*/ +} + +/// Adds a blinded path to [`Refund::paths`]. Must include at least one path if only connected +/// by private channels or if [`Refund::payer_id`] is not a public node id. +/// +/// Successive calls to this method will add another blinded path. Caller is responsible for not +/// adding duplicate paths. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_path(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut path: crate::lightning::blinded_path::message::BlindedMessagePath) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).path(*unsafe { Box::from_raw(path.take_inner()) }); + () /*ret*/ +} + +/// Sets the [`Refund::chain`] of the given [`Network`] for paying an invoice. If not +/// called, [`Network::Bitcoin`] is assumed. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_chain(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut network: crate::bitcoin::network::Network) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).chain(network.into_bitcoin()); + () /*ret*/ +} + +/// Sets [`Refund::quantity`] of items. This is purely for informational purposes. It is useful +/// when the refund pertains to a [`Bolt12Invoice`] that paid for more than one item from an +/// [`Offer`] as specified by [`InvoiceRequest::quantity`]. +/// +/// Successive calls to this method will override the previous setting. +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`InvoiceRequest::quantity`]: crate::offers::invoice_request::InvoiceRequest::quantity +/// [`Offer`]: crate::offers::offer::Offer +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_quantity(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut quantity: u64) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).quantity(quantity); + () /*ret*/ +} + +/// Sets the [`Refund::payer_note`]. +/// +/// Successive calls to this method will override the previous setting. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_payer_note(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder, mut payer_note: crate::c_types::Str) { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).payer_note(payer_note.into_string()); + () /*ret*/ +} + +/// Builds a [`Refund`] after checking for valid semantics. +#[must_use] +#[no_mangle] +pub extern "C" fn RefundMaybeWithDerivedMetadataBuilder_build(mut this_arg: crate::lightning::offers::refund::RefundMaybeWithDerivedMetadataBuilder) -> crate::c_types::derived::CResult_RefundBolt12SemanticErrorZ { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).build(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::Refund { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::offers::parse::Bolt12SemanticError::native_into(e) }).into() }; + local_ret +} + + use lightning::offers::refund::Refund as nativeRefundImport; pub(crate) type nativeRefund = nativeRefundImport; @@ -116,6 +336,12 @@ pub struct Refund { pub is_owned: bool, } +impl core::ops::Deref for Refund { + type Target = nativeRefund; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Refund { } +unsafe impl core::marker::Sync for Refund { } impl Drop for Refund { fn drop(&mut self) { if self.is_owned && !<*mut nativeRefund>::is_null(self.inner) { @@ -146,6 +372,9 @@ impl Refund { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Refund { fn clone(&self) -> Self { @@ -173,9 +402,9 @@ pub extern "C" fn Refund_debug_str_void(o: *const c_void) -> Str { /// but with the caveat that it has not been verified in any way. #[must_use] #[no_mangle] -pub extern "C" fn Refund_description(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_description(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description(); - crate::lightning::util::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::string::PrintableString { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Duration since the Unix epoch when an invoice should no longer be sent. @@ -211,9 +440,9 @@ pub extern "C" fn Refund_is_expired_no_std(this_arg: &crate::lightning::offers:: /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.issuer(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } @@ -221,9 +450,9 @@ pub extern "C" fn Refund_issuer(this_arg: &crate::lightning::offers::refund::Ref /// privacy by obfuscating its node id. #[must_use] #[no_mangle] -pub extern "C" fn Refund_paths(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_BlindedPathZ { +pub extern "C" fn Refund_paths(this_arg: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_BlindedMessagePathZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.paths(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -260,9 +489,9 @@ pub extern "C" fn Refund_amount_msats(this_arg: &crate::lightning::offers::refun /// Features pertaining to requesting an invoice. #[must_use] #[no_mangle] -pub extern "C" fn Refund_features(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::ln::features::InvoiceRequestFeatures { +pub extern "C" fn Refund_features(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::features::InvoiceRequestFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - crate::lightning::ln::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::InvoiceRequestFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::features::InvoiceRequestFeatures<>) as *mut _) }, is_owned: false } } /// The quantity of an item that refund is for. @@ -290,12 +519,29 @@ pub extern "C" fn Refund_payer_id(this_arg: &crate::lightning::offers::refund::R /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Refund_payer_note(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning::util::string::PrintableString { +pub extern "C" fn Refund_payer_note(this_arg: &crate::lightning::offers::refund::Refund) -> crate::lightning_types::string::PrintableString { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payer_note(); - let mut local_ret = crate::lightning::util::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + let mut local_ret = crate::lightning_types::string::PrintableString { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } +/// Generates a non-cryptographic 64-bit hash of the Refund. +#[no_mangle] +pub extern "C" fn Refund_hash(o: &Refund) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +#[no_mangle] +/// Read a Refund from a byte array, created by Refund_write +pub extern "C" fn Refund_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RefundDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::offers::refund::Refund { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} #[no_mangle] /// Serialize the Refund object into a byte array which can be read by Refund_read pub extern "C" fn Refund_write(obj: &crate::lightning::offers::refund::Refund) -> crate::c_types::derived::CVec_u8Z { @@ -303,7 +549,7 @@ pub extern "C" fn Refund_write(obj: &crate::lightning::offers::refund::Refund) - } #[allow(unused)] pub(crate) extern "C" fn Refund_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRefund) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::offers::refund::nativeRefund) }) } #[no_mangle] /// Read a Refund object from a string @@ -321,3 +567,8 @@ pub extern "C" fn Refund_from_str(s: crate::c_types::Str) -> crate::c_types::der }, }.into() } +#[no_mangle] +/// Get the string representation of a Refund object +pub extern "C" fn Refund_to_str(o: &crate::lightning::offers::refund::Refund) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} diff --git a/lightning-c-bindings/src/lightning/onion_message/async_payments.rs b/lightning-c-bindings/src/lightning/onion_message/async_payments.rs new file mode 100644 index 0000000..dc778f6 --- /dev/null +++ b/lightning-c-bindings/src/lightning/onion_message/async_payments.rs @@ -0,0 +1,575 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Message handling for async payments. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// A handler for an [`OnionMessage`] containing an async payments message as its payload. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[repr(C)] +pub struct AsyncPaymentsMessageHandler { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release + /// the held funds. + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub held_htlc_available: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::async_payments::HeldHtlcAvailable, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ, + /// Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC + /// should be released to the corresponding payee. + pub release_held_htlc: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc), + /// Release any [`AsyncPaymentsMessage`]s that need to be sent. + /// + /// Typically, this is used for messages initiating an async payment flow rather than in response + /// to another message. + pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for AsyncPaymentsMessageHandler {} +unsafe impl Sync for AsyncPaymentsMessageHandler {} +#[allow(unused)] +pub(crate) fn AsyncPaymentsMessageHandler_clone_fields(orig: &AsyncPaymentsMessageHandler) -> AsyncPaymentsMessageHandler { + AsyncPaymentsMessageHandler { + this_arg: orig.this_arg, + held_htlc_available: Clone::clone(&orig.held_htlc_available), + release_held_htlc: Clone::clone(&orig.release_held_htlc), + release_pending_messages: Clone::clone(&orig.release_pending_messages), + free: Clone::clone(&orig.free), + } +} + +use lightning::onion_message::async_payments::AsyncPaymentsMessageHandler as rustAsyncPaymentsMessageHandler; +impl rustAsyncPaymentsMessageHandler for AsyncPaymentsMessageHandler { + fn held_htlc_available(&self, mut message: lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: Option) -> Option<(lightning::onion_message::async_payments::ReleaseHeldHtlc, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.held_htlc_available)(self.this_arg, crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(message), is_owned: true }, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_held_htlc(&self, mut message: lightning::onion_message::async_payments::ReleaseHeldHtlc) { + (self.release_held_htlc)(self.this_arg, crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(message), is_owned: true }) + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::async_payments::AsyncPaymentsMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.release_pending_messages)(self.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct AsyncPaymentsMessageHandlerRef(AsyncPaymentsMessageHandler); +impl rustAsyncPaymentsMessageHandler for AsyncPaymentsMessageHandlerRef { + fn held_htlc_available(&self, mut message: lightning::onion_message::async_payments::HeldHtlcAvailable, mut responder: Option) -> Option<(lightning::onion_message::async_payments::ReleaseHeldHtlc, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.held_htlc_available)(self.0.this_arg, crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(message), is_owned: true }, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (*unsafe { Box::from_raw(orig_ret_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_held_htlc(&self, mut message: lightning::onion_message::async_payments::ReleaseHeldHtlc) { + (self.0.release_held_htlc)(self.0.this_arg, crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(message), is_owned: true }) + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::async_payments::AsyncPaymentsMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_messages)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for AsyncPaymentsMessageHandler { + type Target = AsyncPaymentsMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const AsyncPaymentsMessageHandlerRef) } + } +} +impl core::ops::DerefMut for AsyncPaymentsMessageHandler { + fn deref_mut(&mut self) -> &mut AsyncPaymentsMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut AsyncPaymentsMessageHandlerRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessageHandler_free(this_ptr: AsyncPaymentsMessageHandler) { } +impl Drop for AsyncPaymentsMessageHandler { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} +/// Possible async payment messages sent and received via an [`OnionMessage`]. +/// +/// [`OnionMessage`]: crate::ln::msgs::OnionMessage +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum AsyncPaymentsMessage { + /// An HTLC is being held upstream for the often-offline recipient, to be released via + /// [`ReleaseHeldHtlc`]. + HeldHtlcAvailable( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable), + /// Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. + ReleaseHeldHtlc( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc), +} +use lightning::onion_message::async_payments::AsyncPaymentsMessage as AsyncPaymentsMessageImport; +pub(crate) type nativeAsyncPaymentsMessage = AsyncPaymentsMessageImport; + +impl AsyncPaymentsMessage { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeAsyncPaymentsMessage { + match self { + AsyncPaymentsMessage::HeldHtlcAvailable (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeAsyncPaymentsMessage::HeldHtlcAvailable ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + AsyncPaymentsMessage::ReleaseHeldHtlc (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeAsyncPaymentsMessage::ReleaseHeldHtlc ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeAsyncPaymentsMessage { + match self { + AsyncPaymentsMessage::HeldHtlcAvailable (mut a, ) => { + nativeAsyncPaymentsMessage::HeldHtlcAvailable ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + AsyncPaymentsMessage::ReleaseHeldHtlc (mut a, ) => { + nativeAsyncPaymentsMessage::ReleaseHeldHtlc ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &AsyncPaymentsMessageImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeAsyncPaymentsMessage) }; + match native { + nativeAsyncPaymentsMessage::HeldHtlcAvailable (ref a, ) => { + let mut a_nonref = Clone::clone(a); + AsyncPaymentsMessage::HeldHtlcAvailable ( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeAsyncPaymentsMessage::ReleaseHeldHtlc (ref a, ) => { + let mut a_nonref = Clone::clone(a); + AsyncPaymentsMessage::ReleaseHeldHtlc ( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeAsyncPaymentsMessage) -> Self { + match native { + nativeAsyncPaymentsMessage::HeldHtlcAvailable (mut a, ) => { + AsyncPaymentsMessage::HeldHtlcAvailable ( + crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeAsyncPaymentsMessage::ReleaseHeldHtlc (mut a, ) => { + AsyncPaymentsMessage::ReleaseHeldHtlc ( + crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the AsyncPaymentsMessage +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_free(this_ptr: AsyncPaymentsMessage) { } +/// Creates a copy of the AsyncPaymentsMessage +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_clone(orig: &AsyncPaymentsMessage) -> AsyncPaymentsMessage { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AsyncPaymentsMessage_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const AsyncPaymentsMessage)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn AsyncPaymentsMessage_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut AsyncPaymentsMessage) }; +} +#[no_mangle] +/// Utility method to constructs a new HeldHtlcAvailable-variant AsyncPaymentsMessage +pub extern "C" fn AsyncPaymentsMessage_held_htlc_available(a: crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> AsyncPaymentsMessage { + AsyncPaymentsMessage::HeldHtlcAvailable(a, ) +} +#[no_mangle] +/// Utility method to constructs a new ReleaseHeldHtlc-variant AsyncPaymentsMessage +pub extern "C" fn AsyncPaymentsMessage_release_held_htlc(a: crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> AsyncPaymentsMessage { + AsyncPaymentsMessage::ReleaseHeldHtlc(a, ) +} +/// Get a string which allows debug introspection of a AsyncPaymentsMessage object +pub extern "C" fn AsyncPaymentsMessage_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::AsyncPaymentsMessage }).into()} + +use lightning::onion_message::async_payments::HeldHtlcAvailable as nativeHeldHtlcAvailableImport; +pub(crate) type nativeHeldHtlcAvailable = nativeHeldHtlcAvailableImport; + +/// An HTLC destined for the recipient of this message is being held upstream. The reply path +/// accompanying this onion message should be used to send a [`ReleaseHeldHtlc`] response, which +/// will cause the upstream HTLC to be released. +#[must_use] +#[repr(C)] +pub struct HeldHtlcAvailable { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeHeldHtlcAvailable, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for HeldHtlcAvailable { + type Target = nativeHeldHtlcAvailable; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HeldHtlcAvailable { } +unsafe impl core::marker::Sync for HeldHtlcAvailable { } +impl Drop for HeldHtlcAvailable { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeHeldHtlcAvailable>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the HeldHtlcAvailable, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_free(this_obj: HeldHtlcAvailable) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn HeldHtlcAvailable_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeHeldHtlcAvailable) }; +} +#[allow(unused)] +impl HeldHtlcAvailable { + pub(crate) fn get_native_ref(&self) -> &'static nativeHeldHtlcAvailable { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeHeldHtlcAvailable { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeHeldHtlcAvailable { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The secret that will be used by the recipient of this message to release the held HTLC. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_get_payment_release_secret(this_ptr: &HeldHtlcAvailable) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_release_secret; + inner_val +} +/// The secret that will be used by the recipient of this message to release the held HTLC. +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_set_payment_release_secret(this_ptr: &mut HeldHtlcAvailable, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_release_secret = val.data; +} +/// Constructs a new HeldHtlcAvailable given each field +#[must_use] +#[no_mangle] +pub extern "C" fn HeldHtlcAvailable_new(mut payment_release_secret_arg: crate::c_types::ThirtyTwoBytes) -> HeldHtlcAvailable { + HeldHtlcAvailable { inner: ObjOps::heap_alloc(nativeHeldHtlcAvailable { + payment_release_secret: payment_release_secret_arg.data, + }), is_owned: true } +} +impl Clone for HeldHtlcAvailable { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeHeldHtlcAvailable>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn HeldHtlcAvailable_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeHeldHtlcAvailable)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the HeldHtlcAvailable +pub extern "C" fn HeldHtlcAvailable_clone(orig: &HeldHtlcAvailable) -> HeldHtlcAvailable { + orig.clone() +} +/// Get a string which allows debug introspection of a HeldHtlcAvailable object +pub extern "C" fn HeldHtlcAvailable_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::HeldHtlcAvailable }).into()} + +use lightning::onion_message::async_payments::ReleaseHeldHtlc as nativeReleaseHeldHtlcImport; +pub(crate) type nativeReleaseHeldHtlc = nativeReleaseHeldHtlcImport; + +/// Releases the HTLC corresponding to an inbound [`HeldHtlcAvailable`] message. +#[must_use] +#[repr(C)] +pub struct ReleaseHeldHtlc { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeReleaseHeldHtlc, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ReleaseHeldHtlc { + type Target = nativeReleaseHeldHtlc; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReleaseHeldHtlc { } +unsafe impl core::marker::Sync for ReleaseHeldHtlc { } +impl Drop for ReleaseHeldHtlc { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeReleaseHeldHtlc>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ReleaseHeldHtlc, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_free(this_obj: ReleaseHeldHtlc) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReleaseHeldHtlc_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeReleaseHeldHtlc) }; +} +#[allow(unused)] +impl ReleaseHeldHtlc { + pub(crate) fn get_native_ref(&self) -> &'static nativeReleaseHeldHtlc { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeReleaseHeldHtlc { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeReleaseHeldHtlc { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Used to release the HTLC held upstream if it matches the corresponding +/// [`HeldHtlcAvailable::payment_release_secret`]. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_get_payment_release_secret(this_ptr: &ReleaseHeldHtlc) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_release_secret; + inner_val +} +/// Used to release the HTLC held upstream if it matches the corresponding +/// [`HeldHtlcAvailable::payment_release_secret`]. +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_set_payment_release_secret(this_ptr: &mut ReleaseHeldHtlc, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_release_secret = val.data; +} +/// Constructs a new ReleaseHeldHtlc given each field +#[must_use] +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_new(mut payment_release_secret_arg: crate::c_types::ThirtyTwoBytes) -> ReleaseHeldHtlc { + ReleaseHeldHtlc { inner: ObjOps::heap_alloc(nativeReleaseHeldHtlc { + payment_release_secret: payment_release_secret_arg.data, + }), is_owned: true } +} +impl Clone for ReleaseHeldHtlc { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeReleaseHeldHtlc>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ReleaseHeldHtlc_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeReleaseHeldHtlc)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ReleaseHeldHtlc +pub extern "C" fn ReleaseHeldHtlc_clone(orig: &ReleaseHeldHtlc) -> ReleaseHeldHtlc { + orig.clone() +} +/// Get a string which allows debug introspection of a ReleaseHeldHtlc object +pub extern "C" fn ReleaseHeldHtlc_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::async_payments::ReleaseHeldHtlc }).into()} +impl From for crate::lightning::onion_message::packet::OnionMessageContents { + fn from(obj: nativeReleaseHeldHtlc) -> Self { + let rust_obj = crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = ReleaseHeldHtlc_as_OnionMessageContents(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(ReleaseHeldHtlc_free_void); + ret + } +} +/// Constructs a new OnionMessageContents which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is +#[no_mangle] +pub extern "C" fn ReleaseHeldHtlc_as_OnionMessageContents(this_arg: &ReleaseHeldHtlc) -> crate::lightning::onion_message::packet::OnionMessageContents { + crate::lightning::onion_message::packet::OnionMessageContents { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + tlv_type: ReleaseHeldHtlc_OnionMessageContents_tlv_type, + msg_type: ReleaseHeldHtlc_OnionMessageContents_msg_type, + write: ReleaseHeldHtlc_write_void, + debug_str: ReleaseHeldHtlc_debug_str_void, + cloned: Some(OnionMessageContents_ReleaseHeldHtlc_cloned), + } +} + +#[must_use] +extern "C" fn ReleaseHeldHtlc_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeReleaseHeldHtlc) }, ); + ret +} +#[must_use] +extern "C" fn ReleaseHeldHtlc_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeReleaseHeldHtlc) }, ); + ret.into() +} +extern "C" fn OnionMessageContents_ReleaseHeldHtlc_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { + new_obj.this_arg = ReleaseHeldHtlc_clone_void(new_obj.this_arg); + new_obj.free = Some(ReleaseHeldHtlc_free_void); +} + +#[no_mangle] +/// Serialize the HeldHtlcAvailable object into a byte array which can be read by HeldHtlcAvailable_read +pub extern "C" fn HeldHtlcAvailable_write(obj: &crate::lightning::onion_message::async_payments::HeldHtlcAvailable) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn HeldHtlcAvailable_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::async_payments::nativeHeldHtlcAvailable) }) +} +#[no_mangle] +/// Read a HeldHtlcAvailable from a byte array, created by HeldHtlcAvailable_write +pub extern "C" fn HeldHtlcAvailable_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_HeldHtlcAvailableDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::async_payments::HeldHtlcAvailable { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Serialize the ReleaseHeldHtlc object into a byte array which can be read by ReleaseHeldHtlc_read +pub extern "C" fn ReleaseHeldHtlc_write(obj: &crate::lightning::onion_message::async_payments::ReleaseHeldHtlc) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn ReleaseHeldHtlc_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::async_payments::nativeReleaseHeldHtlc) }) +} +#[no_mangle] +/// Read a ReleaseHeldHtlc from a byte array, created by ReleaseHeldHtlc_write +pub extern "C" fn ReleaseHeldHtlc_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ReleaseHeldHtlcDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::async_payments::ReleaseHeldHtlc { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Returns whether `tlv_type` corresponds to a TLV record for async payment messages. +#[must_use] +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_is_known_type(mut tlv_type: u64) -> bool { + let mut ret = lightning::onion_message::async_payments::AsyncPaymentsMessage::is_known_type(tlv_type); + ret +} + +impl From for crate::lightning::onion_message::packet::OnionMessageContents { + fn from(obj: nativeAsyncPaymentsMessage) -> Self { + let rust_obj = crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(obj); + let mut ret = AsyncPaymentsMessage_as_OnionMessageContents(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(AsyncPaymentsMessage_free_void); + ret + } +} +/// Constructs a new OnionMessageContents which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OnionMessageContents must be freed before this_arg is +#[no_mangle] +pub extern "C" fn AsyncPaymentsMessage_as_OnionMessageContents(this_arg: &AsyncPaymentsMessage) -> crate::lightning::onion_message::packet::OnionMessageContents { + crate::lightning::onion_message::packet::OnionMessageContents { + this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const AsyncPaymentsMessage as *mut AsyncPaymentsMessage) as *mut c_void }, + free: None, + tlv_type: AsyncPaymentsMessage_OnionMessageContents_tlv_type, + msg_type: AsyncPaymentsMessage_OnionMessageContents_msg_type, + write: AsyncPaymentsMessage_write_void, + debug_str: AsyncPaymentsMessage_debug_str_void, + cloned: Some(OnionMessageContents_AsyncPaymentsMessage_cloned), + } +} + +#[must_use] +extern "C" fn AsyncPaymentsMessage_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeAsyncPaymentsMessage) }, ); + ret +} +#[must_use] +extern "C" fn AsyncPaymentsMessage_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeAsyncPaymentsMessage) }, ); + ret.into() +} +extern "C" fn OnionMessageContents_AsyncPaymentsMessage_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { + new_obj.this_arg = AsyncPaymentsMessage_clone_void(new_obj.this_arg); + new_obj.free = Some(AsyncPaymentsMessage_free_void); +} + +#[no_mangle] +/// Serialize the AsyncPaymentsMessage object into a byte array which can be read by AsyncPaymentsMessage_read +pub extern "C" fn AsyncPaymentsMessage_write(obj: &crate::lightning::onion_message::async_payments::AsyncPaymentsMessage) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn AsyncPaymentsMessage_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + AsyncPaymentsMessage_write(unsafe { &*(obj as *const AsyncPaymentsMessage) }) +} +#[no_mangle] +/// Read a AsyncPaymentsMessage from a byte array, created by AsyncPaymentsMessage_write +pub extern "C" fn AsyncPaymentsMessage_read(ser: crate::c_types::u8slice, arg: u64) -> crate::c_types::derived::CResult_AsyncPaymentsMessageDecodeErrorZ { + let arg_conv = arg; + let res: Result = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::async_payments::AsyncPaymentsMessage::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/onion_message/messenger.rs b/lightning-c-bindings/src/lightning/onion_message/messenger.rs index 5db5629..a5323a8 100644 --- a/lightning-c-bindings/src/lightning/onion_message/messenger.rs +++ b/lightning-c-bindings/src/lightning/onion_message/messenger.rs @@ -20,7 +20,7 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::onion_message::messenger::OnionMessenger as nativeOnionMessengerImport; -pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; +pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport; /// A sender, receiver and forwarder of [`OnionMessage`]s. /// @@ -43,12 +43,13 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport( -/// # &self, _recipient: PublicKey, _peers: Vec, _secp_ctx: &Secp256k1 -/// # ) -> Result, ()> { +/// # &self, _recipient: PublicKey, _context: MessageContext, _peers: Vec, _secp_ctx: &Secp256k1 +/// # ) -> Result, ()> { /// # unreachable!() /// # } /// # } @@ -86,14 +87,16 @@ pub(crate) type nativeOnionMessenger = nativeOnionMessengerImport &'static str { \"YourCustomMessageType\" } /// } /// // Send a custom onion message to a node id. /// let destination = Destination::Node(destination_node_id); -/// let reply_path = None; +/// let instructions = MessageSendInstructions::WithoutReplyPath { destination }; /// # let message = YourCustomMessage {}; -/// onion_messenger.send_onion_message(message, destination, reply_path); +/// onion_messenger.send_onion_message(message, instructions); /// /// // Create a blinded path to yourself, for someone to send an onion message to. /// # let your_node_id = hop_node_id1; -/// let hops = [hop_node_id3, hop_node_id4, your_node_id]; -/// let blinded_path = BlindedPath::new_for_message(&hops, &keys_manager, &secp_ctx).unwrap(); +/// let hops = [ +/// \tMessageForwardNode { node_id: hop_node_id3, short_channel_id: None }, +/// \tMessageForwardNode { node_id: hop_node_id4, short_channel_id: None }, +/// ]; +/// let context = MessageContext::Custom(Vec::new()); +/// let blinded_path = BlindedMessagePath::new(&hops, your_node_id, context, &keys_manager, &secp_ctx).unwrap(); /// /// // Send a custom onion message to a blinded path. /// let destination = Destination::BlindedPath(blinded_path); -/// let reply_path = None; +/// let instructions = MessageSendInstructions::WithoutReplyPath { destination }; /// # let message = YourCustomMessage {}; -/// onion_messenger.send_onion_message(message, destination, reply_path); +/// onion_messenger.send_onion_message(message, instructions); /// ``` /// /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest @@ -145,6 +153,12 @@ pub struct OnionMessenger { pub is_owned: bool, } +impl core::ops::Deref for OnionMessenger { + type Target = nativeOnionMessenger; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessenger { } +unsafe impl core::marker::Sync for OnionMessenger { } impl Drop for OnionMessenger { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessenger>::is_null(self.inner) { @@ -175,6 +189,424 @@ impl OnionMessenger { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning::onion_message::messenger::Responder as nativeResponderImport; +pub(crate) type nativeResponder = nativeResponderImport; + +/// The `Responder` struct creates an appropriate [`ResponseInstruction`] for responding to a +/// message. +#[must_use] +#[repr(C)] +pub struct Responder { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeResponder, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Responder { + type Target = nativeResponder; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Responder { } +unsafe impl core::marker::Sync for Responder { } +impl Drop for Responder { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeResponder>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Responder, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Responder_free(this_obj: Responder) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Responder_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeResponder) }; +} +#[allow(unused)] +impl Responder { + pub(crate) fn get_native_ref(&self) -> &'static nativeResponder { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeResponder { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeResponder { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for Responder { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeResponder>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Responder_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeResponder)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Responder +pub extern "C" fn Responder_clone(orig: &Responder) -> Responder { + orig.clone() +} +/// Get a string which allows debug introspection of a Responder object +pub extern "C" fn Responder_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::Responder }).into()} +/// Checks if two Responders contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Responder_eq(a: &Responder, b: &Responder) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +#[no_mangle] +/// Serialize the Responder object into a byte array which can be read by Responder_read +pub extern "C" fn Responder_write(obj: &crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn Responder_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::messenger::nativeResponder) }) +} +#[no_mangle] +/// Read a Responder from a byte array, created by Responder_write +pub extern "C" fn Responder_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_ResponderDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::Responder { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// Creates a [`ResponseInstruction`] for responding without including a reply path. +/// +/// Use when the recipient doesn't need to send back a reply to us. +#[must_use] +#[no_mangle] +pub extern "C" fn Responder_respond(mut this_arg: crate::lightning::onion_message::messenger::Responder) -> crate::lightning::onion_message::messenger::ResponseInstruction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).respond(); + crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Creates a [`ResponseInstruction`] for responding including a reply path. +/// +/// Use when the recipient needs to send back a reply to us. +#[must_use] +#[no_mangle] +pub extern "C" fn Responder_respond_with_reply_path(mut this_arg: crate::lightning::onion_message::messenger::Responder, mut context: crate::lightning::blinded_path::message::MessageContext) -> crate::lightning::onion_message::messenger::ResponseInstruction { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).respond_with_reply_path(context.into_native()); + crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + + +use lightning::onion_message::messenger::ResponseInstruction as nativeResponseInstructionImport; +pub(crate) type nativeResponseInstruction = nativeResponseInstructionImport; + +/// Instructions for how and where to send the response to an onion message. +#[must_use] +#[repr(C)] +pub struct ResponseInstruction { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeResponseInstruction, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ResponseInstruction { + type Target = nativeResponseInstruction; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ResponseInstruction { } +unsafe impl core::marker::Sync for ResponseInstruction { } +impl Drop for ResponseInstruction { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeResponseInstruction>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ResponseInstruction, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ResponseInstruction_free(this_obj: ResponseInstruction) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ResponseInstruction_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeResponseInstruction) }; +} +#[allow(unused)] +impl ResponseInstruction { + pub(crate) fn get_native_ref(&self) -> &'static nativeResponseInstruction { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeResponseInstruction { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeResponseInstruction { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +impl Clone for ResponseInstruction { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeResponseInstruction>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ResponseInstruction_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeResponseInstruction)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ResponseInstruction +pub extern "C" fn ResponseInstruction_clone(orig: &ResponseInstruction) -> ResponseInstruction { + orig.clone() +} +/// Instructions for how and where to send a message. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum MessageSendInstructions { + /// Indicates that a message should be sent including the provided reply path for the recipient + /// to respond. + WithSpecifiedReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + /// The reply path which should be included in the message. + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath, + }, + /// Indicates that a message should be sent including a reply path for the recipient to + /// respond. + WithReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + /// The context to include in the reply path we'll give the recipient so they can respond + /// to us. + context: crate::lightning::blinded_path::message::MessageContext, + }, + /// Indicates that a message should be sent without including a reply path, preventing the + /// recipient from responding. + WithoutReplyPath { + /// The destination where we need to send our message. + destination: crate::lightning::onion_message::messenger::Destination, + }, + /// Indicates that a message is being sent as a reply to a received message. + ForReply { + /// The instructions provided by the [`Responder`]. + instructions: crate::lightning::onion_message::messenger::ResponseInstruction, + }, +} +use lightning::onion_message::messenger::MessageSendInstructions as MessageSendInstructionsImport; +pub(crate) type nativeMessageSendInstructions = MessageSendInstructionsImport; + +impl MessageSendInstructions { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeMessageSendInstructions { + match self { + MessageSendInstructions::WithSpecifiedReplyPath {ref destination, ref reply_path, } => { + let mut destination_nonref = Clone::clone(destination); + let mut reply_path_nonref = Clone::clone(reply_path); + nativeMessageSendInstructions::WithSpecifiedReplyPath { + destination: destination_nonref.into_native(), + reply_path: *unsafe { Box::from_raw(reply_path_nonref.take_inner()) }, + } + }, + MessageSendInstructions::WithReplyPath {ref destination, ref context, } => { + let mut destination_nonref = Clone::clone(destination); + let mut context_nonref = Clone::clone(context); + nativeMessageSendInstructions::WithReplyPath { + destination: destination_nonref.into_native(), + context: context_nonref.into_native(), + } + }, + MessageSendInstructions::WithoutReplyPath {ref destination, } => { + let mut destination_nonref = Clone::clone(destination); + nativeMessageSendInstructions::WithoutReplyPath { + destination: destination_nonref.into_native(), + } + }, + MessageSendInstructions::ForReply {ref instructions, } => { + let mut instructions_nonref = Clone::clone(instructions); + nativeMessageSendInstructions::ForReply { + instructions: *unsafe { Box::from_raw(instructions_nonref.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeMessageSendInstructions { + match self { + MessageSendInstructions::WithSpecifiedReplyPath {mut destination, mut reply_path, } => { + nativeMessageSendInstructions::WithSpecifiedReplyPath { + destination: destination.into_native(), + reply_path: *unsafe { Box::from_raw(reply_path.take_inner()) }, + } + }, + MessageSendInstructions::WithReplyPath {mut destination, mut context, } => { + nativeMessageSendInstructions::WithReplyPath { + destination: destination.into_native(), + context: context.into_native(), + } + }, + MessageSendInstructions::WithoutReplyPath {mut destination, } => { + nativeMessageSendInstructions::WithoutReplyPath { + destination: destination.into_native(), + } + }, + MessageSendInstructions::ForReply {mut instructions, } => { + nativeMessageSendInstructions::ForReply { + instructions: *unsafe { Box::from_raw(instructions.take_inner()) }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &MessageSendInstructionsImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeMessageSendInstructions) }; + match native { + nativeMessageSendInstructions::WithSpecifiedReplyPath {ref destination, ref reply_path, } => { + let mut destination_nonref = Clone::clone(destination); + let mut reply_path_nonref = Clone::clone(reply_path); + MessageSendInstructions::WithSpecifiedReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(reply_path_nonref), is_owned: true }, + } + }, + nativeMessageSendInstructions::WithReplyPath {ref destination, ref context, } => { + let mut destination_nonref = Clone::clone(destination); + let mut context_nonref = Clone::clone(context); + MessageSendInstructions::WithReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + context: crate::lightning::blinded_path::message::MessageContext::native_into(context_nonref), + } + }, + nativeMessageSendInstructions::WithoutReplyPath {ref destination, } => { + let mut destination_nonref = Clone::clone(destination); + MessageSendInstructions::WithoutReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination_nonref), + } + }, + nativeMessageSendInstructions::ForReply {ref instructions, } => { + let mut instructions_nonref = Clone::clone(instructions); + MessageSendInstructions::ForReply { + instructions: crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(instructions_nonref), is_owned: true }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeMessageSendInstructions) -> Self { + match native { + nativeMessageSendInstructions::WithSpecifiedReplyPath {mut destination, mut reply_path, } => { + MessageSendInstructions::WithSpecifiedReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + reply_path: crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(reply_path), is_owned: true }, + } + }, + nativeMessageSendInstructions::WithReplyPath {mut destination, mut context, } => { + MessageSendInstructions::WithReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + context: crate::lightning::blinded_path::message::MessageContext::native_into(context), + } + }, + nativeMessageSendInstructions::WithoutReplyPath {mut destination, } => { + MessageSendInstructions::WithoutReplyPath { + destination: crate::lightning::onion_message::messenger::Destination::native_into(destination), + } + }, + nativeMessageSendInstructions::ForReply {mut instructions, } => { + MessageSendInstructions::ForReply { + instructions: crate::lightning::onion_message::messenger::ResponseInstruction { inner: ObjOps::heap_alloc(instructions), is_owned: true }, + } + }, + } + } +} +/// Frees any resources used by the MessageSendInstructions +#[no_mangle] +pub extern "C" fn MessageSendInstructions_free(this_ptr: MessageSendInstructions) { } +/// Creates a copy of the MessageSendInstructions +#[no_mangle] +pub extern "C" fn MessageSendInstructions_clone(orig: &MessageSendInstructions) -> MessageSendInstructions { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageSendInstructions_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const MessageSendInstructions)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn MessageSendInstructions_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut MessageSendInstructions) }; +} +#[no_mangle] +/// Utility method to constructs a new WithSpecifiedReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_with_specified_reply_path(destination: crate::lightning::onion_message::messenger::Destination, reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> MessageSendInstructions { + MessageSendInstructions::WithSpecifiedReplyPath { + destination, + reply_path, + } +} +#[no_mangle] +/// Utility method to constructs a new WithReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_with_reply_path(destination: crate::lightning::onion_message::messenger::Destination, context: crate::lightning::blinded_path::message::MessageContext) -> MessageSendInstructions { + MessageSendInstructions::WithReplyPath { + destination, + context, + } +} +#[no_mangle] +/// Utility method to constructs a new WithoutReplyPath-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_without_reply_path(destination: crate::lightning::onion_message::messenger::Destination) -> MessageSendInstructions { + MessageSendInstructions::WithoutReplyPath { + destination, + } +} +#[no_mangle] +/// Utility method to constructs a new ForReply-variant MessageSendInstructions +pub extern "C" fn MessageSendInstructions_for_reply(instructions: crate::lightning::onion_message::messenger::ResponseInstruction) -> MessageSendInstructions { + MessageSendInstructions::ForReply { + instructions, + } } /// A trait defining behavior for routing an [`OnionMessage`]. #[repr(C)] @@ -184,9 +616,23 @@ pub struct MessageRouter { pub this_arg: *mut c_void, /// Returns a route for sending an [`OnionMessage`] to the given [`Destination`]. pub find_path: extern "C" fn (this_arg: *const c_void, sender: crate::c_types::PublicKey, peers: crate::c_types::derived::CVec_PublicKeyZ, destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ, - /// Creates [`BlindedPath`]s to the `recipient` node. The nodes in `peers` are assumed to be - /// direct peers with the `recipient`. - pub create_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ, + /// Creates [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are assumed to + /// be direct peers with the `recipient`. + pub create_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, context: crate::lightning::blinded_path::message::MessageContext, peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ, + /// Creates compact [`BlindedMessagePath`]s to the `recipient` node. The nodes in `peers` are + /// assumed to be direct peers with the `recipient`. + /// + /// Compact blinded paths use short channel ids instead of pubkeys for a smaller serialization, + /// which is beneficial when a QR code is used to transport the data. The SCID is passed using + /// a [`MessageForwardNode`] but may be `None` for graceful degradation. + /// + /// Implementations using additional intermediate nodes are responsible for using a + /// [`MessageForwardNode`] with `Some` short channel id, if possible. Similarly, implementations + /// should call [`BlindedMessagePath::use_compact_introduction_node`]. + /// + /// The provided implementation simply delegates to [`MessageRouter::create_blinded_paths`], + /// ignoring the short channel ids. + pub create_compact_blinded_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, context: crate::lightning::blinded_path::message::MessageContext, peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -199,6 +645,7 @@ pub(crate) fn MessageRouter_clone_fields(orig: &MessageRouter) -> MessageRouter this_arg: orig.this_arg, find_path: Clone::clone(&orig.find_path), create_blinded_paths: Clone::clone(&orig.create_blinded_paths), + create_compact_blinded_paths: Clone::clone(&orig.create_compact_blinded_paths), free: Clone::clone(&orig.free), } } @@ -211,9 +658,37 @@ impl rustMessageRouter for MessageRouter { let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.create_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.create_compact_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct MessageRouterRef(MessageRouter); +impl rustMessageRouter for MessageRouterRef { + fn find_path(&self, mut sender: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut destination: lightning::onion_message::messenger::Destination) -> Result { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.0.find_path)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&sender), local_peers.into(), crate::lightning::onion_message::messenger::Destination::native_into(destination)); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; - let mut ret = (self.create_blinded_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_peers.into()); + let mut ret = (self.0.create_blinded_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.create_compact_blinded_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } @@ -222,14 +697,14 @@ impl rustMessageRouter for MessageRouter { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for MessageRouter { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = MessageRouterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const MessageRouterRef) } } } impl core::ops::DerefMut for MessageRouter { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut MessageRouterRef { + unsafe { &mut *(self as *mut _ as *mut MessageRouterRef) } } } /// Calls the free function if one is set @@ -244,9 +719,16 @@ impl Drop for MessageRouter { } use lightning::onion_message::messenger::DefaultMessageRouter as nativeDefaultMessageRouterImport; -pub(crate) type nativeDefaultMessageRouter = nativeDefaultMessageRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource>; +pub(crate) type nativeDefaultMessageRouter = nativeDefaultMessageRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, >; /// A [`MessageRouter`] that can only route to a directly connected [`Destination`]. +/// +/// # Privacy +/// +/// Creating [`BlindedMessagePath`]s may affect privacy since, if a suitable path cannot be found, +/// it will create a one-hop path using the recipient as the introduction node if it is a announced +/// node. Otherwise, there is no way to find a path to the introduction node in order to send a +/// message, and thus an `Err` is returned. #[must_use] #[repr(C)] pub struct DefaultMessageRouter { @@ -262,6 +744,12 @@ pub struct DefaultMessageRouter { pub is_owned: bool, } +impl core::ops::Deref for DefaultMessageRouter { + type Target = nativeDefaultMessageRouter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DefaultMessageRouter { } +unsafe impl core::marker::Sync for DefaultMessageRouter { } impl Drop for DefaultMessageRouter { fn drop(&mut self) { if self.is_owned && !<*mut nativeDefaultMessageRouter>::is_null(self.inner) { @@ -292,6 +780,9 @@ impl DefaultMessageRouter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a [`DefaultMessageRouter`] using the given [`NetworkGraph`]. #[must_use] @@ -320,21 +811,29 @@ pub extern "C" fn DefaultMessageRouter_as_MessageRouter(this_arg: &DefaultMessag free: None, find_path: DefaultMessageRouter_MessageRouter_find_path, create_blinded_paths: DefaultMessageRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultMessageRouter_MessageRouter_create_compact_blinded_paths, } } #[must_use] extern "C" fn DefaultMessageRouter_MessageRouter_find_path(this_arg: *const c_void, mut sender: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = >::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, sender.into_rust(), local_peers, destination.into_native()); + let mut ret = ::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, sender.into_rust(), local_peers, destination.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::OnionMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn DefaultMessageRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ { +extern "C" fn DefaultMessageRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = >::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), local_peers, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), context.into_native(), local_peers, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn DefaultMessageRouter_MessageRouter_create_compact_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = ::create_compact_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultMessageRouter) }, recipient.into_rust(), context.into_native(), local_peers, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -358,6 +857,12 @@ pub struct OnionMessagePath { pub is_owned: bool, } +impl core::ops::Deref for OnionMessagePath { + type Target = nativeOnionMessagePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OnionMessagePath { } +unsafe impl core::marker::Sync for OnionMessagePath { } impl Drop for OnionMessagePath { fn drop(&mut self) { if self.is_owned && !<*mut nativeOnionMessagePath>::is_null(self.inner) { @@ -388,6 +893,9 @@ impl OnionMessagePath { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Nodes on the path between the sender and the destination. /// @@ -468,11 +976,14 @@ pub extern "C" fn OnionMessagePath_clone(orig: &OnionMessagePath) -> OnionMessag orig.clone() } /// Returns the first node in the path. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] pub extern "C" fn OnionMessagePath_first_node(this_arg: &crate::lightning::onion_message::messenger::OnionMessagePath) -> crate::c_types::PublicKey { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.first_node(); - crate::c_types::PublicKey::from_rust(&ret) + let mut local_ret = if ret.is_none() { crate::c_types::PublicKey::null() } else { { crate::c_types::PublicKey::from_rust(&(ret.unwrap())) } }; + local_ret } /// The destination of an onion message. @@ -485,7 +996,7 @@ pub enum Destination { crate::c_types::PublicKey), /// We're sending this onion message to a blinded path. BlindedPath( - crate::lightning::blinded_path::BlindedPath), + crate::lightning::blinded_path::message::BlindedMessagePath), } use lightning::onion_message::messenger::Destination as DestinationImport; pub(crate) type nativeDestination = DestinationImport; @@ -536,7 +1047,7 @@ impl Destination { nativeDestination::BlindedPath (ref a, ) => { let mut a_nonref = Clone::clone(a); Destination::BlindedPath ( - crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, ) }, } @@ -551,7 +1062,7 @@ impl Destination { }, nativeDestination::BlindedPath (mut a, ) => { Destination::BlindedPath ( - crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(a), is_owned: true }, + crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(a), is_owned: true }, ) }, } @@ -582,9 +1093,35 @@ pub extern "C" fn Destination_node(a: crate::c_types::PublicKey) -> Destination } #[no_mangle] /// Utility method to constructs a new BlindedPath-variant Destination -pub extern "C" fn Destination_blinded_path(a: crate::lightning::blinded_path::BlindedPath) -> Destination { +pub extern "C" fn Destination_blinded_path(a: crate::lightning::blinded_path::message::BlindedMessagePath) -> Destination { Destination::BlindedPath(a, ) } +/// Generates a non-cryptographic 64-bit hash of the Destination. +#[no_mangle] +pub extern "C" fn Destination_hash(o: &Destination) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Get a string which allows debug introspection of a Destination object +pub extern "C" fn Destination_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::Destination }).into()} +/// Checks if two Destinations contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn Destination_eq(a: &Destination, b: &Destination) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// Attempts to resolve the [`IntroductionNode::DirectedShortChannelId`] of a +/// [`Destination::BlindedPath`] to a [`IntroductionNode::NodeId`], if applicable, using the +/// provided [`ReadOnlyNetworkGraph`]. +#[no_mangle] +pub extern "C" fn Destination_resolve(this_arg: &mut crate::lightning::onion_message::messenger::Destination, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph) { + this_arg.to_native().resolve(network_graph.get_native_ref()) +} + /// Result of successfully [sending an onion message]. /// /// [sending an onion message]: OnionMessenger::send_onion_message @@ -679,6 +1216,15 @@ pub extern "C" fn SendSuccess_buffered() -> SendSuccess { pub extern "C" fn SendSuccess_buffered_awaiting_connection(a: crate::c_types::PublicKey) -> SendSuccess { SendSuccess::BufferedAwaitingConnection(a, ) } +/// Generates a non-cryptographic 64-bit hash of the SendSuccess. +#[no_mangle] +pub extern "C" fn SendSuccess_hash(o: &SendSuccess) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Get a string which allows debug introspection of a SendSuccess object pub extern "C" fn SendSuccess_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::SendSuccess }).into()} @@ -701,13 +1247,17 @@ pub enum SendError { /// Because implementations such as Eclair will drop onion messages where the message packet /// exceeds 32834 bytes, we refuse to send messages where the packet exceeds this size. TooBigPacket, - /// The provided [`Destination`] was an invalid [`BlindedPath`] due to not having any blinded - /// hops. + /// The provided [`Destination`] was an invalid [`BlindedMessagePath`] due to not having any + /// blinded hops. TooFewBlindedHops, /// The first hop is not a peer and doesn't have a known [`SocketAddress`]. InvalidFirstHop( crate::c_types::PublicKey), - /// A path from the sender to the destination could not be found by the [`MessageRouter`]. + /// Indicates that a path could not be found by the [`MessageRouter`]. + /// + /// This occurs when either: + /// - No path from the sender to the destination was found to send the onion message + /// - No reply path to the sender could be created when responding to an onion message PathNotFound, /// Onion message contents must have a TLV type >= 64. InvalidMessage, @@ -717,6 +1267,10 @@ pub enum SendError { /// /// [`NodeSigner`]: crate::sign::NodeSigner GetNodeIdFailed, + /// The provided [`Destination`] has a blinded path with an unresolved introduction node. An + /// attempt to resolve it in the [`MessageRouter`] when finding an [`OnionMessagePath`] likely + /// failed. + UnresolvedIntroductionNode, /// We attempted to send to a blinded path where we are the introduction node, and failed to /// advance the blinded path to make the second hop the new introduction node. Either /// [`NodeSigner::ecdh`] failed, we failed to tweak the current blinding point to get the @@ -748,6 +1302,7 @@ impl SendError { SendError::InvalidMessage => nativeSendError::InvalidMessage, SendError::BufferFull => nativeSendError::BufferFull, SendError::GetNodeIdFailed => nativeSendError::GetNodeIdFailed, + SendError::UnresolvedIntroductionNode => nativeSendError::UnresolvedIntroductionNode, SendError::BlindedPathAdvanceFailed => nativeSendError::BlindedPathAdvanceFailed, } } @@ -770,6 +1325,7 @@ impl SendError { SendError::InvalidMessage => nativeSendError::InvalidMessage, SendError::BufferFull => nativeSendError::BufferFull, SendError::GetNodeIdFailed => nativeSendError::GetNodeIdFailed, + SendError::UnresolvedIntroductionNode => nativeSendError::UnresolvedIntroductionNode, SendError::BlindedPathAdvanceFailed => nativeSendError::BlindedPathAdvanceFailed, } } @@ -795,6 +1351,7 @@ impl SendError { nativeSendError::InvalidMessage => SendError::InvalidMessage, nativeSendError::BufferFull => SendError::BufferFull, nativeSendError::GetNodeIdFailed => SendError::GetNodeIdFailed, + nativeSendError::UnresolvedIntroductionNode => SendError::UnresolvedIntroductionNode, nativeSendError::BlindedPathAdvanceFailed => SendError::BlindedPathAdvanceFailed, } } @@ -817,6 +1374,7 @@ impl SendError { nativeSendError::InvalidMessage => SendError::InvalidMessage, nativeSendError::BufferFull => SendError::BufferFull, nativeSendError::GetNodeIdFailed => SendError::GetNodeIdFailed, + nativeSendError::UnresolvedIntroductionNode => SendError::UnresolvedIntroductionNode, nativeSendError::BlindedPathAdvanceFailed => SendError::BlindedPathAdvanceFailed, } } @@ -874,9 +1432,22 @@ pub extern "C" fn SendError_buffer_full() -> SendError { pub extern "C" fn SendError_get_node_id_failed() -> SendError { SendError::GetNodeIdFailed} #[no_mangle] +/// Utility method to constructs a new UnresolvedIntroductionNode-variant SendError +pub extern "C" fn SendError_unresolved_introduction_node() -> SendError { + SendError::UnresolvedIntroductionNode} +#[no_mangle] /// Utility method to constructs a new BlindedPathAdvanceFailed-variant SendError pub extern "C" fn SendError_blinded_path_advance_failed() -> SendError { SendError::BlindedPathAdvanceFailed} +/// Generates a non-cryptographic 64-bit hash of the SendError. +#[no_mangle] +pub extern "C" fn SendError_hash(o: &SendError) -> u64 { + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(&o.to_native(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} /// Get a string which allows debug introspection of a SendError object pub extern "C" fn SendError_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::SendError }).into()} @@ -904,7 +1475,9 @@ pub struct CustomOnionMessageHandler { /// Called with the custom message that was received, returning a response to send, if any. /// /// The returned [`Self::CustomMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. - pub handle_custom_message: extern "C" fn (this_arg: *const c_void, msg: crate::lightning::onion_message::packet::OnionMessageContents) -> crate::c_types::derived::COption_OnionMessageContentsZ, + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub handle_custom_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::packet::OnionMessageContents, context: crate::c_types::derived::COption_CVec_u8ZZ, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OnionMessageContentsResponseInstructionZZ, /// Read a custom message of type `message_type` from `buffer`, returning `Ok(None)` if the /// message type is unknown. pub read_custom_message: extern "C" fn (this_arg: *const c_void, message_type: u64, buffer: crate::c_types::u8slice) -> crate::c_types::derived::CResult_COption_OnionMessageContentsZDecodeErrorZ, @@ -912,7 +1485,7 @@ pub struct CustomOnionMessageHandler { /// /// Typically, this is used for messages initiating a message flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_custom_message`]. - pub release_pending_custom_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ, + pub release_pending_custom_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -933,9 +1506,11 @@ pub(crate) fn CustomOnionMessageHandler_clone_fields(orig: &CustomOnionMessageHa use lightning::onion_message::messenger::CustomOnionMessageHandler as rustCustomOnionMessageHandler; impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { type CustomMessage = crate::lightning::onion_message::packet::OnionMessageContents; - fn handle_custom_message(&self, mut msg: crate::lightning::onion_message::packet::OnionMessageContents) -> Option { - let mut ret = (self.handle_custom_message)(self.this_arg, Into::into(msg)); - let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { { ret_opt.take() } }})} }; + fn handle_custom_message(&self, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: Option>, mut responder: Option) -> Option<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_context_0 = Vec::new(); for mut item in context.unwrap().drain(..) { local_context_0.push( { item }); }; local_context_0.into() }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.handle_custom_message)(self.this_arg, Into::into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; local_ret } fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { @@ -943,9 +1518,31 @@ impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } - fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::Destination, Option)> { + fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::MessageSendInstructions)> { let mut ret = (self.release_pending_custom_messages)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native(), local_orig_ret_0_2); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct CustomOnionMessageHandlerRef(CustomOnionMessageHandler); +impl rustCustomOnionMessageHandler for CustomOnionMessageHandlerRef { + type CustomMessage = crate::lightning::onion_message::packet::OnionMessageContents; + fn handle_custom_message(&self, mut message: crate::lightning::onion_message::packet::OnionMessageContents, mut context: Option>, mut responder: Option) -> Option<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_CVec_u8ZZ::None } else { crate::c_types::derived::COption_CVec_u8ZZ::Some( { let mut local_context_0 = Vec::new(); for mut item in context.unwrap().drain(..) { local_context_0.push( { item }); }; local_context_0.into() }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.handle_custom_message)(self.0.this_arg, Into::into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0, *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn read_custom_message(&self, mut message_type: u64, mut buffer: &mut R) -> Result, lightning::ln::msgs::DecodeError> { + let mut ret = (self.0.read_custom_message)(self.0.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer))); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); if ret_0_opt.is_none() { None } else { Some({ { { ret_0_opt.take() } }})} }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn release_pending_custom_messages(&self) -> Vec<(crate::lightning::onion_message::packet::OnionMessageContents, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_custom_messages)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0, orig_ret_0_1.into_native()); local_ret_0 }); }; local_ret } } @@ -953,14 +1550,14 @@ impl rustCustomOnionMessageHandler for CustomOnionMessageHandler { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for CustomOnionMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = CustomOnionMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const CustomOnionMessageHandlerRef) } } } impl core::ops::DerefMut for CustomOnionMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut CustomOnionMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut CustomOnionMessageHandlerRef) } } } /// Calls the free function if one is set @@ -981,20 +1578,18 @@ impl Drop for CustomOnionMessageHandler { pub enum PeeledOnion { /// Forwarded onion, with the next node id and a new onion Forward( - crate::c_types::PublicKey, + crate::lightning::blinded_path::message::NextMessageHop, crate::lightning::ln::msgs::OnionMessage), - /// Received onion message, with decrypted contents, path_id, and reply path + /// Received onion message, with decrypted contents, context, and reply path Receive( crate::lightning::onion_message::packet::ParsedOnionMessageContents, + crate::c_types::derived::COption_MessageContextZ, /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - crate::c_types::ThirtyTwoBytes, - /// - /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - crate::lightning::blinded_path::BlindedPath), + crate::lightning::blinded_path::message::BlindedMessagePath), } use lightning::onion_message::messenger::PeeledOnion as PeeledOnionImport; -pub(crate) type nativePeeledOnion = PeeledOnionImport; +pub(crate) type nativePeeledOnion = PeeledOnionImport; impl PeeledOnion { #[allow(unused)] @@ -1004,14 +1599,14 @@ impl PeeledOnion { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); nativePeeledOnion::Forward ( - a_nonref.into_rust(), + a_nonref.into_native(), *unsafe { Box::from_raw(b_nonref.take_inner()) }, ) }, PeeledOnion::Receive (ref a, ref b, ref c, ) => { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); - let mut local_b_nonref = if b_nonref.data == [0; 32] { None } else { Some( { b_nonref.data }) }; + let mut local_b_nonref = { /*b_nonref*/ let b_nonref_opt = b_nonref; if b_nonref_opt.is_none() { None } else { Some({ { { b_nonref_opt.take() }.into_native() }})} }; let mut c_nonref = Clone::clone(c); let mut local_c_nonref = if c_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(c_nonref.take_inner()) } }) }; nativePeeledOnion::Receive ( @@ -1027,12 +1622,12 @@ impl PeeledOnion { match self { PeeledOnion::Forward (mut a, mut b, ) => { nativePeeledOnion::Forward ( - a.into_rust(), + a.into_native(), *unsafe { Box::from_raw(b.take_inner()) }, ) }, PeeledOnion::Receive (mut a, mut b, mut c, ) => { - let mut local_b = if b.data == [0; 32] { None } else { Some( { b.data }) }; + let mut local_b = { /*b*/ let b_opt = b; if b_opt.is_none() { None } else { Some({ { { b_opt.take() }.into_native() }})} }; let mut local_c = if c.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(c.take_inner()) } }) }; nativePeeledOnion::Receive ( a.into_native(), @@ -1043,23 +1638,23 @@ impl PeeledOnion { } } #[allow(unused)] - pub(crate) fn from_native(native: &PeeledOnionImport) -> Self { + pub(crate) fn from_native(native: &PeeledOnionImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativePeeledOnion) }; match native { nativePeeledOnion::Forward (ref a, ref b, ) => { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); PeeledOnion::Forward ( - crate::c_types::PublicKey::from_rust(&a_nonref), + crate::lightning::blinded_path::message::NextMessageHop::native_into(a_nonref), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(b_nonref), is_owned: true }, ) }, nativePeeledOnion::Receive (ref a, ref b, ref c, ) => { let mut a_nonref = Clone::clone(a); let mut b_nonref = Clone::clone(b); - let mut local_b_nonref = if b_nonref.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (b_nonref.unwrap()) } } }; + let mut local_b_nonref = if b_nonref.is_none() { crate::c_types::derived::COption_MessageContextZ::None } else { crate::c_types::derived::COption_MessageContextZ::Some( { crate::lightning::blinded_path::message::MessageContext::native_into(b_nonref.unwrap()) }) }; let mut c_nonref = Clone::clone(c); - let mut local_c_nonref = crate::lightning::blinded_path::BlindedPath { inner: if c_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c_nonref.unwrap())) } }, is_owned: true }; + let mut local_c_nonref = crate::lightning::blinded_path::message::BlindedMessagePath { inner: if c_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c_nonref.unwrap())) } }, is_owned: true }; PeeledOnion::Receive ( crate::lightning::onion_message::packet::ParsedOnionMessageContents::native_into(a_nonref), local_b_nonref, @@ -1073,13 +1668,13 @@ impl PeeledOnion { match native { nativePeeledOnion::Forward (mut a, mut b, ) => { PeeledOnion::Forward ( - crate::c_types::PublicKey::from_rust(&a), + crate::lightning::blinded_path::message::NextMessageHop::native_into(a), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(b), is_owned: true }, ) }, nativePeeledOnion::Receive (mut a, mut b, mut c, ) => { - let mut local_b = if b.is_none() { crate::c_types::ThirtyTwoBytes { data: [0; 32] } } else { { crate::c_types::ThirtyTwoBytes { data: (b.unwrap()) } } }; - let mut local_c = crate::lightning::blinded_path::BlindedPath { inner: if c.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c.unwrap())) } }, is_owned: true }; + let mut local_b = if b.is_none() { crate::c_types::derived::COption_MessageContextZ::None } else { crate::c_types::derived::COption_MessageContextZ::Some( { crate::lightning::blinded_path::message::MessageContext::native_into(b.unwrap()) }) }; + let mut local_c = crate::lightning::blinded_path::message::BlindedMessagePath { inner: if c.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((c.unwrap())) } }, is_owned: true }; PeeledOnion::Receive ( crate::lightning::onion_message::packet::ParsedOnionMessageContents::native_into(a), local_b, @@ -1109,25 +1704,50 @@ pub(crate) extern "C" fn PeeledOnion_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new Forward-variant PeeledOnion -pub extern "C" fn PeeledOnion_forward(a: crate::c_types::PublicKey,b: crate::lightning::ln::msgs::OnionMessage) -> PeeledOnion { +pub extern "C" fn PeeledOnion_forward(a: crate::lightning::blinded_path::message::NextMessageHop,b: crate::lightning::ln::msgs::OnionMessage) -> PeeledOnion { PeeledOnion::Forward(a, b, ) } #[no_mangle] /// Utility method to constructs a new Receive-variant PeeledOnion -pub extern "C" fn PeeledOnion_receive(a: crate::lightning::onion_message::packet::ParsedOnionMessageContents,b: crate::c_types::ThirtyTwoBytes,c: crate::lightning::blinded_path::BlindedPath) -> PeeledOnion { +pub extern "C" fn PeeledOnion_receive(a: crate::lightning::onion_message::packet::ParsedOnionMessageContents,b: crate::c_types::derived::COption_MessageContextZ,c: crate::lightning::blinded_path::message::BlindedMessagePath) -> PeeledOnion { PeeledOnion::Receive(a, b, c, ) } +/// Get a string which allows debug introspection of a PeeledOnion object +pub extern "C" fn PeeledOnion_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::messenger::PeeledOnion }).into()} +/// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of +/// `path`, first calling [`Destination::resolve`] on `path.destination` with the given +/// [`ReadOnlyNetworkGraph`]. +/// +/// Returns the node id of the peer to send the message to, the message itself, and any addresses +/// needed to connect to the first node. +/// +/// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn create_onion_message_resolving_destination(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, network_graph: &crate::lightning::routing::gossip::ReadOnlyNetworkGraph, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { + let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; + let mut ret = lightning::onion_message::messenger::create_onion_message_resolving_destination::(entropy_source, node_signer, node_id_lookup, network_graph.get_native_ref(), secp256k1::global::SECP256K1, *unsafe { Box::from_raw(path.take_inner()) }, contents, local_reply_path); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_CVec_SocketAddressZZ::None } else { crate::c_types::derived::COption_CVec_SocketAddressZZ::Some( { let mut local_orig_ret_0_2_0 = Vec::new(); for mut item in orig_ret_0_2.unwrap().drain(..) { local_orig_ret_0_2_0.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_orig_ret_0_2_0.into() }) }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; + local_ret +} + /// Creates an [`OnionMessage`] with the given `contents` for sending to the destination of /// `path`. /// /// Returns the node id of the peer to send the message to, the message itself, and any addresses -/// need to connect to the first node. +/// needed to connect to the first node. +/// +/// Returns [`SendError::UnresolvedIntroductionNode`] if: +/// - `destination` contains a blinded path with an [`IntroductionNode::DirectedShortChannelId`], +/// - unless it can be resolved by [`NodeIdLookUp::next_node_id`]. +/// Use [`create_onion_message_resolving_destination`] instead to resolve the introduction node +/// first with a [`ReadOnlyNetworkGraph`]. /// /// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn create_onion_message(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { +pub extern "C" fn create_onion_message(entropy_source: &crate::lightning::sign::EntropySource, node_signer: &crate::lightning::sign::NodeSigner, node_id_lookup: &crate::lightning::blinded_path::NodeIdLookUp, mut path: crate::lightning::onion_message::messenger::OnionMessagePath, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut reply_path: crate::lightning::blinded_path::message::BlindedMessagePath) -> crate::c_types::derived::CResult_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ { let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; - let mut ret = lightning::onion_message::messenger::create_onion_message::(entropy_source, node_signer, secp256k1::global::SECP256K1, *unsafe { Box::from_raw(path.take_inner()) }, contents, local_reply_path); + let mut ret = lightning::onion_message::messenger::create_onion_message::(entropy_source, node_signer, node_id_lookup, secp256k1::global::SECP256K1, *unsafe { Box::from_raw(path.take_inner()) }, contents, local_reply_path); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_CVec_SocketAddressZZ::None } else { crate::c_types::derived::COption_CVec_SocketAddressZZ::Some( { let mut local_orig_ret_0_2_0 = Vec::new(); for mut item in orig_ret_0_2.unwrap().drain(..) { local_orig_ret_0_2_0.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_orig_ret_0_2_0.into() }) }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), crate::lightning::ln::msgs::OnionMessage { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, local_orig_ret_0_2).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; local_ret } @@ -1138,7 +1758,7 @@ pub extern "C" fn create_onion_message(entropy_source: &crate::lightning::sign:: /// receiver. #[no_mangle] pub extern "C" fn peel_onion_message(msg: &crate::lightning::ln::msgs::OnionMessage, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::c_types::derived::CResult_PeeledOnionNoneZ { - let mut ret = lightning::onion_message::messenger::peel_onion_message::(msg.get_native_ref(), secp256k1::global::SECP256K1, node_signer, logger, custom_handler); + let mut ret = lightning::onion_message::messenger::peel_onion_message::(msg.get_native_ref(), secp256k1::global::SECP256K1, node_signer, logger, custom_handler); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::PeeledOnion::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -1147,25 +1767,115 @@ pub extern "C" fn peel_onion_message(msg: &crate::lightning::ln::msgs::OnionMess /// their respective handlers. #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { - let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, message_router, offers_handler, custom_handler); +pub extern "C" fn OnionMessenger_new(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut node_id_lookup: crate::lightning::blinded_path::NodeIdLookUp, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut async_payments_handler: crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { + let mut ret = lightning::onion_message::messenger::OnionMessenger::new(entropy_source, node_signer, logger, node_id_lookup, message_router, offers_handler, async_payments_handler, custom_handler); crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Sends an [`OnionMessage`] with the given `contents` to `destination`. +/// Similar to [`Self::new`], but rather than dropping onion messages that are +/// intended to be forwarded to offline peers, we will intercept them for +/// later forwarding. /// -/// See [`OnionMessenger`] for example usage. +/// Interception flow: +/// 1. If an onion message for an offline peer is received, `OnionMessenger` will +/// generate an [`Event::OnionMessageIntercepted`]. Event handlers can +/// then choose to persist this onion message for later forwarding, or drop +/// it. +/// 2. When the offline peer later comes back online, `OnionMessenger` will +/// generate an [`Event::OnionMessagePeerConnected`]. Event handlers will +/// then fetch all previously intercepted onion messages for this peer. +/// 3. Once the stored onion messages are fetched, they can finally be +/// forwarded to the now-online peer via [`Self::forward_onion_message`]. /// -/// Note that reply_path (or a relevant inner pointer) may be NULL or all-0s to represent None +/// # Note +/// +/// LDK will not rate limit how many [`Event::OnionMessageIntercepted`]s +/// are generated, so it is the caller's responsibility to limit how many +/// onion messages are persisted and only persist onion messages for relevant +/// peers. #[must_use] #[no_mangle] -pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut destination: crate::lightning::onion_message::messenger::Destination, mut reply_path: crate::lightning::blinded_path::BlindedPath) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { - let mut local_reply_path = if reply_path.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(reply_path.take_inner()) } }) }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(contents, destination.into_native(), local_reply_path); +pub extern "C" fn OnionMessenger_new_with_offline_peer_interception(mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut node_id_lookup: crate::lightning::blinded_path::NodeIdLookUp, mut message_router: crate::lightning::onion_message::messenger::MessageRouter, mut offers_handler: crate::lightning::onion_message::offers::OffersMessageHandler, mut async_payments_handler: crate::lightning::onion_message::async_payments::AsyncPaymentsMessageHandler, mut custom_handler: crate::lightning::onion_message::messenger::CustomOnionMessageHandler) -> crate::lightning::onion_message::messenger::OnionMessenger { + let mut ret = lightning::onion_message::messenger::OnionMessenger::new_with_offline_peer_interception(entropy_source, node_signer, logger, node_id_lookup, message_router, offers_handler, async_payments_handler, custom_handler); + crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Sends an [`OnionMessage`] based on its [`MessageSendInstructions`]. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_send_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut contents: crate::lightning::onion_message::packet::OnionMessageContents, mut instructions: crate::lightning::onion_message::messenger::MessageSendInstructions) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.send_onion_message(contents, instructions.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::SendSuccess::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; local_ret } +/// Forwards an [`OnionMessage`] to `peer_node_id`. Useful if we initialized +/// the [`OnionMessenger`] with [`Self::new_with_offline_peer_interception`] +/// and want to forward a previously intercepted onion message to a peer that +/// has just come online. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_forward_onion_message(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut message: crate::lightning::ln::msgs::OnionMessage, mut peer_node_id: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.forward_onion_message(*unsafe { Box::from_raw(message.take_inner()) }, &peer_node_id.into_rust()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; + local_ret +} + +/// Handles the response to an [`OnionMessage`] based on its [`ResponseInstruction`], +/// enqueueing any response for sending. +/// +/// This function is useful for asynchronous handling of [`OnionMessage`]s. +/// Handlers have the option to return `None`, indicating that no immediate response should be +/// sent. Then, they can transfer the associated [`Responder`] to another task responsible for +/// generating the response asynchronously. Subsequently, when the response is prepared and +/// ready for sending, that task can invoke this method to enqueue the response for delivery. +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_handle_onion_message_response(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger, mut response: crate::lightning::onion_message::packet::OnionMessageContents, mut instructions: crate::lightning::onion_message::messenger::ResponseInstruction) -> crate::c_types::derived::CResult_SendSuccessSendErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.handle_onion_message_response(response, *unsafe { Box::from_raw(instructions.take_inner()) }); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::SendSuccess::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::onion_message::messenger::SendError::native_into(e) }).into() }; + local_ret +} + +/// Gets a [`Future`] that completes when an event is available via +/// [`EventsProvider::process_pending_events`] or [`Self::process_pending_events_async`]. +/// +/// Note that callbacks registered on the [`Future`] MUST NOT call back into this +/// [`OnionMessenger`] and should instead register actions to be taken later. +/// +/// [`EventsProvider::process_pending_events`]: crate::events::EventsProvider::process_pending_events +#[must_use] +#[no_mangle] +pub extern "C" fn OnionMessenger_get_update_future(this_arg: &crate::lightning::onion_message::messenger::OnionMessenger) -> crate::lightning::util::wakers::Future { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_update_future(); + crate::lightning::util::wakers::Future { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::events::EventsProvider { + fn from(obj: nativeOnionMessenger) -> Self { + let rust_obj = crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = OnionMessenger_as_EventsProvider(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(OnionMessenger_free_void); + ret + } +} +/// Constructs a new EventsProvider which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EventsProvider must be freed before this_arg is +#[no_mangle] +pub extern "C" fn OnionMessenger_as_EventsProvider(this_arg: &OnionMessenger) -> crate::lightning::events::EventsProvider { + crate::lightning::events::EventsProvider { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + process_pending_events: OnionMessenger_EventsProvider_process_pending_events, + } +} + +extern "C" fn OnionMessenger_EventsProvider_process_pending_events(this_arg: *const c_void, mut handler: crate::lightning::events::EventHandler) { + ::process_pending_events(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, handler) +} + impl From for crate::lightning::ln::msgs::OnionMessageHandler { fn from(obj: nativeOnionMessenger) -> Self { let rust_obj = crate::lightning::onion_message::messenger::OnionMessenger { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -1183,7 +1893,6 @@ pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenge crate::lightning::ln::msgs::OnionMessageHandler { this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, free: None, - get_and_clear_connections_needed: OnionMessenger_OnionMessageHandler_get_and_clear_connections_needed, handle_onion_message: OnionMessenger_OnionMessageHandler_handle_onion_message, next_onion_message_for_peer: OnionMessenger_OnionMessageHandler_next_onion_message_for_peer, peer_connected: OnionMessenger_OnionMessageHandler_peer_connected, @@ -1194,41 +1903,35 @@ pub extern "C" fn OnionMessenger_as_OnionMessageHandler(this_arg: &OnionMessenge } } -#[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_get_and_clear_connections_needed(this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_PublicKeyCVec_SocketAddressZZZ { - let mut ret = >::get_and_clear_connections_needed(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; let mut local_ret_0 = (crate::c_types::PublicKey::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }); }; - local_ret.into() -} extern "C" fn OnionMessenger_OnionMessageHandler_handle_onion_message(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey, msg: &crate::lightning::ln::msgs::OnionMessage) { - >::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &peer_node_id.into_rust(), msg.get_native_ref()) + ::handle_onion_message(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &peer_node_id.into_rust(), msg.get_native_ref()) } #[must_use] extern "C" fn OnionMessenger_OnionMessageHandler_next_onion_message_for_peer(this_arg: *const c_void, mut peer_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::msgs::OnionMessage { - let mut ret = >::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, peer_node_id.into_rust()); + let mut ret = ::next_onion_message_for_peer(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, peer_node_id.into_rust()); let mut local_ret = crate::lightning::ln::msgs::OnionMessage { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } #[must_use] extern "C" fn OnionMessenger_OnionMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } extern "C" fn OnionMessenger_OnionMessageHandler_peer_disconnected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) { - >::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust()) + ::peer_disconnected(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust()) } extern "C" fn OnionMessenger_OnionMessageHandler_timer_tick_occurred(this_arg: *const c_void) { - >::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ) + ::timer_tick_occurred(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ) } #[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn OnionMessenger_OnionMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn OnionMessenger_OnionMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeOnionMessenger) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning/onion_message/mod.rs b/lightning-c-bindings/src/lightning/onion_message/mod.rs index e900a34..f4c9ae5 100644 --- a/lightning-c-bindings/src/lightning/onion_message/mod.rs +++ b/lightning-c-bindings/src/lightning/onion_message/mod.rs @@ -17,7 +17,7 @@ //! information on its usage. //! //! [offers]: -//! [blinded paths]: crate::blinded_path::BlindedPath +//! [blinded paths]: crate::blinded_path::message::BlindedMessagePath //! [`OnionMessenger`]: self::messenger::OnionMessenger use alloc::str::FromStr; @@ -29,6 +29,7 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; +pub mod async_payments; pub mod messenger; pub mod offers; pub mod packet; diff --git a/lightning-c-bindings/src/lightning/onion_message/offers.rs b/lightning-c-bindings/src/lightning/onion_message/offers.rs index 9e319bd..e99e5fb 100644 --- a/lightning-c-bindings/src/lightning/onion_message/offers.rs +++ b/lightning-c-bindings/src/lightning/onion_message/offers.rs @@ -31,12 +31,14 @@ pub struct OffersMessageHandler { /// The returned [`OffersMessage`], if any, is enqueued to be sent by [`OnionMessenger`]. /// /// [`OnionMessenger`]: crate::onion_message::messenger::OnionMessenger - pub handle_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::offers::OffersMessage) -> crate::c_types::derived::COption_OffersMessageZ, + /// + /// Note that responder (or a relevant inner pointer) may be NULL or all-0s to represent None + pub handle_message: extern "C" fn (this_arg: *const c_void, message: crate::lightning::onion_message::offers::OffersMessage, context: crate::c_types::derived::COption_OffersContextZ, responder: crate::lightning::onion_message::messenger::Responder) -> crate::c_types::derived::COption_C2Tuple_OffersMessageResponseInstructionZZ, /// Releases any [`OffersMessage`]s that need to be sent. /// /// Typically, this is used for messages initiating a payment flow rather than in response to /// another message. The latter should use the return value of [`Self::handle_message`]. - pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ, + pub release_pending_messages: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_C2Tuple_OffersMessageMessageSendInstructionsZZ, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -55,14 +57,32 @@ pub(crate) fn OffersMessageHandler_clone_fields(orig: &OffersMessageHandler) -> use lightning::onion_message::offers::OffersMessageHandler as rustOffersMessageHandler; impl rustOffersMessageHandler for OffersMessageHandler { - fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage) -> Option { - let mut ret = (self.handle_message)(self.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message)); - let mut local_ret = { /*ret*/ let ret_opt = ret; if ret_opt.is_none() { None } else { Some({ { { ret_opt.take() }.into_native() }})} }; + fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage, mut context: Option, mut responder: Option) -> Option<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.handle_message)(self.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; local_ret } - fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::Destination, Option)> { + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::MessageSendInstructions)> { let mut ret = (self.release_pending_messages)(self.this_arg); - let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item.to_rust(); let mut local_orig_ret_0_2 = if orig_ret_0_2.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(orig_ret_0_2.take_inner()) } }) }; let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native(), local_orig_ret_0_2); local_ret_0 }); }; + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; + local_ret + } +} + +pub struct OffersMessageHandlerRef(OffersMessageHandler); +impl rustOffersMessageHandler for OffersMessageHandlerRef { + fn handle_message(&self, mut message: lightning::onion_message::offers::OffersMessage, mut context: Option, mut responder: Option) -> Option<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::ResponseInstruction)> { + let mut local_context = if context.is_none() { crate::c_types::derived::COption_OffersContextZ::None } else { crate::c_types::derived::COption_OffersContextZ::Some( { crate::lightning::blinded_path::message::OffersContext::native_into(context.unwrap()) }) }; + let mut local_responder = crate::lightning::onion_message::messenger::Responder { inner: if responder.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((responder.unwrap())) } }, is_owned: true }; + let mut ret = (self.0.handle_message)(self.0.this_arg, crate::lightning::onion_message::offers::OffersMessage::native_into(message), local_context, local_responder); + let mut local_ret = if ret.is_some() { Some( { let (mut orig_ret_0_0, mut orig_ret_0_1) = ret.take().to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), *unsafe { Box::from_raw(orig_ret_0_1.take_inner()) }); local_ret_0 }) } else { None }; + local_ret + } + fn release_pending_messages(&self) -> Vec<(lightning::onion_message::offers::OffersMessage, lightning::onion_message::messenger::MessageSendInstructions)> { + let mut ret = (self.0.release_pending_messages)(self.0.this_arg); + let mut local_ret = Vec::new(); for mut item in ret.into_rust().drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1) = item.to_rust(); let mut local_ret_0 = (orig_ret_0_0.into_native(), orig_ret_0_1.into_native()); local_ret_0 }); }; local_ret } } @@ -70,14 +90,14 @@ impl rustOffersMessageHandler for OffersMessageHandler { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for OffersMessageHandler { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OffersMessageHandlerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OffersMessageHandlerRef) } } } impl core::ops::DerefMut for OffersMessageHandler { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OffersMessageHandlerRef { + unsafe { &mut *(self as *mut _ as *mut OffersMessageHandlerRef) } } } /// Calls the free function if one is set @@ -265,6 +285,7 @@ pub extern "C" fn OffersMessage_as_OnionMessageContents(this_arg: &OffersMessage this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const OffersMessage as *mut OffersMessage) as *mut c_void }, free: None, tlv_type: OffersMessage_OnionMessageContents_tlv_type, + msg_type: OffersMessage_OnionMessageContents_msg_type, write: OffersMessage_write_void, debug_str: OffersMessage_debug_str_void, cloned: Some(OnionMessageContents_OffersMessage_cloned), @@ -273,9 +294,14 @@ pub extern "C" fn OffersMessage_as_OnionMessageContents(this_arg: &OffersMessage #[must_use] extern "C" fn OffersMessage_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { - let mut ret = >::tlv_type(unsafe { &mut *(this_arg as *mut nativeOffersMessage) }, ); + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeOffersMessage) }, ); ret } +#[must_use] +extern "C" fn OffersMessage_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeOffersMessage) }, ); + ret.into() +} extern "C" fn OnionMessageContents_OffersMessage_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { new_obj.this_arg = OffersMessage_clone_void(new_obj.this_arg); new_obj.free = Some(OffersMessage_free_void); diff --git a/lightning-c-bindings/src/lightning/onion_message/packet.rs b/lightning-c-bindings/src/lightning/onion_message/packet.rs index 6a6714e..0288684 100644 --- a/lightning-c-bindings/src/lightning/onion_message/packet.rs +++ b/lightning-c-bindings/src/lightning/onion_message/packet.rs @@ -37,6 +37,12 @@ pub struct Packet { pub is_owned: bool, } +impl core::ops::Deref for Packet { + type Target = nativePacket; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Packet { } +unsafe impl core::marker::Sync for Packet { } impl Drop for Packet { fn drop(&mut self) { if self.is_owned && !<*mut nativePacket>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl Packet { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Bolt 04 version number #[no_mangle] @@ -147,9 +156,6 @@ pub(crate) extern "C" fn Packet_clone_void(this_ptr: *const c_void) -> *mut c_vo pub extern "C" fn Packet_clone(orig: &Packet) -> Packet { orig.clone() } -/// Get a string which allows debug introspection of a Packet object -pub extern "C" fn Packet_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::packet::Packet }).into()} /// Generates a non-cryptographic 64-bit hash of the Packet. #[no_mangle] pub extern "C" fn Packet_hash(o: &Packet) -> u64 { @@ -169,6 +175,9 @@ pub extern "C" fn Packet_eq(a: &Packet, b: &Packet) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Get a string which allows debug introspection of a Packet object +pub extern "C" fn Packet_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::onion_message::packet::Packet }).into()} #[no_mangle] /// Serialize the Packet object into a byte array which can be read by Packet_read pub extern "C" fn Packet_write(obj: &crate::lightning::onion_message::packet::Packet) -> crate::c_types::derived::CVec_u8Z { @@ -176,7 +185,7 @@ pub extern "C" fn Packet_write(obj: &crate::lightning::onion_message::packet::Pa } #[allow(unused)] pub(crate) extern "C" fn Packet_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePacket) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::onion_message::packet::nativePacket) }) } /// The contents of an [`OnionMessage`] as read from the wire. /// @@ -193,7 +202,7 @@ pub enum ParsedOnionMessageContents { crate::lightning::onion_message::packet::OnionMessageContents), } use lightning::onion_message::packet::ParsedOnionMessageContents as ParsedOnionMessageContentsImport; -pub(crate) type nativeParsedOnionMessageContents = ParsedOnionMessageContentsImport; +pub(crate) type nativeParsedOnionMessageContents = ParsedOnionMessageContentsImport; impl ParsedOnionMessageContents { #[allow(unused)] @@ -229,7 +238,7 @@ impl ParsedOnionMessageContents { } } #[allow(unused)] - pub(crate) fn from_native(native: &ParsedOnionMessageContentsImport) -> Self { + pub(crate) fn from_native(native: &ParsedOnionMessageContentsImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeParsedOnionMessageContents) }; match native { nativeParsedOnionMessageContents::Offers (ref a, ) => { @@ -311,6 +320,7 @@ pub extern "C" fn ParsedOnionMessageContents_as_OnionMessageContents(this_arg: & this_arg: unsafe { ObjOps::untweak_ptr(this_arg as *const ParsedOnionMessageContents as *mut ParsedOnionMessageContents) as *mut c_void }, free: None, tlv_type: ParsedOnionMessageContents_OnionMessageContents_tlv_type, + msg_type: ParsedOnionMessageContents_OnionMessageContents_msg_type, write: ParsedOnionMessageContents_write_void, debug_str: ParsedOnionMessageContents_debug_str_void, cloned: Some(OnionMessageContents_ParsedOnionMessageContents_cloned), @@ -319,9 +329,14 @@ pub extern "C" fn ParsedOnionMessageContents_as_OnionMessageContents(this_arg: & #[must_use] extern "C" fn ParsedOnionMessageContents_OnionMessageContents_tlv_type(this_arg: *const c_void) -> u64 { - let mut ret = >::tlv_type(unsafe { &mut *(this_arg as *mut nativeParsedOnionMessageContents) }, ); + let mut ret = ::tlv_type(unsafe { &mut *(this_arg as *mut nativeParsedOnionMessageContents) }, ); ret } +#[must_use] +extern "C" fn ParsedOnionMessageContents_OnionMessageContents_msg_type(this_arg: *const c_void) -> crate::c_types::Str { + let mut ret = ::msg_type(unsafe { &mut *(this_arg as *mut nativeParsedOnionMessageContents) }, ); + ret.into() +} extern "C" fn OnionMessageContents_ParsedOnionMessageContents_cloned(new_obj: &mut crate::lightning::onion_message::packet::OnionMessageContents) { new_obj.this_arg = ParsedOnionMessageContents_clone_void(new_obj.this_arg); new_obj.free = Some(ParsedOnionMessageContents_free_void); @@ -344,6 +359,8 @@ pub struct OnionMessageContents { pub this_arg: *mut c_void, /// Returns the TLV type identifying the message contents. MUST be >= 64. pub tlv_type: extern "C" fn (this_arg: *const c_void) -> u64, + /// Returns the message type + pub msg_type: extern "C" fn (this_arg: *const c_void) -> crate::c_types::Str, /// Serialize the object into a byte array pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, /// Return a human-readable "debug" string describing this object @@ -363,6 +380,7 @@ pub(crate) fn OnionMessageContents_clone_fields(orig: &OnionMessageContents) -> OnionMessageContents { this_arg: orig.this_arg, tlv_type: Clone::clone(&orig.tlv_type), + msg_type: Clone::clone(&orig.msg_type), write: Clone::clone(&orig.write), debug_str: Clone::clone(&orig.debug_str), cloned: Clone::clone(&orig.cloned), @@ -375,11 +393,22 @@ impl lightning::util::ser::Writeable for OnionMessageContents { w.write_all(vec.as_slice()) } } +impl lightning::util::ser::Writeable for OnionMessageContentsRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} impl core::fmt::Debug for OnionMessageContents { fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { f.write_str((self.debug_str)(self.this_arg).into_str()) } } +impl core::fmt::Debug for OnionMessageContentsRef { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.write_str((self.0.debug_str)(self.0.this_arg).into_str()) + } +} #[no_mangle] /// Creates a copy of a OnionMessageContents pub extern "C" fn OnionMessageContents_clone(orig: &OnionMessageContents) -> OnionMessageContents { @@ -392,6 +421,11 @@ impl Clone for OnionMessageContents { OnionMessageContents_clone(self) } } +impl Clone for OnionMessageContentsRef { + fn clone(&self) -> Self { + Self(OnionMessageContents_clone(&self.0)) + } +} use lightning::onion_message::packet::OnionMessageContents as rustOnionMessageContents; impl rustOnionMessageContents for OnionMessageContents { @@ -399,19 +433,35 @@ impl rustOnionMessageContents for OnionMessageContents { let mut ret = (self.tlv_type)(self.this_arg); ret } + fn msg_type(&self) -> String { + let mut ret = (self.msg_type)(self.this_arg); + ret.into_string() + } +} + +pub struct OnionMessageContentsRef(OnionMessageContents); +impl rustOnionMessageContents for OnionMessageContentsRef { + fn tlv_type(&self) -> u64 { + let mut ret = (self.0.tlv_type)(self.0.this_arg); + ret + } + fn msg_type(&self) -> String { + let mut ret = (self.0.msg_type)(self.0.this_arg); + ret.into_string() + } } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for OnionMessageContents { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = OnionMessageContentsRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OnionMessageContentsRef) } } } impl core::ops::DerefMut for OnionMessageContents { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut OnionMessageContentsRef { + unsafe { &mut *(self as *mut _ as *mut OnionMessageContentsRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/routing/gossip.rs b/lightning-c-bindings/src/lightning/routing/gossip.rs index b97a92e..39db985 100644 --- a/lightning-c-bindings/src/lightning/routing/gossip.rs +++ b/lightning-c-bindings/src/lightning/routing/gossip.rs @@ -37,6 +37,12 @@ pub struct NodeId { pub is_owned: bool, } +impl core::ops::Deref for NodeId { + type Target = nativeNodeId; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeId { } +unsafe impl core::marker::Sync for NodeId { } impl Drop for NodeId { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeId>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl NodeId { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for NodeId { fn clone(&self) -> Self { @@ -87,6 +96,15 @@ pub(crate) extern "C" fn NodeId_clone_void(this_ptr: *const c_void) -> *mut c_vo pub extern "C" fn NodeId_clone(orig: &NodeId) -> NodeId { orig.clone() } +/// Checks if two NodeIds contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn NodeId_eq(a: &NodeId, b: &NodeId) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} /// Create a new NodeId from a public key #[must_use] #[no_mangle] @@ -95,6 +113,15 @@ pub extern "C" fn NodeId_from_pubkey(mut pubkey: crate::c_types::PublicKey) -> c crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Create a new NodeId from a slice of bytes +#[must_use] +#[no_mangle] +pub extern "C" fn NodeId_from_slice(mut bytes: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeIdDecodeErrorZ { + let mut ret = lightning::routing::gossip::NodeId::from_slice(bytes.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeId { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_ret +} + /// Get the public key slice from this NodeId #[must_use] #[no_mangle] @@ -124,6 +151,11 @@ pub extern "C" fn NodeId_as_pubkey(this_arg: &crate::lightning::routing::gossip: /// Get a string which allows debug introspection of a NodeId object pub extern "C" fn NodeId_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::NodeId }).into()} +#[no_mangle] +/// Get the string representation of a NodeId object +pub extern "C" fn NodeId_to_str(o: &crate::lightning::routing::gossip::NodeId) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} /// Generates a non-cryptographic 64-bit hash of the NodeId. #[no_mangle] pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 { @@ -141,7 +173,7 @@ pub extern "C" fn NodeId_write(obj: &crate::lightning::routing::gossip::NodeId) } #[allow(unused)] pub(crate) extern "C" fn NodeId_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeId) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeId) }) } #[no_mangle] /// Read a NodeId from a byte array, created by NodeId_write @@ -152,7 +184,7 @@ pub extern "C" fn NodeId_read(ser: crate::c_types::u8slice) -> crate::c_types::d } use lightning::routing::gossip::NetworkGraph as nativeNetworkGraphImport; -pub(crate) type nativeNetworkGraph = nativeNetworkGraphImport; +pub(crate) type nativeNetworkGraph = nativeNetworkGraphImport; /// Represents the network as nodes and channels between them #[must_use] @@ -170,6 +202,12 @@ pub struct NetworkGraph { pub is_owned: bool, } +impl core::ops::Deref for NetworkGraph { + type Target = nativeNetworkGraph; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NetworkGraph { } +unsafe impl core::marker::Sync for NetworkGraph { } impl Drop for NetworkGraph { fn drop(&mut self) { if self.is_owned && !<*mut nativeNetworkGraph>::is_null(self.inner) { @@ -200,10 +238,13 @@ impl NetworkGraph { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::gossip::ReadOnlyNetworkGraph as nativeReadOnlyNetworkGraphImport; -pub(crate) type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static>; +pub(crate) type nativeReadOnlyNetworkGraph = nativeReadOnlyNetworkGraphImport<'static, >; /// A read-only view of [`NetworkGraph`]. #[must_use] @@ -221,6 +262,12 @@ pub struct ReadOnlyNetworkGraph { pub is_owned: bool, } +impl core::ops::Deref for ReadOnlyNetworkGraph { + type Target = nativeReadOnlyNetworkGraph; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ReadOnlyNetworkGraph { } +unsafe impl core::marker::Sync for ReadOnlyNetworkGraph { } impl Drop for ReadOnlyNetworkGraph { fn drop(&mut self) { if self.is_owned && !<*mut nativeReadOnlyNetworkGraph>::is_null(self.inner) { @@ -251,6 +298,9 @@ impl ReadOnlyNetworkGraph { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion /// return packet by a node along the route. See [BOLT #4] for details. @@ -260,12 +310,6 @@ impl ReadOnlyNetworkGraph { #[must_use] #[repr(C)] pub enum NetworkUpdate { - /// An error indicating a `channel_update` messages should be applied via - /// [`NetworkGraph::update_channel`]. - ChannelUpdateMessage { - /// The update to apply via [`NetworkGraph::update_channel`]. - msg: crate::lightning::ln::msgs::ChannelUpdate, - }, /// An error indicating that a channel failed to route a payment, which should be applied via /// [`NetworkGraph::channel_failed_permanent`] if permanent. ChannelFailure { @@ -292,12 +336,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn to_native(&self) -> nativeNetworkUpdate { match self { - NetworkUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - nativeNetworkUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg_nonref.take_inner()) }, - } - }, NetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => { let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut is_permanent_nonref = Clone::clone(is_permanent); @@ -319,11 +357,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn into_native(self) -> nativeNetworkUpdate { match self { - NetworkUpdate::ChannelUpdateMessage {mut msg, } => { - nativeNetworkUpdate::ChannelUpdateMessage { - msg: *unsafe { Box::from_raw(msg.take_inner()) }, - } - }, NetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => { nativeNetworkUpdate::ChannelFailure { short_channel_id: short_channel_id, @@ -342,12 +375,6 @@ impl NetworkUpdate { pub(crate) fn from_native(native: &NetworkUpdateImport) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNetworkUpdate) }; match native { - nativeNetworkUpdate::ChannelUpdateMessage {ref msg, } => { - let mut msg_nonref = Clone::clone(msg); - NetworkUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg_nonref), is_owned: true }, - } - }, nativeNetworkUpdate::ChannelFailure {ref short_channel_id, ref is_permanent, } => { let mut short_channel_id_nonref = Clone::clone(short_channel_id); let mut is_permanent_nonref = Clone::clone(is_permanent); @@ -369,11 +396,6 @@ impl NetworkUpdate { #[allow(unused)] pub(crate) fn native_into(native: nativeNetworkUpdate) -> Self { match native { - nativeNetworkUpdate::ChannelUpdateMessage {mut msg, } => { - NetworkUpdate::ChannelUpdateMessage { - msg: crate::lightning::ln::msgs::ChannelUpdate { inner: ObjOps::heap_alloc(msg), is_owned: true }, - } - }, nativeNetworkUpdate::ChannelFailure {mut short_channel_id, mut is_permanent, } => { NetworkUpdate::ChannelFailure { short_channel_id: short_channel_id, @@ -408,13 +430,6 @@ pub(crate) extern "C" fn NetworkUpdate_free_void(this_ptr: *mut c_void) { let _ = unsafe { Box::from_raw(this_ptr as *mut NetworkUpdate) }; } #[no_mangle] -/// Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate -pub extern "C" fn NetworkUpdate_channel_update_message(msg: crate::lightning::ln::msgs::ChannelUpdate) -> NetworkUpdate { - NetworkUpdate::ChannelUpdateMessage { - msg, - } -} -#[no_mangle] /// Utility method to constructs a new ChannelFailure-variant NetworkUpdate pub extern "C" fn NetworkUpdate_channel_failure(short_channel_id: u64, is_permanent: bool) -> NetworkUpdate { NetworkUpdate::ChannelFailure { @@ -457,7 +472,7 @@ pub extern "C" fn NetworkUpdate_read(ser: crate::c_types::u8slice) -> crate::c_t } use lightning::routing::gossip::P2PGossipSync as nativeP2PGossipSyncImport; -pub(crate) type nativeP2PGossipSync = nativeP2PGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger>; +pub(crate) type nativeP2PGossipSync = nativeP2PGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger, >; /// Receives and validates network updates from peers, /// stores authentic and relevant data as a network graph. @@ -479,6 +494,12 @@ pub struct P2PGossipSync { pub is_owned: bool, } +impl core::ops::Deref for P2PGossipSync { + type Target = nativeP2PGossipSync; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for P2PGossipSync { } +unsafe impl core::marker::Sync for P2PGossipSync { } impl Drop for P2PGossipSync { fn drop(&mut self) { if self.is_owned && !<*mut nativeP2PGossipSync>::is_null(self.inner) { @@ -509,6 +530,9 @@ impl P2PGossipSync { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new tracker of the actual state of the network of channels and nodes, /// assuming an existing [`NetworkGraph`]. @@ -532,8 +556,6 @@ pub extern "C" fn P2PGossipSync_add_utxo_lookup(this_arg: &crate::lightning::rou } /// Handles any network updates originating from [`Event`]s. -/// Note that this will skip applying any [`NetworkUpdate::ChannelUpdateMessage`] to avoid -/// leaking possibly identifying information of the sender to the public network. /// /// [`Event`]: crate::events::Event #[no_mangle] @@ -609,79 +631,79 @@ pub extern "C" fn P2PGossipSync_as_RoutingMessageHandler(this_arg: &P2PGossipSyn #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_node_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::NodeAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); + let mut ret = ::handle_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_channel_announcement(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelAnnouncement) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); + let mut ret = ::handle_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_channel_update(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::ChannelUpdate) -> crate::c_types::derived::CResult_boolLightningErrorZ { - let mut ret = >::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); + let mut ret = ::handle_channel_update(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, msg.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_channel_announcement(this_arg: *const c_void, mut starting_point: u64) -> crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ { - let mut ret = >::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, starting_point); + let mut ret = ::get_next_channel_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, starting_point); let mut local_ret = if ret.is_none() { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::None } else { crate::c_types::derived::COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ::Some( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = (ret.unwrap()); let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }) }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_get_next_node_announcement(this_arg: *const c_void, mut starting_point: crate::lightning::routing::gossip::NodeId) -> crate::lightning::ln::msgs::NodeAnnouncement { let mut local_starting_point = if starting_point.inner.is_null() { None } else { Some( { starting_point.get_native_ref() }) }; - let mut ret = >::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, local_starting_point); + let mut ret = ::get_next_node_announcement(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, local_starting_point); let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_peer_connected(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, init: &crate::lightning::ln::msgs::Init, mut inbound: bool) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); + let mut ret = ::peer_connected(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), init.get_native_ref(), inbound); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_reply_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_reply_short_channel_ids_end(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::ReplyShortChannelIdsEnd) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_reply_short_channel_ids_end(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_query_channel_range(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryChannelRange) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_query_channel_range(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_handle_query_short_channel_ids(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey, mut msg: crate::lightning::ln::msgs::QueryShortChannelIds) -> crate::c_types::derived::CResult_NoneLightningErrorZ { - let mut ret = >::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); + let mut ret = ::handle_query_short_channel_ids(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust(), *unsafe { Box::from_raw(msg.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn P2PGossipSync_RoutingMessageHandler_processing_queue_high(this_arg: *const c_void) -> bool { - let mut ret = >::processing_queue_high(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); + let mut ret = ::processing_queue_high(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); ret } #[must_use] -extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning::ln::features::NodeFeatures { - let mut ret = >::provided_node_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); - crate::lightning::ln::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_node_features(this_arg: *const c_void) -> crate::lightning_types::features::NodeFeatures { + let mut ret = ::provided_node_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } #[must_use] -extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning::ln::features::InitFeatures { - let mut ret = >::provided_init_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust()); - crate::lightning::ln::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +extern "C" fn P2PGossipSync_RoutingMessageHandler_provided_init_features(this_arg: *const c_void, mut their_node_id: crate::c_types::PublicKey) -> crate::lightning_types::features::InitFeatures { + let mut ret = ::provided_init_features(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, &their_node_id.into_rust()); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } } impl From for crate::lightning::events::MessageSendEventsProvider { @@ -707,7 +729,7 @@ pub extern "C" fn P2PGossipSync_as_MessageSendEventsProvider(this_arg: &P2PGossi #[must_use] extern "C" fn P2PGossipSync_MessageSendEventsProvider_get_and_clear_pending_msg_events(this_arg: *const c_void) -> crate::c_types::derived::CVec_MessageSendEventZ { - let mut ret = >::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); + let mut ret = ::get_and_clear_pending_msg_events(unsafe { &mut *(this_arg as *mut nativeP2PGossipSync) }, ); let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::events::MessageSendEvent::native_into(item) }); }; local_ret.into() } @@ -732,6 +754,12 @@ pub struct ChannelUpdateInfo { pub is_owned: bool, } +impl core::ops::Deref for ChannelUpdateInfo { + type Target = nativeChannelUpdateInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUpdateInfo { } +unsafe impl core::marker::Sync for ChannelUpdateInfo { } impl Drop for ChannelUpdateInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUpdateInfo>::is_null(self.inner) { @@ -762,41 +790,9 @@ impl ChannelUpdateInfo { self.inner = core::ptr::null_mut(); ret } -} -/// When the last update to the channel direction was issued. -/// Value is opaque, as set in the announcement. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; - *inner_val -} -/// When the last update to the channel direction was issued. -/// Value is opaque, as set in the announcement. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; -} -/// Whether the channel can be currently used for payments (in this one direction). -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled; - *inner_val -} -/// Whether the channel can be currently used for payments (in this one direction). -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val; -} -/// The difference in CLTV values that you must have when routing through this channel. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// The difference in CLTV values that you must have when routing through this channel. -#[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The minimum value, which must be relayed to the next hop via the channel #[no_mangle] @@ -822,15 +818,50 @@ pub extern "C" fn ChannelUpdateInfo_set_htlc_maximum_msat(this_ptr: &mut Channel } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning::routing::gossip::RoutingFees { +pub extern "C" fn ChannelUpdateInfo_get_fees(this_ptr: &ChannelUpdateInfo) -> crate::lightning_types::routing::RoutingFees { let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; - crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false } + crate::lightning_types::routing::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::routing::RoutingFees<>) as *mut _) }, is_owned: false } } /// Fees charged when the channel is used for routing #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning::routing::gossip::RoutingFees) { +pub extern "C" fn ChannelUpdateInfo_set_fees(this_ptr: &mut ChannelUpdateInfo, mut val: crate::lightning_types::routing::RoutingFees) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; } +/// When the last update to the channel direction was issued. +/// Value is opaque, as set in the announcement. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_last_update(this_ptr: &ChannelUpdateInfo) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; + *inner_val +} +/// When the last update to the channel direction was issued. +/// Value is opaque, as set in the announcement. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_last_update(this_ptr: &mut ChannelUpdateInfo, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; +} +/// The difference in CLTV values that you must have when routing through this channel. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_cltv_expiry_delta(this_ptr: &ChannelUpdateInfo) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// The difference in CLTV values that you must have when routing through this channel. +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_cltv_expiry_delta(this_ptr: &mut ChannelUpdateInfo, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// Whether the channel can be currently used for payments (in this one direction). +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_get_enabled(this_ptr: &ChannelUpdateInfo) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().enabled; + *inner_val +} +/// Whether the channel can be currently used for payments (in this one direction). +#[no_mangle] +pub extern "C" fn ChannelUpdateInfo_set_enabled(this_ptr: &mut ChannelUpdateInfo, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.enabled = val; +} /// Most recent update for the channel received from the network /// Mostly redundant with the data we store in fields explicitly. /// Everything else is useful only for sending out for initial routing sync. @@ -859,15 +890,15 @@ pub extern "C" fn ChannelUpdateInfo_set_last_update_message(this_ptr: &mut Chann /// Note that last_update_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn ChannelUpdateInfo_new(mut last_update_arg: u32, mut enabled_arg: bool, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo { +pub extern "C" fn ChannelUpdateInfo_new(mut htlc_minimum_msat_arg: u64, mut htlc_maximum_msat_arg: u64, mut fees_arg: crate::lightning_types::routing::RoutingFees, mut last_update_arg: u32, mut cltv_expiry_delta_arg: u16, mut enabled_arg: bool, mut last_update_message_arg: crate::lightning::ln::msgs::ChannelUpdate) -> ChannelUpdateInfo { let mut local_last_update_message_arg = if last_update_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(last_update_message_arg.take_inner()) } }) }; ChannelUpdateInfo { inner: ObjOps::heap_alloc(nativeChannelUpdateInfo { - last_update: last_update_arg, - enabled: enabled_arg, - cltv_expiry_delta: cltv_expiry_delta_arg, htlc_minimum_msat: htlc_minimum_msat_arg, htlc_maximum_msat: htlc_maximum_msat_arg, fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, + last_update: last_update_arg, + cltv_expiry_delta: cltv_expiry_delta_arg, + enabled: enabled_arg, last_update_message: local_last_update_message_arg, }), is_owned: true } } @@ -903,13 +934,18 @@ pub extern "C" fn ChannelUpdateInfo_eq(a: &ChannelUpdateInfo, b: &ChannelUpdateI if a.get_native_ref() == b.get_native_ref() { true } else { false } } #[no_mangle] +/// Get the string representation of a ChannelUpdateInfo object +pub extern "C" fn ChannelUpdateInfo_to_str(o: &crate::lightning::routing::gossip::ChannelUpdateInfo) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} +#[no_mangle] /// Serialize the ChannelUpdateInfo object into a byte array which can be read by ChannelUpdateInfo_read pub extern "C" fn ChannelUpdateInfo_write(obj: &crate::lightning::routing::gossip::ChannelUpdateInfo) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn ChannelUpdateInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelUpdateInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeChannelUpdateInfo) }) } #[no_mangle] /// Read a ChannelUpdateInfo from a byte array, created by ChannelUpdateInfo_write @@ -939,6 +975,12 @@ pub struct ChannelInfo { pub is_owned: bool, } +impl core::ops::Deref for ChannelInfo { + type Target = nativeChannelInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelInfo { } +unsafe impl core::marker::Sync for ChannelInfo { } impl Drop for ChannelInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelInfo>::is_null(self.inner) { @@ -969,16 +1011,19 @@ impl ChannelInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Protocol features of a channel communicated during its announcement #[no_mangle] -pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn ChannelInfo_get_features(this_ptr: &ChannelInfo) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// Protocol features of a channel communicated during its announcement #[no_mangle] -pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn ChannelInfo_set_features(this_ptr: &mut ChannelInfo, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// Source node of the first direction of a channel @@ -992,6 +1037,30 @@ pub extern "C" fn ChannelInfo_get_node_one(this_ptr: &ChannelInfo) -> crate::lig pub extern "C" fn ChannelInfo_set_node_one(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_one = *unsafe { Box::from_raw(val.take_inner()) }; } +/// Source node of the second direction of a channel +#[no_mangle] +pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two; + crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } +} +/// Source node of the second direction of a channel +#[no_mangle] +pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The channel capacity as seen on-chain, if chain lookup is available. +#[no_mangle] +pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.capacity_sats = local_val; +} /// Details about the first direction of a channel /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None @@ -1009,17 +1078,6 @@ pub extern "C" fn ChannelInfo_set_one_to_two(this_ptr: &mut ChannelInfo, mut val let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.one_to_two = local_val; } -/// Source node of the second direction of a channel -#[no_mangle] -pub extern "C" fn ChannelInfo_get_node_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::gossip::NodeId { - let mut inner_val = &mut this_ptr.get_native_mut_ref().node_two; - crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } -} -/// Source node of the second direction of a channel -#[no_mangle] -pub extern "C" fn ChannelInfo_set_node_two(this_ptr: &mut ChannelInfo, mut val: crate::lightning::routing::gossip::NodeId) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_two = *unsafe { Box::from_raw(val.take_inner()) }; -} /// Details about the second direction of a channel /// /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None @@ -1037,19 +1095,6 @@ pub extern "C" fn ChannelInfo_set_two_to_one(this_ptr: &mut ChannelInfo, mut val let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.two_to_one = local_val; } -/// The channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_get_capacity_sats(this_ptr: &ChannelInfo) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().capacity_sats; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The channel capacity as seen on-chain, if chain lookup is available. -#[no_mangle] -pub extern "C" fn ChannelInfo_set_capacity_sats(this_ptr: &mut ChannelInfo, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.capacity_sats = local_val; -} /// An initial announcement of the channel /// Mostly redundant with the data we store in fields explicitly. /// Everything else is useful only for sending out for initial routing sync. @@ -1115,6 +1160,11 @@ pub extern "C" fn ChannelInfo_get_directional_info(this_arg: &crate::lightning:: local_ret } +#[no_mangle] +/// Get the string representation of a ChannelInfo object +pub extern "C" fn ChannelInfo_to_str(o: &crate::lightning::routing::gossip::ChannelInfo) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} #[no_mangle] /// Serialize the ChannelInfo object into a byte array which can be read by ChannelInfo_read pub extern "C" fn ChannelInfo_write(obj: &crate::lightning::routing::gossip::ChannelInfo) -> crate::c_types::derived::CVec_u8Z { @@ -1122,7 +1172,7 @@ pub extern "C" fn ChannelInfo_write(obj: &crate::lightning::routing::gossip::Cha } #[allow(unused)] pub(crate) extern "C" fn ChannelInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeChannelInfo) }) } #[no_mangle] /// Read a ChannelInfo from a byte array, created by ChannelInfo_write @@ -1133,7 +1183,7 @@ pub extern "C" fn ChannelInfo_read(ser: crate::c_types::u8slice) -> crate::c_typ } use lightning::routing::gossip::DirectedChannelInfo as nativeDirectedChannelInfoImport; -pub(crate) type nativeDirectedChannelInfo = nativeDirectedChannelInfoImport<'static>; +pub(crate) type nativeDirectedChannelInfo = nativeDirectedChannelInfoImport<'static, >; /// A wrapper around [`ChannelInfo`] representing information about the channel as directed from a /// source node to a target node. @@ -1152,6 +1202,12 @@ pub struct DirectedChannelInfo { pub is_owned: bool, } +impl core::ops::Deref for DirectedChannelInfo { + type Target = nativeDirectedChannelInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DirectedChannelInfo { } +unsafe impl core::marker::Sync for DirectedChannelInfo { } impl Drop for DirectedChannelInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeDirectedChannelInfo>::is_null(self.inner) { @@ -1182,6 +1238,9 @@ impl DirectedChannelInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for DirectedChannelInfo { fn clone(&self) -> Self { @@ -1222,6 +1281,26 @@ pub extern "C" fn DirectedChannelInfo_effective_capacity(this_arg: &crate::light crate::lightning::routing::gossip::EffectiveCapacity::native_into(ret) } +/// Returns the `node_id` of the source hop. +/// +/// Refers to the `node_id` forwarding the payment to the next hop. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelInfo_source(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.source(); + crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } +} + +/// Returns the `node_id` of the target hop. +/// +/// Refers to the `node_id` receiving the payment from the previous hop. +#[must_use] +#[no_mangle] +pub extern "C" fn DirectedChannelInfo_target(this_arg: &crate::lightning::routing::gossip::DirectedChannelInfo) -> crate::lightning::routing::gossip::NodeId { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.target(); + crate::lightning::routing::gossip::NodeId { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::routing::gossip::NodeId<>) as *mut _) }, is_owned: false } +} + /// Get a string which allows debug introspection of a DirectedChannelInfo object pub extern "C" fn DirectedChannelInfo_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::DirectedChannelInfo }).into()} @@ -1463,160 +1542,35 @@ pub extern "C" fn EffectiveCapacity_as_msat(this_arg: &crate::lightning::routing ret } - -use lightning::routing::gossip::RoutingFees as nativeRoutingFeesImport; -pub(crate) type nativeRoutingFees = nativeRoutingFeesImport; - -/// Fees for routing via a given channel or a node -#[must_use] -#[repr(C)] -pub struct RoutingFees { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeRoutingFees, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RoutingFees { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoutingFees) }; -} -#[allow(unused)] -impl RoutingFees { - pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// Flat routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat; - *inner_val -} -/// Flat routing fee in millisatoshis. -#[no_mangle] -pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val; -} -/// Liquidity-based routing fee in millionths of a routed amount. -/// In other words, 10000 is 1%. -#[no_mangle] -pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths; - *inner_val -} -/// Liquidity-based routing fee in millionths of a routed amount. -/// In other words, 10000 is 1%. -#[no_mangle] -pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val; -} -/// Constructs a new RoutingFees given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees { - RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees { - base_msat: base_msat_arg, - proportional_millionths: proportional_millionths_arg, - }), is_owned: true } -} -/// Checks if two RoutingFeess contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -impl Clone for RoutingFees { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoutingFees)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RoutingFees -pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { - orig.clone() -} -/// Get a string which allows debug introspection of a RoutingFees object -pub extern "C" fn RoutingFees_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::RoutingFees }).into()} -/// Generates a non-cryptographic 64-bit hash of the RoutingFees. -#[no_mangle] -pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} #[no_mangle] /// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read -pub extern "C" fn RoutingFees_write(obj: &crate::lightning::routing::gossip::RoutingFees) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RoutingFees_write(obj: &crate::lightning_types::routing::RoutingFees) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RoutingFees_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoutingFees) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRoutingFees) }) } #[no_mangle] /// Read a RoutingFees from a byte array, created by RoutingFees_write pub extern "C" fn RoutingFees_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RoutingFeesDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::routing::RoutingFees { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } -use lightning::routing::gossip::NodeAnnouncementInfo as nativeNodeAnnouncementInfoImport; -pub(crate) type nativeNodeAnnouncementInfo = nativeNodeAnnouncementInfoImport; +use lightning::routing::gossip::NodeAnnouncementDetails as nativeNodeAnnouncementDetailsImport; +pub(crate) type nativeNodeAnnouncementDetails = nativeNodeAnnouncementDetailsImport; -/// Information received in the latest node_announcement from this node. +/// Non-relayable information received in the latest node_announcement from this node. #[must_use] #[repr(C)] -pub struct NodeAnnouncementInfo { +pub struct NodeAnnouncementDetails { /// A pointer to the opaque Rust object. /// Nearly everywhere, inner must be non-null, however in places where /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeNodeAnnouncementInfo, + pub inner: *mut nativeNodeAnnouncementDetails, /// Indicates that this is the only struct which contains the same pointer. /// Rust functions which take ownership of an object provided via an argument require @@ -1624,77 +1578,86 @@ pub struct NodeAnnouncementInfo { pub is_owned: bool, } -impl Drop for NodeAnnouncementInfo { +impl core::ops::Deref for NodeAnnouncementDetails { + type Target = nativeNodeAnnouncementDetails; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAnnouncementDetails { } +unsafe impl core::marker::Sync for NodeAnnouncementDetails { } +impl Drop for NodeAnnouncementDetails { fn drop(&mut self) { - if self.is_owned && !<*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { + if self.is_owned && !<*mut nativeNodeAnnouncementDetails>::is_null(self.inner) { let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; } } } -/// Frees any resources used by the NodeAnnouncementInfo, if is_owned is set and inner is non-NULL. +/// Frees any resources used by the NodeAnnouncementDetails, if is_owned is set and inner is non-NULL. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_free(this_obj: NodeAnnouncementInfo) { } +pub extern "C" fn NodeAnnouncementDetails_free(this_obj: NodeAnnouncementDetails) { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncementInfo) }; +pub(crate) extern "C" fn NodeAnnouncementDetails_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeAnnouncementDetails) }; } #[allow(unused)] -impl NodeAnnouncementInfo { - pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementInfo { +impl NodeAnnouncementDetails { + pub(crate) fn get_native_ref(&self) -> &'static nativeNodeAnnouncementDetails { unsafe { &*ObjOps::untweak_ptr(self.inner) } } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementInfo { + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeAnnouncementDetails { unsafe { &mut *ObjOps::untweak_ptr(self.inner) } } /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo { + pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementDetails { assert!(self.is_owned); let ret = ObjOps::untweak_ptr(self.inner); self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Protocol features the node announced support for #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_features(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn NodeAnnouncementDetails_get_features(this_ptr: &NodeAnnouncementDetails) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// Protocol features the node announced support for #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_features(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn NodeAnnouncementDetails_set_features(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.features = *unsafe { Box::from_raw(val.take_inner()) }; } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_last_update(this_ptr: &NodeAnnouncementInfo) -> u32 { +pub extern "C" fn NodeAnnouncementDetails_get_last_update(this_ptr: &NodeAnnouncementDetails) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update; *inner_val } /// When the last known update to the node state was issued. /// Value is opaque, as set in the announcement. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_last_update(this_ptr: &mut NodeAnnouncementInfo, mut val: u32) { +pub extern "C" fn NodeAnnouncementDetails_set_last_update(this_ptr: &mut NodeAnnouncementDetails, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.last_update = val; } /// Color assigned to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_rgb(this_ptr: &NodeAnnouncementInfo) -> *const [u8; 3] { +pub extern "C" fn NodeAnnouncementDetails_get_rgb(this_ptr: &NodeAnnouncementDetails) -> *const [u8; 3] { let mut inner_val = &mut this_ptr.get_native_mut_ref().rgb; inner_val } /// Color assigned to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_rgb(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::c_types::ThreeBytes) { +pub extern "C" fn NodeAnnouncementDetails_set_rgb(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::c_types::ThreeBytes) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.rgb = val.data; } /// Moniker assigned to the node. /// May be invalid or malicious (eg control chars), /// should not be exposed to the user. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::routing::gossip::NodeAlias { +pub extern "C" fn NodeAnnouncementDetails_get_alias(this_ptr: &NodeAnnouncementDetails) -> crate::lightning::routing::gossip::NodeAlias { let mut inner_val = &mut this_ptr.get_native_mut_ref().alias; crate::lightning::routing::gossip::NodeAlias { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::NodeAlias<>) as *mut _) }, is_owned: false } } @@ -1702,51 +1665,41 @@ pub extern "C" fn NodeAnnouncementInfo_get_alias(this_ptr: &NodeAnnouncementInfo /// May be invalid or malicious (eg control chars), /// should not be exposed to the user. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_alias(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::routing::gossip::NodeAlias) { +pub extern "C" fn NodeAnnouncementDetails_set_alias(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::lightning::routing::gossip::NodeAlias) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.alias = *unsafe { Box::from_raw(val.take_inner()) }; } -/// An initial announcement of the node -/// Mostly redundant with the data we store in fields explicitly. -/// Everything else is useful only for sending out for initial routing sync. -/// Not stored if contains excess data to prevent DoS. +/// Internet-level addresses via which one can connect to the node /// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Returns a copy of the field. #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message; - let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false }; - local_inner_val +pub extern "C" fn NodeAnnouncementDetails_get_addresses(this_ptr: &NodeAnnouncementDetails) -> crate::c_types::derived::CVec_SocketAddressZ { + let mut inner_val = this_ptr.get_native_mut_ref().addresses.clone(); + let mut local_inner_val = Vec::new(); for mut item in inner_val.drain(..) { local_inner_val.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; + local_inner_val.into() } -/// An initial announcement of the node -/// Mostly redundant with the data we store in fields explicitly. -/// Everything else is useful only for sending out for initial routing sync. -/// Not stored if contains excess data to prevent DoS. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Internet-level addresses via which one can connect to the node #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_set_announcement_message(this_ptr: &mut NodeAnnouncementInfo, mut val: crate::lightning::ln::msgs::NodeAnnouncement) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_message = local_val; +pub extern "C" fn NodeAnnouncementDetails_set_addresses(this_ptr: &mut NodeAnnouncementDetails, mut val: crate::c_types::derived::CVec_SocketAddressZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { item.into_native() }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.addresses = local_val; } -/// Constructs a new NodeAnnouncementInfo given each field -/// -/// Note that announcement_message_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Constructs a new NodeAnnouncementDetails given each field #[must_use] #[no_mangle] -pub extern "C" fn NodeAnnouncementInfo_new(mut features_arg: crate::lightning::ln::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut announcement_message_arg: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { - let mut local_announcement_message_arg = if announcement_message_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_message_arg.take_inner()) } }) }; - NodeAnnouncementInfo { inner: ObjOps::heap_alloc(nativeNodeAnnouncementInfo { +pub extern "C" fn NodeAnnouncementDetails_new(mut features_arg: crate::lightning_types::features::NodeFeatures, mut last_update_arg: u32, mut rgb_arg: crate::c_types::ThreeBytes, mut alias_arg: crate::lightning::routing::gossip::NodeAlias, mut addresses_arg: crate::c_types::derived::CVec_SocketAddressZ) -> NodeAnnouncementDetails { + let mut local_addresses_arg = Vec::new(); for mut item in addresses_arg.into_rust().drain(..) { local_addresses_arg.push( { item.into_native() }); }; + NodeAnnouncementDetails { inner: ObjOps::heap_alloc(nativeNodeAnnouncementDetails { features: *unsafe { Box::from_raw(features_arg.take_inner()) }, last_update: last_update_arg, rgb: rgb_arg.data, alias: *unsafe { Box::from_raw(alias_arg.take_inner()) }, - announcement_message: local_announcement_message_arg, + addresses: local_addresses_arg, }), is_owned: true } } -impl Clone for NodeAnnouncementInfo { +impl Clone for NodeAnnouncementDetails { fn clone(&self) -> Self { Self { - inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else { + inner: if <*mut nativeNodeAnnouncementDetails>::is_null(self.inner) { core::ptr::null_mut() } else { ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, is_owned: true, } @@ -1754,49 +1707,219 @@ impl Clone for NodeAnnouncementInfo { } #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncementInfo)).clone() })) as *mut c_void +pub(crate) extern "C" fn NodeAnnouncementDetails_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeAnnouncementDetails)).clone() })) as *mut c_void } #[no_mangle] +/// Creates a copy of the NodeAnnouncementDetails +pub extern "C" fn NodeAnnouncementDetails_clone(orig: &NodeAnnouncementDetails) -> NodeAnnouncementDetails { + orig.clone() +} +/// Get a string which allows debug introspection of a NodeAnnouncementDetails object +pub extern "C" fn NodeAnnouncementDetails_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::NodeAnnouncementDetails }).into()} +/// Checks if two NodeAnnouncementDetailss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn NodeAnnouncementDetails_eq(a: &NodeAnnouncementDetails, b: &NodeAnnouncementDetails) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Information received in the latest node_announcement from this node. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum NodeAnnouncementInfo { + /// An initial announcement of the node + /// Everything else is useful only for sending out for initial routing sync. + /// Not stored if contains excess data to prevent DoS. + Relayed( + crate::lightning::ln::msgs::NodeAnnouncement), + /// Non-relayable information received in the latest node_announcement from this node. + Local( + crate::lightning::routing::gossip::NodeAnnouncementDetails), +} +use lightning::routing::gossip::NodeAnnouncementInfo as NodeAnnouncementInfoImport; +pub(crate) type nativeNodeAnnouncementInfo = NodeAnnouncementInfoImport; + +impl NodeAnnouncementInfo { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeNodeAnnouncementInfo { + match self { + NodeAnnouncementInfo::Relayed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNodeAnnouncementInfo::Relayed ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + NodeAnnouncementInfo::Local (ref a, ) => { + let mut a_nonref = Clone::clone(a); + nativeNodeAnnouncementInfo::Local ( + *unsafe { Box::from_raw(a_nonref.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeNodeAnnouncementInfo { + match self { + NodeAnnouncementInfo::Relayed (mut a, ) => { + nativeNodeAnnouncementInfo::Relayed ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + NodeAnnouncementInfo::Local (mut a, ) => { + nativeNodeAnnouncementInfo::Local ( + *unsafe { Box::from_raw(a.take_inner()) }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &NodeAnnouncementInfoImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeNodeAnnouncementInfo) }; + match native { + nativeNodeAnnouncementInfo::Relayed (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NodeAnnouncementInfo::Relayed ( + crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + nativeNodeAnnouncementInfo::Local (ref a, ) => { + let mut a_nonref = Clone::clone(a); + NodeAnnouncementInfo::Local ( + crate::lightning::routing::gossip::NodeAnnouncementDetails { inner: ObjOps::heap_alloc(a_nonref), is_owned: true }, + ) + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeNodeAnnouncementInfo) -> Self { + match native { + nativeNodeAnnouncementInfo::Relayed (mut a, ) => { + NodeAnnouncementInfo::Relayed ( + crate::lightning::ln::msgs::NodeAnnouncement { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + nativeNodeAnnouncementInfo::Local (mut a, ) => { + NodeAnnouncementInfo::Local ( + crate::lightning::routing::gossip::NodeAnnouncementDetails { inner: ObjOps::heap_alloc(a), is_owned: true }, + ) + }, + } + } +} +/// Frees any resources used by the NodeAnnouncementInfo +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_free(this_ptr: NodeAnnouncementInfo) { } /// Creates a copy of the NodeAnnouncementInfo +#[no_mangle] pub extern "C" fn NodeAnnouncementInfo_clone(orig: &NodeAnnouncementInfo) -> NodeAnnouncementInfo { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeAnnouncementInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const NodeAnnouncementInfo)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeAnnouncementInfo_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut NodeAnnouncementInfo) }; +} +#[no_mangle] +/// Utility method to constructs a new Relayed-variant NodeAnnouncementInfo +pub extern "C" fn NodeAnnouncementInfo_relayed(a: crate::lightning::ln::msgs::NodeAnnouncement) -> NodeAnnouncementInfo { + NodeAnnouncementInfo::Relayed(a, ) +} +#[no_mangle] +/// Utility method to constructs a new Local-variant NodeAnnouncementInfo +pub extern "C" fn NodeAnnouncementInfo_local(a: crate::lightning::routing::gossip::NodeAnnouncementDetails) -> NodeAnnouncementInfo { + NodeAnnouncementInfo::Local(a, ) +} /// Get a string which allows debug introspection of a NodeAnnouncementInfo object pub extern "C" fn NodeAnnouncementInfo_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::gossip::NodeAnnouncementInfo }).into()} /// Checks if two NodeAnnouncementInfos contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_eq(a: &NodeAnnouncementInfo, b: &NodeAnnouncementInfo) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } + if &a.to_native() == &b.to_native() { true } else { false } +} +/// Protocol features the node announced support for +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_features(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning_types::features::NodeFeatures { + let mut ret = this_arg.to_native().features(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// When the last known update to the node state was issued. +/// +/// Value may or may not be a timestamp, depending on the policy of the origin node. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_last_update(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> u32 { + let mut ret = this_arg.to_native().last_update(); + ret } + +/// Color assigned to the node +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_rgb(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::ThreeBytes { + let mut ret = this_arg.to_native().rgb(); + crate::c_types::ThreeBytes { data: ret } +} + +/// Moniker assigned to the node. +/// +/// May be invalid or malicious (eg control chars), should not be exposed to the user. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_alias(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning::routing::gossip::NodeAlias { + let mut ret = this_arg.to_native().alias(); + crate::lightning::routing::gossip::NodeAlias { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + /// Internet-level addresses via which one can connect to the node #[must_use] #[no_mangle] pub extern "C" fn NodeAnnouncementInfo_addresses(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_SocketAddressZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.addresses(); - let mut local_ret_clone = Vec::new(); local_ret_clone.extend_from_slice(ret); let mut ret = local_ret_clone; let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; + let mut ret = this_arg.to_native().addresses(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::ln::msgs::SocketAddress::native_into(item) }); }; local_ret.into() } +/// An initial announcement of the node +/// +/// Not stored if contains excess data to prevent DoS. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn NodeAnnouncementInfo_announcement_message(this_arg: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement { + let mut ret = this_arg.to_native().announcement_message(); + let mut local_ret = crate::lightning::ln::msgs::NodeAnnouncement { inner: if ret.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((ret.unwrap())) } }, is_owned: true }; + local_ret +} + #[no_mangle] /// Serialize the NodeAnnouncementInfo object into a byte array which can be read by NodeAnnouncementInfo_read pub extern "C" fn NodeAnnouncementInfo_write(obj: &crate::lightning::routing::gossip::NodeAnnouncementInfo) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } #[allow(unused)] pub(crate) extern "C" fn NodeAnnouncementInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAnnouncementInfo) }) + NodeAnnouncementInfo_write(unsafe { &*(obj as *const NodeAnnouncementInfo) }) } #[no_mangle] /// Read a NodeAnnouncementInfo from a byte array, created by NodeAnnouncementInfo_write pub extern "C" fn NodeAnnouncementInfo_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NodeAnnouncementInfoDecodeErrorZ { let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAnnouncementInfo { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NodeAnnouncementInfo::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } @@ -1822,6 +1945,12 @@ pub struct NodeAlias { pub is_owned: bool, } +impl core::ops::Deref for NodeAlias { + type Target = nativeNodeAlias; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeAlias { } +unsafe impl core::marker::Sync for NodeAlias { } impl Drop for NodeAlias { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeAlias>::is_null(self.inner) { @@ -1852,6 +1981,9 @@ impl NodeAlias { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn NodeAlias_get_a(this_ptr: &NodeAlias) -> *const [u8; 32] { @@ -1912,13 +2044,18 @@ pub extern "C" fn NodeAlias_eq(a: &NodeAlias, b: &NodeAlias) -> bool { if a.get_native_ref() == b.get_native_ref() { true } else { false } } #[no_mangle] +/// Get the string representation of a NodeAlias object +pub extern "C" fn NodeAlias_to_str(o: &crate::lightning::routing::gossip::NodeAlias) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} +#[no_mangle] /// Serialize the NodeAlias object into a byte array which can be read by NodeAlias_read pub extern "C" fn NodeAlias_write(obj: &crate::lightning::routing::gossip::NodeAlias) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn NodeAlias_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeAlias) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeAlias) }) } #[no_mangle] /// Read a NodeAlias from a byte array, created by NodeAlias_write @@ -1947,6 +2084,12 @@ pub struct NodeInfo { pub is_owned: bool, } +impl core::ops::Deref for NodeInfo { + type Target = nativeNodeInfo; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeInfo { } +unsafe impl core::marker::Sync for NodeInfo { } impl Drop for NodeInfo { fn drop(&mut self) { if self.is_owned && !<*mut nativeNodeInfo>::is_null(self.inner) { @@ -1977,6 +2120,9 @@ impl NodeInfo { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// All valid channels a node has announced /// @@ -1997,36 +2143,21 @@ pub extern "C" fn NodeInfo_set_channels(this_ptr: &mut NodeInfo, mut val: crate: /// Optional because we store a Node entry after learning about it from /// a channel announcement, but before receiving a node announcement. /// -/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Returns a copy of the field. #[no_mangle] -pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::gossip::NodeAnnouncementInfo { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info; - let mut local_inner_val = crate::lightning::routing::gossip::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::gossip::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false }; +pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::c_types::derived::COption_NodeAnnouncementInfoZ { + let mut inner_val = this_ptr.get_native_mut_ref().announcement_info.clone(); + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_NodeAnnouncementInfoZ::None } else { crate::c_types::derived::COption_NodeAnnouncementInfoZ::Some( { crate::lightning::routing::gossip::NodeAnnouncementInfo::native_into(inner_val.unwrap()) }) }; local_inner_val } /// More information about a node from node_announcement. /// Optional because we store a Node entry after learning about it from /// a channel announcement, but before receiving a node announcement. -/// -/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::lightning::routing::gossip::NodeAnnouncementInfo) { - let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; +pub extern "C" fn NodeInfo_set_announcement_info(this_ptr: &mut NodeInfo, mut val: crate::c_types::derived::COption_NodeAnnouncementInfoZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { { val_opt.take() }.into_native() }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announcement_info = local_val; } -/// Constructs a new NodeInfo given each field -/// -/// Note that announcement_info_arg (or a relevant inner pointer) may be NULL or all-0s to represent None -#[must_use] -#[no_mangle] -pub extern "C" fn NodeInfo_new(mut channels_arg: crate::c_types::derived::CVec_u64Z, mut announcement_info_arg: crate::lightning::routing::gossip::NodeAnnouncementInfo) -> NodeInfo { - let mut local_channels_arg = Vec::new(); for mut item in channels_arg.into_rust().drain(..) { local_channels_arg.push( { item }); }; - let mut local_announcement_info_arg = if announcement_info_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(announcement_info_arg.take_inner()) } }) }; - NodeInfo { inner: ObjOps::heap_alloc(nativeNodeInfo { - channels: local_channels_arg, - announcement_info: local_announcement_info_arg, - }), is_owned: true } -} impl Clone for NodeInfo { fn clone(&self) -> Self { Self { @@ -2058,6 +2189,19 @@ pub extern "C" fn NodeInfo_eq(a: &NodeInfo, b: &NodeInfo) -> bool { if a.inner.is_null() || b.inner.is_null() { return false; } if a.get_native_ref() == b.get_native_ref() { true } else { false } } +/// Returns whether the node has only announced Tor addresses. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeInfo_is_tor_only(this_arg: &crate::lightning::routing::gossip::NodeInfo) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_tor_only(); + ret +} + +#[no_mangle] +/// Get the string representation of a NodeInfo object +pub extern "C" fn NodeInfo_to_str(o: &crate::lightning::routing::gossip::NodeInfo) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} #[no_mangle] /// Serialize the NodeInfo object into a byte array which can be read by NodeInfo_read pub extern "C" fn NodeInfo_write(obj: &crate::lightning::routing::gossip::NodeInfo) -> crate::c_types::derived::CVec_u8Z { @@ -2065,7 +2209,7 @@ pub extern "C" fn NodeInfo_write(obj: &crate::lightning::routing::gossip::NodeIn } #[allow(unused)] pub(crate) extern "C" fn NodeInfo_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNodeInfo) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNodeInfo) }) } #[no_mangle] /// Read a NodeInfo from a byte array, created by NodeInfo_write @@ -2081,7 +2225,7 @@ pub extern "C" fn NetworkGraph_write(obj: &crate::lightning::routing::gossip::Ne } #[allow(unused)] pub(crate) extern "C" fn NetworkGraph_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeNetworkGraph) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::gossip::nativeNetworkGraph) }) } #[no_mangle] /// Read a NetworkGraph from a byte array, created by NetworkGraph_write @@ -2091,6 +2235,11 @@ pub extern "C" fn NetworkGraph_read(ser: crate::c_types::u8slice, arg: crate::li let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::gossip::NetworkGraph { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } +#[no_mangle] +/// Get the string representation of a NetworkGraph object +pub extern "C" fn NetworkGraph_to_str(o: &crate::lightning::routing::gossip::NetworkGraph) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} /// Creates a new, empty, network graph. #[must_use] #[no_mangle] @@ -2205,7 +2354,7 @@ pub extern "C" fn NetworkGraph_update_channel_from_unsigned_announcement(this_ar /// All other parameters as used in [`msgs::UnsignedChannelAnnouncement`] fields. #[must_use] #[no_mangle] -pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut timestamp: u64, mut features: crate::lightning::ln::features::ChannelFeatures, mut node_id_1: crate::c_types::PublicKey, mut node_id_2: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ { +pub extern "C" fn NetworkGraph_add_channel_from_partial_announcement(this_arg: &crate::lightning::routing::gossip::NetworkGraph, mut short_channel_id: u64, mut timestamp: u64, mut features: crate::lightning_types::features::ChannelFeatures, mut node_id_1: crate::c_types::PublicKey, mut node_id_2: crate::c_types::PublicKey) -> crate::c_types::derived::CResult_NoneLightningErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.add_channel_from_partial_announcement(short_channel_id, timestamp, *unsafe { Box::from_raw(features.take_inner()) }, node_id_1.into_rust(), node_id_2.into_rust()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret diff --git a/lightning-c-bindings/src/lightning/routing/mod.rs b/lightning-c-bindings/src/lightning/routing/mod.rs index ec19271..96c6c3c 100644 --- a/lightning-c-bindings/src/lightning/routing/mod.rs +++ b/lightning-c-bindings/src/lightning/routing/mod.rs @@ -21,3 +21,15 @@ pub mod utxo; pub mod gossip; pub mod router; pub mod scoring; +mod log_approx { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/routing/router.rs b/lightning-c-bindings/src/lightning/routing/router.rs index b3b8f44..84e3a73 100644 --- a/lightning-c-bindings/src/lightning/routing/router.rs +++ b/lightning-c-bindings/src/lightning/routing/router.rs @@ -19,9 +19,14 @@ use alloc::{vec::Vec, boxed::Box}; use lightning::routing::router::DefaultRouter as nativeDefaultRouterImport; -pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, crate::lightning::routing::scoring::LockableScore>; +pub(crate) type nativeDefaultRouter = nativeDefaultRouterImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, crate::lightning::sign::EntropySource, crate::lightning::routing::scoring::LockableScore, >; /// A [`Router`] implemented using [`find_route`]. +/// +/// # Privacy +/// +/// Implements [`MessageRouter`] by delegating to [`DefaultMessageRouter`]. See those docs for +/// privacy implications. #[must_use] #[repr(C)] pub struct DefaultRouter { @@ -37,6 +42,12 @@ pub struct DefaultRouter { pub is_owned: bool, } +impl core::ops::Deref for DefaultRouter { + type Target = nativeDefaultRouter; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DefaultRouter { } +unsafe impl core::marker::Sync for DefaultRouter { } impl Drop for DefaultRouter { fn drop(&mut self) { if self.is_owned && !<*mut nativeDefaultRouter>::is_null(self.inner) { @@ -67,6 +78,9 @@ impl DefaultRouter { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Creates a new router. #[must_use] @@ -101,6 +115,7 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li free: None, find_path: DefaultRouter_MessageRouter_find_path, create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultRouter_MessageRouter_create_compact_blinded_paths, }, } } @@ -108,22 +123,22 @@ pub extern "C" fn DefaultRouter_as_Router(this_arg: &DefaultRouter) -> crate::li #[must_use] extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }); + let mut ret = ::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] extern "C" fn DefaultRouter_Router_find_route_with_id(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, mut _payment_hash: crate::c_types::ThirtyTwoBytes, mut _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = >::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }, ::lightning::ln::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); + let mut ret = ::find_route_with_id(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), route_params.get_native_ref(), local_first_hops, *unsafe { Box::from_raw(inflight_htlcs.take_inner()) }, ::lightning::ln::types::PaymentHash(_payment_hash.data), ::lightning::ln::channelmanager::PaymentId(_payment_id.data)); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } #[must_use] -extern "C" fn DefaultRouter_Router_create_blinded_payment_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, mut tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ { +extern "C" fn DefaultRouter_Router_create_blinded_payment_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, mut tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64) -> crate::c_types::derived::CResult_CVec_BlindedPaymentPathZNoneZ { let mut local_first_hops = Vec::new(); for mut item in first_hops.into_rust().drain(..) { local_first_hops.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut ret = >::create_blinded_payment_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_first_hops, *unsafe { Box::from_raw(tlvs.take_inner()) }, amount_msats, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_ret_0_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + let mut ret = ::create_blinded_payment_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_first_hops, *unsafe { Box::from_raw(tlvs.take_inner()) }, amount_msats, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -146,21 +161,29 @@ pub extern "C" fn DefaultRouter_as_MessageRouter(this_arg: &DefaultRouter) -> cr free: None, find_path: DefaultRouter_MessageRouter_find_path, create_blinded_paths: DefaultRouter_MessageRouter_create_blinded_paths, + create_compact_blinded_paths: DefaultRouter_MessageRouter_create_compact_blinded_paths, } } #[must_use] extern "C" fn DefaultRouter_MessageRouter_find_path(this_arg: *const c_void, mut sender: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ, mut destination: crate::lightning::onion_message::messenger::Destination) -> crate::c_types::derived::CResult_OnionMessagePathNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = >::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, sender.into_rust(), local_peers, destination.into_native()); + let mut ret = ::find_path(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, sender.into_rust(), local_peers, destination.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::onion_message::messenger::OnionMessagePath { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn DefaultRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedPathZNoneZ { +extern "C" fn DefaultRouter_MessageRouter_create_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_PublicKeyZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { item.into_rust() }); }; - let mut ret = >::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), local_peers, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + let mut ret = ::create_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), context.into_native(), local_peers, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} +#[must_use] +extern "C" fn DefaultRouter_MessageRouter_create_compact_blinded_paths(this_arg: *const c_void, mut recipient: crate::c_types::PublicKey, mut context: crate::lightning::blinded_path::message::MessageContext, mut peers: crate::c_types::derived::CVec_MessageForwardNodeZ) -> crate::c_types::derived::CResult_CVec_BlindedMessagePathZNoneZ { + let mut local_peers = Vec::new(); for mut item in peers.into_rust().drain(..) { local_peers.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + let mut ret = ::create_compact_blinded_paths(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, recipient.into_rust(), context.into_native(), local_peers, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { crate::lightning::blinded_path::message::BlindedMessagePath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -187,10 +210,10 @@ pub struct Router { /// /// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None pub find_route_with_id: extern "C" fn (this_arg: *const c_void, payer: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, inflight_htlcs: crate::lightning::routing::router::InFlightHtlcs, _payment_hash: crate::c_types::ThirtyTwoBytes, _payment_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_RouteLightningErrorZ, - /// Creates [`BlindedPath`]s for payment to the `recipient` node. The channels in `first_hops` + /// Creates [`BlindedPaymentPath`]s for payment to the `recipient` node. The channels in `first_hops` /// are assumed to be with the `recipient`'s peers. The payment secret and any constraints are /// given in `tlvs`. - pub create_blinded_payment_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, amount_msats: u64) -> crate::c_types::derived::CResult_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ, + pub create_blinded_payment_paths: extern "C" fn (this_arg: *const c_void, recipient: crate::c_types::PublicKey, first_hops: crate::c_types::derived::CVec_ChannelDetailsZ, tlvs: crate::lightning::blinded_path::payment::ReceiveTlvs, amount_msats: u64) -> crate::c_types::derived::CResult_CVec_BlindedPaymentPathZNoneZ, /// Implementation of MessageRouter for this object. pub MessageRouter: crate::lightning::onion_message::messenger::MessageRouter, /// Frees any resources associated with this object given its this_arg pointer. @@ -217,9 +240,35 @@ impl lightning::onion_message::messenger::MessageRouter for Router { let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.MessageRouter.create_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.MessageRouter.create_compact_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} +impl lightning::onion_message::messenger::MessageRouter for RouterRef { + fn find_path(&self, mut sender: bitcoin::secp256k1::PublicKey, mut peers: Vec, mut destination: lightning::onion_message::messenger::Destination) -> Result { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; + let mut ret = (self.0.MessageRouter.find_path)(self.0.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&sender), local_peers.into(), crate::lightning::onion_message::messenger::Destination::native_into(destination)); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::c_types::PublicKey::from_rust(&item) }); }; - let mut ret = (self.MessageRouter.create_blinded_paths)(self.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_peers.into()); + let mut ret = (self.0.MessageRouter.create_blinded_paths)(self.0.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn create_compact_blinded_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut context: lightning::blinded_path::message::MessageContext, mut peers: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_peers = Vec::new(); for mut item in peers.drain(..) { local_peers.push( { crate::lightning::blinded_path::message::MessageForwardNode { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.MessageRouter.create_compact_blinded_paths)(self.0.MessageRouter.this_arg, crate::c_types::PublicKey::from_rust(&recipient), crate::lightning::blinded_path::message::MessageContext::native_into(context), local_peers.into()); let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } @@ -227,22 +276,44 @@ impl lightning::onion_message::messenger::MessageRouter for Router { use lightning::routing::router::Router as rustRouter; impl rustRouter for Router { - fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result { - let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result { + let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; let mut ret = (self.find_route)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channelmanager::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning::ln::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { - let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channelmanager::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning_types::payment::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { + let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; let mut ret = (self.find_route_with_id)(self.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; local_ret } - fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { - let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channelmanager::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut ret = (self.create_blinded_payment_paths)(self.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_first_hops.into(), crate::lightning::blinded_path::payment::ReceiveTlvs { inner: ObjOps::heap_alloc(tlvs), is_owned: true }, amount_msats); - let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item.to_rust(); let mut local_ret_0_0 = (*unsafe { Box::from_raw(orig_ret_0_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_ret_0_0_1.take_inner()) }); local_ret_0_0 }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct RouterRef(Router); +impl rustRouter for RouterRef { + fn find_route(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs) -> Result { + let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + let mut ret = (self.0.find_route)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn find_route_with_id(&self, mut payer: &bitcoin::secp256k1::PublicKey, mut route_params: &lightning::routing::router::RouteParameters, mut first_hops: Option<&[&lightning::ln::channel_state::ChannelDetails]>, mut inflight_htlcs: lightning::routing::router::InFlightHtlcs, mut _payment_hash: lightning_types::payment::PaymentHash, mut _payment_id: lightning::ln::channelmanager::PaymentId) -> Result { + let mut local_first_hops_base = if first_hops.is_none() { SmartPtr::null() } else { SmartPtr::from_obj( { let mut local_first_hops_0 = Vec::new(); for item in (first_hops.unwrap()).iter() { local_first_hops_0.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: unsafe { ObjOps::nonnull_ptr_to_inner(((*item) as *const lightning::ln::channel_state::ChannelDetails<>) as *mut _) }, is_owned: false } }); }; local_first_hops_0.into() }) }; let mut local_first_hops = *local_first_hops_base; + let mut ret = (self.0.find_route_with_id)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&payer), &crate::lightning::routing::router::RouteParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((route_params as *const lightning::routing::router::RouteParameters<>) as *mut _) }, is_owned: false }, local_first_hops, crate::lightning::routing::router::InFlightHtlcs { inner: ObjOps::heap_alloc(inflight_htlcs), is_owned: true }, crate::c_types::ThirtyTwoBytes { data: _payment_hash.0 }, crate::c_types::ThirtyTwoBytes { data: _payment_id.0 }); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })}; + local_ret + } + fn create_blinded_payment_paths(&self, mut recipient: bitcoin::secp256k1::PublicKey, mut first_hops: Vec, mut tlvs: lightning::blinded_path::payment::ReceiveTlvs, mut amount_msats: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result, ()> { + let mut local_first_hops = Vec::new(); for mut item in first_hops.drain(..) { local_first_hops.push( { crate::lightning::ln::channel_state::ChannelDetails { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut ret = (self.0.create_blinded_payment_paths)(self.0.this_arg, crate::c_types::PublicKey::from_rust(&recipient), local_first_hops.into(), crate::lightning::blinded_path::payment::ReceiveTlvs { inner: ObjOps::heap_alloc(tlvs), is_owned: true }, amount_msats); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } } @@ -250,14 +321,14 @@ impl rustRouter for Router { // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Router { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = RouterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const RouterRef) } } } impl core::ops::DerefMut for Router { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut RouterRef { + unsafe { &mut *(self as *mut _ as *mut RouterRef) } } } /// Calls the free function if one is set @@ -272,7 +343,7 @@ impl Drop for Router { } use lightning::routing::router::ScorerAccountingForInFlightHtlcs as nativeScorerAccountingForInFlightHtlcsImport; -pub(crate) type nativeScorerAccountingForInFlightHtlcs = nativeScorerAccountingForInFlightHtlcsImport<'static, crate::lightning::routing::scoring::ScoreLookUp>; +pub(crate) type nativeScorerAccountingForInFlightHtlcs = nativeScorerAccountingForInFlightHtlcsImport<'static, crate::lightning::routing::scoring::ScoreLookUp, >; /// [`ScoreLookUp`] implementation that factors in in-flight HTLC liquidity. /// @@ -295,6 +366,12 @@ pub struct ScorerAccountingForInFlightHtlcs { pub is_owned: bool, } +impl core::ops::Deref for ScorerAccountingForInFlightHtlcs { + type Target = nativeScorerAccountingForInFlightHtlcs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ScorerAccountingForInFlightHtlcs { } +unsafe impl core::marker::Sync for ScorerAccountingForInFlightHtlcs { } impl Drop for ScorerAccountingForInFlightHtlcs { fn drop(&mut self) { if self.is_owned && !<*mut nativeScorerAccountingForInFlightHtlcs>::is_null(self.inner) { @@ -325,6 +402,9 @@ impl ScorerAccountingForInFlightHtlcs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Initialize a new `ScorerAccountingForInFlightHtlcs`. #[must_use] @@ -357,7 +437,7 @@ pub extern "C" fn ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(this_arg: &Sco #[must_use] extern "C" fn ScorerAccountingForInFlightHtlcs_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); + let mut ret = ::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeScorerAccountingForInFlightHtlcs) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } @@ -382,6 +462,12 @@ pub struct InFlightHtlcs { pub is_owned: bool, } +impl core::ops::Deref for InFlightHtlcs { + type Target = nativeInFlightHtlcs; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InFlightHtlcs { } +unsafe impl core::marker::Sync for InFlightHtlcs { } impl Drop for InFlightHtlcs { fn drop(&mut self) { if self.is_owned && !<*mut nativeInFlightHtlcs>::is_null(self.inner) { @@ -412,6 +498,9 @@ impl InFlightHtlcs { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for InFlightHtlcs { fn clone(&self) -> Self { @@ -470,7 +559,7 @@ pub extern "C" fn InFlightHtlcs_write(obj: &crate::lightning::routing::router::I } #[allow(unused)] pub(crate) extern "C" fn InFlightHtlcs_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInFlightHtlcs) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeInFlightHtlcs) }) } #[no_mangle] /// Read a InFlightHtlcs from a byte array, created by InFlightHtlcs_write @@ -500,6 +589,12 @@ pub struct RouteHop { pub is_owned: bool, } +impl core::ops::Deref for RouteHop { + type Target = nativeRouteHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHop { } +unsafe impl core::marker::Sync for RouteHop { } impl Drop for RouteHop { fn drop(&mut self) { if self.is_owned && !<*mut nativeRouteHop>::is_null(self.inner) { @@ -530,6 +625,9 @@ impl RouteHop { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The node_id of the node at this hop. #[no_mangle] @@ -545,14 +643,14 @@ pub extern "C" fn RouteHop_set_pubkey(this_ptr: &mut RouteHop, mut val: crate::c /// The node_announcement features of the node at this hop. For the last hop, these may be /// amended to match the features present in the invoice this node generated. #[no_mangle] -pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::NodeFeatures { +pub extern "C" fn RouteHop_get_node_features(this_ptr: &RouteHop) -> crate::lightning_types::features::NodeFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().node_features; - crate::lightning::ln::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::NodeFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::NodeFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::NodeFeatures<>) as *mut _) }, is_owned: false } } /// The node_announcement features of the node at this hop. For the last hop, these may be /// amended to match the features present in the invoice this node generated. #[no_mangle] -pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::NodeFeatures) { +pub extern "C" fn RouteHop_set_node_features(this_ptr: &mut RouteHop, mut val: crate::lightning_types::features::NodeFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.node_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The channel that should be used from the previous hop to reach this node. @@ -569,22 +667,21 @@ pub extern "C" fn RouteHop_set_short_channel_id(this_ptr: &mut RouteHop, mut val /// The channel_announcement features of the channel that should be used from the previous hop /// to reach this node. #[no_mangle] -pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning::ln::features::ChannelFeatures { +pub extern "C" fn RouteHop_get_channel_features(this_ptr: &RouteHop) -> crate::lightning_types::features::ChannelFeatures { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_features; - crate::lightning::ln::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::ln::features::ChannelFeatures<>) as *mut _) }, is_owned: false } + crate::lightning_types::features::ChannelFeatures { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::features::ChannelFeatures<>) as *mut _) }, is_owned: false } } /// The channel_announcement features of the channel that should be used from the previous hop /// to reach this node. #[no_mangle] -pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning::ln::features::ChannelFeatures) { +pub extern "C" fn RouteHop_set_channel_features(this_ptr: &mut RouteHop, mut val: crate::lightning_types::features::ChannelFeatures) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_features = *unsafe { Box::from_raw(val.take_inner()) }; } /// The fee taken on this hop (for paying for the use of the *next* channel in the path). /// If this is the last hop in [`Path::hops`]: -/// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path +/// * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire +/// blinded path /// * otherwise, this is the full value of this [`Path`]'s part of the payment -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath #[no_mangle] pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_msat; @@ -592,20 +689,18 @@ pub extern "C" fn RouteHop_get_fee_msat(this_ptr: &RouteHop) -> u64 { } /// The fee taken on this hop (for paying for the use of the *next* channel in the path). /// If this is the last hop in [`Path::hops`]: -/// * if we're sending to a [`BlindedPath`], this is the fee paid for use of the entire blinded path +/// * if we're sending to a [`BlindedPaymentPath`], this is the fee paid for use of the entire +/// blinded path /// * otherwise, this is the full value of this [`Path`]'s part of the payment -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath #[no_mangle] pub extern "C" fn RouteHop_set_fee_msat(this_ptr: &mut RouteHop, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fee_msat = val; } /// The CLTV delta added for this hop. /// If this is the last hop in [`Path::hops`]: -/// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path +/// * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded +/// path /// * otherwise, this is the CLTV delta expected at the destination -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath #[no_mangle] pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; @@ -613,10 +708,9 @@ pub extern "C" fn RouteHop_get_cltv_expiry_delta(this_ptr: &RouteHop) -> u32 { } /// The CLTV delta added for this hop. /// If this is the last hop in [`Path::hops`]: -/// * if we're sending to a [`BlindedPath`], this is the CLTV delta for the entire blinded path +/// * if we're sending to a [`BlindedPaymentPath`], this is the CLTV delta for the entire blinded +/// path /// * otherwise, this is the CLTV delta expected at the destination -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath #[no_mangle] pub extern "C" fn RouteHop_set_cltv_expiry_delta(this_ptr: &mut RouteHop, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; @@ -649,7 +743,7 @@ pub extern "C" fn RouteHop_set_maybe_announced_channel(this_ptr: &mut RouteHop, /// Constructs a new RouteHop given each field #[must_use] #[no_mangle] -pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning::ln::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning::ln::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32, mut maybe_announced_channel_arg: bool) -> RouteHop { +pub extern "C" fn RouteHop_new(mut pubkey_arg: crate::c_types::PublicKey, mut node_features_arg: crate::lightning_types::features::NodeFeatures, mut short_channel_id_arg: u64, mut channel_features_arg: crate::lightning_types::features::ChannelFeatures, mut fee_msat_arg: u64, mut cltv_expiry_delta_arg: u32, mut maybe_announced_channel_arg: bool) -> RouteHop { RouteHop { inner: ObjOps::heap_alloc(nativeRouteHop { pubkey: pubkey_arg.into_rust(), node_features: *unsafe { Box::from_raw(node_features_arg.take_inner()) }, @@ -708,7 +802,7 @@ pub extern "C" fn RouteHop_write(obj: &crate::lightning::routing::router::RouteH } #[allow(unused)] pub(crate) extern "C" fn RouteHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRouteHop) }) } #[no_mangle] /// Read a RouteHop from a byte array, created by RouteHop_write @@ -740,6 +834,12 @@ pub struct BlindedTail { pub is_owned: bool, } +impl core::ops::Deref for BlindedTail { + type Target = nativeBlindedTail; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedTail { } +unsafe impl core::marker::Sync for BlindedTail { } impl Drop for BlindedTail { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedTail>::is_null(self.inner) { @@ -770,35 +870,30 @@ impl BlindedTail { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } -/// The hops of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The hops of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_get_hops(this_ptr: &BlindedTail) -> crate::c_types::derived::CVec_BlindedHopZ { let mut inner_val = &mut this_ptr.get_native_mut_ref().hops; let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::blinded_path::BlindedHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::blinded_path::BlindedHop<>) as *mut _) }, is_owned: false } }); }; local_inner_val.into() } -/// The hops of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The hops of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_set_hops(this_ptr: &mut BlindedTail, mut val: crate::c_types::derived::CVec_BlindedHopZ) { let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.hops = local_val; } -/// The blinding point of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_get_blinding_point(this_ptr: &BlindedTail) -> crate::c_types::PublicKey { let mut inner_val = &mut this_ptr.get_native_mut_ref().blinding_point; crate::c_types::PublicKey::from_rust(&inner_val) } -/// The blinding point of the [`BlindedPath`] provided by the recipient. -/// -/// [`BlindedPath`]: crate::blinded_path::BlindedPath +/// The blinding point of the [`BlindedPaymentPath`] provided by the recipient. #[no_mangle] pub extern "C" fn BlindedTail_set_blinding_point(this_ptr: &mut BlindedTail, mut val: crate::c_types::PublicKey) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.blinding_point = val.into_rust(); @@ -887,7 +982,7 @@ pub extern "C" fn BlindedTail_write(obj: &crate::lightning::routing::router::Bli } #[allow(unused)] pub(crate) extern "C" fn BlindedTail_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBlindedTail) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeBlindedTail) }) } #[no_mangle] /// Read a BlindedTail from a byte array, created by BlindedTail_write @@ -917,6 +1012,12 @@ pub struct Path { pub is_owned: bool, } +impl core::ops::Deref for Path { + type Target = nativePath; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Path { } +unsafe impl core::marker::Sync for Path { } impl Drop for Path { fn drop(&mut self) { if self.is_owned && !<*mut nativePath>::is_null(self.inner) { @@ -947,6 +1048,9 @@ impl Path { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The list of unblinded hops in this [`Path`]. Must be at least length one. #[no_mangle] @@ -1078,6 +1182,12 @@ pub struct Route { pub is_owned: bool, } +impl core::ops::Deref for Route { + type Target = nativeRoute; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Route { } +unsafe impl core::marker::Sync for Route { } impl Drop for Route { fn drop(&mut self) { if self.is_owned && !<*mut nativeRoute>::is_null(self.inner) { @@ -1108,6 +1218,9 @@ impl Route { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The list of [`Path`]s taken for a single (potentially-)multi-part payment. If no /// [`BlindedTail`]s are present, then the pubkey of the last [`RouteHop`] in each path must be @@ -1232,6 +1345,11 @@ pub extern "C" fn Route_get_total_amount(this_arg: &crate::lightning::routing::r ret } +#[no_mangle] +/// Get the string representation of a Route object +pub extern "C" fn Route_to_str(o: &crate::lightning::routing::router::Route) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} #[no_mangle] /// Serialize the Route object into a byte array which can be read by Route_read pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> crate::c_types::derived::CVec_u8Z { @@ -1239,7 +1357,7 @@ pub extern "C" fn Route_write(obj: &crate::lightning::routing::router::Route) -> } #[allow(unused)] pub(crate) extern "C" fn Route_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRoute) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRoute) }) } #[no_mangle] /// Read a Route from a byte array, created by Route_write @@ -1270,6 +1388,12 @@ pub struct RouteParameters { pub is_owned: bool, } +impl core::ops::Deref for RouteParameters { + type Target = nativeRouteParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteParameters { } +unsafe impl core::marker::Sync for RouteParameters { } impl Drop for RouteParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeRouteParameters>::is_null(self.inner) { @@ -1300,6 +1424,9 @@ impl RouteParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters of the failed payment path. #[no_mangle] @@ -1408,6 +1535,16 @@ pub extern "C" fn RouteParameters_from_payment_params_and_value(mut payment_para crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } +/// Sets the maximum number of hops that can be included in a payment path, based on the provided +/// [`RecipientOnionFields`] and blinded paths. +#[must_use] +#[no_mangle] +pub extern "C" fn RouteParameters_set_max_path_length(this_arg: &mut crate::lightning::routing::router::RouteParameters, recipient_onion: &crate::lightning::ln::outbound_payment::RecipientOnionFields, mut is_keysend: bool, mut best_block_height: u32) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning::routing::router::nativeRouteParameters)) }.set_max_path_length(recipient_onion.get_native_ref(), is_keysend, best_block_height); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + #[no_mangle] /// Serialize the RouteParameters object into a byte array which can be read by RouteParameters_read pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router::RouteParameters) -> crate::c_types::derived::CVec_u8Z { @@ -1415,7 +1552,7 @@ pub extern "C" fn RouteParameters_write(obj: &crate::lightning::routing::router: } #[allow(unused)] pub(crate) extern "C" fn RouteParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativeRouteParameters) }) } #[no_mangle] /// Read a RouteParameters from a byte array, created by RouteParameters_write @@ -1432,6 +1569,11 @@ pub static DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA: u32 = lightning::routing::router #[no_mangle] pub static DEFAULT_MAX_PATH_COUNT: u8 = lightning::routing::router::DEFAULT_MAX_PATH_COUNT; +/// Estimated maximum number of hops that can be included in a payment path. May be inaccurate if +/// payment metadata, custom TLVs, or blinded paths are included in the payment. + +#[no_mangle] +pub static MAX_PATH_LENGTH_ESTIMATE: u8 = lightning::routing::router::MAX_PATH_LENGTH_ESTIMATE; use lightning::routing::router::PaymentParameters as nativePaymentParametersImport; pub(crate) type nativePaymentParameters = nativePaymentParametersImport; @@ -1452,6 +1594,12 @@ pub struct PaymentParameters { pub is_owned: bool, } +impl core::ops::Deref for PaymentParameters { + type Target = nativePaymentParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PaymentParameters { } +unsafe impl core::marker::Sync for PaymentParameters { } impl Drop for PaymentParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativePaymentParameters>::is_null(self.inner) { @@ -1482,6 +1630,9 @@ impl PaymentParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Information about the payee, such as their features and route hints for their channels. #[no_mangle] @@ -1533,6 +1684,19 @@ pub extern "C" fn PaymentParameters_get_max_path_count(this_ptr: &PaymentParamet pub extern "C" fn PaymentParameters_set_max_path_count(this_ptr: &mut PaymentParameters, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_count = val; } +/// The maximum number of [`Path::hops`] in any returned path. +/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. +#[no_mangle] +pub extern "C" fn PaymentParameters_get_max_path_length(this_ptr: &PaymentParameters) -> u8 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().max_path_length; + *inner_val +} +/// The maximum number of [`Path::hops`] in any returned path. +/// Defaults to [`MAX_PATH_LENGTH_ESTIMATE`]. +#[no_mangle] +pub extern "C" fn PaymentParameters_set_max_path_length(this_ptr: &mut PaymentParameters, mut val: u8) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_path_length = val; +} /// Selects the maximum share of a channel's total capacity which will be sent over a channel, /// as a power of 1/2. A higher value prefers to send the payment using more MPP parts whereas /// a lower value prefers to send larger MPP parts, potentially saturating channels and @@ -1609,7 +1773,7 @@ pub extern "C" fn PaymentParameters_set_previously_failed_blinded_path_idxs(this /// Constructs a new PaymentParameters given each field #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut previously_failed_blinded_path_idxs_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters { +pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing::router::Payee, mut expiry_time_arg: crate::c_types::derived::COption_u64Z, mut max_total_cltv_expiry_delta_arg: u32, mut max_path_count_arg: u8, mut max_path_length_arg: u8, mut max_channel_saturation_power_of_half_arg: u8, mut previously_failed_channels_arg: crate::c_types::derived::CVec_u64Z, mut previously_failed_blinded_path_idxs_arg: crate::c_types::derived::CVec_u64Z) -> PaymentParameters { let mut local_expiry_time_arg = if expiry_time_arg.is_some() { Some( { expiry_time_arg.take() }) } else { None }; let mut local_previously_failed_channels_arg = Vec::new(); for mut item in previously_failed_channels_arg.into_rust().drain(..) { local_previously_failed_channels_arg.push( { item }); }; let mut local_previously_failed_blinded_path_idxs_arg = Vec::new(); for mut item in previously_failed_blinded_path_idxs_arg.into_rust().drain(..) { local_previously_failed_blinded_path_idxs_arg.push( { item }); }; @@ -1618,6 +1782,7 @@ pub extern "C" fn PaymentParameters_new(mut payee_arg: crate::lightning::routing expiry_time: local_expiry_time_arg, max_total_cltv_expiry_delta: max_total_cltv_expiry_delta_arg, max_path_count: max_path_count_arg, + max_path_length: max_path_length_arg, max_channel_saturation_power_of_half: max_channel_saturation_power_of_half_arg, previously_failed_channels: local_previously_failed_channels_arg, previously_failed_blinded_path_idxs: local_previously_failed_blinded_path_idxs_arg, @@ -1671,7 +1836,7 @@ pub extern "C" fn PaymentParameters_write(obj: &crate::lightning::routing::route } #[allow(unused)] pub(crate) extern "C" fn PaymentParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativePaymentParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::router::nativePaymentParameters) }) } #[no_mangle] /// Read a PaymentParameters from a byte array, created by PaymentParameters_write @@ -1723,8 +1888,8 @@ pub extern "C" fn PaymentParameters_from_bolt12_invoice(invoice: &crate::lightni /// Creates parameters for paying to a blinded payee from the provided blinded route hints. #[must_use] #[no_mangle] -pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ) -> crate::lightning::routing::router::PaymentParameters { - let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { let (mut orig_blinded_route_hints_0_0, mut orig_blinded_route_hints_0_1) = item.to_rust(); let mut local_blinded_route_hints_0 = (*unsafe { Box::from_raw(orig_blinded_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_blinded_route_hints_0_1.take_inner()) }); local_blinded_route_hints_0 }); }; +pub extern "C" fn PaymentParameters_blinded(mut blinded_route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ) -> crate::lightning::routing::router::PaymentParameters { + let mut local_blinded_route_hints = Vec::new(); for mut item in blinded_route_hints.into_rust().drain(..) { local_blinded_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut ret = lightning::routing::router::PaymentParameters::blinded(local_blinded_route_hints); crate::lightning::routing::router::PaymentParameters { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -1740,14 +1905,14 @@ pub enum Payee { Blinded { /// Aggregated routing info and blinded paths, for routing to the payee without knowing their /// node id. - route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, + route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ, /// Features supported by the payee. /// /// May be set from the payee's invoice. May be `None` if the invoice does not contain any /// features. /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - features: crate::lightning::ln::features::Bolt12InvoiceFeatures, + features: crate::lightning_types::features::Bolt12InvoiceFeatures, }, /// The recipient included these route hints in their BOLT11 invoice. Clear { @@ -1763,7 +1928,7 @@ pub enum Payee { /// [`for_keysend`]: PaymentParameters::for_keysend /// /// Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None - features: crate::lightning::ln::features::Bolt11InvoiceFeatures, + features: crate::lightning_types::features::Bolt11InvoiceFeatures, /// The minimum CLTV delta at the end of the route. This value must not be zero. final_cltv_expiry_delta: u32, }, @@ -1777,7 +1942,7 @@ impl Payee { match self { Payee::Blinded {ref route_hints, ref features, } => { let mut route_hints_nonref = Clone::clone(route_hints); - let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item.to_rust(); let mut local_route_hints_nonref_0 = (*unsafe { Box::from_raw(orig_route_hints_nonref_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_nonref_0_1.take_inner()) }); local_route_hints_nonref_0 }); }; + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.into_rust().drain(..) { local_route_hints_nonref.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut features_nonref = Clone::clone(features); let mut local_features_nonref = if features_nonref.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features_nonref.take_inner()) } }) }; nativePayee::Blinded { @@ -1805,7 +1970,7 @@ impl Payee { pub(crate) fn into_native(self) -> nativePayee { match self { Payee::Blinded {mut route_hints, mut features, } => { - let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item.to_rust(); let mut local_route_hints_0 = (*unsafe { Box::from_raw(orig_route_hints_0_0.take_inner()) }, *unsafe { Box::from_raw(orig_route_hints_0_1.take_inner()) }); local_route_hints_0 }); }; + let mut local_route_hints = Vec::new(); for mut item in route_hints.into_rust().drain(..) { local_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; let mut local_features = if features.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(features.take_inner()) } }) }; nativePayee::Blinded { route_hints: local_route_hints, @@ -1830,9 +1995,9 @@ impl Payee { match native { nativePayee::Blinded {ref route_hints, ref features, } => { let mut route_hints_nonref = Clone::clone(route_hints); - let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { let (mut orig_route_hints_nonref_0_0, mut orig_route_hints_nonref_0_1) = item; let mut local_route_hints_nonref_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_nonref_0_1), is_owned: true }).into(); local_route_hints_nonref_0 }); }; + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut features_nonref = Clone::clone(features); - let mut local_features_nonref = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + let mut local_features_nonref = crate::lightning_types::features::Bolt12InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; Payee::Blinded { route_hints: local_route_hints_nonref.into(), features: local_features_nonref, @@ -1841,9 +2006,9 @@ impl Payee { nativePayee::Clear {ref node_id, ref route_hints, ref features, ref final_cltv_expiry_delta, } => { let mut node_id_nonref = Clone::clone(node_id); let mut route_hints_nonref = Clone::clone(route_hints); - let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_route_hints_nonref = Vec::new(); for mut item in route_hints_nonref.drain(..) { local_route_hints_nonref.push( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; let mut features_nonref = Clone::clone(features); - let mut local_features_nonref = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; + let mut local_features_nonref = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: if features_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features_nonref.unwrap())) } }, is_owned: true }; let mut final_cltv_expiry_delta_nonref = Clone::clone(final_cltv_expiry_delta); Payee::Clear { node_id: crate::c_types::PublicKey::from_rust(&node_id_nonref), @@ -1858,16 +2023,16 @@ impl Payee { pub(crate) fn native_into(native: nativePayee) -> Self { match native { nativePayee::Blinded {mut route_hints, mut features, } => { - let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { let (mut orig_route_hints_0_0, mut orig_route_hints_0_1) = item; let mut local_route_hints_0 = (crate::lightning::offers::invoice::BlindedPayInfo { inner: ObjOps::heap_alloc(orig_route_hints_0_0), is_owned: true }, crate::lightning::blinded_path::BlindedPath { inner: ObjOps::heap_alloc(orig_route_hints_0_1), is_owned: true }).into(); local_route_hints_0 }); }; - let mut local_features = crate::lightning::ln::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::blinded_path::payment::BlindedPaymentPath { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning_types::features::Bolt12InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; Payee::Blinded { route_hints: local_route_hints.into(), features: local_features, } }, nativePayee::Clear {mut node_id, mut route_hints, mut features, mut final_cltv_expiry_delta, } => { - let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; - let mut local_features = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; + let mut local_route_hints = Vec::new(); for mut item in route_hints.drain(..) { local_route_hints.push( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_features = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: if features.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((features.unwrap())) } }, is_owned: true }; Payee::Clear { node_id: crate::c_types::PublicKey::from_rust(&node_id), route_hints: local_route_hints.into(), @@ -1898,7 +2063,7 @@ pub(crate) extern "C" fn Payee_free_void(this_ptr: *mut c_void) { } #[no_mangle] /// Utility method to constructs a new Blinded-variant Payee -pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tuple_BlindedPayInfoBlindedPathZZ, features: crate::lightning::ln::features::Bolt12InvoiceFeatures) -> Payee { +pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_BlindedPaymentPathZ, features: crate::lightning_types::features::Bolt12InvoiceFeatures) -> Payee { Payee::Blinded { route_hints, features, @@ -1906,7 +2071,7 @@ pub extern "C" fn Payee_blinded(route_hints: crate::c_types::derived::CVec_C2Tup } #[no_mangle] /// Utility method to constructs a new Clear-variant Payee -pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning::ln::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee { +pub extern "C" fn Payee_clear(node_id: crate::c_types::PublicKey, route_hints: crate::c_types::derived::CVec_RouteHintZ, features: crate::lightning_types::features::Bolt11InvoiceFeatures, final_cltv_expiry_delta: u32) -> Payee { Payee::Clear { node_id, route_hints, @@ -1932,334 +2097,41 @@ pub extern "C" fn Payee_hash(o: &Payee) -> u64 { pub extern "C" fn Payee_eq(a: &Payee, b: &Payee) -> bool { if &a.to_native() == &b.to_native() { true } else { false } } - -use lightning::routing::router::RouteHint as nativeRouteHintImport; -pub(crate) type nativeRouteHint = nativeRouteHintImport; - -/// A list of hops along a payment path terminating with a channel to the recipient. -#[must_use] -#[repr(C)] -pub struct RouteHint { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeRouteHint, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RouteHint { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHint_free(this_obj: RouteHint) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) }; -} -#[allow(unused)] -impl RouteHint { - pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning::routing::router::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning::routing::router::RouteHintHop<>) as *mut _) }, is_owned: false } }); }; - local_inner_val.into() -} -#[no_mangle] -pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) { - let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = local_val; -} -/// Constructs a new RouteHint given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint { - let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - RouteHint { inner: ObjOps::heap_alloc(lightning::routing::router::RouteHint ( - local_a_arg, - )), is_owned: true } -} -impl Clone for RouteHint { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RouteHint -pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { - orig.clone() -} -/// Get a string which allows debug introspection of a RouteHint object -pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHint }).into()} -/// Generates a non-cryptographic 64-bit hash of the RouteHint. -#[no_mangle] -pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Checks if two RouteHints contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} #[no_mangle] /// Serialize the RouteHint object into a byte array which can be read by RouteHint_read -pub extern "C" fn RouteHint_write(obj: &crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RouteHint_write(obj: &crate::lightning_types::routing::RouteHint) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RouteHint_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHint) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRouteHint) }) } #[no_mangle] /// Read a RouteHint from a byte array, created by RouteHint_write pub extern "C" fn RouteHint_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } - -use lightning::routing::router::RouteHintHop as nativeRouteHintHopImport; -pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport; - -/// A channel descriptor for a hop along a payment path. -/// -/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are -/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as -/// fields not supported in BOLT 11 will be stripped. -#[must_use] -#[repr(C)] -pub struct RouteHintHop { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeRouteHintHop, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for RouteHintHop { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) }; -} -#[allow(unused)] -impl RouteHintHop { - pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -/// The node_id of the non-target end of the route -#[no_mangle] -pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey { - let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id; - crate::c_types::PublicKey::from_rust(&inner_val) -} -/// The node_id of the non-target end of the route -#[no_mangle] -pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust(); -} -/// The short_channel_id of this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; - *inner_val -} -/// The short_channel_id of this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val; -} -/// The fees which must be paid to use this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning::routing::gossip::RoutingFees { - let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; - crate::lightning::routing::gossip::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning::routing::gossip::RoutingFees<>) as *mut _) }, is_owned: false } -} -/// The fees which must be paid to use this channel -#[no_mangle] -pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning::routing::gossip::RoutingFees) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; -} -/// The difference in CLTV values between this node and the next node. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 { - let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; - *inner_val -} -/// The difference in CLTV values between this node and the next node. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; -} -/// The minimum value, in msat, which must be relayed to the next hop. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The minimum value, in msat, which must be relayed to the next hop. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = local_val; -} -/// The maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { - let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; - local_inner_val -} -/// The maximum value in msat available for routing with a single HTLC. -#[no_mangle] -pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) { - let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val; -} -/// Constructs a new RouteHintHop given each field -#[must_use] -#[no_mangle] -pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning::routing::gossip::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop { - let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; - let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; - RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop { - src_node_id: src_node_id_arg.into_rust(), - short_channel_id: short_channel_id_arg, - fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, - cltv_expiry_delta: cltv_expiry_delta_arg, - htlc_minimum_msat: local_htlc_minimum_msat_arg, - htlc_maximum_msat: local_htlc_maximum_msat_arg, - }), is_owned: true } -} -impl Clone for RouteHintHop { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the RouteHintHop -pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop { - orig.clone() -} -/// Get a string which allows debug introspection of a RouteHintHop object -pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::RouteHintHop }).into()} -/// Generates a non-cryptographic 64-bit hash of the RouteHintHop. -#[no_mangle] -pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -/// Checks if two RouteHintHops contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} #[no_mangle] /// Serialize the RouteHintHop object into a byte array which can be read by RouteHintHop_read -pub extern "C" fn RouteHintHop_write(obj: &crate::lightning::routing::router::RouteHintHop) -> crate::c_types::derived::CVec_u8Z { +pub extern "C" fn RouteHintHop_write(obj: &crate::lightning_types::routing::RouteHintHop) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } #[allow(unused)] pub(crate) extern "C" fn RouteHintHop_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRouteHintHop) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::routing::nativeRouteHintHop) }) } #[no_mangle] /// Read a RouteHintHop from a byte array, created by RouteHintHop_write pub extern "C" fn RouteHintHop_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RouteHintHopDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::RouteHintHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::routing::RouteHintHop { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } use lightning::routing::router::FirstHopCandidate as nativeFirstHopCandidateImport; -pub(crate) type nativeFirstHopCandidate = nativeFirstHopCandidateImport<'static>; +pub(crate) type nativeFirstHopCandidate = nativeFirstHopCandidateImport<'static, >; /// A [`CandidateRouteHop::FirstHop`] entry. #[must_use] @@ -2277,6 +2149,12 @@ pub struct FirstHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for FirstHopCandidate { + type Target = nativeFirstHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FirstHopCandidate { } +unsafe impl core::marker::Sync for FirstHopCandidate { } impl Drop for FirstHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeFirstHopCandidate>::is_null(self.inner) { @@ -2307,6 +2185,9 @@ impl FirstHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for FirstHopCandidate { fn clone(&self) -> Self { @@ -2332,7 +2213,7 @@ pub extern "C" fn FirstHopCandidate_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::FirstHopCandidate }).into()} use lightning::routing::router::PublicHopCandidate as nativePublicHopCandidateImport; -pub(crate) type nativePublicHopCandidate = nativePublicHopCandidateImport<'static>; +pub(crate) type nativePublicHopCandidate = nativePublicHopCandidateImport<'static, >; /// A [`CandidateRouteHop::PublicHop`] entry. #[must_use] @@ -2350,6 +2231,12 @@ pub struct PublicHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for PublicHopCandidate { + type Target = nativePublicHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PublicHopCandidate { } +unsafe impl core::marker::Sync for PublicHopCandidate { } impl Drop for PublicHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativePublicHopCandidate>::is_null(self.inner) { @@ -2380,6 +2267,9 @@ impl PublicHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The short channel ID of the channel, i.e. the identifier by which we refer to this /// channel. @@ -2418,7 +2308,7 @@ pub extern "C" fn PublicHopCandidate_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PublicHopCandidate }).into()} use lightning::routing::router::PrivateHopCandidate as nativePrivateHopCandidateImport; -pub(crate) type nativePrivateHopCandidate = nativePrivateHopCandidateImport<'static>; +pub(crate) type nativePrivateHopCandidate = nativePrivateHopCandidateImport<'static, >; /// A [`CandidateRouteHop::PrivateHop`] entry. #[must_use] @@ -2436,6 +2326,12 @@ pub struct PrivateHopCandidate { pub is_owned: bool, } +impl core::ops::Deref for PrivateHopCandidate { + type Target = nativePrivateHopCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrivateHopCandidate { } +unsafe impl core::marker::Sync for PrivateHopCandidate { } impl Drop for PrivateHopCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativePrivateHopCandidate>::is_null(self.inner) { @@ -2466,6 +2362,9 @@ impl PrivateHopCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for PrivateHopCandidate { fn clone(&self) -> Self { @@ -2491,7 +2390,7 @@ pub extern "C" fn PrivateHopCandidate_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::PrivateHopCandidate }).into()} use lightning::routing::router::BlindedPathCandidate as nativeBlindedPathCandidateImport; -pub(crate) type nativeBlindedPathCandidate = nativeBlindedPathCandidateImport<'static>; +pub(crate) type nativeBlindedPathCandidate = nativeBlindedPathCandidateImport<'static, >; /// A [`CandidateRouteHop::Blinded`] entry. #[must_use] @@ -2509,6 +2408,12 @@ pub struct BlindedPathCandidate { pub is_owned: bool, } +impl core::ops::Deref for BlindedPathCandidate { + type Target = nativeBlindedPathCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedPathCandidate { } +unsafe impl core::marker::Sync for BlindedPathCandidate { } impl Drop for BlindedPathCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeBlindedPathCandidate>::is_null(self.inner) { @@ -2539,6 +2444,9 @@ impl BlindedPathCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for BlindedPathCandidate { fn clone(&self) -> Self { @@ -2564,7 +2472,7 @@ pub extern "C" fn BlindedPathCandidate_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning::routing::router::BlindedPathCandidate }).into()} use lightning::routing::router::OneHopBlindedPathCandidate as nativeOneHopBlindedPathCandidateImport; -pub(crate) type nativeOneHopBlindedPathCandidate = nativeOneHopBlindedPathCandidateImport<'static>; +pub(crate) type nativeOneHopBlindedPathCandidate = nativeOneHopBlindedPathCandidateImport<'static, >; /// A [`CandidateRouteHop::OneHopBlinded`] entry. #[must_use] @@ -2582,6 +2490,12 @@ pub struct OneHopBlindedPathCandidate { pub is_owned: bool, } +impl core::ops::Deref for OneHopBlindedPathCandidate { + type Target = nativeOneHopBlindedPathCandidate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OneHopBlindedPathCandidate { } +unsafe impl core::marker::Sync for OneHopBlindedPathCandidate { } impl Drop for OneHopBlindedPathCandidate { fn drop(&mut self) { if self.is_owned && !<*mut nativeOneHopBlindedPathCandidate>::is_null(self.inner) { @@ -2612,6 +2526,9 @@ impl OneHopBlindedPathCandidate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for OneHopBlindedPathCandidate { fn clone(&self) -> Self { @@ -2676,11 +2593,13 @@ pub enum CandidateRouteHop { /// /// This primarily exists to track that we need to included a blinded path at the end of our /// [`Route`], even though it doesn't actually add an additional hop in the payment. + /// + /// [`BlindedPayInfo`]: crate::blinded_path::payment::BlindedPayInfo OneHopBlinded( crate::lightning::routing::router::OneHopBlindedPathCandidate), } use lightning::routing::router::CandidateRouteHop as CandidateRouteHopImport; -pub(crate) type nativeCandidateRouteHop = CandidateRouteHopImport<'static>; +pub(crate) type nativeCandidateRouteHop = CandidateRouteHopImport<'static, >; impl CandidateRouteHop { #[allow(unused)] @@ -2749,7 +2668,7 @@ impl CandidateRouteHop { } } #[allow(unused)] - pub(crate) fn from_native(native: &CandidateRouteHopImport<'_>) -> Self { + pub(crate) fn from_native(native: &CandidateRouteHopImport<'_, >) -> Self { let native = unsafe { &*(native as *const _ as *const c_void as *const nativeCandidateRouteHop) }; match native { nativeCandidateRouteHop::FirstHop (ref a, ) => { @@ -2897,9 +2816,9 @@ pub extern "C" fn CandidateRouteHop_htlc_minimum_msat(this_arg: &crate::lightnin /// Returns the fees that must be paid to route an HTLC over this channel. #[must_use] #[no_mangle] -pub extern "C" fn CandidateRouteHop_fees(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning::routing::gossip::RoutingFees { +pub extern "C" fn CandidateRouteHop_fees(this_arg: &crate::lightning::routing::router::CandidateRouteHop) -> crate::lightning_types::routing::RoutingFees { let mut ret = this_arg.to_native().fees(); - crate::lightning::routing::gossip::RoutingFees { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::routing::RoutingFees { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Returns the source node id of current hop. @@ -2963,7 +2882,7 @@ pub extern "C" fn CandidateRouteHop_target(this_arg: &crate::lightning::routing: #[no_mangle] pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::ScoreLookUp, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]); - let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, score_params.get_native_ref(), unsafe { &*random_seed_bytes}); + let mut ret = lightning::routing::router::find_route::(&our_node_pubkey.into_rust(), route_params.get_native_ref(), network_graph.get_native_ref(), local_first_hops, logger, scorer, score_params.get_native_ref(), unsafe { &*random_seed_bytes}); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } @@ -2975,7 +2894,7 @@ pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, rou #[no_mangle] pub extern "C" fn build_route_from_hops(mut our_node_pubkey: crate::c_types::PublicKey, mut hops: crate::c_types::derived::CVec_PublicKeyZ, route_params: &crate::lightning::routing::router::RouteParameters, network_graph: &crate::lightning::routing::gossip::NetworkGraph, mut logger: crate::lightning::util::logger::Logger, random_seed_bytes: *const [u8; 32]) -> crate::c_types::derived::CResult_RouteLightningErrorZ { let mut local_hops = Vec::new(); for mut item in hops.into_rust().drain(..) { local_hops.push( { item.into_rust() }); }; - let mut ret = lightning::routing::router::build_route_from_hops::(&our_node_pubkey.into_rust(), &local_hops[..], route_params.get_native_ref(), network_graph.get_native_ref(), logger, unsafe { &*random_seed_bytes}); + let mut ret = lightning::routing::router::build_route_from_hops::(&our_node_pubkey.into_rust(), &local_hops[..], route_params.get_native_ref(), network_graph.get_native_ref(), logger, unsafe { &*random_seed_bytes}); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning/routing/scoring.rs b/lightning-c-bindings/src/lightning/routing/scoring.rs index 5ae5850..59e0e98 100644 --- a/lightning-c-bindings/src/lightning/routing/scoring.rs +++ b/lightning-c-bindings/src/lightning/routing/scoring.rs @@ -48,11 +48,6 @@ //! # } //! ``` //! -//! # Note -//! -//! Persisting when built with feature `no-std` and restoring without it, or vice versa, uses -//! different types and thus is undefined. -//! //! [`find_route`]: crate::routing::router::find_route use alloc::str::FromStr; @@ -106,17 +101,25 @@ impl rustScoreLookUp for ScoreLookUp { } } +pub struct ScoreLookUpRef(ScoreLookUp); +impl rustScoreLookUp for ScoreLookUpRef { + fn channel_penalty_msat(&self, mut candidate: &lightning::routing::router::CandidateRouteHop, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.0.channel_penalty_msat)(self.0.this_arg, &crate::lightning::routing::router::CandidateRouteHop::from_native(candidate), crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }, &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((score_params as *const lightning::routing::scoring::ProbabilisticScoringFeeParameters<>) as *mut _) }, is_owned: false }); + ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for ScoreLookUp { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreLookUpRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreLookUpRef) } } } impl core::ops::DerefMut for ScoreLookUp { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreLookUpRef { + unsafe { &mut *(self as *mut _ as *mut ScoreLookUpRef) } } } /// Calls the free function if one is set @@ -186,17 +189,36 @@ impl rustScoreUpdate for ScoreUpdate { } } +pub struct ScoreUpdateRef(ScoreUpdate); +impl rustScoreUpdate for ScoreUpdateRef { + fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.payment_path_failed)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn payment_path_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.payment_path_successful)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn probe_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.probe_failed)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn probe_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.probe_successful)(self.0.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn time_passed(&mut self, mut duration_since_epoch: core::time::Duration) { + (self.0.time_passed)(self.0.this_arg, duration_since_epoch.as_secs()) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for ScoreUpdate { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreUpdateRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreUpdateRef) } } } impl core::ops::DerefMut for ScoreUpdate { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreUpdateRef { + unsafe { &mut *(self as *mut _ as *mut ScoreUpdateRef) } } } /// Calls the free function if one is set @@ -248,6 +270,12 @@ impl lightning::routing::scoring::ScoreLookUp for Score { ret } } +impl lightning::routing::scoring::ScoreLookUp for ScoreRef { + fn channel_penalty_msat(&self, mut candidate: &lightning::routing::router::CandidateRouteHop, mut usage: lightning::routing::scoring::ChannelUsage, mut score_params: &lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { + let mut ret = (self.0.ScoreLookUp.channel_penalty_msat)(self.0.ScoreLookUp.this_arg, &crate::lightning::routing::router::CandidateRouteHop::from_native(candidate), crate::lightning::routing::scoring::ChannelUsage { inner: ObjOps::heap_alloc(usage), is_owned: true }, &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((score_params as *const lightning::routing::scoring::ProbabilisticScoringFeeParameters<>) as *mut _) }, is_owned: false }); + ret + } +} impl lightning::routing::scoring::ScoreUpdate for Score { fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { (self.ScoreUpdate.payment_path_failed)(self.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) @@ -265,28 +293,55 @@ impl lightning::routing::scoring::ScoreUpdate for Score { (self.ScoreUpdate.time_passed)(self.ScoreUpdate.this_arg, duration_since_epoch.as_secs()) } } +impl lightning::routing::scoring::ScoreUpdate for ScoreRef { + fn payment_path_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.payment_path_failed)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn payment_path_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.payment_path_successful)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn probe_failed(&mut self, mut path: &lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.probe_failed)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, short_channel_id, duration_since_epoch.as_secs()) + } + fn probe_successful(&mut self, mut path: &lightning::routing::router::Path, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.probe_successful)(self.0.ScoreUpdate.this_arg, &crate::lightning::routing::router::Path { inner: unsafe { ObjOps::nonnull_ptr_to_inner((path as *const lightning::routing::router::Path<>) as *mut _) }, is_owned: false }, duration_since_epoch.as_secs()) + } + fn time_passed(&mut self, mut duration_since_epoch: core::time::Duration) { + (self.0.ScoreUpdate.time_passed)(self.0.ScoreUpdate.this_arg, duration_since_epoch.as_secs()) + } +} impl lightning::util::ser::Writeable for Score { fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { let vec = (self.write)(self.this_arg); w.write_all(vec.as_slice()) } } +impl lightning::util::ser::Writeable for ScoreRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} use lightning::routing::scoring::Score as rustScore; impl rustScore for Score { } +pub struct ScoreRef(Score); +impl rustScore for ScoreRef { +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Score { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ScoreRef) } } } impl core::ops::DerefMut for Score { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ScoreRef { + unsafe { &mut *(self as *mut _ as *mut ScoreRef) } } } /// Calls the free function if one is set @@ -333,9 +388,9 @@ pub(crate) fn LockableScore_clone_fields(orig: &LockableScore) -> LockableScore } use lightning::routing::scoring::LockableScore as rustLockableScore; -impl<'a> rustLockableScore<'a> for LockableScore { - type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdate; - type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUp; +impl<'a> rustLockableScore<'a, > for LockableScore { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { @@ -348,17 +403,33 @@ impl<'a> rustLockableScore<'a> for LockableScore { } } +pub struct LockableScoreRef(LockableScore); +impl<'a> rustLockableScore<'a, > for LockableScoreRef { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; + type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; + type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; + fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { + let mut ret = (self.0.read_lock)(self.0.this_arg); + ret + } + fn write_lock(&'a self) -> crate::lightning::routing::scoring::ScoreUpdate { + let mut ret = (self.0.write_lock)(self.0.this_arg); + ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for LockableScore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = LockableScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const LockableScoreRef) } } } impl core::ops::DerefMut for LockableScore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut LockableScoreRef { + unsafe { &mut *(self as *mut _ as *mut LockableScoreRef) } } } /// Calls the free function if one is set @@ -399,9 +470,9 @@ pub(crate) fn WriteableScore_clone_fields(orig: &WriteableScore) -> WriteableSco free: Clone::clone(&orig.free), } } -impl<'a> lightning::routing::scoring::LockableScore<'a> for WriteableScore { - type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdate; - type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUp; +impl<'a> lightning::routing::scoring::LockableScore<'a, > for WriteableScore { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { @@ -413,28 +484,52 @@ impl<'a> lightning::routing::scoring::LockableScore<'a> for WriteableScore { ret } } +impl<'a> lightning::routing::scoring::LockableScore<'a, > for WriteableScoreRef { + type ScoreUpdate = crate::lightning::routing::scoring::ScoreUpdateRef; + type ScoreLookUp = crate::lightning::routing::scoring::ScoreLookUpRef; + type WriteLocked = crate::lightning::routing::scoring::ScoreUpdate; + type ReadLocked = crate::lightning::routing::scoring::ScoreLookUp; + fn read_lock(&'a self) -> crate::lightning::routing::scoring::ScoreLookUp { + let mut ret = (self.0.LockableScore.read_lock)(self.0.LockableScore.this_arg); + ret + } + fn write_lock(&'a self) -> crate::lightning::routing::scoring::ScoreUpdate { + let mut ret = (self.0.LockableScore.write_lock)(self.0.LockableScore.this_arg); + ret + } +} impl lightning::util::ser::Writeable for WriteableScore { fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { let vec = (self.write)(self.this_arg); w.write_all(vec.as_slice()) } } +impl lightning::util::ser::Writeable for WriteableScoreRef { + fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { + let vec = (self.0.write)(self.0.this_arg); + w.write_all(vec.as_slice()) + } +} use lightning::routing::scoring::WriteableScore as rustWriteableScore; -impl<'a> rustWriteableScore<'a> for WriteableScore { +impl<'a> rustWriteableScore<'a, > for WriteableScore { +} + +pub struct WriteableScoreRef(WriteableScore); +impl<'a> rustWriteableScore<'a, > for WriteableScoreRef { } // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for WriteableScore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = WriteableScoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const WriteableScoreRef) } } } impl core::ops::DerefMut for WriteableScore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut WriteableScoreRef { + unsafe { &mut *(self as *mut _ as *mut WriteableScoreRef) } } } /// Calls the free function if one is set @@ -449,7 +544,7 @@ impl Drop for WriteableScore { } use lightning::routing::scoring::MultiThreadedLockableScore as nativeMultiThreadedLockableScoreImport; -pub(crate) type nativeMultiThreadedLockableScore = nativeMultiThreadedLockableScoreImport; +pub(crate) type nativeMultiThreadedLockableScore = nativeMultiThreadedLockableScoreImport; /// A concrete implementation of [`LockableScore`] which supports multi-threading. #[must_use] @@ -467,6 +562,12 @@ pub struct MultiThreadedLockableScore { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedLockableScore { + type Target = nativeMultiThreadedLockableScore; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedLockableScore { } +unsafe impl core::marker::Sync for MultiThreadedLockableScore { } impl Drop for MultiThreadedLockableScore { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedLockableScore>::is_null(self.inner) { @@ -497,6 +598,9 @@ impl MultiThreadedLockableScore { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::routing::scoring::LockableScore { fn from(obj: nativeMultiThreadedLockableScore) -> Self { @@ -522,12 +626,12 @@ pub extern "C" fn MultiThreadedLockableScore_as_LockableScore(this_arg: &MultiTh #[must_use] extern "C" fn MultiThreadedLockableScore_LockableScore_read_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::ScoreLookUp { - let mut ret = >::read_lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); + let mut ret = >::read_lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); Into::into(ret) } #[must_use] extern "C" fn MultiThreadedLockableScore_LockableScore_write_lock(this_arg: *const c_void) -> crate::lightning::routing::scoring::ScoreUpdate { - let mut ret = >::write_lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); + let mut ret = >::write_lock(unsafe { &mut *(this_arg as *mut nativeMultiThreadedLockableScore) }, ); Into::into(ret) } @@ -538,7 +642,7 @@ pub extern "C" fn MultiThreadedLockableScore_write(obj: &crate::lightning::routi } #[allow(unused)] pub(crate) extern "C" fn MultiThreadedLockableScore_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedLockableScore) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeMultiThreadedLockableScore) }) } impl From for crate::lightning::routing::scoring::WriteableScore { fn from(obj: nativeMultiThreadedLockableScore) -> Self { @@ -578,7 +682,7 @@ pub extern "C" fn MultiThreadedLockableScore_new(mut score: crate::lightning::ro use lightning::routing::scoring::MultiThreadedScoreLockRead as nativeMultiThreadedScoreLockReadImport; -pub(crate) type nativeMultiThreadedScoreLockRead = nativeMultiThreadedScoreLockReadImport<'static, crate::lightning::routing::scoring::Score>; +pub(crate) type nativeMultiThreadedScoreLockRead = nativeMultiThreadedScoreLockReadImport<'static, crate::lightning::routing::scoring::Score, >; /// A locked `MultiThreadedLockableScore`. #[must_use] @@ -596,6 +700,12 @@ pub struct MultiThreadedScoreLockRead { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedScoreLockRead { + type Target = nativeMultiThreadedScoreLockRead; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedScoreLockRead { } +unsafe impl core::marker::Sync for MultiThreadedScoreLockRead { } impl Drop for MultiThreadedScoreLockRead { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedScoreLockRead>::is_null(self.inner) { @@ -626,10 +736,13 @@ impl MultiThreadedScoreLockRead { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::scoring::MultiThreadedScoreLockWrite as nativeMultiThreadedScoreLockWriteImport; -pub(crate) type nativeMultiThreadedScoreLockWrite = nativeMultiThreadedScoreLockWriteImport<'static, crate::lightning::routing::scoring::Score>; +pub(crate) type nativeMultiThreadedScoreLockWrite = nativeMultiThreadedScoreLockWriteImport<'static, crate::lightning::routing::scoring::Score, >; /// A locked `MultiThreadedLockableScore`. #[must_use] @@ -647,6 +760,12 @@ pub struct MultiThreadedScoreLockWrite { pub is_owned: bool, } +impl core::ops::Deref for MultiThreadedScoreLockWrite { + type Target = nativeMultiThreadedScoreLockWrite; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MultiThreadedScoreLockWrite { } +unsafe impl core::marker::Sync for MultiThreadedScoreLockWrite { } impl Drop for MultiThreadedScoreLockWrite { fn drop(&mut self) { if self.is_owned && !<*mut nativeMultiThreadedScoreLockWrite>::is_null(self.inner) { @@ -677,6 +796,9 @@ impl MultiThreadedScoreLockWrite { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::routing::scoring::ScoreLookUp { fn from(obj: nativeMultiThreadedScoreLockRead) -> Self { @@ -701,7 +823,7 @@ pub extern "C" fn MultiThreadedScoreLockRead_as_ScoreLookUp(this_arg: &MultiThre #[must_use] extern "C" fn MultiThreadedScoreLockRead_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockRead) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); + let mut ret = ::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockRead) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } @@ -712,7 +834,7 @@ pub extern "C" fn MultiThreadedScoreLockWrite_write(obj: &crate::lightning::rout } #[allow(unused)] pub(crate) extern "C" fn MultiThreadedScoreLockWrite_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeMultiThreadedScoreLockWrite) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeMultiThreadedScoreLockWrite) }) } impl From for crate::lightning::routing::scoring::ScoreUpdate { fn from(obj: nativeMultiThreadedScoreLockWrite) -> Self { @@ -740,19 +862,19 @@ pub extern "C" fn MultiThreadedScoreLockWrite_as_ScoreUpdate(this_arg: &MultiThr } extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::probe_failed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::probe_successful(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn MultiThreadedScoreLockWrite_ScoreUpdate_time_passed(this_arg: *mut c_void, mut duration_since_epoch: u64) { - >::time_passed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, core::time::Duration::from_secs(duration_since_epoch)) + ::time_passed(unsafe { &mut *(this_arg as *mut nativeMultiThreadedScoreLockWrite) }, core::time::Duration::from_secs(duration_since_epoch)) } @@ -775,6 +897,12 @@ pub struct ChannelUsage { pub is_owned: bool, } +impl core::ops::Deref for ChannelUsage { + type Target = nativeChannelUsage; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelUsage { } +unsafe impl core::marker::Sync for ChannelUsage { } impl Drop for ChannelUsage { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelUsage>::is_null(self.inner) { @@ -805,6 +933,9 @@ impl ChannelUsage { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The amount to send through the channel, denominated in millisatoshis. #[no_mangle] @@ -893,6 +1024,12 @@ pub struct FixedPenaltyScorer { pub is_owned: bool, } +impl core::ops::Deref for FixedPenaltyScorer { + type Target = nativeFixedPenaltyScorer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FixedPenaltyScorer { } +unsafe impl core::marker::Sync for FixedPenaltyScorer { } impl Drop for FixedPenaltyScorer { fn drop(&mut self) { if self.is_owned && !<*mut nativeFixedPenaltyScorer>::is_null(self.inner) { @@ -923,6 +1060,9 @@ impl FixedPenaltyScorer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for FixedPenaltyScorer { fn clone(&self) -> Self { @@ -974,7 +1114,7 @@ pub extern "C" fn FixedPenaltyScorer_as_ScoreLookUp(this_arg: &FixedPenaltyScore #[must_use] extern "C" fn FixedPenaltyScorer_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); + let mut ret = ::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } @@ -1004,19 +1144,19 @@ pub extern "C" fn FixedPenaltyScorer_as_ScoreUpdate(this_arg: &FixedPenaltyScore } extern "C" fn FixedPenaltyScorer_ScoreUpdate_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn FixedPenaltyScorer_ScoreUpdate_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn FixedPenaltyScorer_ScoreUpdate_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::probe_failed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn FixedPenaltyScorer_ScoreUpdate_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::probe_successful(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn FixedPenaltyScorer_ScoreUpdate_time_passed(this_arg: *mut c_void, mut duration_since_epoch: u64) { - >::time_passed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, core::time::Duration::from_secs(duration_since_epoch)) + ::time_passed(unsafe { &mut *(this_arg as *mut nativeFixedPenaltyScorer) }, core::time::Duration::from_secs(duration_since_epoch)) } #[no_mangle] @@ -1026,7 +1166,7 @@ pub extern "C" fn FixedPenaltyScorer_write(obj: &crate::lightning::routing::scor } #[allow(unused)] pub(crate) extern "C" fn FixedPenaltyScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeFixedPenaltyScorer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeFixedPenaltyScorer) }) } #[no_mangle] /// Read a FixedPenaltyScorer from a byte array, created by FixedPenaltyScorer_write @@ -1038,7 +1178,7 @@ pub extern "C" fn FixedPenaltyScorer_read(ser: crate::c_types::u8slice, arg: u64 } use lightning::routing::scoring::ProbabilisticScorer as nativeProbabilisticScorerImport; -pub(crate) type nativeProbabilisticScorer = nativeProbabilisticScorerImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger>; +pub(crate) type nativeProbabilisticScorer = nativeProbabilisticScorerImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, >; /// [`ScoreLookUp`] implementation using channel success probability distributions. /// @@ -1086,6 +1226,12 @@ pub struct ProbabilisticScorer { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScorer { + type Target = nativeProbabilisticScorer; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScorer { } +unsafe impl core::marker::Sync for ProbabilisticScorer { } impl Drop for ProbabilisticScorer { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScorer>::is_null(self.inner) { @@ -1116,6 +1262,9 @@ impl ProbabilisticScorer { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } use lightning::routing::scoring::ProbabilisticScoringFeeParameters as nativeProbabilisticScoringFeeParametersImport; @@ -1143,6 +1292,12 @@ pub struct ProbabilisticScoringFeeParameters { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScoringFeeParameters { + type Target = nativeProbabilisticScoringFeeParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScoringFeeParameters { } +unsafe impl core::marker::Sync for ProbabilisticScoringFeeParameters { } impl Drop for ProbabilisticScoringFeeParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScoringFeeParameters>::is_null(self.inner) { @@ -1173,6 +1328,9 @@ impl ProbabilisticScoringFeeParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// A fixed penalty in msats to apply to each channel. /// @@ -1601,6 +1759,12 @@ pub struct ProbabilisticScoringDecayParameters { pub is_owned: bool, } +impl core::ops::Deref for ProbabilisticScoringDecayParameters { + type Target = nativeProbabilisticScoringDecayParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ProbabilisticScoringDecayParameters { } +unsafe impl core::marker::Sync for ProbabilisticScoringDecayParameters { } impl Drop for ProbabilisticScoringDecayParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeProbabilisticScoringDecayParameters>::is_null(self.inner) { @@ -1631,6 +1795,9 @@ impl ProbabilisticScoringDecayParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// If we aren't learning any new datapoints for a channel, the historical liquidity bounds /// tracking can simply live on with increasingly stale data. Instead, when a channel has not @@ -1844,7 +2011,7 @@ pub extern "C" fn ProbabilisticScorer_as_ScoreLookUp(this_arg: &ProbabilisticSco #[must_use] extern "C" fn ProbabilisticScorer_ScoreLookUp_channel_penalty_msat(this_arg: *const c_void, candidate: &crate::lightning::routing::router::CandidateRouteHop, mut usage: crate::lightning::routing::scoring::ChannelUsage, score_params: &crate::lightning::routing::scoring::ProbabilisticScoringFeeParameters) -> u64 { - let mut ret = >::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); + let mut ret = ::channel_penalty_msat(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, &candidate.to_native(), *unsafe { Box::from_raw(usage.take_inner()) }, score_params.get_native_ref()); ret } @@ -1874,19 +2041,19 @@ pub extern "C" fn ProbabilisticScorer_as_ScoreUpdate(this_arg: &ProbabilisticSco } extern "C" fn ProbabilisticScorer_ScoreUpdate_payment_path_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn ProbabilisticScorer_ScoreUpdate_payment_path_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::payment_path_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn ProbabilisticScorer_ScoreUpdate_probe_failed(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut short_channel_id: u64, mut duration_since_epoch: u64) { - >::probe_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) + ::probe_failed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), short_channel_id, core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn ProbabilisticScorer_ScoreUpdate_probe_successful(this_arg: *mut c_void, path: &crate::lightning::routing::router::Path, mut duration_since_epoch: u64) { - >::probe_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) + ::probe_successful(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, path.get_native_ref(), core::time::Duration::from_secs(duration_since_epoch)) } extern "C" fn ProbabilisticScorer_ScoreUpdate_time_passed(this_arg: *mut c_void, mut duration_since_epoch: u64) { - >::time_passed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, core::time::Duration::from_secs(duration_since_epoch)) + ::time_passed(unsafe { &mut *(this_arg as *mut nativeProbabilisticScorer) }, core::time::Duration::from_secs(duration_since_epoch)) } impl From for crate::lightning::routing::scoring::Score { @@ -1925,18 +2092,6 @@ pub extern "C" fn ProbabilisticScorer_as_Score(this_arg: &ProbabilisticScorer) - } -mod approx { - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -} mod bucketed_history { use alloc::str::FromStr; @@ -1956,7 +2111,7 @@ pub extern "C" fn ProbabilisticScorer_write(obj: &crate::lightning::routing::sco } #[allow(unused)] pub(crate) extern "C" fn ProbabilisticScorer_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeProbabilisticScorer) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::routing::scoring::nativeProbabilisticScorer) }) } #[no_mangle] /// Read a ProbabilisticScorer from a byte array, created by ProbabilisticScorer_write diff --git a/lightning-c-bindings/src/lightning/routing/utxo.rs b/lightning-c-bindings/src/lightning/routing/utxo.rs index b978317..517d633 100644 --- a/lightning-c-bindings/src/lightning/routing/utxo.rs +++ b/lightning-c-bindings/src/lightning/routing/utxo.rs @@ -243,23 +243,31 @@ pub(crate) fn UtxoLookup_clone_fields(orig: &UtxoLookup) -> UtxoLookup { use lightning::routing::utxo::UtxoLookup as rustUtxoLookup; impl rustUtxoLookup for UtxoLookup { - fn get_utxo(&self, mut chain_hash: &bitcoin::blockdata::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { + fn get_utxo(&self, mut chain_hash: &bitcoin::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { let mut ret = (self.get_utxo)(self.this_arg, chain_hash.as_ref(), short_channel_id); ret.into_native() } } +pub struct UtxoLookupRef(UtxoLookup); +impl rustUtxoLookup for UtxoLookupRef { + fn get_utxo(&self, mut chain_hash: &bitcoin::constants::ChainHash, mut short_channel_id: u64) -> lightning::routing::utxo::UtxoResult { + let mut ret = (self.0.get_utxo)(self.0.this_arg, chain_hash.as_ref(), short_channel_id); + ret.into_native() + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for UtxoLookup { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = UtxoLookupRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const UtxoLookupRef) } } } impl core::ops::DerefMut for UtxoLookup { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut UtxoLookupRef { + unsafe { &mut *(self as *mut _ as *mut UtxoLookupRef) } } } /// Calls the free function if one is set @@ -294,6 +302,12 @@ pub struct UtxoFuture { pub is_owned: bool, } +impl core::ops::Deref for UtxoFuture { + type Target = nativeUtxoFuture; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UtxoFuture { } +unsafe impl core::marker::Sync for UtxoFuture { } impl Drop for UtxoFuture { fn drop(&mut self) { if self.is_owned && !<*mut nativeUtxoFuture>::is_null(self.inner) { @@ -324,6 +338,9 @@ impl UtxoFuture { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for UtxoFuture { fn clone(&self) -> Self { diff --git a/lightning-c-bindings/src/lightning/sign/ecdsa.rs b/lightning-c-bindings/src/lightning/sign/ecdsa.rs index eff9145..78668f2 100644 --- a/lightning-c-bindings/src/lightning/sign/ecdsa.rs +++ b/lightning-c-bindings/src/lightning/sign/ecdsa.rs @@ -53,6 +53,13 @@ pub struct EcdsaChannelSigner { /// This may be called multiple times for the same transaction. /// /// An external signer implementation should check that the commitment has not been revoked. + /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_holder_commitment: extern "C" fn (this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Create a signature for the given input in a transaction spending an HTLC transaction output /// or a commitment transaction `to_local` output when our counterparty broadcasts an old state. @@ -68,6 +75,13 @@ pub struct EcdsaChannelSigner { /// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does /// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do /// so). + /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_justice_revoked_output: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Create a signature for the given input in a transaction spending a commitment transaction /// HTLC output when our counterparty broadcasts an old state. @@ -87,6 +101,13 @@ pub struct EcdsaChannelSigner { /// /// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script /// (which is committed to in the BIP 143 signatures). + /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_justice_revoked_htlc: extern "C" fn (this_arg: *const c_void, justice_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Computes the signature for a commitment transaction's HTLC output used as an input within /// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned @@ -96,8 +117,14 @@ pub struct EcdsaChannelSigner { /// [`ChannelMonitor`] [replica](https://github.com/lightningdevkit/rust-lightning/blob/main/GLOSSARY.md#monitor-replicas) /// broadcasts it before receiving the update for the latest commitment transaction. /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// /// [`EcdsaSighashType::All`]: bitcoin::sighash::EcdsaSighashType::All /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_holder_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, htlc_descriptor: &crate::lightning::sign::HTLCDescriptor) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment /// transaction, either offered or received. @@ -116,6 +143,13 @@ pub struct EcdsaChannelSigner { /// detected onchain. It has been generated by our counterparty and is used to derive /// channel state keys, which are then included in the witness script and committed to in the /// BIP 143 signature. + /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_counterparty_htlc_transaction: extern "C" fn (this_arg: *const c_void, htlc_tx: crate::c_types::Transaction, input: usize, amount: u64, per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Create a signature for a (proposed) closing transaction. /// @@ -124,6 +158,13 @@ pub struct EcdsaChannelSigner { pub sign_closing_transaction: extern "C" fn (this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Computes the signature for a commitment transaction's anchor output used as an /// input within `anchor_tx`, which spends the commitment transaction, at index `input`. + /// + /// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid + /// signature and should be retried later. Once the signer is ready to provide a signature after + /// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its + /// monitor. + /// + /// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked pub sign_holder_anchor_input: extern "C" fn (this_arg: *const c_void, anchor_tx: crate::c_types::Transaction, input: usize) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Signs a channel announcement message with our funding key proving it comes from one of the /// channel participants. @@ -139,6 +180,10 @@ pub struct EcdsaChannelSigner { pub sign_channel_announcement_with_funding_key: extern "C" fn (this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ, /// Implementation of ChannelSigner for this object. pub ChannelSigner: crate::lightning::sign::ChannelSigner, + /// Called, if set, after this EcdsaChannelSigner has been cloned into a duplicate object. + /// The new EcdsaChannelSigner is provided, and should be mutated as needed to perform a + /// deep copy of the object pointed to by this_arg or avoid any double-freeing. + pub cloned: Option, /// Frees any resources associated with this object given its this_arg pointer. /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. pub free: Option, @@ -159,19 +204,22 @@ pub(crate) fn EcdsaChannelSigner_clone_fields(orig: &EcdsaChannelSigner) -> Ecds sign_holder_anchor_input: Clone::clone(&orig.sign_holder_anchor_input), sign_channel_announcement_with_funding_key: Clone::clone(&orig.sign_channel_announcement_with_funding_key), ChannelSigner: crate::lightning::sign::ChannelSigner_clone_fields(&orig.ChannelSigner), + cloned: Clone::clone(&orig.cloned), free: Clone::clone(&orig.free), } } impl lightning::sign::ChannelSigner for EcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.ChannelSigner.get_per_commitment_point)(self.ChannelSigner.this_arg, idx); - ret.into_rust() + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { let mut ret = (self.ChannelSigner.release_commitment_secret)(self.ChannelSigner.this_arg, idx); - ret.data + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut ret = (self.ChannelSigner.validate_holder_commitment)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_outbound_htlc_preimages.into()); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; @@ -196,10 +244,63 @@ impl lightning::sign::ChannelSigner for EcdsaChannelSigner { (self.ChannelSigner.provide_channel_parameters)(self.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) } } +impl lightning::sign::ChannelSigner for EcdsaChannelSignerRef { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.ChannelSigner.get_per_commitment_point)(self.0.ChannelSigner.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { + let mut ret = (self.0.ChannelSigner.release_commitment_secret)(self.0.ChannelSigner.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.0.ChannelSigner.validate_holder_commitment)(self.0.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_outbound_htlc_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.0.ChannelSigner.validate_counterparty_revocation)(self.0.ChannelSigner.this_arg, idx, secret.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.0.ChannelSigner.set_pubkeys { + (f)(&self.0.ChannelSigner); + } + unsafe { &*self.0.ChannelSigner.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.0.ChannelSigner.channel_keys_id)(self.0.ChannelSigner.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.0.ChannelSigner.provide_channel_parameters)(self.0.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) + } +} +#[no_mangle] +/// Creates a copy of a EcdsaChannelSigner +pub extern "C" fn EcdsaChannelSigner_clone(orig: &EcdsaChannelSigner) -> EcdsaChannelSigner { + let mut res = EcdsaChannelSigner_clone_fields(orig); + if let Some(f) = orig.cloned { (f)(&mut res) }; + res +} +impl Clone for EcdsaChannelSigner { + fn clone(&self) -> Self { + EcdsaChannelSigner_clone(self) + } +} +impl Clone for EcdsaChannelSignerRef { + fn clone(&self) -> Self { + Self(EcdsaChannelSigner_clone(&self.0)) + } +} use lightning::sign::ecdsa::EcdsaChannelSigner as rustEcdsaChannelSigner; impl rustEcdsaChannelSigner for EcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.drain(..) { local_inbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut ret = (self.sign_counterparty_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_inbound_htlc_preimages.into(), local_outbound_htlc_preimages.into()); @@ -211,22 +312,22 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_justice_revoked_output)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_justice_revoked_htlc)(self.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_holder_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::HTLCDescriptor<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_counterparty_htlc_transaction)(self.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret @@ -236,7 +337,7 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.sign_holder_anchor_input)(self.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret @@ -248,188 +349,74 @@ impl rustEcdsaChannelSigner for EcdsaChannelSigner { } } -// We're essentially a pointer already, or at least a set of pointers, so allow us to be used -// directly as a Deref trait in higher-level structs: -impl core::ops::Deref for EcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self - } -} -impl core::ops::DerefMut for EcdsaChannelSigner { - fn deref_mut(&mut self) -> &mut Self { - self - } -} -/// Calls the free function if one is set -#[no_mangle] -pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { } -impl Drop for EcdsaChannelSigner { - fn drop(&mut self) { - if let Some(f) = self.free { - f(self.this_arg); - } - } -} -/// A writeable signer. -/// -/// There will always be two instances of a signer per channel, one occupied by the -/// [`ChannelManager`] and another by the channel's [`ChannelMonitor`]. -/// -/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager -/// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor -#[repr(C)] -pub struct WriteableEcdsaChannelSigner { - /// An opaque pointer which is passed to your function implementations as an argument. - /// This has no meaning in the LDK, and can be NULL or any other value. - pub this_arg: *mut c_void, - /// Implementation of EcdsaChannelSigner for this object. - pub EcdsaChannelSigner: crate::lightning::sign::ecdsa::EcdsaChannelSigner, - /// Serialize the object into a byte array - pub write: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CVec_u8Z, - /// Called, if set, after this WriteableEcdsaChannelSigner has been cloned into a duplicate object. - /// The new WriteableEcdsaChannelSigner is provided, and should be mutated as needed to perform a - /// deep copy of the object pointed to by this_arg or avoid any double-freeing. - pub cloned: Option, - /// Frees any resources associated with this object given its this_arg pointer. - /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. - pub free: Option, -} -unsafe impl Send for WriteableEcdsaChannelSigner {} -unsafe impl Sync for WriteableEcdsaChannelSigner {} -#[allow(unused)] -pub(crate) fn WriteableEcdsaChannelSigner_clone_fields(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - WriteableEcdsaChannelSigner { - this_arg: orig.this_arg, - EcdsaChannelSigner: crate::lightning::sign::ecdsa::EcdsaChannelSigner_clone_fields(&orig.EcdsaChannelSigner), - write: Clone::clone(&orig.write), - cloned: Clone::clone(&orig.cloned), - free: Clone::clone(&orig.free), - } -} -impl lightning::sign::ecdsa::EcdsaChannelSigner for WriteableEcdsaChannelSigner { - fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { +pub struct EcdsaChannelSignerRef(EcdsaChannelSigner); +impl rustEcdsaChannelSigner for EcdsaChannelSignerRef { + fn sign_counterparty_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: Vec, mut outbound_htlc_preimages: Vec, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result<(bitcoin::secp256k1::ecdsa::Signature, Vec), ()> { let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.drain(..) { local_inbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_inbound_htlc_preimages.into(), local_outbound_htlc_preimages.into()); + let mut ret = (self.0.sign_counterparty_commitment)(self.0.this_arg, &crate::lightning::ln::chan_utils::CommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::CommitmentTransaction<>) as *mut _) }, is_owned: false }, local_inbound_htlc_preimages.into(), local_outbound_htlc_preimages.into()); let mut local_ret = match ret.result_ok { true => Ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).to_rust(); let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.into_rust().drain(..) { local_orig_ret_0_1.push( { item.into_rust() }); }; let mut local_ret_0 = (orig_ret_0_0.into_rust(), local_orig_ret_0_1); local_ret_0 }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_holder_commitment(&self, mut commitment_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_commitment)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); + let mut ret = (self.0.sign_holder_commitment)(self.0.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((commitment_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_output)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); + fn sign_justice_revoked_output(&self, mut justice_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_justice_revoked_output)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref()); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_justice_revoked_htlc)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + fn sign_justice_revoked_htlc(&self, mut justice_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_key: &bitcoin::secp256k1::SecretKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_justice_revoked_htlc)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(justice_tx), input, amount, per_commitment_key.as_ref(), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::HTLCDescriptor<>) as *mut _) }, is_owned: false }); + fn sign_holder_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut htlc_descriptor: &lightning::sign::HTLCDescriptor, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_holder_htlc_transaction)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, &crate::lightning::sign::HTLCDescriptor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc_descriptor as *const lightning::sign::HTLCDescriptor<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_counterparty_htlc_transaction)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); + fn sign_counterparty_htlc_transaction(&self, mut htlc_tx: &bitcoin::transaction::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: &bitcoin::secp256k1::PublicKey, mut htlc: &lightning::ln::chan_utils::HTLCOutputInCommitment, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_counterparty_htlc_transaction)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(htlc_tx), input, amount, crate::c_types::PublicKey::from_rust(&per_commitment_point), &crate::lightning::ln::chan_utils::HTLCOutputInCommitment { inner: unsafe { ObjOps::nonnull_ptr_to_inner((htlc as *const lightning::ln::chan_utils::HTLCOutputInCommitment<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_closing_transaction(&self, mut closing_tx: &lightning::ln::chan_utils::ClosingTransaction, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_closing_transaction)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); + let mut ret = (self.0.sign_closing_transaction)(self.0.this_arg, &crate::lightning::ln::chan_utils::ClosingTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((closing_tx as *const lightning::ln::chan_utils::ClosingTransaction<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::blockdata::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_holder_anchor_input)(self.EcdsaChannelSigner.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); + fn sign_holder_anchor_input(&self, mut anchor_tx: &bitcoin::transaction::Transaction, mut input: usize, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.sign_holder_anchor_input)(self.0.this_arg, crate::c_types::Transaction::from_bitcoin(anchor_tx), input); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn sign_channel_announcement_with_funding_key(&self, mut msg: &lightning::ln::msgs::UnsignedChannelAnnouncement, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { - let mut ret = (self.EcdsaChannelSigner.sign_channel_announcement_with_funding_key)(self.EcdsaChannelSigner.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); + let mut ret = (self.0.sign_channel_announcement_with_funding_key)(self.0.this_arg, &crate::lightning::ln::msgs::UnsignedChannelAnnouncement { inner: unsafe { ObjOps::nonnull_ptr_to_inner((msg as *const lightning::ln::msgs::UnsignedChannelAnnouncement<>) as *mut _) }, is_owned: false }); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } } -impl lightning::sign::ChannelSigner for WriteableEcdsaChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.get_per_commitment_point)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.into_rust() - } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.release_commitment_secret)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx); - ret.data - } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { - let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_holder_commitment)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_outbound_htlc_preimages.into()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.validate_counterparty_revocation)(self.EcdsaChannelSigner.ChannelSigner.this_arg, idx, secret.as_ref()); - let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; - local_ret - } - fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { - if let Some(f) = self.EcdsaChannelSigner.ChannelSigner.set_pubkeys { - (f)(&self.EcdsaChannelSigner.ChannelSigner); - } - unsafe { &*self.EcdsaChannelSigner.ChannelSigner.pubkeys.get() }.get_native_ref() - } - fn channel_keys_id(&self) -> [u8; 32] { - let mut ret = (self.EcdsaChannelSigner.ChannelSigner.channel_keys_id)(self.EcdsaChannelSigner.ChannelSigner.this_arg); - ret.data - } - fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { - (self.EcdsaChannelSigner.ChannelSigner.provide_channel_parameters)(self.EcdsaChannelSigner.ChannelSigner.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) - } -} -impl lightning::util::ser::Writeable for WriteableEcdsaChannelSigner { - fn write(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> { - let vec = (self.write)(self.this_arg); - w.write_all(vec.as_slice()) - } -} -#[no_mangle] -/// Creates a copy of a WriteableEcdsaChannelSigner -pub extern "C" fn WriteableEcdsaChannelSigner_clone(orig: &WriteableEcdsaChannelSigner) -> WriteableEcdsaChannelSigner { - let mut res = WriteableEcdsaChannelSigner_clone_fields(orig); - if let Some(f) = orig.cloned { (f)(&mut res) }; - res -} -impl Clone for WriteableEcdsaChannelSigner { - fn clone(&self) -> Self { - WriteableEcdsaChannelSigner_clone(self) - } -} - -use lightning::sign::ecdsa::WriteableEcdsaChannelSigner as rustWriteableEcdsaChannelSigner; -impl rustWriteableEcdsaChannelSigner for WriteableEcdsaChannelSigner { -} // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: -impl core::ops::Deref for WriteableEcdsaChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self +impl core::ops::Deref for EcdsaChannelSigner { + type Target = EcdsaChannelSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EcdsaChannelSignerRef) } } } -impl core::ops::DerefMut for WriteableEcdsaChannelSigner { - fn deref_mut(&mut self) -> &mut Self { - self +impl core::ops::DerefMut for EcdsaChannelSigner { + fn deref_mut(&mut self) -> &mut EcdsaChannelSignerRef { + unsafe { &mut *(self as *mut _ as *mut EcdsaChannelSignerRef) } } } /// Calls the free function if one is set #[no_mangle] -pub extern "C" fn WriteableEcdsaChannelSigner_free(this_ptr: WriteableEcdsaChannelSigner) { } -impl Drop for WriteableEcdsaChannelSigner { +pub extern "C" fn EcdsaChannelSigner_free(this_ptr: EcdsaChannelSigner) { } +impl Drop for EcdsaChannelSigner { fn drop(&mut self) { if let Some(f) = self.free { f(self.this_arg); diff --git a/lightning-c-bindings/src/lightning/sign/mod.rs b/lightning-c-bindings/src/lightning/sign/mod.rs index e565a04..1f4b228 100644 --- a/lightning-c-bindings/src/lightning/sign/mod.rs +++ b/lightning-c-bindings/src/lightning/sign/mod.rs @@ -55,6 +55,12 @@ pub struct DelayedPaymentOutputDescriptor { pub is_owned: bool, } +impl core::ops::Deref for DelayedPaymentOutputDescriptor { + type Target = nativeDelayedPaymentOutputDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for DelayedPaymentOutputDescriptor { } +unsafe impl core::marker::Sync for DelayedPaymentOutputDescriptor { } impl Drop for DelayedPaymentOutputDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { @@ -85,6 +91,9 @@ impl DelayedPaymentOutputDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The outpoint which is spendable. #[no_mangle] @@ -169,10 +178,36 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_value_satoshis(this pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_value_satoshis(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_value_satoshis = val; } +/// The channel public keys and other parameters needed to generate a spending transaction or +/// to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. +/// +/// Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_get_channel_transaction_parameters(this_ptr: &DelayedPaymentOutputDescriptor) -> crate::lightning::ln::chan_utils::ChannelTransactionParameters { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_transaction_parameters; + let mut local_inner_val = crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel public keys and other parameters needed to generate a spending transaction or +/// to provide to a re-derived signer through [`ChannelSigner::provide_channel_parameters`]. +/// +/// Added as optional, but always `Some` if the descriptor was produced in v0.0.123 or later. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn DelayedPaymentOutputDescriptor_set_channel_transaction_parameters(this_ptr: &mut DelayedPaymentOutputDescriptor, mut val: crate::lightning::ln::chan_utils::ChannelTransactionParameters) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_transaction_parameters = local_val; +} /// Constructs a new DelayedPaymentOutputDescriptor given each field +/// +/// Note that channel_transaction_parameters_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::lightning::ln::channel_keys::RevocationKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64) -> DelayedPaymentOutputDescriptor { +pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::lightning::chain::transaction::OutPoint, mut per_commitment_point_arg: crate::c_types::PublicKey, mut to_self_delay_arg: u16, mut output_arg: crate::c_types::TxOut, mut revocation_pubkey_arg: crate::lightning::ln::channel_keys::RevocationKey, mut channel_keys_id_arg: crate::c_types::ThirtyTwoBytes, mut channel_value_satoshis_arg: u64, mut channel_transaction_parameters_arg: crate::lightning::ln::chan_utils::ChannelTransactionParameters) -> DelayedPaymentOutputDescriptor { + let mut local_channel_transaction_parameters_arg = if channel_transaction_parameters_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_transaction_parameters_arg.take_inner()) } }) }; DelayedPaymentOutputDescriptor { inner: ObjOps::heap_alloc(nativeDelayedPaymentOutputDescriptor { outpoint: *unsafe { Box::from_raw(outpoint_arg.take_inner()) }, per_commitment_point: per_commitment_point_arg.into_rust(), @@ -181,6 +216,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_new(mut outpoint_arg: crate::li revocation_pubkey: *unsafe { Box::from_raw(revocation_pubkey_arg.take_inner()) }, channel_keys_id: channel_keys_id_arg.data, channel_value_satoshis: channel_value_satoshis_arg, + channel_transaction_parameters: local_channel_transaction_parameters_arg, }), is_owned: true } } impl Clone for DelayedPaymentOutputDescriptor { @@ -231,7 +267,7 @@ pub extern "C" fn DelayedPaymentOutputDescriptor_write(obj: &crate::lightning::s } #[allow(unused)] pub(crate) extern "C" fn DelayedPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeDelayedPaymentOutputDescriptor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeDelayedPaymentOutputDescriptor) }) } #[no_mangle] /// Read a DelayedPaymentOutputDescriptor from a byte array, created by DelayedPaymentOutputDescriptor_write @@ -262,6 +298,12 @@ pub struct StaticPaymentOutputDescriptor { pub is_owned: bool, } +impl core::ops::Deref for StaticPaymentOutputDescriptor { + type Target = nativeStaticPaymentOutputDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for StaticPaymentOutputDescriptor { } +unsafe impl core::marker::Sync for StaticPaymentOutputDescriptor { } impl Drop for StaticPaymentOutputDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { @@ -292,6 +334,9 @@ impl StaticPaymentOutputDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The outpoint which is spendable. #[no_mangle] @@ -447,7 +492,7 @@ pub extern "C" fn StaticPaymentOutputDescriptor_write(obj: &crate::lightning::si } #[allow(unused)] pub(crate) extern "C" fn StaticPaymentOutputDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeStaticPaymentOutputDescriptor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeStaticPaymentOutputDescriptor) }) } #[no_mangle] /// Read a StaticPaymentOutputDescriptor from a byte array, created by StaticPaymentOutputDescriptor_write @@ -733,7 +778,7 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::sign::SpendableOutputDescriptor::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } -/// Creates an unsigned [`PartiallySignedTransaction`] which spends the given descriptors to +/// Creates an unsigned [`Psbt`] which spends the given descriptors to /// the given outputs, plus an output to the given change destination (if sufficient /// change value remains). The PSBT will have a feerate, at least, of the given value. /// @@ -754,8 +799,8 @@ pub extern "C" fn SpendableOutputDescriptor_read(ser: crate::c_types::u8slice) - pub extern "C" fn SpendableOutputDescriptor_create_spendable_outputs_psbt(mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_C2Tuple_CVec_u8Zu64ZNoneZ { let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime); + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = lightning::sign::SpendableOutputDescriptor::create_spendable_outputs_psbt(secp256k1::global::SECP256K1, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (orig_ret_0_0.serialize().into(), orig_ret_0_1).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -780,6 +825,12 @@ pub struct ChannelDerivationParameters { pub is_owned: bool, } +impl core::ops::Deref for ChannelDerivationParameters { + type Target = nativeChannelDerivationParameters; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelDerivationParameters { } +unsafe impl core::marker::Sync for ChannelDerivationParameters { } impl Drop for ChannelDerivationParameters { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelDerivationParameters>::is_null(self.inner) { @@ -810,6 +861,9 @@ impl ChannelDerivationParameters { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The value in satoshis of the channel we're attempting to spend the anchor output of. #[no_mangle] @@ -894,7 +948,7 @@ pub extern "C" fn ChannelDerivationParameters_write(obj: &crate::lightning::sign } #[allow(unused)] pub(crate) extern "C" fn ChannelDerivationParameters_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelDerivationParameters) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeChannelDerivationParameters) }) } #[no_mangle] /// Read a ChannelDerivationParameters from a byte array, created by ChannelDerivationParameters_write @@ -923,6 +977,12 @@ pub struct HTLCDescriptor { pub is_owned: bool, } +impl core::ops::Deref for HTLCDescriptor { + type Target = nativeHTLCDescriptor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for HTLCDescriptor { } +unsafe impl core::marker::Sync for HTLCDescriptor { } impl Drop for HTLCDescriptor { fn drop(&mut self) { if self.is_owned && !<*mut nativeHTLCDescriptor>::is_null(self.inner) { @@ -953,6 +1013,9 @@ impl HTLCDescriptor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The parameters required to derive the signer for the HTLC input. #[no_mangle] @@ -965,6 +1028,17 @@ pub extern "C" fn HTLCDescriptor_get_channel_derivation_parameters(this_ptr: &HT pub extern "C" fn HTLCDescriptor_set_channel_derivation_parameters(this_ptr: &mut HTLCDescriptor, mut val: crate::lightning::sign::ChannelDerivationParameters) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_derivation_parameters = *unsafe { Box::from_raw(val.take_inner()) }; } +/// The txid of the commitment transaction in which the HTLC output lives. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_get_commitment_txid(this_ptr: &HTLCDescriptor) -> *const [u8; 32] { + let mut inner_val = &mut this_ptr.get_native_mut_ref().commitment_txid; + inner_val.as_ref() +} +/// The txid of the commitment transaction in which the HTLC output lives. +#[no_mangle] +pub extern "C" fn HTLCDescriptor_set_commitment_txid(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::ThirtyTwoBytes) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.commitment_txid = ::bitcoin::hash_types::Txid::from_slice(&val.data[..]).unwrap(); +} /// The number of the commitment transaction in which the HTLC output lives. #[no_mangle] pub extern "C" fn HTLCDescriptor_get_per_commitment_number(this_ptr: &HTLCDescriptor) -> u64 { @@ -1033,7 +1107,7 @@ pub extern "C" fn HTLCDescriptor_get_preimage(this_ptr: &HTLCDescriptor) -> crat /// taken. #[no_mangle] pub extern "C" fn HTLCDescriptor_set_preimage(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentPreimage({ val_opt.take() }.data) }})} }; + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ val_opt.take() }.data) }})} }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.preimage = local_val; } /// The counterparty's signature required to spend the HTLC output. @@ -1047,6 +1121,22 @@ pub extern "C" fn HTLCDescriptor_get_counterparty_sig(this_ptr: &HTLCDescriptor) pub extern "C" fn HTLCDescriptor_set_counterparty_sig(this_ptr: &mut HTLCDescriptor, mut val: crate::c_types::ECDSASignature) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.counterparty_sig = val.into_rust(); } +/// Constructs a new HTLCDescriptor given each field +#[must_use] +#[no_mangle] +pub extern "C" fn HTLCDescriptor_new(mut channel_derivation_parameters_arg: crate::lightning::sign::ChannelDerivationParameters, mut commitment_txid_arg: crate::c_types::ThirtyTwoBytes, mut per_commitment_number_arg: u64, mut per_commitment_point_arg: crate::c_types::PublicKey, mut feerate_per_kw_arg: u32, mut htlc_arg: crate::lightning::ln::chan_utils::HTLCOutputInCommitment, mut preimage_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut counterparty_sig_arg: crate::c_types::ECDSASignature) -> HTLCDescriptor { + let mut local_preimage_arg = { /*preimage_arg*/ let preimage_arg_opt = preimage_arg; if preimage_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentPreimage({ preimage_arg_opt.take() }.data) }})} }; + HTLCDescriptor { inner: ObjOps::heap_alloc(nativeHTLCDescriptor { + channel_derivation_parameters: *unsafe { Box::from_raw(channel_derivation_parameters_arg.take_inner()) }, + commitment_txid: ::bitcoin::hash_types::Txid::from_slice(&commitment_txid_arg.data[..]).unwrap(), + per_commitment_number: per_commitment_number_arg, + per_commitment_point: per_commitment_point_arg.into_rust(), + feerate_per_kw: feerate_per_kw_arg, + htlc: *unsafe { Box::from_raw(htlc_arg.take_inner()) }, + preimage: local_preimage_arg, + counterparty_sig: counterparty_sig_arg.into_rust(), + }), is_owned: true } +} impl Clone for HTLCDescriptor { fn clone(&self) -> Self { Self { @@ -1085,7 +1175,7 @@ pub extern "C" fn HTLCDescriptor_write(obj: &crate::lightning::sign::HTLCDescrip } #[allow(unused)] pub(crate) extern "C" fn HTLCDescriptor_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHTLCDescriptor) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeHTLCDescriptor) }) } #[no_mangle] /// Read a HTLCDescriptor from a byte array, created by HTLCDescriptor_write @@ -1143,20 +1233,24 @@ pub extern "C" fn HTLCDescriptor_witness_script(this_arg: &crate::lightning::sig #[must_use] #[no_mangle] pub extern "C" fn HTLCDescriptor_tx_input_witness(this_arg: &crate::lightning::sign::HTLCDescriptor, mut signature: crate::c_types::ECDSASignature, mut witness_script: crate::c_types::u8slice) -> crate::c_types::Witness { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), ::bitcoin::blockdata::script::Script::from_bytes(witness_script.to_slice())); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tx_input_witness(&signature.into_rust(), ::bitcoin::script::Script::from_bytes(witness_script.to_slice())); crate::c_types::Witness::from_bitcoin(&ret) } /// Derives the channel signer required to sign the HTLC input. #[must_use] #[no_mangle] -pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::sign::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { +pub extern "C" fn HTLCDescriptor_derive_channel_signer(this_arg: &crate::lightning::sign::HTLCDescriptor, signer_provider: &crate::lightning::sign::SignerProvider) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.derive_channel_signer(signer_provider); Into::into(ret) } /// A trait to handle Lightning channel key material without concretizing the channel type or /// the signature mechanism. +/// +/// Several methods allow error types to be returned to support async signing. This feature +/// is not yet complete, and panics may occur in certain situations when returning errors +/// for these methods. #[repr(C)] pub struct ChannelSigner { /// An opaque pointer which is passed to your function implementations as an argument. @@ -1165,7 +1259,12 @@ pub struct ChannelSigner { /// Gets the per-commitment point for a specific commitment number /// /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::PublicKey, + /// + /// If the signer returns `Err`, then the user is responsible for either force-closing the channel + /// or calling `ChannelManager::signer_unblocked` (this method is only available when the + /// `async_signing` cfg flag is enabled) once the signature is ready. + /// + pub get_per_commitment_point: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::derived::CResult_PublicKeyNoneZ, /// Gets the commitment secret for a specific commitment number as part of the revocation process /// /// An external signer implementation should error here if the commitment was already signed @@ -1174,7 +1273,7 @@ pub struct ChannelSigner { /// May be called more than once for the same index. /// /// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards. - pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::ThirtyTwoBytes, + pub release_commitment_secret: extern "C" fn (this_arg: *const c_void, idx: u64) -> crate::c_types::derived::CResult__u832NoneZ, /// Validate the counterparty's signatures on the holder commitment transaction and HTLCs. /// /// This is required in order for the signer to make sure that releasing a commitment @@ -1238,15 +1337,17 @@ pub(crate) fn ChannelSigner_clone_fields(orig: &ChannelSigner) -> ChannelSigner use lightning::sign::ChannelSigner as rustChannelSigner; impl rustChannelSigner for ChannelSigner { - fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> bitcoin::secp256k1::PublicKey { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { let mut ret = (self.get_per_commitment_point)(self.this_arg, idx); - ret.into_rust() + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret } - fn release_commitment_secret(&self, mut idx: u64) -> [u8; 32] { + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { let mut ret = (self.release_commitment_secret)(self.this_arg, idx); - ret.data + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret } - fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; let mut ret = (self.validate_holder_commitment)(self.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_outbound_htlc_preimages.into()); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; @@ -1272,17 +1373,55 @@ impl rustChannelSigner for ChannelSigner { } } +pub struct ChannelSignerRef(ChannelSigner); +impl rustChannelSigner for ChannelSignerRef { + fn get_per_commitment_point(&self, mut idx: u64, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut ret = (self.0.get_per_commitment_point)(self.0.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn release_commitment_secret(&self, mut idx: u64) -> Result<[u8; 32], ()> { + let mut ret = (self.0.release_commitment_secret)(self.0.this_arg, idx); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_holder_commitment(&self, mut holder_tx: &lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: Vec) -> Result<(), ()> { + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.drain(..) { local_outbound_htlc_preimages.push( { crate::c_types::ThirtyTwoBytes { data: item.0 } }); }; + let mut ret = (self.0.validate_holder_commitment)(self.0.this_arg, &crate::lightning::ln::chan_utils::HolderCommitmentTransaction { inner: unsafe { ObjOps::nonnull_ptr_to_inner((holder_tx as *const lightning::ln::chan_utils::HolderCommitmentTransaction<>) as *mut _) }, is_owned: false }, local_outbound_htlc_preimages.into()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn validate_counterparty_revocation(&self, mut idx: u64, mut secret: &bitcoin::secp256k1::SecretKey) -> Result<(), ()> { + let mut ret = (self.0.validate_counterparty_revocation)(self.0.this_arg, idx, secret.as_ref()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn pubkeys(&self) -> &lightning::ln::chan_utils::ChannelPublicKeys { + if let Some(f) = self.0.set_pubkeys { + (f)(&self.0); + } + unsafe { &*self.0.pubkeys.get() }.get_native_ref() + } + fn channel_keys_id(&self) -> [u8; 32] { + let mut ret = (self.0.channel_keys_id)(self.0.this_arg); + ret.data + } + fn provide_channel_parameters(&mut self, mut channel_parameters: &lightning::ln::chan_utils::ChannelTransactionParameters) { + (self.0.provide_channel_parameters)(self.0.this_arg, &crate::lightning::ln::chan_utils::ChannelTransactionParameters { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_parameters as *const lightning::ln::chan_utils::ChannelTransactionParameters<>) as *mut _) }, is_owned: false }) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for ChannelSigner { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = ChannelSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChannelSignerRef) } } } impl core::ops::DerefMut for ChannelSigner { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut ChannelSignerRef { + unsafe { &mut *(self as *mut _ as *mut ChannelSignerRef) } } } /// Calls the free function if one is set @@ -1400,17 +1539,25 @@ impl rustEntropySource for EntropySource { } } +pub struct EntropySourceRef(EntropySource); +impl rustEntropySource for EntropySourceRef { + fn get_secure_random_bytes(&self) -> [u8; 32] { + let mut ret = (self.0.get_secure_random_bytes)(self.0.this_arg); + ret.data + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for EntropySource { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = EntropySourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const EntropySourceRef) } } } impl core::ops::DerefMut for EntropySource { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut EntropySourceRef { + unsafe { &mut *(self as *mut _ as *mut EntropySourceRef) } } } /// Calls the free function if one is set @@ -1466,7 +1613,7 @@ pub struct NodeSigner { /// The secret key used to sign the invoice is dependent on the [`Recipient`]. /// /// Errors if the [`Recipient`] variant is not supported by the implementation. - pub sign_invoice: extern "C" fn (this_arg: *const c_void, hrp_bytes: crate::c_types::u8slice, invoice_data: crate::c_types::derived::CVec_U5Z, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, + pub sign_invoice: extern "C" fn (this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ, /// Signs the [`TaggedHash`] of a BOLT 12 invoice request. /// /// May be called by a function passed to [`UnsignedInvoiceRequest::sign`] where @@ -1536,10 +1683,8 @@ impl rustNodeSigner for NodeSigner { let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } - fn sign_invoice(&self, mut hrp_bytes: &[u8], mut invoice_data: &[bitcoin::bech32::u5], mut recipient: lightning::sign::Recipient) -> Result { - let mut local_hrp_bytes = crate::c_types::u8slice::from_slice(hrp_bytes); - let mut local_invoice_data_clone = Vec::new(); local_invoice_data_clone.extend_from_slice(invoice_data); let mut invoice_data = local_invoice_data_clone; let mut local_invoice_data = Vec::new(); for mut item in invoice_data.drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = (self.sign_invoice)(self.this_arg, local_hrp_bytes, local_invoice_data.into(), crate::lightning::sign::Recipient::native_into(recipient)); + fn sign_invoice(&self, mut invoice: &lightning_invoice::RawBolt11Invoice, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.sign_invoice)(self.this_arg, &crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false }, crate::lightning::sign::Recipient::native_into(recipient)); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } @@ -1560,17 +1705,56 @@ impl rustNodeSigner for NodeSigner { } } +pub struct NodeSignerRef(NodeSigner); +impl rustNodeSigner for NodeSignerRef { + fn get_inbound_payment_key_material(&self) -> lightning::sign::KeyMaterial { + let mut ret = (self.0.get_inbound_payment_key_material)(self.0.this_arg); + ::lightning::sign::KeyMaterial(ret.data) + } + fn get_node_id(&self, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.0.get_node_id)(self.0.this_arg, crate::lightning::sign::Recipient::native_into(recipient)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn ecdh(&self, mut recipient: lightning::sign::Recipient, mut other_key: &bitcoin::secp256k1::PublicKey, mut tweak: Option<&bitcoin::secp256k1::Scalar>) -> Result { + let mut local_tweak = if tweak.is_none() { crate::c_types::derived::COption_BigEndianScalarZ::None } else { crate::c_types::derived::COption_BigEndianScalarZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::BigEndianScalar::from_rust(&(*tweak.as_ref().unwrap()).clone()) }) }; + let mut ret = (self.0.ecdh)(self.0.this_arg, crate::lightning::sign::Recipient::native_into(recipient), crate::c_types::PublicKey::from_rust(&other_key), local_tweak); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).data) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_invoice(&self, mut invoice: &lightning_invoice::RawBolt11Invoice, mut recipient: lightning::sign::Recipient) -> Result { + let mut ret = (self.0.sign_invoice)(self.0.this_arg, &crate::lightning_invoice::RawBolt11Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning_invoice::RawBolt11Invoice<>) as *mut _) }, is_owned: false }, crate::lightning::sign::Recipient::native_into(recipient)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_bolt12_invoice_request(&self, mut invoice_request: &lightning::offers::invoice_request::UnsignedInvoiceRequest) -> Result { + let mut ret = (self.0.sign_bolt12_invoice_request)(self.0.this_arg, &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice_request as *const lightning::offers::invoice_request::UnsignedInvoiceRequest<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_bolt12_invoice(&self, mut invoice: &lightning::offers::invoice::UnsignedBolt12Invoice) -> Result { + let mut ret = (self.0.sign_bolt12_invoice)(self.0.this_arg, &crate::lightning::offers::invoice::UnsignedBolt12Invoice { inner: unsafe { ObjOps::nonnull_ptr_to_inner((invoice as *const lightning::offers::invoice::UnsignedBolt12Invoice<>) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn sign_gossip_message(&self, mut msg: lightning::ln::msgs::UnsignedGossipMessage) -> Result { + let mut ret = (self.0.sign_gossip_message)(self.0.this_arg, crate::lightning::ln::msgs::UnsignedGossipMessage::native_into(msg)); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for NodeSigner { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = NodeSignerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const NodeSignerRef) } } } impl core::ops::DerefMut for NodeSigner { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut NodeSignerRef { + unsafe { &mut *(self as *mut _ as *mut NodeSignerRef) } } } /// Calls the free function if one is set @@ -1583,6 +1767,88 @@ impl Drop for NodeSigner { } } } +/// A trait that describes a wallet capable of creating a spending [`Transaction`] from a set of +/// [`SpendableOutputDescriptor`]s. +#[repr(C)] +pub struct OutputSpender { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an + /// output to the given change destination (if sufficient change value remains). The + /// transaction will have a feerate, at least, of the given value. + /// + /// The `locktime` argument is used to set the transaction's locktime. If `None`, the + /// transaction will have a locktime of 0. It it recommended to set this to the current block + /// height to avoid fee sniping, unless you have some specific reason to use a different + /// locktime. + /// + /// Returns `Err(())` if the output value is greater than the input value minus required fee, + /// if a descriptor was duplicated, or if an output descriptor `script_pubkey` + /// does not match the one we can spend. + pub spend_spendable_outputs: extern "C" fn (this_arg: *const c_void, descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, outputs: crate::c_types::derived::CVec_TxOutZ, change_destination_script: crate::c_types::derived::CVec_u8Z, feerate_sat_per_1000_weight: u32, locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for OutputSpender {} +unsafe impl Sync for OutputSpender {} +#[allow(unused)] +pub(crate) fn OutputSpender_clone_fields(orig: &OutputSpender) -> OutputSpender { + OutputSpender { + this_arg: orig.this_arg, + spend_spendable_outputs: Clone::clone(&orig.spend_spendable_outputs), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::OutputSpender as rustOutputSpender; +impl rustOutputSpender for OutputSpender { + fn spend_spendable_outputs(&self, mut descriptors: &[&lightning::sign::SpendableOutputDescriptor], mut outputs: Vec, mut change_destination_script: bitcoin::script::ScriptBuf, mut feerate_sat_per_1000_weight: u32, mut locktime: Option, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_descriptors = Vec::new(); for item in descriptors.iter() { local_descriptors.push( { crate::lightning::sign::SpendableOutputDescriptor::from_native((*item)) }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::c_types::TxOut::from_rust(&item) }); }; + let mut local_locktime = if locktime.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { locktime.unwrap().to_consensus_u32() }) }; + let mut ret = (self.spend_spendable_outputs)(self.this_arg, local_descriptors.into(), local_outputs.into(), change_destination_script.to_bytes().into(), feerate_sat_per_1000_weight, local_locktime); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct OutputSpenderRef(OutputSpender); +impl rustOutputSpender for OutputSpenderRef { + fn spend_spendable_outputs(&self, mut descriptors: &[&lightning::sign::SpendableOutputDescriptor], mut outputs: Vec, mut change_destination_script: bitcoin::script::ScriptBuf, mut feerate_sat_per_1000_weight: u32, mut locktime: Option, mut _secp_ctx: &bitcoin::secp256k1::Secp256k1) -> Result { + let mut local_descriptors = Vec::new(); for item in descriptors.iter() { local_descriptors.push( { crate::lightning::sign::SpendableOutputDescriptor::from_native((*item)) }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.drain(..) { local_outputs.push( { crate::c_types::TxOut::from_rust(&item) }); }; + let mut local_locktime = if locktime.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { locktime.unwrap().to_consensus_u32() }) }; + let mut ret = (self.0.spend_spendable_outputs)(self.0.this_arg, local_descriptors.into(), local_outputs.into(), change_destination_script.to_bytes().into(), feerate_sat_per_1000_weight, local_locktime); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_bitcoin() }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for OutputSpender { + type Target = OutputSpenderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const OutputSpenderRef) } + } +} +impl core::ops::DerefMut for OutputSpender { + fn deref_mut(&mut self) -> &mut OutputSpenderRef { + unsafe { &mut *(self as *mut _ as *mut OutputSpenderRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn OutputSpender_free(this_ptr: OutputSpender) { } +impl Drop for OutputSpender { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} /// A trait that can return signer instances for individual channels. #[repr(C)] pub struct SignerProvider { @@ -1602,10 +1868,10 @@ pub struct SignerProvider { /// [`SignerProvider::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be /// re-derived from its `channel_keys_id`, which can be obtained through its trait method /// [`ChannelSigner::channel_keys_id`]. - pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner, + pub derive_channel_signer: extern "C" fn (this_arg: *const c_void, channel_value_satoshis: u64, channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner, /// Reads a [`Signer`] for this [`SignerProvider`] from the given input stream. /// This is only called during deserialization of other objects which contain - /// [`WriteableEcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). + /// [`EcdsaChannelSigner`]-implementing objects (i.e., [`ChannelMonitor`]s and [`ChannelManager`]s). /// The bytes are exactly those which `::write()` writes, and /// contain no versioning scheme. You may wish to include your own version prefix and ensure /// you've read all of the provided bytes to ensure no corruption occurred. @@ -1616,7 +1882,7 @@ pub struct SignerProvider { /// [`Signer`]: Self::EcdsaSigner /// [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager - pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ, + pub read_chan_signer: extern "C" fn (this_arg: *const c_void, reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ, /// Get a script pubkey which we send funds to when claiming on-chain contestable outputs. /// /// If this function returns an error, this will result in a channel failing to open. @@ -1655,24 +1921,24 @@ pub(crate) fn SignerProvider_clone_fields(orig: &SignerProvider) -> SignerProvid use lightning::sign::SignerProvider as rustSignerProvider; impl rustSignerProvider for SignerProvider { - type EcdsaSigner = crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner; + type EcdsaSigner = crate::lightning::sign::ecdsa::EcdsaChannelSigner; fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] { let mut ret = (self.generate_channel_keys_id)(self.this_arg, inbound, channel_value_satoshis, user_channel_id.into()); ret.data } - fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { + fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { let mut ret = (self.derive_channel_signer)(self.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); ret } - fn read_chan_signer(&self, mut reader: &[u8]) -> Result { + fn read_chan_signer(&self, mut reader: &[u8]) -> Result { let mut local_reader = crate::c_types::u8slice::from_slice(reader); let mut ret = (self.read_chan_signer)(self.this_arg, local_reader); let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; local_ret } - fn get_destination_script(&self, mut channel_keys_id: [u8; 32]) -> Result { + fn get_destination_script(&self, mut channel_keys_id: [u8; 32]) -> Result { let mut ret = (self.get_destination_script)(self.this_arg, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); - let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::blockdata::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; local_ret } fn get_shutdown_scriptpubkey(&self) -> Result { @@ -1682,17 +1948,46 @@ impl rustSignerProvider for SignerProvider { } } +pub struct SignerProviderRef(SignerProvider); +impl rustSignerProvider for SignerProviderRef { + type EcdsaSigner = crate::lightning::sign::ecdsa::EcdsaChannelSigner; + fn generate_channel_keys_id(&self, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: u128) -> [u8; 32] { + let mut ret = (self.0.generate_channel_keys_id)(self.0.this_arg, inbound, channel_value_satoshis, user_channel_id.into()); + ret.data + } + fn derive_channel_signer(&self, mut channel_value_satoshis: u64, mut channel_keys_id: [u8; 32]) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { + let mut ret = (self.0.derive_channel_signer)(self.0.this_arg, channel_value_satoshis, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); + ret + } + fn read_chan_signer(&self, mut reader: &[u8]) -> Result { + let mut local_reader = crate::c_types::u8slice::from_slice(reader); + let mut ret = (self.0.read_chan_signer)(self.0.this_arg, local_reader); + let mut local_ret = match ret.result_ok { true => Ok( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }) }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })}; + local_ret + } + fn get_destination_script(&self, mut channel_keys_id: [u8; 32]) -> Result { + let mut ret = (self.0.get_destination_script)(self.0.this_arg, crate::c_types::ThirtyTwoBytes { data: channel_keys_id }); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } + fn get_shutdown_scriptpubkey(&self) -> Result { + let mut ret = (self.0.get_shutdown_scriptpubkey)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).take_inner()) } }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for SignerProvider { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = SignerProviderRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const SignerProviderRef) } } } impl core::ops::DerefMut for SignerProvider { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut SignerProviderRef { + unsafe { &mut *(self as *mut _ as *mut SignerProviderRef) } } } /// Calls the free function if one is set @@ -1705,11 +2000,80 @@ impl Drop for SignerProvider { } } } +/// A helper trait that describes an on-chain wallet capable of returning a (change) destination +/// script. +#[repr(C)] +pub struct ChangeDestinationSource { + /// An opaque pointer which is passed to your function implementations as an argument. + /// This has no meaning in the LDK, and can be NULL or any other value. + pub this_arg: *mut c_void, + /// Returns a script pubkey which can be used as a change destination for + /// [`OutputSpender::spend_spendable_outputs`]. + /// + /// This method should return a different value each time it is called, to avoid linking + /// on-chain funds controlled to the same user. + pub get_change_destination_script: extern "C" fn (this_arg: *const c_void) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ, + /// Frees any resources associated with this object given its this_arg pointer. + /// Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. + pub free: Option, +} +unsafe impl Send for ChangeDestinationSource {} +unsafe impl Sync for ChangeDestinationSource {} +#[allow(unused)] +pub(crate) fn ChangeDestinationSource_clone_fields(orig: &ChangeDestinationSource) -> ChangeDestinationSource { + ChangeDestinationSource { + this_arg: orig.this_arg, + get_change_destination_script: Clone::clone(&orig.get_change_destination_script), + free: Clone::clone(&orig.free), + } +} + +use lightning::sign::ChangeDestinationSource as rustChangeDestinationSource; +impl rustChangeDestinationSource for ChangeDestinationSource { + fn get_change_destination_script(&self) -> Result { + let mut ret = (self.get_change_destination_script)(self.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +pub struct ChangeDestinationSourceRef(ChangeDestinationSource); +impl rustChangeDestinationSource for ChangeDestinationSourceRef { + fn get_change_destination_script(&self) -> Result { + let mut ret = (self.0.get_change_destination_script)(self.0.this_arg); + let mut local_ret = match ret.result_ok { true => Ok( { ::bitcoin::script::ScriptBuf::from((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust()) }), false => Err( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) })*/ })}; + local_ret + } +} + +// We're essentially a pointer already, or at least a set of pointers, so allow us to be used +// directly as a Deref trait in higher-level structs: +impl core::ops::Deref for ChangeDestinationSource { + type Target = ChangeDestinationSourceRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const ChangeDestinationSourceRef) } + } +} +impl core::ops::DerefMut for ChangeDestinationSource { + fn deref_mut(&mut self) -> &mut ChangeDestinationSourceRef { + unsafe { &mut *(self as *mut _ as *mut ChangeDestinationSourceRef) } + } +} +/// Calls the free function if one is set +#[no_mangle] +pub extern "C" fn ChangeDestinationSource_free(this_ptr: ChangeDestinationSource) { } +impl Drop for ChangeDestinationSource { + fn drop(&mut self) { + if let Some(f) = self.free { + f(self.this_arg); + } + } +} use lightning::sign::InMemorySigner as nativeInMemorySignerImport; pub(crate) type nativeInMemorySigner = nativeInMemorySignerImport; -/// A simple implementation of [`WriteableEcdsaChannelSigner`] that just keeps the private keys in memory. +/// A simple implementation of [`EcdsaChannelSigner`] that just keeps the private keys in memory. /// /// This implementation performs no policy checks and is insufficient by itself as /// a secure external signer. @@ -1728,6 +2092,12 @@ pub struct InMemorySigner { pub is_owned: bool, } +impl core::ops::Deref for InMemorySigner { + type Target = nativeInMemorySigner; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InMemorySigner { } +unsafe impl core::marker::Sync for InMemorySigner { } impl Drop for InMemorySigner { fn drop(&mut self) { if self.is_owned && !<*mut nativeInMemorySigner>::is_null(self.inner) { @@ -1758,6 +2128,9 @@ impl InMemorySigner { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the /// holder's anchor output in a commitment transaction, if one is present. @@ -1949,9 +2322,9 @@ pub extern "C" fn InMemorySigner_get_channel_parameters(this_arg: &crate::lightn /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning::ln::features::ChannelTypeFeatures { +pub extern "C" fn InMemorySigner_channel_type_features(this_arg: &crate::lightning::sign::InMemorySigner) -> crate::lightning_types::features::ChannelTypeFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.channel_type_features(); - let mut local_ret = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::ChannelTypeFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2012,7 +2385,7 @@ pub extern "C" fn InMemorySigner_as_EntropySource(this_arg: &InMemorySigner) -> #[must_use] extern "C" fn InMemorySigner_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + let mut ret = ::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); crate::c_types::ThirtyTwoBytes { data: ret } } @@ -2046,47 +2419,49 @@ pub extern "C" fn InMemorySigner_as_ChannelSigner(this_arg: &InMemorySigner) -> } #[must_use] -extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::PublicKey { - let mut ret = >::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1); - crate::c_types::PublicKey::from_rust(&ret) +extern "C" fn InMemorySigner_ChannelSigner_get_per_commitment_point(this_arg: *const c_void, mut idx: u64) -> crate::c_types::derived::CResult_PublicKeyNoneZ { + let mut ret = ::get_per_commitment_point(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret } #[must_use] -extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); - crate::c_types::ThirtyTwoBytes { data: ret } +extern "C" fn InMemorySigner_ChannelSigner_release_commitment_secret(this_arg: *const c_void, mut idx: u64) -> crate::c_types::derived::CResult__u832NoneZ { + let mut ret = ::release_commitment_secret(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret } #[must_use] extern "C" fn InMemorySigner_ChannelSigner_validate_holder_commitment(this_arg: *const c_void, holder_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction, mut outbound_htlc_preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.into_rust().drain(..) { local_outbound_htlc_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_outbound_htlc_preimages); + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.into_rust().drain(..) { local_outbound_htlc_preimages.push( { ::lightning::ln::types::PaymentPreimage(item.data) }); }; + let mut ret = ::validate_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, holder_tx.get_native_ref(), local_outbound_htlc_preimages); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_ChannelSigner_validate_counterparty_revocation(this_arg: *const c_void, mut idx: u64, secret: *const [u8; 32]) -> crate::c_types::derived::CResult_NoneNoneZ { - let mut ret = >::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap()); + let mut ret = ::validate_counterparty_revocation(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, idx, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *secret}[..]).unwrap()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_ChannelSigner_pubkeys(this_arg: *const c_void) -> crate::lightning::ln::chan_utils::ChannelPublicKeys { - let mut ret = >::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + let mut ret = ::pubkeys(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning::ln::chan_utils::ChannelPublicKeys<>) as *mut _) }, is_owned: false } } -extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &ChannelSigner) { +extern "C" fn InMemorySigner_ChannelSigner_set_pubkeys(trait_self_arg: &crate::lightning::sign::ChannelSigner) { // This is a bit race-y in the general case, but for our specific use-cases today, we're safe // Specifically, we must ensure that the first time we're called it can never be in parallel if unsafe { &*trait_self_arg.pubkeys.get() }.inner.is_null() { - *unsafe { &mut *(&*(trait_self_arg as *const ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); + *unsafe { &mut *(&*(trait_self_arg as *const crate::lightning::sign::ChannelSigner)).pubkeys.get() } = InMemorySigner_ChannelSigner_pubkeys(trait_self_arg.this_arg).into(); } } #[must_use] extern "C" fn InMemorySigner_ChannelSigner_channel_keys_id(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); + let mut ret = ::channel_keys_id(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, ); crate::c_types::ThirtyTwoBytes { data: ret } } extern "C" fn InMemorySigner_ChannelSigner_provide_channel_parameters(this_arg: *mut c_void, channel_parameters: &crate::lightning::ln::chan_utils::ChannelTransactionParameters) { - >::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref()) + ::provide_channel_parameters(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, channel_parameters.get_native_ref()) } impl From for crate::lightning::sign::ecdsa::EcdsaChannelSigner { @@ -2128,121 +2503,71 @@ pub extern "C" fn InMemorySigner_as_EcdsaChannelSigner(this_arg: &InMemorySigner channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, }, + cloned: Some(EcdsaChannelSigner_InMemorySigner_cloned), } } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::CommitmentTransaction, mut inbound_htlc_preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ, mut outbound_htlc_preimages: crate::c_types::derived::CVec_ThirtyTwoBytesZ) -> crate::c_types::derived::CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ { - let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.into_rust().drain(..) { local_inbound_htlc_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.into_rust().drain(..) { local_outbound_htlc_preimages.push( { ::lightning::ln::PaymentPreimage(item.data) }); }; - let mut ret = >::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_inbound_htlc_preimages, local_outbound_htlc_preimages, secp256k1::global::SECP256K1); + let mut local_inbound_htlc_preimages = Vec::new(); for mut item in inbound_htlc_preimages.into_rust().drain(..) { local_inbound_htlc_preimages.push( { ::lightning::ln::types::PaymentPreimage(item.data) }); }; + let mut local_outbound_htlc_preimages = Vec::new(); for mut item in outbound_htlc_preimages.into_rust().drain(..) { local_outbound_htlc_preimages.push( { ::lightning::ln::types::PaymentPreimage(item.data) }); }; + let mut ret = ::sign_counterparty_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), local_inbound_htlc_preimages, local_outbound_htlc_preimages, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_orig_ret_0_1 = Vec::new(); for mut item in orig_ret_0_1.drain(..) { local_orig_ret_0_1.push( { crate::c_types::ECDSASignature::from_rust(&item) }); }; let mut local_ret_0 = (crate::c_types::ECDSASignature::from_rust(&orig_ret_0_0), local_orig_ret_0_1.into()).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_commitment(this_arg: *const c_void, commitment_tx: &crate::lightning::ln::chan_utils::HolderCommitmentTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_holder_commitment(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, commitment_tx.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32]) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1); + let mut ret = ::sign_justice_revoked_output(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc(this_arg: *const c_void, mut justice_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, per_commitment_key: *const [u8; 32], htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_justice_revoked_htlc(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &justice_tx.into_bitcoin(), input, amount, &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *per_commitment_key}[..]).unwrap(), htlc.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, htlc_descriptor: &crate::lightning::sign::HTLCDescriptor) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_holder_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, htlc_descriptor.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_holder_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, htlc_descriptor.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction(this_arg: *const c_void, mut htlc_tx: crate::c_types::Transaction, mut input: usize, mut amount: u64, mut per_commitment_point: crate::c_types::PublicKey, htlc: &crate::lightning::ln::chan_utils::HTLCOutputInCommitment) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_counterparty_htlc_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &htlc_tx.into_bitcoin(), input, amount, &per_commitment_point.into_rust(), htlc.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_closing_transaction(this_arg: *const c_void, closing_tx: &crate::lightning::ln::chan_utils::ClosingTransaction) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_closing_transaction(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, closing_tx.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input(this_arg: *const c_void, mut anchor_tx: crate::c_types::Transaction, mut input: usize) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1); + let mut ret = ::sign_holder_anchor_input(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, &anchor_tx.into_bitcoin(), input, secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(this_arg: *const c_void, msg: &crate::lightning::ln::msgs::UnsignedChannelAnnouncement) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1); + let mut ret = ::sign_channel_announcement_with_funding_key(unsafe { &mut *(this_arg as *mut nativeInMemorySigner) }, msg.get_native_ref(), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } - -impl From for crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - fn from(obj: nativeInMemorySigner) -> Self { - let rust_obj = crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true }; - let mut ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&rust_obj); - // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn - core::mem::forget(rust_obj); - ret.free = Some(InMemorySigner_free_void); - ret - } -} -/// Constructs a new WriteableEcdsaChannelSigner which calls the relevant methods on this_arg. -/// This copies the `inner` pointer in this_arg and thus the returned WriteableEcdsaChannelSigner must be freed before this_arg is -#[no_mangle] -pub extern "C" fn InMemorySigner_as_WriteableEcdsaChannelSigner(this_arg: &InMemorySigner) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - EcdsaChannelSigner: crate::lightning::sign::ecdsa::EcdsaChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - sign_counterparty_commitment: InMemorySigner_EcdsaChannelSigner_sign_counterparty_commitment, - sign_holder_commitment: InMemorySigner_EcdsaChannelSigner_sign_holder_commitment, - sign_justice_revoked_output: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_output, - sign_justice_revoked_htlc: InMemorySigner_EcdsaChannelSigner_sign_justice_revoked_htlc, - sign_holder_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_holder_htlc_transaction, - sign_counterparty_htlc_transaction: InMemorySigner_EcdsaChannelSigner_sign_counterparty_htlc_transaction, - sign_closing_transaction: InMemorySigner_EcdsaChannelSigner_sign_closing_transaction, - sign_holder_anchor_input: InMemorySigner_EcdsaChannelSigner_sign_holder_anchor_input, - sign_channel_announcement_with_funding_key: InMemorySigner_EcdsaChannelSigner_sign_channel_announcement_with_funding_key, - ChannelSigner: crate::lightning::sign::ChannelSigner { - this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, - free: None, - get_per_commitment_point: InMemorySigner_ChannelSigner_get_per_commitment_point, - release_commitment_secret: InMemorySigner_ChannelSigner_release_commitment_secret, - validate_holder_commitment: InMemorySigner_ChannelSigner_validate_holder_commitment, - validate_counterparty_revocation: InMemorySigner_ChannelSigner_validate_counterparty_revocation, - - pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true }.into(), - set_pubkeys: Some(InMemorySigner_ChannelSigner_set_pubkeys), - channel_keys_id: InMemorySigner_ChannelSigner_channel_keys_id, - provide_channel_parameters: InMemorySigner_ChannelSigner_provide_channel_parameters, - }, - }, - write: InMemorySigner_write_void, - cloned: Some(WriteableEcdsaChannelSigner_InMemorySigner_cloned), - } -} - -extern "C" fn WriteableEcdsaChannelSigner_InMemorySigner_cloned(new_obj: &mut crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner) { +extern "C" fn EcdsaChannelSigner_InMemorySigner_cloned(new_obj: &mut crate::lightning::sign::ecdsa::EcdsaChannelSigner) { new_obj.this_arg = InMemorySigner_clone_void(new_obj.this_arg); new_obj.free = Some(InMemorySigner_free_void); - new_obj.EcdsaChannelSigner.this_arg = new_obj.this_arg; - new_obj.EcdsaChannelSigner.free = None; - new_obj.EcdsaChannelSigner.ChannelSigner.this_arg = new_obj.this_arg; - new_obj.EcdsaChannelSigner.ChannelSigner.free = None; + new_obj.ChannelSigner.this_arg = new_obj.this_arg; + new_obj.ChannelSigner.free = None; } #[no_mangle] @@ -2252,7 +2577,7 @@ pub extern "C" fn InMemorySigner_write(obj: &crate::lightning::sign::InMemorySig } #[allow(unused)] pub(crate) extern "C" fn InMemorySigner_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeInMemorySigner) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::sign::nativeInMemorySigner) }) } #[no_mangle] /// Read a InMemorySigner from a byte array, created by InMemorySigner_write @@ -2294,6 +2619,12 @@ pub struct KeysManager { pub is_owned: bool, } +impl core::ops::Deref for KeysManager { + type Target = nativeKeysManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for KeysManager { } +unsafe impl core::marker::Sync for KeysManager { } impl Drop for KeysManager { fn drop(&mut self) { if self.is_owned && !<*mut nativeKeysManager>::is_null(self.inner) { @@ -2324,6 +2655,9 @@ impl KeysManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a [`KeysManager`] from a 32-byte seed. If the seed is in some way biased (e.g., /// your CSRNG is busted) this may panic (but more importantly, you will possibly lose funds). @@ -2357,7 +2691,7 @@ pub extern "C" fn KeysManager_get_node_secret_key(this_arg: &crate::lightning::s crate::c_types::SecretKey::from_rust(ret) } -/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. +/// Derive an old [`EcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters. #[must_use] #[no_mangle] pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::sign::KeysManager, mut channel_value_satoshis: u64, params: *const [u8; 32]) -> crate::lightning::sign::InMemorySigner { @@ -2365,7 +2699,7 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::s crate::lightning::sign::InMemorySigner { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// Signs the given [`PartiallySignedTransaction`] which spends the given [`SpendableOutputDescriptor`]s. +/// Signs the given [`Psbt`] which spends the given [`SpendableOutputDescriptor`]s. /// The resulting inputs will be finalized and the PSBT will be ready for broadcast if there /// are no other inputs that need signing. /// @@ -2377,39 +2711,11 @@ pub extern "C" fn KeysManager_derive_channel_keys(this_arg: &crate::lightning::s #[no_mangle] pub extern "C" fn KeysManager_sign_spendable_outputs_psbt(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut psbt: crate::c_types::derived::CVec_u8Z) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ { let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], ::bitcoin::psbt::PartiallySignedTransaction::deserialize(psbt.as_slice()).expect("Invalid PSBT format"), secp256k1::global::SECP256K1); + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.sign_spendable_outputs_psbt(&local_descriptors.iter().collect::>()[..], ::bitcoin::Psbt::deserialize(psbt.as_slice()).expect("Invalid PSBT format"), secp256k1::global::SECP256K1); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.serialize().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } -/// Creates a [`Transaction`] which spends the given descriptors to the given outputs, plus an -/// output to the given change destination (if sufficient change value remains). The -/// transaction will have a feerate, at least, of the given value. -/// -/// The `locktime` argument is used to set the transaction's locktime. If `None`, the -/// transaction will have a locktime of 0. It it recommended to set this to the current block -/// height to avoid fee sniping, unless you have some specific reason to use a different -/// locktime. -/// -/// Returns `Err(())` if the output value is greater than the input value minus required fee, -/// if a descriptor was duplicated, or if an output descriptor `script_pubkey` -/// does not match the one we can spend. -/// -/// We do not enforce that outputs meet the dust limit or that any output scripts are standard. -/// -/// May panic if the [`SpendableOutputDescriptor`]s were not generated by channels which used -/// this [`KeysManager`] or one of the [`InMemorySigner`] created by this [`KeysManager`]. -#[must_use] -#[no_mangle] -pub extern "C" fn KeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::KeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - impl From for crate::lightning::sign::EntropySource { fn from(obj: nativeKeysManager) -> Self { let rust_obj = crate::lightning::sign::KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -2433,7 +2739,7 @@ pub extern "C" fn KeysManager_as_EntropySource(this_arg: &KeysManager) -> crate: #[must_use] extern "C" fn KeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + let mut ret = ::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); crate::c_types::ThirtyTwoBytes { data: ret } } @@ -2466,48 +2772,78 @@ pub extern "C" fn KeysManager_as_NodeSigner(this_arg: &KeysManager) -> crate::li #[must_use] extern "C" fn KeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + let mut ret = ::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); crate::c_types::ThirtyTwoBytes { data: ret.0 } } #[must_use] extern "C" fn KeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native()); + let mut ret = ::get_node_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_BigEndianScalarZ) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); + let mut ret = ::ecdh(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); +extern "C" fn KeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut ret = ::sign_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice.get_native_ref(), recipient.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_NodeSigner_sign_bolt12_invoice_request(this_arg: *const c_void, invoice_request: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ { - let mut ret = >::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice_request.get_native_ref()); + let mut ret = ::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice_request.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_NodeSigner_sign_bolt12_invoice(this_arg: *const c_void, invoice: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ { - let mut ret = >::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice.get_native_ref()); + let mut ret = ::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, invoice.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native()); + let mut ret = ::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, msg.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } +impl From for crate::lightning::sign::OutputSpender { + fn from(obj: nativeKeysManager) -> Self { + let rust_obj = crate::lightning::sign::KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = KeysManager_as_OutputSpender(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(KeysManager_free_void); + ret + } +} +/// Constructs a new OutputSpender which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is +#[no_mangle] +pub extern "C" fn KeysManager_as_OutputSpender(this_arg: &KeysManager) -> crate::lightning::sign::OutputSpender { + crate::lightning::sign::OutputSpender { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + spend_spendable_outputs: KeysManager_OutputSpender_spend_spendable_outputs, + } +} + +#[must_use] +extern "C" fn KeysManager_OutputSpender_spend_spendable_outputs(this_arg: *const c_void, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + impl From for crate::lightning::sign::SignerProvider { fn from(obj: nativeKeysManager) -> Self { let rust_obj = crate::lightning::sign::KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -2535,29 +2871,29 @@ pub extern "C" fn KeysManager_as_SignerProvider(this_arg: &KeysManager) -> crate #[must_use] extern "C" fn KeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); + let mut ret = ::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data); +extern "C" fn KeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { + let mut ret = ::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_value_satoshis, channel_keys_id.data); Into::into(ret) } #[must_use] -extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); +extern "C" fn KeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ { + let mut ret = ::read_chan_signer(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, reader.to_slice()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_SignerProvider_get_destination_script(this_arg: *const c_void, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_keys_id.data); + let mut ret = ::get_destination_script(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, channel_keys_id.data); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.to_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn KeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); + let mut ret = ::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativeKeysManager) }, ); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -2596,6 +2932,12 @@ pub struct PhantomKeysManager { pub is_owned: bool, } +impl core::ops::Deref for PhantomKeysManager { + type Target = nativePhantomKeysManager; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PhantomKeysManager { } +unsafe impl core::marker::Sync for PhantomKeysManager { } impl Drop for PhantomKeysManager { fn drop(&mut self) { if self.is_owned && !<*mut nativePhantomKeysManager>::is_null(self.inner) { @@ -2626,6 +2968,9 @@ impl PhantomKeysManager { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl From for crate::lightning::sign::EntropySource { fn from(obj: nativePhantomKeysManager) -> Self { @@ -2650,7 +2995,7 @@ pub extern "C" fn PhantomKeysManager_as_EntropySource(this_arg: &PhantomKeysMana #[must_use] extern "C" fn PhantomKeysManager_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + let mut ret = ::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); crate::c_types::ThirtyTwoBytes { data: ret } } @@ -2683,48 +3028,78 @@ pub extern "C" fn PhantomKeysManager_as_NodeSigner(this_arg: &PhantomKeysManager #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_get_inbound_payment_key_material(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + let mut ret = ::get_inbound_payment_key_material(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); crate::c_types::ThirtyTwoBytes { data: ret.0 } } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_get_node_id(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_PublicKeyNoneZ { - let mut ret = >::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native()); + let mut ret = ::get_node_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::PublicKey::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_ecdh(this_arg: *const c_void, mut recipient: crate::lightning::sign::Recipient, mut other_key: crate::c_types::PublicKey, mut tweak: crate::c_types::derived::COption_BigEndianScalarZ) -> crate::c_types::derived::CResult_ThirtyTwoBytesNoneZ { let mut local_tweak_base = { /*tweak*/ let tweak_opt = tweak; if tweak_opt.is_none() { None } else { Some({ { { tweak_opt.take() }.into_rust() }})} }; let mut local_tweak = local_tweak_base.as_ref(); - let mut ret = >::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); + let mut ret = ::ecdh(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, recipient.into_native(), &other_key.into_rust(), local_tweak); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ThirtyTwoBytes { data: o.secret_bytes() } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] -extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, mut hrp_bytes: crate::c_types::u8slice, mut invoice_data: crate::c_types::derived::CVec_U5Z, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { - let mut local_invoice_data = Vec::new(); for mut item in invoice_data.into_rust().drain(..) { local_invoice_data.push( { item.into() }); }; - let mut ret = >::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, hrp_bytes.to_slice(), &local_invoice_data[..], recipient.into_native()); +extern "C" fn PhantomKeysManager_NodeSigner_sign_invoice(this_arg: *const c_void, invoice: &crate::lightning_invoice::RawBolt11Invoice, mut recipient: crate::lightning::sign::Recipient) -> crate::c_types::derived::CResult_RecoverableSignatureNoneZ { + let mut ret = ::sign_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice.get_native_ref(), recipient.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::RecoverableSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_sign_bolt12_invoice_request(this_arg: *const c_void, invoice_request: &crate::lightning::offers::invoice_request::UnsignedInvoiceRequest) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ { - let mut ret = >::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice_request.get_native_ref()); + let mut ret = ::sign_bolt12_invoice_request(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice_request.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_sign_bolt12_invoice(this_arg: *const c_void, invoice: &crate::lightning::offers::invoice::UnsignedBolt12Invoice) -> crate::c_types::derived::CResult_SchnorrSignatureNoneZ { - let mut ret = >::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice.get_native_ref()); + let mut ret = ::sign_bolt12_invoice(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, invoice.get_native_ref()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::SchnorrSignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_NodeSigner_sign_gossip_message(this_arg: *const c_void, mut msg: crate::lightning::ln::msgs::UnsignedGossipMessage) -> crate::c_types::derived::CResult_ECDSASignatureNoneZ { - let mut ret = >::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native()); + let mut ret = ::sign_gossip_message(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, msg.into_native()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::ECDSASignature::from_rust(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } +impl From for crate::lightning::sign::OutputSpender { + fn from(obj: nativePhantomKeysManager) -> Self { + let rust_obj = crate::lightning::sign::PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = PhantomKeysManager_as_OutputSpender(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(PhantomKeysManager_free_void); + ret + } +} +/// Constructs a new OutputSpender which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned OutputSpender must be freed before this_arg is +#[no_mangle] +pub extern "C" fn PhantomKeysManager_as_OutputSpender(this_arg: &PhantomKeysManager) -> crate::lightning::sign::OutputSpender { + crate::lightning::sign::OutputSpender { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + spend_spendable_outputs: PhantomKeysManager_OutputSpender_spend_spendable_outputs, + } +} + +#[must_use] +extern "C" fn PhantomKeysManager_OutputSpender_spend_spendable_outputs(this_arg: *const c_void, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ { + let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; + let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; + let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; + let mut ret = ::spend_spendable_outputs(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, &local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + impl From for crate::lightning::sign::SignerProvider { fn from(obj: nativePhantomKeysManager) -> Self { let rust_obj = crate::lightning::sign::PhantomKeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true }; @@ -2752,29 +3127,29 @@ pub extern "C" fn PhantomKeysManager_as_SignerProvider(this_arg: &PhantomKeysMan #[must_use] extern "C" fn PhantomKeysManager_SignerProvider_generate_channel_keys_id(this_arg: *const c_void, mut inbound: bool, mut channel_value_satoshis: u64, mut user_channel_id: crate::c_types::U128) -> crate::c_types::ThirtyTwoBytes { - let mut ret = >::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); + let mut ret = ::generate_channel_keys_id(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, inbound, channel_value_satoshis, user_channel_id.into()); crate::c_types::ThirtyTwoBytes { data: ret } } #[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::WriteableEcdsaChannelSigner { - let mut ret = >::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data); +extern "C" fn PhantomKeysManager_SignerProvider_derive_channel_signer(this_arg: *const c_void, mut channel_value_satoshis: u64, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::ecdsa::EcdsaChannelSigner { + let mut ret = ::derive_channel_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_value_satoshis, channel_keys_id.data); Into::into(ret) } #[must_use] -extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_WriteableEcdsaChannelSignerDecodeErrorZ { - let mut ret = >::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice()); +extern "C" fn PhantomKeysManager_SignerProvider_read_chan_signer(this_arg: *const c_void, mut reader: crate::c_types::u8slice) -> crate::c_types::derived::CResult_EcdsaChannelSignerDecodeErrorZ { + let mut ret = ::read_chan_signer(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, reader.to_slice()); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { Into::into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_SignerProvider_get_destination_script(this_arg: *const c_void, mut channel_keys_id: crate::c_types::ThirtyTwoBytes) -> crate::c_types::derived::CResult_CVec_u8ZNoneZ { - let mut ret = >::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_keys_id.data); + let mut ret = ::get_destination_script(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, channel_keys_id.data); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.to_bytes().into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } #[must_use] extern "C" fn PhantomKeysManager_SignerProvider_get_shutdown_scriptpubkey(this_arg: *const c_void) -> crate::c_types::derived::CResult_ShutdownScriptNoneZ { - let mut ret = >::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); + let mut ret = ::get_shutdown_scriptpubkey(unsafe { &mut *(this_arg as *mut nativePhantomKeysManager) }, ); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::script::ShutdownScript { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; local_ret } @@ -2797,18 +3172,6 @@ pub extern "C" fn PhantomKeysManager_new(seed: *const [u8; 32], mut starting_tim crate::lightning::sign::PhantomKeysManager { inner: ObjOps::heap_alloc(ret), is_owned: true } } -/// See [`KeysManager::spend_spendable_outputs`] for documentation on this method. -#[must_use] -#[no_mangle] -pub extern "C" fn PhantomKeysManager_spend_spendable_outputs(this_arg: &crate::lightning::sign::PhantomKeysManager, mut descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut outputs: crate::c_types::derived::CVec_TxOutZ, mut change_destination_script: crate::c_types::derived::CVec_u8Z, mut feerate_sat_per_1000_weight: u32, mut locktime: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_TransactionNoneZ { - let mut local_descriptors = Vec::new(); for mut item in descriptors.into_rust().drain(..) { local_descriptors.push( { item.into_native() }); }; - let mut local_outputs = Vec::new(); for mut item in outputs.into_rust().drain(..) { local_outputs.push( { item.into_rust() }); }; - let mut local_locktime = { /*locktime*/ let locktime_opt = locktime; if locktime_opt.is_none() { None } else { Some({ { ::bitcoin::blockdata::locktime::absolute::LockTime::from_consensus({ locktime_opt.take() }) }})} }; - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.spend_spendable_outputs(&local_descriptors.iter().collect::>()[..], local_outputs, ::bitcoin::blockdata::script::ScriptBuf::from(change_destination_script.into_rust()), feerate_sat_per_1000_weight, local_locktime, secp256k1::global::SECP256K1); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::c_types::Transaction::from_bitcoin(&o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - /// See [`KeysManager::derive_channel_keys`] for documentation on this method. #[must_use] #[no_mangle] @@ -2834,3 +3197,101 @@ pub extern "C" fn PhantomKeysManager_get_phantom_node_secret_key(this_arg: &crat crate::c_types::SecretKey::from_rust(ret) } + +use lightning::sign::RandomBytes as nativeRandomBytesImport; +pub(crate) type nativeRandomBytes = nativeRandomBytesImport; + +/// An implementation of [`EntropySource`] using ChaCha20. +#[must_use] +#[repr(C)] +pub struct RandomBytes { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRandomBytes, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RandomBytes { + type Target = nativeRandomBytes; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RandomBytes { } +unsafe impl core::marker::Sync for RandomBytes { } +impl Drop for RandomBytes { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRandomBytes>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RandomBytes, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RandomBytes_free(this_obj: RandomBytes) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RandomBytes_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRandomBytes) }; +} +#[allow(unused)] +impl RandomBytes { + pub(crate) fn get_native_ref(&self) -> &'static nativeRandomBytes { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRandomBytes { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRandomBytes { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Get a string which allows debug introspection of a RandomBytes object +pub extern "C" fn RandomBytes_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::sign::RandomBytes }).into()} +/// Creates a new instance using the given seed. +#[must_use] +#[no_mangle] +pub extern "C" fn RandomBytes_new(mut seed: crate::c_types::ThirtyTwoBytes) -> crate::lightning::sign::RandomBytes { + let mut ret = lightning::sign::RandomBytes::new(seed.data); + crate::lightning::sign::RandomBytes { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::sign::EntropySource { + fn from(obj: nativeRandomBytes) -> Self { + let rust_obj = crate::lightning::sign::RandomBytes { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = RandomBytes_as_EntropySource(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(RandomBytes_free_void); + ret + } +} +/// Constructs a new EntropySource which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned EntropySource must be freed before this_arg is +#[no_mangle] +pub extern "C" fn RandomBytes_as_EntropySource(this_arg: &RandomBytes) -> crate::lightning::sign::EntropySource { + crate::lightning::sign::EntropySource { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + get_secure_random_bytes: RandomBytes_EntropySource_get_secure_random_bytes, + } +} + +#[must_use] +extern "C" fn RandomBytes_EntropySource_get_secure_random_bytes(this_arg: *const c_void) -> crate::c_types::ThirtyTwoBytes { + let mut ret = ::get_secure_random_bytes(unsafe { &mut *(this_arg as *mut nativeRandomBytes) }, ); + crate::c_types::ThirtyTwoBytes { data: ret } +} + diff --git a/lightning-c-bindings/src/lightning/util/config.rs b/lightning-c-bindings/src/lightning/util/config.rs index 3043b3f..5573510 100644 --- a/lightning-c-bindings/src/lightning/util/config.rs +++ b/lightning-c-bindings/src/lightning/util/config.rs @@ -24,7 +24,7 @@ pub(crate) type nativeChannelHandshakeConfig = nativeChannelHandshakeConfigImpor /// Configuration we set when applicable. /// -/// Default::default() provides sane defaults. +/// `Default::default()` provides sane defaults. #[must_use] #[repr(C)] pub struct ChannelHandshakeConfig { @@ -40,6 +40,12 @@ pub struct ChannelHandshakeConfig { pub is_owned: bool, } +impl core::ops::Deref for ChannelHandshakeConfig { + type Target = nativeChannelHandshakeConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelHandshakeConfig { } +unsafe impl core::marker::Sync for ChannelHandshakeConfig { } impl Drop for ChannelHandshakeConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelHandshakeConfig>::is_null(self.inner) { @@ -70,17 +76,20 @@ impl ChannelHandshakeConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Confirmations we will wait for before considering the channel locked in. -/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the +/// Applied only for inbound channels (see [`ChannelHandshakeLimits::max_minimum_depth`] for the /// equivalent limit applied to outbound channels). /// -/// A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment +/// A lower-bound of `1` is applied, requiring all channels to have a confirmed commitment /// transaction before operation. If you wish to accept channels with zero confirmations, see /// [`UserConfig::manually_accept_inbound_channels`] and /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. /// -/// Default value: 6. +/// Default value: `6` /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf @@ -90,15 +99,15 @@ pub extern "C" fn ChannelHandshakeConfig_get_minimum_depth(this_ptr: &ChannelHan *inner_val } /// Confirmations we will wait for before considering the channel locked in. -/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the +/// Applied only for inbound channels (see [`ChannelHandshakeLimits::max_minimum_depth`] for the /// equivalent limit applied to outbound channels). /// -/// A lower-bound of 1 is applied, requiring all channels to have a confirmed commitment +/// A lower-bound of `1` is applied, requiring all channels to have a confirmed commitment /// transaction before operation. If you wish to accept channels with zero confirmations, see /// [`UserConfig::manually_accept_inbound_channels`] and /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]. /// -/// Default value: 6. +/// Default value: `6` /// /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel /// [`ChannelManager::accept_inbound_channel_from_trusted_peer_0conf`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel_from_trusted_peer_0conf @@ -119,8 +128,8 @@ pub extern "C" fn ChannelHandshakeConfig_set_minimum_depth(this_ptr: &mut Channe /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you -/// can tweak config to ask for more security, not less. +/// Default value: [`BREAKDOWN_TIMEOUT`] (We enforce it as a minimum at channel opening so you +/// can tweak config to ask for more security, not less.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_to_self_delay; @@ -139,8 +148,8 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_to_self_delay(this_ptr: &Channe /// case of an honest unilateral channel close, which implicitly decrease the economic value of /// our channel. /// -/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you -/// can tweak config to ask for more security, not less. +/// Default value: [`BREAKDOWN_TIMEOUT`] (We enforce it as a minimum at channel opening so you +/// can tweak config to ask for more security, not less.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_to_self_delay = val; @@ -150,8 +159,8 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_to_self_delay(this_ptr: &mut Ch /// This value is sent to our counterparty on channel-open and we close the channel any time /// our counterparty misbehaves by sending us an HTLC with a value smaller than this. /// -/// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required -/// by the protocol. +/// Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is +/// required by the protocol. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &ChannelHandshakeConfig) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_htlc_minimum_msat; @@ -162,8 +171,8 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_htlc_minimum_msat(this_ptr: &Ch /// This value is sent to our counterparty on channel-open and we close the channel any time /// our counterparty misbehaves by sending us an HTLC with a value smaller than this. /// -/// Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required -/// by the protocol. +/// Default value: `1` (If the value is less than `1`, it is ignored and set to `1`, as is +/// required by the protocol. #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeConfig, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_htlc_minimum_msat = val; @@ -175,22 +184,24 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_htlc_minimum_msat(this_ptr: &mu /// channel value in whole percentages. /// /// Note that: -/// * If configured to another value than the default value 10, any new channels created with -/// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the -/// `ChannelManager`. +/// * If configured to another value than the default value `10`, any new channels created with +/// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the +/// `ChannelManager`. /// /// * This caps the total value for inbound HTLCs in-flight only, and there's currently -/// no way to configure the cap for the total value of outbound HTLCs in-flight. +/// no way to configure the cap for the total value of outbound HTLCs in-flight. /// /// * The requirements for your node being online to ensure the safety of HTLC-encumbered funds -/// are different from the non-HTLC-encumbered funds. This makes this an important knob to -/// restrict exposure to loss due to being offline for too long. -/// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] -/// for more information. +/// are different from the non-HTLC-encumbered funds. This makes this an important knob to +/// restrict exposure to loss due to being offline for too long. +/// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] +/// for more information. +/// +/// Default value: `10` +/// +/// Minimum value: `1` (Any values less will be treated as `1` instead.) /// -/// Default value: 10. -/// Minimum value: 1, any values less than 1 will be treated as 1 instead. -/// Maximum value: 100, any values larger than 100 will be treated as 100 instead. +/// Maximum value: `100` (Any values larger will be treated as `100` instead.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &ChannelHandshakeConfig) -> u8 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_inbound_htlc_value_in_flight_percent_of_channel; @@ -203,22 +214,24 @@ pub extern "C" fn ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_pe /// channel value in whole percentages. /// /// Note that: -/// * If configured to another value than the default value 10, any new channels created with -/// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the -/// `ChannelManager`. +/// * If configured to another value than the default value `10`, any new channels created with +/// the non default value will cause versions of LDK prior to 0.0.104 to refuse to read the +/// `ChannelManager`. /// /// * This caps the total value for inbound HTLCs in-flight only, and there's currently -/// no way to configure the cap for the total value of outbound HTLCs in-flight. +/// no way to configure the cap for the total value of outbound HTLCs in-flight. /// /// * The requirements for your node being online to ensure the safety of HTLC-encumbered funds -/// are different from the non-HTLC-encumbered funds. This makes this an important knob to -/// restrict exposure to loss due to being offline for too long. -/// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] -/// for more information. +/// are different from the non-HTLC-encumbered funds. This makes this an important knob to +/// restrict exposure to loss due to being offline for too long. +/// See [`ChannelHandshakeConfig::our_to_self_delay`] and [`ChannelConfig::cltv_expiry_delta`] +/// for more information. /// -/// Default value: 10. -/// Minimum value: 1, any values less than 1 will be treated as 1 instead. -/// Maximum value: 100, any values larger than 100 will be treated as 100 instead. +/// Default value: `10` +/// +/// Minimum value: `1` (Any values less will be treated as `1` instead.) +/// +/// Maximum value: `100` (Any values larger will be treated as `100` instead.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: u8) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_inbound_htlc_value_in_flight_percent_of_channel = val; @@ -237,10 +250,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_pe /// private channel without that option. /// /// Ignored if the channel is negotiated to be announced, see -/// [`ChannelHandshakeConfig::announced_channel`] and +/// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. /// -/// Default value: false. This value is likely to change to true in the future. +/// Default value: `false` (This value is likely to change to `true` in the future.) /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue @@ -263,10 +276,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_negotiate_scid_privacy(this_ptr: &C /// private channel without that option. /// /// Ignored if the channel is negotiated to be announced, see -/// [`ChannelHandshakeConfig::announced_channel`] and +/// [`ChannelHandshakeConfig::announce_for_forwarding`] and /// [`ChannelHandshakeLimits::force_announced_channel_preference`] for more. /// -/// Default value: false. This value is likely to change to true in the future. +/// Default value: `false` (This value is likely to change to `true` in the future.) /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`DecodeError::InvalidValue`]: crate::ln::msgs::DecodeError::InvalidValue @@ -282,10 +295,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_negotiate_scid_privacy(this_ptr: &m /// As the node which funds a channel picks this value this will only apply for new outbound /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. /// -/// Default value: false. +/// Default value: `false` #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_get_announced_channel(this_ptr: &ChannelHandshakeConfig) -> bool { - let mut inner_val = &mut this_ptr.get_native_mut_ref().announced_channel; +pub extern "C" fn ChannelHandshakeConfig_get_announce_for_forwarding(this_ptr: &ChannelHandshakeConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().announce_for_forwarding; *inner_val } /// Set to announce the channel publicly and notify all nodes that they can route via this @@ -296,10 +309,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_announced_channel(this_ptr: &Channe /// As the node which funds a channel picks this value this will only apply for new outbound /// channels unless [`ChannelHandshakeLimits::force_announced_channel_preference`] is set. /// -/// Default value: false. +/// Default value: `false` #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announced_channel = val; +pub extern "C" fn ChannelHandshakeConfig_set_announce_for_forwarding(this_ptr: &mut ChannelHandshakeConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.announce_for_forwarding = val; } /// When set, we commit to an upfront shutdown_pubkey at channel open. If our counterparty /// supports it, they will then enforce the mutual-close output to us matches what we provided @@ -311,7 +324,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_announced_channel(this_ptr: &mut Ch /// /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. /// -/// Default value: true. +/// Default value: `true` /// /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] @@ -329,7 +342,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(this /// /// The upfront key committed is provided from [`SignerProvider::get_shutdown_scriptpubkey`]. /// -/// Default value: true. +/// Default value: `true` /// /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey #[no_mangle] @@ -353,11 +366,15 @@ pub extern "C" fn ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(this /// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve /// other than the default value. /// -/// Default value: 1% of channel value, i.e., configured as 10,000 millionths. -/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated -/// as 1000 sats instead, which is a safe implementation-specific lower bound. -/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) -/// instead, although channel negotiations will fail in that case. +/// Default value: `10_000` millionths (i.e., 1% of channel value) +/// +/// Minimum value: If the calculated proportional value is less than `1000` sats, it will be +/// treated as `1000` sats instead, which is a safe implementation-specific lower +/// bound. +/// +/// Maximum value: `1_000_000` (i.e., 100% of channel value. Any values larger than one million +/// will be treated as one million instead, although channel negotiations will +/// fail in that case.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(this_ptr: &ChannelHandshakeConfig) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().their_channel_reserve_proportional_millionths; @@ -380,11 +397,15 @@ pub extern "C" fn ChannelHandshakeConfig_get_their_channel_reserve_proportional_ /// Note: Versions of LDK earlier than v0.0.104 will fail to read channels with any channel reserve /// other than the default value. /// -/// Default value: 1% of channel value, i.e., configured as 10,000 millionths. -/// Minimum value: If the calculated proportional value is less than 1000 sats, it will be treated -/// as 1000 sats instead, which is a safe implementation-specific lower bound. -/// Maximum value: 1,000,000, any values larger than 1 Million will be treated as 1 Million (or 100%) -/// instead, although channel negotiations will fail in that case. +/// Default value: `10_000` millionths (i.e., 1% of channel value) +/// +/// Minimum value: If the calculated proportional value is less than `1000` sats, it will be +/// treated as `1000` sats instead, which is a safe implementation-specific lower +/// bound. +/// +/// Maximum value: `1_000_000` (i.e., 100% of channel value. Any values larger than one million +/// will be treated as one million instead, although channel negotiations will +/// fail in that case.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(this_ptr: &mut ChannelHandshakeConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.their_channel_reserve_proportional_millionths = val; @@ -411,7 +432,7 @@ pub extern "C" fn ChannelHandshakeConfig_set_their_channel_reserve_proportional_ /// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee /// Considered Harmful`] mailing list post. /// -/// Default value: false. This value is likely to change to true in the future. +/// Default value: `false` (This value is likely to change to `true` in the future.) /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel @@ -444,7 +465,7 @@ pub extern "C" fn ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx( /// vulnerability after its deployment. For more context, see the [`SIGHASH_SINGLE + update_fee /// Considered Harmful`] mailing list post. /// -/// Default value: false. This value is likely to change to true in the future. +/// Default value: `false` (This value is likely to change to `true` in the future.) /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager /// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel @@ -462,9 +483,10 @@ pub extern "C" fn ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx( /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration /// other than the default value. /// -/// Default value: 50 -/// Maximum value: 483, any values larger will be treated as 483. -/// This is the BOLT #2 spec limit on `max_accepted_htlcs`. +/// Default value: `50` +/// +/// Maximum value: `483` (Any values larger will be treated as `483`. This is the BOLT #2 spec +/// limit on `max_accepted_htlcs`.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &ChannelHandshakeConfig) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().our_max_accepted_htlcs; @@ -478,9 +500,10 @@ pub extern "C" fn ChannelHandshakeConfig_get_our_max_accepted_htlcs(this_ptr: &C /// Note: Versions of LDK earlier than v0.0.115 will fail to read channels with a configuration /// other than the default value. /// -/// Default value: 50 -/// Maximum value: 483, any values larger will be treated as 483. -/// This is the BOLT #2 spec limit on `max_accepted_htlcs`. +/// Default value: `50` +/// +/// Maximum value: `483` (Any values larger will be treated as `483`. This is the BOLT #2 spec +/// limit on `max_accepted_htlcs`.) #[no_mangle] pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeConfig, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.our_max_accepted_htlcs = val; @@ -488,14 +511,14 @@ pub extern "C" fn ChannelHandshakeConfig_set_our_max_accepted_htlcs(this_ptr: &m /// Constructs a new ChannelHandshakeConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announced_channel_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut negotiate_anchors_zero_fee_htlc_tx_arg: bool, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { +pub extern "C" fn ChannelHandshakeConfig_new(mut minimum_depth_arg: u32, mut our_to_self_delay_arg: u16, mut our_htlc_minimum_msat_arg: u64, mut max_inbound_htlc_value_in_flight_percent_of_channel_arg: u8, mut negotiate_scid_privacy_arg: bool, mut announce_for_forwarding_arg: bool, mut commit_upfront_shutdown_pubkey_arg: bool, mut their_channel_reserve_proportional_millionths_arg: u32, mut negotiate_anchors_zero_fee_htlc_tx_arg: bool, mut our_max_accepted_htlcs_arg: u16) -> ChannelHandshakeConfig { ChannelHandshakeConfig { inner: ObjOps::heap_alloc(nativeChannelHandshakeConfig { minimum_depth: minimum_depth_arg, our_to_self_delay: our_to_self_delay_arg, our_htlc_minimum_msat: our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel: max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy: negotiate_scid_privacy_arg, - announced_channel: announced_channel_arg, + announce_for_forwarding: announce_for_forwarding_arg, commit_upfront_shutdown_pubkey: commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths: their_channel_reserve_proportional_millionths_arg, negotiate_anchors_zero_fee_htlc_tx: negotiate_anchors_zero_fee_htlc_tx_arg, @@ -538,7 +561,7 @@ pub(crate) type nativeChannelHandshakeLimits = nativeChannelHandshakeLimitsImpor /// /// These limits are only applied to our counterparty's limits, not our own. /// -/// Use 0/`::max_value()` as appropriate to skip checking. +/// Use `0` or `::max_value()` as appropriate to skip checking. /// /// Provides sane defaults for most configurations. /// @@ -560,6 +583,12 @@ pub struct ChannelHandshakeLimits { pub is_owned: bool, } +impl core::ops::Deref for ChannelHandshakeLimits { + type Target = nativeChannelHandshakeLimits; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelHandshakeLimits { } +unsafe impl core::marker::Sync for ChannelHandshakeLimits { } impl Drop for ChannelHandshakeLimits { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelHandshakeLimits>::is_null(self.inner) { @@ -590,11 +619,15 @@ impl ChannelHandshakeLimits { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 0. +/// Default value: `1000` +/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_funding_satoshis; @@ -603,7 +636,8 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_funding_satoshis(this_ptr: &Cha /// Minimum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 0. +/// Default value: `1000` +/// (Minimum of [`ChannelHandshakeConfig::their_channel_reserve_proportional_millionths`]) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_funding_satoshis = val; @@ -611,7 +645,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_funding_satoshis(this_ptr: &mut /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 2^24 - 1. +/// Default value: `2^24 - 1` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_funding_satoshis; @@ -620,7 +654,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_funding_satoshis(this_ptr: &Cha /// Maximum allowed satoshis when a channel is funded. This is supplied by the sender and so /// only applies to inbound channels. /// -/// Default value: 2^24 - 1. +/// Default value: `2^24 - 1` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_funding_satoshis = val; @@ -628,7 +662,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_funding_satoshis(this_ptr: &mut /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows /// you to limit the maximum minimum-size they can require. /// -/// Default value: u64::max_value. +/// Default value: `u64::max_value` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_htlc_minimum_msat; @@ -637,7 +671,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_htlc_minimum_msat(this_ptr: &Ch /// The remote node sets a limit on the minimum size of HTLCs we can send to them. This allows /// you to limit the maximum minimum-size they can require. /// -/// Default value: u64::max_value. +/// Default value: `u64::max_value` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_htlc_minimum_msat = val; @@ -645,7 +679,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_htlc_minimum_msat(this_ptr: &mu /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_htlc_value_in_flight_msat; @@ -654,7 +688,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(t /// The remote node sets a limit on the maximum value of pending HTLCs to them at any given /// time to limit their funds exposure to HTLCs. This allows you to set a minimum such value. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_htlc_value_in_flight_msat = val; @@ -663,7 +697,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(t /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). /// -/// Default value: u64::max_value. +/// Default value: `u64::max_value`. #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_ptr: &ChannelHandshakeLimits) -> u64 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_channel_reserve_satoshis; @@ -673,7 +707,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_channel_reserve_satoshis(this_p /// time, ensuring that we are able to be punished if we broadcast an old state. This allows to /// you limit the amount which we will have to keep to ourselves (and cannot use for HTLCs). /// -/// Default value: u64::max_value. +/// Default value: `u64::max_value`. #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_ptr: &mut ChannelHandshakeLimits, mut val: u64) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_channel_reserve_satoshis = val; @@ -681,7 +715,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_channel_reserve_satoshis(this_p /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given /// time. This allows you to set a minimum such value. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &ChannelHandshakeLimits) -> u16 { let mut inner_val = &mut this_ptr.get_native_mut_ref().min_max_accepted_htlcs; @@ -690,7 +724,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_min_max_accepted_htlcs(this_ptr: &C /// The remote node sets a limit on the maximum number of pending HTLCs to them at any given /// time. This allows you to set a minimum such value. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.min_max_accepted_htlcs = val; @@ -700,7 +734,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_min_max_accepted_htlcs(this_ptr: &m /// assume they aren't going to double-spend themselves). /// This config allows you to set a limit on the maximum amount of time to wait. /// -/// Default value: 144, or roughly one day and only applies to outbound channels. +/// Default value: `144`, or roughly one day and only applies to outbound channels #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &ChannelHandshakeLimits) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_minimum_depth; @@ -711,7 +745,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_max_minimum_depth(this_ptr: &Channe /// assume they aren't going to double-spend themselves). /// This config allows you to set a limit on the maximum amount of time to wait. /// -/// Default value: 144, or roughly one day and only applies to outbound channels. +/// Default value: `144`, or roughly one day and only applies to outbound channels #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut ChannelHandshakeLimits, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_minimum_depth = val; @@ -727,12 +761,12 @@ pub extern "C" fn ChannelHandshakeLimits_set_max_minimum_depth(this_ptr: &mut Ch /// You may wish to un-set this if you allow the user to (or do in an automated fashion) /// double-spend the funding transaction to RBF with an alternative channel open. /// -/// This only applies if our counterparty set their confirmations-required value to 0, and we -/// always trust our own funding transaction at 1 confirmation irrespective of this value. +/// This only applies if our counterparty set their confirmations-required value to `0`, and we +/// always trust our own funding transaction at `1` confirmation irrespective of this value. /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being -/// `true` (0) and `false` (1). +/// `true` (`0`) and `false` (`1`). /// -/// Default value: true +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: &ChannelHandshakeLimits) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().trust_own_funding_0conf; @@ -749,37 +783,37 @@ pub extern "C" fn ChannelHandshakeLimits_get_trust_own_funding_0conf(this_ptr: & /// You may wish to un-set this if you allow the user to (or do in an automated fashion) /// double-spend the funding transaction to RBF with an alternative channel open. /// -/// This only applies if our counterparty set their confirmations-required value to 0, and we -/// always trust our own funding transaction at 1 confirmation irrespective of this value. +/// This only applies if our counterparty set their confirmations-required value to `0`, and we +/// always trust our own funding transaction at `1` confirmation irrespective of this value. /// Thus, this effectively acts as a `min_minimum_depth`, with the only possible values being -/// `true` (0) and `false` (1). +/// `true` (`0`) and `false` (`1`). /// -/// Default value: true +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_trust_own_funding_0conf(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.trust_own_funding_0conf = val; } /// Set to force an incoming channel to match our announced channel preference in -/// [`ChannelHandshakeConfig::announced_channel`]. +/// [`ChannelHandshakeConfig::announce_for_forwarding`]. /// /// For a node which is not online reliably, this should be set to true and -/// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) +/// [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) /// channels will ever be opened. /// -/// Default value: true. +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_force_announced_channel_preference(this_ptr: &ChannelHandshakeLimits) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().force_announced_channel_preference; *inner_val } /// Set to force an incoming channel to match our announced channel preference in -/// [`ChannelHandshakeConfig::announced_channel`]. +/// [`ChannelHandshakeConfig::announce_for_forwarding`]. /// /// For a node which is not online reliably, this should be set to true and -/// [`ChannelHandshakeConfig::announced_channel`] set to false, ensuring that no announced (aka public) +/// [`ChannelHandshakeConfig::announce_for_forwarding`] set to false, ensuring that no announced (aka public) /// channels will ever be opened. /// -/// Default value: true. +/// Default value: `true` #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference(this_ptr: &mut ChannelHandshakeLimits, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.force_announced_channel_preference = val; @@ -789,7 +823,7 @@ pub extern "C" fn ChannelHandshakeLimits_set_force_announced_channel_preference( /// Not checking this value would be a security issue, as our peer would be able to set it to /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. /// -/// Default value: 2016, which we also enforce as a maximum value so you can tweak config to +/// Default value: `2016`, which we also enforce as a maximum value so you can tweak config to /// reduce the loss of having useless locked funds (if your peer accepts) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &ChannelHandshakeLimits) -> u16 { @@ -801,7 +835,7 @@ pub extern "C" fn ChannelHandshakeLimits_get_their_to_self_delay(this_ptr: &Chan /// Not checking this value would be a security issue, as our peer would be able to set it to /// max relative lock-time (a year) and we would \"lose\" money as it would be locked for a long time. /// -/// Default value: 2016, which we also enforce as a maximum value so you can tweak config to +/// Default value: `2016`, which we also enforce as a maximum value so you can tweak config to /// reduce the loss of having useless locked funds (if your peer accepts) #[no_mangle] pub extern "C" fn ChannelHandshakeLimits_set_their_to_self_delay(this_ptr: &mut ChannelHandshakeLimits, mut val: u16) { @@ -852,7 +886,7 @@ pub extern "C" fn ChannelHandshakeLimits_debug_str_void(o: *const c_void) -> Str pub extern "C" fn ChannelHandshakeLimits_default() -> ChannelHandshakeLimits { ChannelHandshakeLimits { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } } -/// Options for how to set the max dust HTLC exposure allowed on a channel. See +/// Options for how to set the max dust exposure allowed on a channel. See /// [`ChannelConfig::max_dust_htlc_exposure`] for details. #[derive(Clone)] #[must_use] @@ -869,19 +903,17 @@ pub enum MaxDustHTLCExposure { /// exposure and the new minimum value for HTLCs to be economically viable to claim. FixedLimitMsat( u64), - /// This sets a multiplier on the estimated high priority feerate (sats/KW, as obtained from - /// [`FeeEstimator`]) to determine the maximum allowed dust exposure. If this variant is used - /// then the maximum dust exposure in millisatoshis is calculated as: - /// `high_priority_feerate_per_kw * value`. For example, with our default value - /// `FeeRateMultiplier(5000)`: + /// This sets a multiplier on the [`ConfirmationTarget::MaximumFeeEstimate`] feerate (in + /// sats/KW) to determine the maximum allowed dust exposure. If this variant is used then the + /// maximum dust exposure in millisatoshis is calculated as: + /// `feerate_per_kw * value`. For example, with our default value + /// `FeeRateMultiplier(10_000)`: /// /// - For the minimum fee rate of 1 sat/vByte (250 sat/KW, although the minimum - /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would - /// be 253 * 5000 = 1,265,000 msats. + /// defaults to 253 sats/KW for rounding, see [`FeeEstimator`]), the max dust exposure would + /// be 253 * 10_000 = 2,530,000 msats. /// - For a fee rate of 30 sat/vByte (7500 sat/KW), the max dust exposure would be - /// 7500 * 5000 = 37,500,000 msats. - /// - /// This allows the maximum dust exposure to automatically scale with fee rate changes. + /// 7500 * 50_000 = 75,000,000 msats (0.00075 BTC). /// /// Note, if you're using a third-party fee estimator, this may leave you more exposed to a /// fee griefing attack, where your fee estimator may purposely overestimate the fee rate, @@ -896,6 +928,7 @@ pub enum MaxDustHTLCExposure { /// by default this will be set to a [`Self::FixedLimitMsat`] of 5,000,000 msat. /// /// [`FeeEstimator`]: crate::chain::chaininterface::FeeEstimator + /// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate FeeRateMultiplier( u64), } @@ -1043,6 +1076,12 @@ pub struct ChannelConfig { pub is_owned: bool, } +impl core::ops::Deref for ChannelConfig { + type Target = nativeChannelConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelConfig { } +unsafe impl core::marker::Sync for ChannelConfig { } impl Drop for ChannelConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelConfig>::is_null(self.inner) { @@ -1073,13 +1112,16 @@ impl ChannelConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound /// over the channel. /// This may be allowed to change at runtime in a later update, however doing so must result in /// update messages sent to notify all nodes of our updated relay fee. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfig) -> u32 { let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_fee_proportional_millionths; @@ -1090,7 +1132,7 @@ pub extern "C" fn ChannelConfig_get_forwarding_fee_proportional_millionths(this_ /// This may be allowed to change at runtime in a later update, however doing so must result in /// update messages sent to notify all nodes of our updated relay fee. /// -/// Default value: 0. +/// Default value: `0` #[no_mangle] pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ptr: &mut ChannelConfig, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.forwarding_fee_proportional_millionths = val; @@ -1104,7 +1146,7 @@ pub extern "C" fn ChannelConfig_set_forwarding_fee_proportional_millionths(this_ /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through /// this node. /// -/// Default value: 1000. +/// Default value: `1000` /// /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths #[no_mangle] @@ -1121,7 +1163,7 @@ pub extern "C" fn ChannelConfig_get_forwarding_fee_base_msat(this_ptr: &ChannelC /// as of July 2021. Adjusting it upwards or downwards may change whether nodes route through /// this node. /// -/// Default value: 1000. +/// Default value: `1000` /// /// [`forwarding_fee_proportional_millionths`]: ChannelConfig::forwarding_fee_proportional_millionths #[no_mangle] @@ -1142,9 +1184,10 @@ pub extern "C" fn ChannelConfig_set_forwarding_fee_base_msat(this_ptr: &mut Chan /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF /// the spending transaction). /// -/// Default value: 72 (12 hours at an average of 6 blocks/hour). -/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as -/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// Default value: `72` (12 hours at an average of 6 blocks/hour) +/// +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`] (Any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead.) /// /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA #[no_mangle] @@ -1166,22 +1209,26 @@ pub extern "C" fn ChannelConfig_get_cltv_expiry_delta(this_ptr: &ChannelConfig) /// enough time to broadcast and confirm a transaction, possibly with time in between to RBF /// the spending transaction). /// -/// Default value: 72 (12 hours at an average of 6 blocks/hour). -/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`], any values less than this will be treated as -/// [`MIN_CLTV_EXPIRY_DELTA`] instead. +/// Default value: `72` (12 hours at an average of 6 blocks/hour) +/// +/// Minimum value: [`MIN_CLTV_EXPIRY_DELTA`] (Any values less than this will be treated as +/// [`MIN_CLTV_EXPIRY_DELTA`] instead.) /// /// [`MIN_CLTV_EXPIRY_DELTA`]: crate::ln::channelmanager::MIN_CLTV_EXPIRY_DELTA #[no_mangle] pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConfig, mut val: u16) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; } -/// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too -/// small to claim on-chain. +/// Limit our total exposure to potential loss to on-chain fees on close, including in-flight +/// HTLCs which are burned to fees as they are too small to claim on-chain and fees on +/// commitment transaction(s) broadcasted by our counterparty in excess of our own fee estimate. +/// +/// # HTLC-based Dust Exposure /// /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will /// not be claimable on-chain, instead being turned into additional miner fees if either /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure -/// to such payments may be sustantial if there are many dust HTLCs present when the +/// to such payments may be substantial if there are many dust HTLCs present when the /// channel is force-closed. /// /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a @@ -1195,19 +1242,52 @@ pub extern "C" fn ChannelConfig_set_cltv_expiry_delta(this_ptr: &mut ChannelConf /// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total /// exposure across all three types per-channel. /// -/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. +/// # Transaction Fee Dust Exposure +/// +/// Further, counterparties broadcasting a commitment transaction in a force-close may result +/// in other balance being burned to fees, and thus all fees on commitment and HTLC +/// transactions in excess of our local fee estimates are included in the dust calculation. +/// +/// Because of this, another way to look at this limit is to divide it by 43,000 (or 218,750 +/// for non-anchor channels) and see it as the maximum feerate disagreement (in sats/vB) per +/// non-dust HTLC we're allowed to have with our peers before risking a force-closure for +/// inbound channels. +/// +/// Thus, for the default value of 10_000 * a current feerate estimate of 10 sat/vB (or 2,500 +/// sat/KW), we risk force-closure if we disagree with our peer by: +/// * `10_000 * 2_500 / 43_000 / (483*2)` = 0.6 sat/vB for anchor channels with 483 HTLCs in +/// both directions (the maximum), +/// * `10_000 * 2_500 / 43_000 / (50*2)` = 5.8 sat/vB for anchor channels with 50 HTLCs in both +/// directions (the LDK default max from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) +/// * `10_000 * 2_500 / 218_750 / (483*2)` = 0.1 sat/vB for non-anchor channels with 483 HTLCs +/// in both directions (the maximum), +/// * `10_000 * 2_500 / 218_750 / (50*2)` = 1.1 sat/vB for non-anchor channels with 50 HTLCs +/// in both (the LDK default maximum from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) +/// +/// Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement +/// will scale linearly with increases (or decreases) in the our feerate estimates. Further, +/// for anchor channels we expect our counterparty to use a relatively low feerate estimate +/// while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) +/// and feerate disagreement force-closures should only occur when theirs is higher than ours. +/// +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` +/// +/// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate #[no_mangle] pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelConfig) -> crate::lightning::util::config::MaxDustHTLCExposure { let mut inner_val = &mut this_ptr.get_native_mut_ref().max_dust_htlc_exposure; crate::lightning::util::config::MaxDustHTLCExposure::from_native(inner_val) } -/// Limit our total exposure to in-flight HTLCs which are burned to fees as they are too -/// small to claim on-chain. +/// Limit our total exposure to potential loss to on-chain fees on close, including in-flight +/// HTLCs which are burned to fees as they are too small to claim on-chain and fees on +/// commitment transaction(s) broadcasted by our counterparty in excess of our own fee estimate. +/// +/// # HTLC-based Dust Exposure /// /// When an HTLC present in one of our channels is below a \"dust\" threshold, the HTLC will /// not be claimable on-chain, instead being turned into additional miner fees if either /// party force-closes the channel. Because the threshold is per-HTLC, our total exposure -/// to such payments may be sustantial if there are many dust HTLCs present when the +/// to such payments may be substantial if there are many dust HTLCs present when the /// channel is force-closed. /// /// The dust threshold for each HTLC is based on the `dust_limit_satoshis` for each party in a @@ -1221,7 +1301,37 @@ pub extern "C" fn ChannelConfig_get_max_dust_htlc_exposure(this_ptr: &ChannelCon /// The selected limit is applied for sent, forwarded, and received HTLCs and limits the total /// exposure across all three types per-channel. /// -/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of 5000. +/// # Transaction Fee Dust Exposure +/// +/// Further, counterparties broadcasting a commitment transaction in a force-close may result +/// in other balance being burned to fees, and thus all fees on commitment and HTLC +/// transactions in excess of our local fee estimates are included in the dust calculation. +/// +/// Because of this, another way to look at this limit is to divide it by 43,000 (or 218,750 +/// for non-anchor channels) and see it as the maximum feerate disagreement (in sats/vB) per +/// non-dust HTLC we're allowed to have with our peers before risking a force-closure for +/// inbound channels. +/// +/// Thus, for the default value of 10_000 * a current feerate estimate of 10 sat/vB (or 2,500 +/// sat/KW), we risk force-closure if we disagree with our peer by: +/// * `10_000 * 2_500 / 43_000 / (483*2)` = 0.6 sat/vB for anchor channels with 483 HTLCs in +/// both directions (the maximum), +/// * `10_000 * 2_500 / 43_000 / (50*2)` = 5.8 sat/vB for anchor channels with 50 HTLCs in both +/// directions (the LDK default max from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) +/// * `10_000 * 2_500 / 218_750 / (483*2)` = 0.1 sat/vB for non-anchor channels with 483 HTLCs +/// in both directions (the maximum), +/// * `10_000 * 2_500 / 218_750 / (50*2)` = 1.1 sat/vB for non-anchor channels with 50 HTLCs +/// in both (the LDK default maximum from [`ChannelHandshakeConfig::our_max_accepted_htlcs`]) +/// +/// Note that when using [`MaxDustHTLCExposure::FeeRateMultiplier`] this maximum disagreement +/// will scale linearly with increases (or decreases) in the our feerate estimates. Further, +/// for anchor channels we expect our counterparty to use a relatively low feerate estimate +/// while we use [`ConfirmationTarget::MaximumFeeEstimate`] (which should be relatively high) +/// and feerate disagreement force-closures should only occur when theirs is higher than ours. +/// +/// Default value: [`MaxDustHTLCExposure::FeeRateMultiplier`] with a multiplier of `10_000` +/// +/// [`ConfirmationTarget::MaximumFeeEstimate`]: crate::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate #[no_mangle] pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut ChannelConfig, mut val: crate::lightning::util::config::MaxDustHTLCExposure) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.max_dust_htlc_exposure = val.into_native(); @@ -1244,7 +1354,7 @@ pub extern "C" fn ChannelConfig_set_max_dust_htlc_exposure(this_ptr: &mut Channe /// [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like. /// Thus, this value is ignored when we are not the funder. /// -/// Default value: 1000 satoshis. +/// Default value: `1000` /// /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee /// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -1271,7 +1381,7 @@ pub extern "C" fn ChannelConfig_get_force_close_avoidance_max_fee_satoshis(this_ /// [`ChannelCloseMinimum`] fee estimate, but allow our counterparty to pay as much fee as they like. /// Thus, this value is ignored when we are not the funder. /// -/// Default value: 1000 satoshis. +/// Default value: `1000` /// /// [`NonAnchorChannelFee`]: crate::chain::chaininterface::ConfirmationTarget::NonAnchorChannelFee /// [`ChannelCloseMinimum`]: crate::chain::chaininterface::ConfirmationTarget::ChannelCloseMinimum @@ -1302,7 +1412,7 @@ pub extern "C" fn ChannelConfig_set_force_close_avoidance_max_fee_satoshis(this_ /// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. /// Unsetting this flag between restarts may lead to payment receive failures. /// -/// Default value: false. +/// Default value: `false` /// /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -1338,7 +1448,7 @@ pub extern "C" fn ChannelConfig_get_accept_underpaying_htlcs(this_ptr: &ChannelC /// Switching this config flag on may break compatibility with versions of LDK prior to 0.0.116. /// Unsetting this flag between restarts may lead to payment receive failures. /// -/// Default value: false. +/// Default value: `false` /// /// [intercept scids]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`forward_intercepted_htlc`]: crate::ln::channelmanager::ChannelManager::forward_intercepted_htlc @@ -1413,7 +1523,7 @@ pub extern "C" fn ChannelConfig_write(obj: &crate::lightning::util::config::Chan } #[allow(unused)] pub(crate) extern "C" fn ChannelConfig_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeChannelConfig) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::config::nativeChannelConfig) }) } #[no_mangle] /// Read a ChannelConfig from a byte array, created by ChannelConfig_write @@ -1442,6 +1552,12 @@ pub struct ChannelConfigUpdate { pub is_owned: bool, } +impl core::ops::Deref for ChannelConfigUpdate { + type Target = nativeChannelConfigUpdate; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelConfigUpdate { } +unsafe impl core::marker::Sync for ChannelConfigUpdate { } impl Drop for ChannelConfigUpdate { fn drop(&mut self) { if self.is_owned && !<*mut nativeChannelConfigUpdate>::is_null(self.inner) { @@ -1472,6 +1588,9 @@ impl ChannelConfigUpdate { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(this_ptr: &ChannelConfigUpdate) -> crate::c_types::derived::COption_u32Z { @@ -1547,20 +1666,14 @@ pub extern "C" fn ChannelConfigUpdate_new(mut forwarding_fee_proportional_millio force_close_avoidance_max_fee_satoshis: local_force_close_avoidance_max_fee_satoshis_arg, }), is_owned: true } } -/// Creates a "default" ChannelConfigUpdate. See struct and individual field documentaiton for details on which values are used. -#[must_use] -#[no_mangle] -pub extern "C" fn ChannelConfigUpdate_default() -> ChannelConfigUpdate { - ChannelConfigUpdate { inner: ObjOps::heap_alloc(Default::default()), is_owned: true } -} use lightning::util::config::UserConfig as nativeUserConfigImport; pub(crate) type nativeUserConfig = nativeUserConfigImport; /// Top-level config which holds ChannelHandshakeLimits and ChannelConfig. /// -/// Default::default() provides sane defaults for most configurations -/// (but currently with 0 relay fees!) +/// `Default::default()` provides sane defaults for most configurations +/// (but currently with zero relay fees!) #[must_use] #[repr(C)] pub struct UserConfig { @@ -1576,6 +1689,12 @@ pub struct UserConfig { pub is_owned: bool, } +impl core::ops::Deref for UserConfig { + type Target = nativeUserConfig; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UserConfig { } +unsafe impl core::marker::Sync for UserConfig { } impl Drop for UserConfig { fn drop(&mut self) { if self.is_owned && !<*mut nativeUserConfig>::is_null(self.inner) { @@ -1606,6 +1725,9 @@ impl UserConfig { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Channel handshake config that we propose to our counterparty. #[no_mangle] @@ -1640,13 +1762,13 @@ pub extern "C" fn UserConfig_get_channel_config(this_ptr: &UserConfig) -> crate: pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut val: crate::lightning::util::config::ChannelConfig) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_config = *unsafe { Box::from_raw(val.take_inner()) }; } -/// If this is set to false, we will reject any HTLCs which were to be forwarded over private +/// If this is set to `false`, we will reject any HTLCs which were to be forwarded over private /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a /// node which is not online reliably. /// /// For nodes which are not online reliably, you should set all channels to *not* be announced -/// (using [`ChannelHandshakeConfig::announced_channel`] and -/// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to +/// (using [`ChannelHandshakeConfig::announce_for_forwarding`] and +/// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to `false` to /// ensure you are not exposed to any forwarding risk. /// /// Note that because you cannot change a channel's announced state after creation, there is no @@ -1655,19 +1777,19 @@ pub extern "C" fn UserConfig_set_channel_config(this_ptr: &mut UserConfig, mut v /// all your channels and open new ones. For privacy, you should also change your node_id /// (swapping all private and public key material for new ones) at that time. /// -/// Default value: false. +/// Default value: `false` #[no_mangle] pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &UserConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_forwards_to_priv_channels; *inner_val } -/// If this is set to false, we will reject any HTLCs which were to be forwarded over private +/// If this is set to `false`, we will reject any HTLCs which were to be forwarded over private /// channels. This prevents us from taking on HTLC-forwarding risk when we intend to run as a /// node which is not online reliably. /// /// For nodes which are not online reliably, you should set all channels to *not* be announced -/// (using [`ChannelHandshakeConfig::announced_channel`] and -/// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to false to +/// (using [`ChannelHandshakeConfig::announce_for_forwarding`] and +/// [`ChannelHandshakeLimits::force_announced_channel_preference`]) and set this to `false` to /// ensure you are not exposed to any forwarding risk. /// /// Note that because you cannot change a channel's announced state after creation, there is no @@ -1676,33 +1798,35 @@ pub extern "C" fn UserConfig_get_accept_forwards_to_priv_channels(this_ptr: &Use /// all your channels and open new ones. For privacy, you should also change your node_id /// (swapping all private and public key material for new ones) at that time. /// -/// Default value: false. +/// Default value: `false` #[no_mangle] pub extern "C" fn UserConfig_set_accept_forwards_to_priv_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_forwards_to_priv_channels = val; } -/// If this is set to false, we do not accept inbound requests to open a new channel. -/// Default value: true. +/// If this is set to `false`, we do not accept inbound requests to open a new channel. +/// +/// Default value: `true` #[no_mangle] pub extern "C" fn UserConfig_get_accept_inbound_channels(this_ptr: &UserConfig) -> bool { let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_inbound_channels; *inner_val } -/// If this is set to false, we do not accept inbound requests to open a new channel. -/// Default value: true. +/// If this is set to `false`, we do not accept inbound requests to open a new channel. +/// +/// Default value: `true` #[no_mangle] pub extern "C" fn UserConfig_set_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_inbound_channels = val; } -/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// If this is set to `true`, the user needs to manually accept inbound requests to open a new /// channel. /// -/// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a +/// When set to `true`, [`Event::OpenChannelRequest`] will be triggered once a request to open a /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the /// user explicitly chooses to accept the request. /// -/// Default value: false. +/// Default value: `false` /// /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -1712,15 +1836,15 @@ pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &Use let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_accept_inbound_channels; *inner_val } -/// If this is set to true, the user needs to manually accept inbound requests to open a new +/// If this is set to `true`, the user needs to manually accept inbound requests to open a new /// channel. /// -/// When set to true, [`Event::OpenChannelRequest`] will be triggered once a request to open a +/// When set to `true`, [`Event::OpenChannelRequest`] will be triggered once a request to open a /// new inbound channel is received through a [`msgs::OpenChannel`] message. In that case, a /// [`msgs::AcceptChannel`] message will not be sent back to the counterparty node unless the /// user explicitly chooses to accept the request. /// -/// Default value: false. +/// Default value: `false` /// /// [`Event::OpenChannelRequest`]: crate::events::Event::OpenChannelRequest /// [`msgs::OpenChannel`]: crate::ln::msgs::OpenChannel @@ -1729,13 +1853,13 @@ pub extern "C" fn UserConfig_get_manually_accept_inbound_channels(this_ptr: &Use pub extern "C" fn UserConfig_set_manually_accept_inbound_channels(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_accept_inbound_channels = val; } -/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over +/// If this is set to `true`, LDK will intercept HTLCs that are attempting to be forwarded over /// fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC /// intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. /// -/// Setting this to true may break backwards compatibility with LDK versions < 0.0.113. +/// Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -1744,13 +1868,13 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_intercept_htlcs; *inner_val } -/// If this is set to true, LDK will intercept HTLCs that are attempting to be forwarded over +/// If this is set to `true`, LDK will intercept HTLCs that are attempting to be forwarded over /// fake short channel ids generated via [`ChannelManager::get_intercept_scid`]. Upon HTLC /// intercept, LDK will generate an [`Event::HTLCIntercepted`] which MUST be handled by the user. /// -/// Setting this to true may break backwards compatibility with LDK versions < 0.0.113. +/// Setting this to `true` may break backwards compatibility with LDK versions < 0.0.113. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager::get_intercept_scid`]: crate::ln::channelmanager::ChannelManager::get_intercept_scid /// [`Event::HTLCIntercepted`]: crate::events::Event::HTLCIntercepted @@ -1758,14 +1882,14 @@ pub extern "C" fn UserConfig_get_accept_intercept_htlcs(this_ptr: &UserConfig) - pub extern "C" fn UserConfig_set_accept_intercept_htlcs(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_intercept_htlcs = val; } -/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple -/// parts. If this is set to true, we'll accept the payment. +/// If this is set to `false`, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to `true`, we'll accept the payment. /// -/// Setting this to true will break backwards compatibility upon downgrading to an LDK -/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// Setting this to `true` will break backwards compatibility upon downgrading to an LDK +/// version prior to 0.0.116 while receiving an MPP keysend. If we have already received an MPP /// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager #[no_mangle] @@ -1773,24 +1897,59 @@ pub extern "C" fn UserConfig_get_accept_mpp_keysend(this_ptr: &UserConfig) -> bo let mut inner_val = &mut this_ptr.get_native_mut_ref().accept_mpp_keysend; *inner_val } -/// If this is set to false, when receiving a keysend payment we'll fail it if it has multiple -/// parts. If this is set to true, we'll accept the payment. +/// If this is set to `false`, when receiving a keysend payment we'll fail it if it has multiple +/// parts. If this is set to `true`, we'll accept the payment. /// -/// Setting this to true will break backwards compatibility upon downgrading to an LDK -/// version < 0.0.116 while receiving an MPP keysend. If we have already received an MPP +/// Setting this to `true` will break backwards compatibility upon downgrading to an LDK +/// version prior to 0.0.116 while receiving an MPP keysend. If we have already received an MPP /// keysend, downgrading will cause us to fail to deserialize [`ChannelManager`]. /// -/// Default value: false. +/// Default value: `false` /// /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager #[no_mangle] pub extern "C" fn UserConfig_set_accept_mpp_keysend(this_ptr: &mut UserConfig, mut val: bool) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.accept_mpp_keysend = val; } +/// If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. +/// +/// When set to `true`, [`Event::InvoiceReceived`] will be generated for each received +/// [`Bolt12Invoice`] instead of being automatically paid after verification. Use +/// [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or +/// [`ChannelManager::abandon_payment`] to abandon the associated payment. +/// +/// Default value: `false` +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived +/// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice +/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment +#[no_mangle] +pub extern "C" fn UserConfig_get_manually_handle_bolt12_invoices(this_ptr: &UserConfig) -> bool { + let mut inner_val = &mut this_ptr.get_native_mut_ref().manually_handle_bolt12_invoices; + *inner_val +} +/// If this is set to `true`, the user needs to manually pay [`Bolt12Invoice`]s when received. +/// +/// When set to `true`, [`Event::InvoiceReceived`] will be generated for each received +/// [`Bolt12Invoice`] instead of being automatically paid after verification. Use +/// [`ChannelManager::send_payment_for_bolt12_invoice`] to pay the invoice or +/// [`ChannelManager::abandon_payment`] to abandon the associated payment. +/// +/// Default value: `false` +/// +/// [`Bolt12Invoice`]: crate::offers::invoice::Bolt12Invoice +/// [`Event::InvoiceReceived`]: crate::events::Event::InvoiceReceived +/// [`ChannelManager::send_payment_for_bolt12_invoice`]: crate::ln::channelmanager::ChannelManager::send_payment_for_bolt12_invoice +/// [`ChannelManager::abandon_payment`]: crate::ln::channelmanager::ChannelManager::abandon_payment +#[no_mangle] +pub extern "C" fn UserConfig_set_manually_handle_bolt12_invoices(this_ptr: &mut UserConfig, mut val: bool) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.manually_handle_bolt12_invoices = val; +} /// Constructs a new UserConfig given each field #[must_use] #[no_mangle] -pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool, mut accept_mpp_keysend_arg: bool) -> UserConfig { +pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightning::util::config::ChannelHandshakeConfig, mut channel_handshake_limits_arg: crate::lightning::util::config::ChannelHandshakeLimits, mut channel_config_arg: crate::lightning::util::config::ChannelConfig, mut accept_forwards_to_priv_channels_arg: bool, mut accept_inbound_channels_arg: bool, mut manually_accept_inbound_channels_arg: bool, mut accept_intercept_htlcs_arg: bool, mut accept_mpp_keysend_arg: bool, mut manually_handle_bolt12_invoices_arg: bool) -> UserConfig { UserConfig { inner: ObjOps::heap_alloc(nativeUserConfig { channel_handshake_config: *unsafe { Box::from_raw(channel_handshake_config_arg.take_inner()) }, channel_handshake_limits: *unsafe { Box::from_raw(channel_handshake_limits_arg.take_inner()) }, @@ -1800,6 +1959,7 @@ pub extern "C" fn UserConfig_new(mut channel_handshake_config_arg: crate::lightn manually_accept_inbound_channels: manually_accept_inbound_channels_arg, accept_intercept_htlcs: accept_intercept_htlcs_arg, accept_mpp_keysend: accept_mpp_keysend_arg, + manually_handle_bolt12_invoices: manually_handle_bolt12_invoices_arg, }), is_owned: true } } impl Clone for UserConfig { diff --git a/lightning-c-bindings/src/lightning/util/hash_tables.rs b/lightning-c-bindings/src/lightning/util/hash_tables.rs new file mode 100644 index 0000000..fce1b4a --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/hash_tables.rs @@ -0,0 +1,35 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Generally LDK uses `std`'s `HashMap`s, however when building for no-std, LDK uses `hashbrown`'s +//! `HashMap`s with the `std` `SipHasher` and uses `getrandom` to opportunistically randomize it, +//! if randomization is available. +//! +//! This module simply re-exports the `HashMap` used in LDK for public consumption. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +mod std_hashtables { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/util/invoice.rs b/lightning-c-bindings/src/lightning/util/invoice.rs deleted file mode 100644 index 5d78528..0000000 --- a/lightning-c-bindings/src/lightning/util/invoice.rs +++ /dev/null @@ -1,28 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Low level invoice utilities. - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -/// Construct the invoice's HRP and signatureless data into a preimage to be hashed. -#[no_mangle] -pub extern "C" fn construct_invoice_preimage(mut hrp_bytes: crate::c_types::u8slice, mut data_without_signature: crate::c_types::derived::CVec_U5Z) -> crate::c_types::derived::CVec_u8Z { - let mut local_data_without_signature = Vec::new(); for mut item in data_without_signature.into_rust().drain(..) { local_data_without_signature.push( { item.into() }); }; - let mut ret = lightning::util::invoice::construct_invoice_preimage(hrp_bytes.to_slice(), &local_data_without_signature[..]); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; - local_ret.into() -} - diff --git a/lightning-c-bindings/src/lightning/util/logger.rs b/lightning-c-bindings/src/lightning/util/logger.rs index 843d2bb..de9816d 100644 --- a/lightning-c-bindings/src/lightning/util/logger.rs +++ b/lightning-c-bindings/src/lightning/util/logger.rs @@ -147,6 +147,11 @@ pub extern "C" fn Level_hash(o: &Level) -> u64 { core::hash::Hash::hash(&o.to_native(), &mut hasher); core::hash::Hasher::finish(&hasher) } +#[no_mangle] +/// Get the string representation of a Level object +pub extern "C" fn Level_to_str(o: &crate::lightning::util::logger::Level) -> Str { + alloc::format!("{}", &o.to_native()).into() +} /// Returns the most verbose logging level. #[must_use] #[no_mangle] @@ -176,6 +181,12 @@ pub struct Record { pub is_owned: bool, } +impl core::ops::Deref for Record { + type Target = nativeRecord; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Record { } +unsafe impl core::marker::Sync for Record { } impl Drop for Record { fn drop(&mut self) { if self.is_owned && !<*mut nativeRecord>::is_null(self.inner) { @@ -206,6 +217,9 @@ impl Record { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// The verbosity level of the message. #[no_mangle] @@ -245,17 +259,21 @@ pub extern "C" fn Record_set_peer_id(this_ptr: &mut Record, mut val: crate::c_ty } /// The channel id of the channel pertaining to the logged record. May be a temporary id before /// the channel has been funded. +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn Record_get_channel_id(this_ptr: &Record) -> crate::c_types::derived::COption_ThirtyTwoBytesZ { +pub extern "C" fn Record_get_channel_id(this_ptr: &Record) -> crate::lightning::ln::types::ChannelId { let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; - let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) }; + let mut local_inner_val = crate::lightning::ln::types::ChannelId { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::types::ChannelId<>) as *mut _ }, is_owned: false }; local_inner_val } /// The channel id of the channel pertaining to the logged record. May be a temporary id before /// the channel has been funded. +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None #[no_mangle] -pub extern "C" fn Record_set_channel_id(this_ptr: &mut Record, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { - let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ val_opt.take() }.data) }})} }; +pub extern "C" fn Record_set_channel_id(this_ptr: &mut Record, mut val: crate::lightning::ln::types::ChannelId) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = local_val; } /// The message body. @@ -302,14 +320,35 @@ pub extern "C" fn Record_get_line(this_ptr: &Record) -> u32 { pub extern "C" fn Record_set_line(this_ptr: &mut Record, mut val: u32) { unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.line = val; } +/// The payment hash. +/// +/// Note that this is only filled in for logs pertaining to a specific payment, and will be +/// `None` for logs which are not directly related to a payment. +#[no_mangle] +pub extern "C" fn Record_get_payment_hash(this_ptr: &Record) -> crate::c_types::derived::COption_ThirtyTwoBytesZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().payment_hash; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some(/* WARNING: CLONING CONVERSION HERE! &Option is otherwise un-expressable. */ { crate::c_types::ThirtyTwoBytes { data: (*inner_val.as_ref().unwrap()).clone().0 } }) }; + local_inner_val +} +/// The payment hash. +/// +/// Note that this is only filled in for logs pertaining to a specific payment, and will be +/// `None` for logs which are not directly related to a payment. +#[no_mangle] +pub extern "C" fn Record_set_payment_hash(this_ptr: &mut Record, mut val: crate::c_types::derived::COption_ThirtyTwoBytesZ) { + let mut local_val = { /*val*/ let val_opt = val; if val_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ val_opt.take() }.data) }})} }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.payment_hash = local_val; +} /// Constructs a new Record given each field /// /// Note that peer_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +/// Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Level, mut peer_id_arg: crate::c_types::PublicKey, mut channel_id_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut args_arg: crate::c_types::Str, mut module_path_arg: crate::c_types::Str, mut file_arg: crate::c_types::Str, mut line_arg: u32) -> Record { +pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Level, mut peer_id_arg: crate::c_types::PublicKey, mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut args_arg: crate::c_types::Str, mut module_path_arg: crate::c_types::Str, mut file_arg: crate::c_types::Str, mut line_arg: u32, mut payment_hash_arg: crate::c_types::derived::COption_ThirtyTwoBytesZ) -> Record { let mut local_peer_id_arg = if peer_id_arg.is_null() { None } else { Some( { peer_id_arg.into_rust() }) }; - let mut local_channel_id_arg = { /*channel_id_arg*/ let channel_id_arg_opt = channel_id_arg; if channel_id_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::ChannelId({ channel_id_arg_opt.take() }.data) }})} }; + let mut local_channel_id_arg = if channel_id_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id_arg.take_inner()) } }) }; + let mut local_payment_hash_arg = { /*payment_hash_arg*/ let payment_hash_arg_opt = payment_hash_arg; if payment_hash_arg_opt.is_none() { None } else { Some({ { ::lightning::ln::types::PaymentHash({ payment_hash_arg_opt.take() }.data) }})} }; Record { inner: ObjOps::heap_alloc(nativeRecord { level: level_arg.into_native(), peer_id: local_peer_id_arg, @@ -318,6 +357,7 @@ pub extern "C" fn Record_new(mut level_arg: crate::lightning::util::logger::Leve module_path: module_path_arg.into_str(), file: file_arg.into_str(), line: line_arg, + payment_hash: local_payment_hash_arg, }), is_owned: true } } impl Clone for Record { @@ -372,17 +412,24 @@ impl rustLogger for Logger { } } +pub struct LoggerRef(Logger); +impl rustLogger for LoggerRef { + fn log(&self, mut record: lightning::util::logger::Record) { + (self.0.log)(self.0.this_arg, crate::lightning::util::logger::Record { inner: ObjOps::heap_alloc(record), is_owned: true }) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Logger { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = LoggerRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const LoggerRef) } } } impl core::ops::DerefMut for Logger { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut LoggerRef { + unsafe { &mut *(self as *mut _ as *mut LoggerRef) } } } /// Calls the free function if one is set diff --git a/lightning-c-bindings/src/lightning/util/message_signing.rs b/lightning-c-bindings/src/lightning/util/message_signing.rs index 8e4dfc6..b07ca03 100644 --- a/lightning-c-bindings/src/lightning/util/message_signing.rs +++ b/lightning-c-bindings/src/lightning/util/message_signing.rs @@ -35,10 +35,9 @@ use alloc::{vec::Vec, boxed::Box}; /// A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller. /// Signatures are EC recoverable, meaning that given the message and the signature the PublicKey of the signer can be extracted. #[no_mangle] -pub extern "C" fn sign(mut msg: crate::c_types::u8slice, sk: *const [u8; 32]) -> crate::c_types::derived::CResult_StrSecp256k1ErrorZ { +pub extern "C" fn sign(mut msg: crate::c_types::u8slice, sk: *const [u8; 32]) -> crate::c_types::Str { let mut ret = lightning::util::message_signing::sign(msg.to_slice(), &::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *sk}[..]).unwrap()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::Secp256k1Error::from_rust(e) }).into() }; - local_ret + ret.into() } /// Recovers the PublicKey of the signer of the message given the message and the signature. diff --git a/lightning-c-bindings/src/lightning/util/mod.rs b/lightning-c-bindings/src/lightning/util/mod.rs index 37ae34c..4fedbfb 100644 --- a/lightning-c-bindings/src/lightning/util/mod.rs +++ b/lightning-c-bindings/src/lightning/util/mod.rs @@ -21,13 +21,15 @@ pub mod ser_macros; pub mod errors; pub mod ser; pub mod message_signing; -pub mod invoice; pub mod persist; -pub mod string; +pub mod scid_utils; +pub mod sweep; pub mod wakers; +pub mod hash_tables; pub mod indexed_map; pub mod logger; pub mod config; +pub mod string; mod fuzz_wrappers { use alloc::str::FromStr; @@ -64,7 +66,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -mod byte_utils { +mod async_poll { use alloc::str::FromStr; use alloc::string::String; @@ -76,7 +78,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -mod transaction_utils { +mod byte_utils { use alloc::str::FromStr; use alloc::string::String; @@ -88,18 +90,7 @@ use crate::c_types::*; use alloc::{vec::Vec, boxed::Box}; } -mod scid_utils { - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -mod fake_scid { +mod transaction_utils { use alloc::str::FromStr; use alloc::string::String; @@ -110,7 +101,6 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -} } mod time { diff --git a/lightning-c-bindings/src/lightning/util/persist.rs b/lightning-c-bindings/src/lightning/util/persist.rs index e2166cf..4d62d06 100644 --- a/lightning-c-bindings/src/lightning/util/persist.rs +++ b/lightning-c-bindings/src/lightning/util/persist.rs @@ -9,6 +9,8 @@ //! This module contains a simple key-value store trait [`KVStore`] that //! allows one to implement the persistence for [`ChannelManager`], [`NetworkGraph`], //! and [`ChannelMonitor`] all in one place. +//! +//! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager use alloc::str::FromStr; use alloc::string::String; @@ -127,17 +129,42 @@ impl rustKVStore for KVStore { } } +pub struct KVStoreRef(KVStore); +impl rustKVStore for KVStoreRef { + fn read(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str) -> Result, lightning::io::Error> { + let mut ret = (self.0.read)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { item }); }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn write(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str, mut buf: &[u8]) -> Result<(), lightning::io::Error> { + let mut local_buf = crate::c_types::u8slice::from_slice(buf); + let mut ret = (self.0.write)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into(), local_buf); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn remove(&self, mut primary_namespace: &str, mut secondary_namespace: &str, mut key: &str, mut lazy: bool) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.remove)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into(), key.into(), lazy); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn list(&self, mut primary_namespace: &str, mut secondary_namespace: &str) -> Result, lightning::io::Error> { + let mut ret = (self.0.list)(self.0.this_arg, primary_namespace.into(), secondary_namespace.into()); + let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = Vec::new(); for mut item in (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }).into_rust().drain(..) { local_ret_0.push( { item.into_string() }); }; local_ret_0 }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for KVStore { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = KVStoreRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const KVStoreRef) } } } impl core::ops::DerefMut for KVStore { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut KVStoreRef { + unsafe { &mut *(self as *mut _ as *mut KVStoreRef) } } } /// Calls the free function if one is set @@ -151,12 +178,16 @@ impl Drop for KVStore { } } /// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. +/// +/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager #[repr(C)] pub struct Persister { /// An opaque pointer which is passed to your function implementations as an argument. /// This has no meaning in the LDK, and can be NULL or any other value. pub this_arg: *mut c_void, /// Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. + /// + /// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager pub persist_manager: extern "C" fn (this_arg: *const c_void, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> crate::c_types::derived::CResult_NoneIOErrorZ, /// Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. pub persist_graph: extern "C" fn (this_arg: *const c_void, network_graph: &crate::lightning::routing::gossip::NetworkGraph) -> crate::c_types::derived::CResult_NoneIOErrorZ, @@ -180,9 +211,9 @@ pub(crate) fn Persister_clone_fields(orig: &Persister) -> Persister { } use lightning::util::persist::Persister as rustPersister; -impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::chain::chaininterface::BroadcasterInterface, crate::lightning::sign::EntropySource, crate::lightning::sign::NodeSigner, crate::lightning::sign::SignerProvider, crate::lightning::chain::chaininterface::FeeEstimator, crate::lightning::routing::router::Router, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore> for Persister { - fn persist_manager(&self, mut channel_manager: &lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { - let mut ret = (self.persist_manager)(self.this_arg, &crate::lightning::ln::channelmanager::ChannelManager { inner: unsafe { ObjOps::nonnull_ptr_to_inner((channel_manager as *const lightning::ln::channelmanager::ChannelManager<_, _, _, _, _, _, _, _, >) as *mut _) }, is_owned: false }); +impl<'a> rustPersister<'a, crate::lightning::ln::channelmanager::ChannelManager, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore, > for Persister { + fn persist_manager(&self, mut channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { + let mut ret = (self.persist_manager)(self.this_arg, &channel_manager.as_ref_to()); let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; local_ret } @@ -198,17 +229,36 @@ impl<'a> rustPersister<'a, crate::lightning::chain::Watch, crate::lightning::cha } } +pub struct PersisterRef(Persister); +impl<'a> rustPersister<'a, crate::lightning::ln::channelmanager::ChannelManager, crate::lightning::util::logger::Logger, crate::lightning::routing::scoring::WriteableScore, > for PersisterRef { + fn persist_manager(&self, mut channel_manager: &crate::lightning::ln::channelmanager::ChannelManager) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_manager)(self.0.this_arg, &channel_manager.as_ref_to()); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn persist_graph(&self, mut network_graph: &lightning::routing::gossip::NetworkGraph) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_graph)(self.0.this_arg, &crate::lightning::routing::gossip::NetworkGraph { inner: unsafe { ObjOps::nonnull_ptr_to_inner((network_graph as *const lightning::routing::gossip::NetworkGraph<_, >) as *mut _) }, is_owned: false }); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } + fn persist_scorer(&self, mut scorer: &crate::lightning::routing::scoring::WriteableScore) -> Result<(), lightning::io::Error> { + let mut ret = (self.0.persist_scorer)(self.0.this_arg, scorer); + let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).to_rust() })}; + local_ret + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for Persister { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = PersisterRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const PersisterRef) } } } impl core::ops::DerefMut for Persister { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut PersisterRef { + unsafe { &mut *(self as *mut _ as *mut PersisterRef) } } } /// Calls the free function if one is set @@ -224,14 +274,14 @@ impl Drop for Persister { /// Read previously persisted [`ChannelMonitor`]s from the store. #[no_mangle] pub extern "C" fn read_channel_monitors(mut kv_store: crate::lightning::util::persist::KVStore, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - let mut ret = lightning::util::persist::read_channel_monitors::(kv_store, entropy_source, signer_provider); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut ret = lightning::util::persist::read_channel_monitors::(kv_store, entropy_source, signer_provider); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } use lightning::util::persist::MonitorUpdatingPersister as nativeMonitorUpdatingPersisterImport; -pub(crate) type nativeMonitorUpdatingPersister = nativeMonitorUpdatingPersisterImport; +pub(crate) type nativeMonitorUpdatingPersister = nativeMonitorUpdatingPersisterImport; /// Implements [`Persist`] in a way that writes and reads both [`ChannelMonitor`]s and /// [`ChannelMonitorUpdate`]s. @@ -331,6 +381,12 @@ pub struct MonitorUpdatingPersister { pub is_owned: bool, } +impl core::ops::Deref for MonitorUpdatingPersister { + type Target = nativeMonitorUpdatingPersister; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MonitorUpdatingPersister { } +unsafe impl core::marker::Sync for MonitorUpdatingPersister { } impl Drop for MonitorUpdatingPersister { fn drop(&mut self) { if self.is_owned && !<*mut nativeMonitorUpdatingPersister>::is_null(self.inner) { @@ -361,6 +417,9 @@ impl MonitorUpdatingPersister { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new [`MonitorUpdatingPersister`]. /// @@ -380,8 +439,8 @@ impl MonitorUpdatingPersister { /// [`MonitorUpdatingPersister::cleanup_stale_updates`]. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::util::persist::KVStore, mut logger: crate::lightning::util::logger::Logger, mut maximum_pending_updates: u64, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider) -> crate::lightning::util::persist::MonitorUpdatingPersister { - let mut ret = lightning::util::persist::MonitorUpdatingPersister::new(kv_store, logger, maximum_pending_updates, entropy_source, signer_provider); +pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::util::persist::KVStore, mut logger: crate::lightning::util::logger::Logger, mut maximum_pending_updates: u64, mut entropy_source: crate::lightning::sign::EntropySource, mut signer_provider: crate::lightning::sign::SignerProvider, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator) -> crate::lightning::util::persist::MonitorUpdatingPersister { + let mut ret = lightning::util::persist::MonitorUpdatingPersister::new(kv_store, logger, maximum_pending_updates, entropy_source, signer_provider, broadcaster, fee_estimator); crate::lightning::util::persist::MonitorUpdatingPersister { inner: ObjOps::heap_alloc(ret), is_owned: true } } @@ -392,9 +451,9 @@ pub extern "C" fn MonitorUpdatingPersister_new(mut kv_store: crate::lightning::u /// documentation for [`MonitorUpdatingPersister`]. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_all_channel_monitors_with_updates(broadcaster, fee_estimator); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; +pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister) -> crate::c_types::derived::CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_all_channel_monitors_with_updates(); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { let (mut orig_ret_0_0_0, mut orig_ret_0_0_1) = item; let mut local_ret_0_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_0_1), is_owned: true }).into(); local_ret_0_0 }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } @@ -417,9 +476,9 @@ pub extern "C" fn MonitorUpdatingPersister_read_all_channel_monitors_with_update /// function to accomplish this. Take care to limit the number of parallel readers. #[must_use] #[no_mangle] -pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, broadcaster: &crate::lightning::chain::chaininterface::BroadcasterInterface, fee_estimator: &crate::lightning::chain::chaininterface::FeeEstimator, mut monitor_key: crate::c_types::Str) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { - let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channel_monitor_with_updates(broadcaster, fee_estimator, monitor_key.into_string()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; +pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, mut monitor_key: crate::c_types::Str) -> crate::c_types::derived::CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.read_channel_monitor_with_updates(monitor_key.into_string()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, crate::lightning::chain::channelmonitor::ChannelMonitor { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } @@ -433,7 +492,7 @@ pub extern "C" fn MonitorUpdatingPersister_read_channel_monitor_with_updates(thi #[no_mangle] pub extern "C" fn MonitorUpdatingPersister_cleanup_stale_updates(this_arg: &crate::lightning::util::persist::MonitorUpdatingPersister, mut lazy: bool) -> crate::c_types::derived::CResult_NoneIOErrorZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.cleanup_stale_updates(lazy); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } @@ -456,18 +515,22 @@ pub extern "C" fn MonitorUpdatingPersister_as_Persist(this_arg: &MonitorUpdating free: None, persist_new_channel: MonitorUpdatingPersister_Persist_persist_new_channel, update_persisted_channel: MonitorUpdatingPersister_Persist_update_persisted_channel, + archive_persisted_channel: MonitorUpdatingPersister_Persist_archive_persisted_channel, } } #[must_use] -extern "C" fn MonitorUpdatingPersister_Persist_persist_new_channel(this_arg: *const c_void, mut channel_id: crate::lightning::chain::transaction::OutPoint, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut ret = >::persist_new_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_id.take_inner()) }, data.get_native_ref(), *unsafe { Box::from_raw(update_id.take_inner()) }); +extern "C" fn MonitorUpdatingPersister_Persist_persist_new_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus { + let mut ret = >::persist_new_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, monitor.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } #[must_use] -extern "C" fn MonitorUpdatingPersister_Persist_update_persisted_channel(this_arg: *const c_void, mut channel_id: crate::lightning::chain::transaction::OutPoint, mut update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, data: &crate::lightning::chain::channelmonitor::ChannelMonitor, mut update_id: crate::lightning::chain::chainmonitor::MonitorUpdateId) -> crate::lightning::chain::ChannelMonitorUpdateStatus { - let mut local_update = if update.inner.is_null() { None } else { Some( { update.get_native_ref() }) }; - let mut ret = >::update_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_id.take_inner()) }, local_update, data.get_native_ref(), *unsafe { Box::from_raw(update_id.take_inner()) }); +extern "C" fn MonitorUpdatingPersister_Persist_update_persisted_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint, mut monitor_update: crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, monitor: &crate::lightning::chain::channelmonitor::ChannelMonitor) -> crate::lightning::chain::ChannelMonitorUpdateStatus { + let mut local_monitor_update = if monitor_update.inner.is_null() { None } else { Some( { monitor_update.get_native_ref() }) }; + let mut ret = >::update_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }, local_monitor_update, monitor.get_native_ref()); crate::lightning::chain::ChannelMonitorUpdateStatus::native_into(ret) } +extern "C" fn MonitorUpdatingPersister_Persist_archive_persisted_channel(this_arg: *const c_void, mut channel_funding_outpoint: crate::lightning::chain::transaction::OutPoint) { + >::archive_persisted_channel(unsafe { &mut *(this_arg as *mut nativeMonitorUpdatingPersister) }, *unsafe { Box::from_raw(channel_funding_outpoint.take_inner()) }) +} diff --git a/lightning-c-bindings/src/lightning/util/scid_utils.rs b/lightning-c-bindings/src/lightning/util/scid_utils.rs new file mode 100644 index 0000000..3542944 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/scid_utils.rs @@ -0,0 +1,162 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Utilities for creating and parsing short channel ids. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Maximum block height that can be used in a `short_channel_id`. This +/// value is based on the 3-bytes available for block height. + +#[no_mangle] +pub static MAX_SCID_BLOCK: u64 = lightning::util::scid_utils::MAX_SCID_BLOCK; +/// Maximum transaction index that can be used in a `short_channel_id`. +/// This value is based on the 3-bytes available for tx index. + +#[no_mangle] +pub static MAX_SCID_TX_INDEX: u64 = lightning::util::scid_utils::MAX_SCID_TX_INDEX; +/// Maximum vout index that can be used in a `short_channel_id`. This +/// value is based on the 2-bytes available for the vout index. + +#[no_mangle] +pub static MAX_SCID_VOUT_INDEX: u64 = lightning::util::scid_utils::MAX_SCID_VOUT_INDEX; +/// A `short_channel_id` construction error +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum ShortChannelIdError { + /// Block height too high + BlockOverflow, + /// Tx index too high + TxIndexOverflow, + /// Vout index too high + VoutIndexOverflow, +} +use lightning::util::scid_utils::ShortChannelIdError as ShortChannelIdErrorImport; +pub(crate) type nativeShortChannelIdError = ShortChannelIdErrorImport; + +impl ShortChannelIdError { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeShortChannelIdError { + match self { + ShortChannelIdError::BlockOverflow => nativeShortChannelIdError::BlockOverflow, + ShortChannelIdError::TxIndexOverflow => nativeShortChannelIdError::TxIndexOverflow, + ShortChannelIdError::VoutIndexOverflow => nativeShortChannelIdError::VoutIndexOverflow, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeShortChannelIdError { + match self { + ShortChannelIdError::BlockOverflow => nativeShortChannelIdError::BlockOverflow, + ShortChannelIdError::TxIndexOverflow => nativeShortChannelIdError::TxIndexOverflow, + ShortChannelIdError::VoutIndexOverflow => nativeShortChannelIdError::VoutIndexOverflow, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &ShortChannelIdErrorImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeShortChannelIdError) }; + match native { + nativeShortChannelIdError::BlockOverflow => ShortChannelIdError::BlockOverflow, + nativeShortChannelIdError::TxIndexOverflow => ShortChannelIdError::TxIndexOverflow, + nativeShortChannelIdError::VoutIndexOverflow => ShortChannelIdError::VoutIndexOverflow, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeShortChannelIdError) -> Self { + match native { + nativeShortChannelIdError::BlockOverflow => ShortChannelIdError::BlockOverflow, + nativeShortChannelIdError::TxIndexOverflow => ShortChannelIdError::TxIndexOverflow, + nativeShortChannelIdError::VoutIndexOverflow => ShortChannelIdError::VoutIndexOverflow, + } + } +} +/// Creates a copy of the ShortChannelIdError +#[no_mangle] +pub extern "C" fn ShortChannelIdError_clone(orig: &ShortChannelIdError) -> ShortChannelIdError { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ShortChannelIdError_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ShortChannelIdError)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ShortChannelIdError_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut ShortChannelIdError) }; +} +#[no_mangle] +/// Utility method to constructs a new BlockOverflow-variant ShortChannelIdError +pub extern "C" fn ShortChannelIdError_block_overflow() -> ShortChannelIdError { + ShortChannelIdError::BlockOverflow} +#[no_mangle] +/// Utility method to constructs a new TxIndexOverflow-variant ShortChannelIdError +pub extern "C" fn ShortChannelIdError_tx_index_overflow() -> ShortChannelIdError { + ShortChannelIdError::TxIndexOverflow} +#[no_mangle] +/// Utility method to constructs a new VoutIndexOverflow-variant ShortChannelIdError +pub extern "C" fn ShortChannelIdError_vout_index_overflow() -> ShortChannelIdError { + ShortChannelIdError::VoutIndexOverflow} +/// Get a string which allows debug introspection of a ShortChannelIdError object +pub extern "C" fn ShortChannelIdError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::scid_utils::ShortChannelIdError }).into()} +/// Checks if two ShortChannelIdErrors contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn ShortChannelIdError_eq(a: &ShortChannelIdError, b: &ShortChannelIdError) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +/// Extracts the block height (most significant 3-bytes) from the `short_channel_id` +#[no_mangle] +pub extern "C" fn block_from_scid(mut short_channel_id: u64) -> u32 { + let mut ret = lightning::util::scid_utils::block_from_scid(short_channel_id); + ret +} + +/// Extracts the tx index (bytes [2..4]) from the `short_channel_id` +#[no_mangle] +pub extern "C" fn tx_index_from_scid(mut short_channel_id: u64) -> u32 { + let mut ret = lightning::util::scid_utils::tx_index_from_scid(short_channel_id); + ret +} + +/// Extracts the vout (bytes [0..2]) from the `short_channel_id` +#[no_mangle] +pub extern "C" fn vout_from_scid(mut short_channel_id: u64) -> u16 { + let mut ret = lightning::util::scid_utils::vout_from_scid(short_channel_id); + ret +} + +/// Constructs a `short_channel_id` using the components pieces. Results in an error +/// if the block height, tx index, or vout index overflow the maximum sizes. +#[no_mangle] +pub extern "C" fn scid_from_parts(mut block: u64, mut tx_index: u64, mut vout_index: u64) -> crate::c_types::derived::CResult_u64ShortChannelIdErrorZ { + let mut ret = lightning::util::scid_utils::scid_from_parts(block, tx_index, vout_index); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { o }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::scid_utils::ShortChannelIdError::native_into(e) }).into() }; + local_ret +} + +mod fake_scid { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +} diff --git a/lightning-c-bindings/src/lightning/util/ser.rs b/lightning-c-bindings/src/lightning/util/ser.rs index 6b5c46c..a792229 100644 --- a/lightning-c-bindings/src/lightning/util/ser.rs +++ b/lightning-c-bindings/src/lightning/util/ser.rs @@ -51,6 +51,12 @@ pub struct BigSize { pub is_owned: bool, } +impl core::ops::Deref for BigSize { + type Target = nativeBigSize; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BigSize { } +unsafe impl core::marker::Sync for BigSize { } impl Drop for BigSize { fn drop(&mut self) { if self.is_owned && !<*mut nativeBigSize>::is_null(self.inner) { @@ -81,6 +87,9 @@ impl BigSize { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn BigSize_get_a(this_ptr: &BigSize) -> u64 { @@ -147,7 +156,7 @@ pub extern "C" fn BigSize_write(obj: &crate::lightning::util::ser::BigSize) -> c } #[allow(unused)] pub(crate) extern "C" fn BigSize_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeBigSize) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeBigSize) }) } #[no_mangle] /// Read a BigSize from a byte array, created by BigSize_write @@ -156,6 +165,22 @@ pub extern "C" fn BigSize_read(ser: crate::c_types::u8slice) -> crate::c_types:: let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::ser::BigSize { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; local_res } +#[no_mangle] +/// Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read +pub extern "C" fn UntrustedString_write(obj: &crate::lightning_types::string::UntrustedString) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn UntrustedString_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning_types::string::nativeUntrustedString) }) +} +#[no_mangle] +/// Read a UntrustedString from a byte array, created by UntrustedString_write +pub extern "C" fn UntrustedString_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UntrustedStringDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} use lightning::util::ser::Hostname as nativeHostnameImport; pub(crate) type nativeHostname = nativeHostnameImport; @@ -182,6 +207,12 @@ pub struct Hostname { pub is_owned: bool, } +impl core::ops::Deref for Hostname { + type Target = nativeHostname; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Hostname { } +unsafe impl core::marker::Sync for Hostname { } impl Drop for Hostname { fn drop(&mut self) { if self.is_owned && !<*mut nativeHostname>::is_null(self.inner) { @@ -212,6 +243,9 @@ impl Hostname { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Hostname { fn clone(&self) -> Self { @@ -262,6 +296,11 @@ pub extern "C" fn Hostname_len(this_arg: &crate::lightning::util::ser::Hostname) ret } +#[no_mangle] +/// Get the string representation of a Hostname object +pub extern "C" fn Hostname_to_str(o: &crate::lightning::util::ser::Hostname) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} #[no_mangle] /// Serialize the Hostname object into a byte array which can be read by Hostname_read pub extern "C" fn Hostname_write(obj: &crate::lightning::util::ser::Hostname) -> crate::c_types::derived::CVec_u8Z { @@ -269,7 +308,7 @@ pub extern "C" fn Hostname_write(obj: &crate::lightning::util::ser::Hostname) -> } #[allow(unused)] pub(crate) extern "C" fn Hostname_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeHostname) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeHostname) }) } #[no_mangle] /// Read a Hostname from a byte array, created by Hostname_write @@ -301,6 +340,12 @@ pub struct TransactionU16LenLimited { pub is_owned: bool, } +impl core::ops::Deref for TransactionU16LenLimited { + type Target = nativeTransactionU16LenLimited; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TransactionU16LenLimited { } +unsafe impl core::marker::Sync for TransactionU16LenLimited { } impl Drop for TransactionU16LenLimited { fn drop(&mut self) { if self.is_owned && !<*mut nativeTransactionU16LenLimited>::is_null(self.inner) { @@ -331,6 +376,9 @@ impl TransactionU16LenLimited { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for TransactionU16LenLimited { fn clone(&self) -> Self { @@ -391,6 +439,14 @@ pub extern "C" fn TransactionU16LenLimited_into_transaction(mut this_arg: crate: crate::c_types::Transaction::from_bitcoin(&ret) } +/// Returns a reference to the contained `Transaction` +#[must_use] +#[no_mangle] +pub extern "C" fn TransactionU16LenLimited_as_transaction(this_arg: &crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::Transaction { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_transaction(); + crate::c_types::Transaction::from_bitcoin(ret) +} + #[no_mangle] /// Serialize the TransactionU16LenLimited object into a byte array which can be read by TransactionU16LenLimited_read pub extern "C" fn TransactionU16LenLimited_write(obj: &crate::lightning::util::ser::TransactionU16LenLimited) -> crate::c_types::derived::CVec_u8Z { @@ -398,7 +454,7 @@ pub extern "C" fn TransactionU16LenLimited_write(obj: &crate::lightning::util::s } #[allow(unused)] pub(crate) extern "C" fn TransactionU16LenLimited_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeTransactionU16LenLimited) }) + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::ser::nativeTransactionU16LenLimited) }) } #[no_mangle] /// Read a TransactionU16LenLimited from a byte array, created by TransactionU16LenLimited_write diff --git a/lightning-c-bindings/src/lightning/util/string.rs b/lightning-c-bindings/src/lightning/util/string.rs index dfd1b5b..04f9777 100644 --- a/lightning-c-bindings/src/lightning/util/string.rs +++ b/lightning-c-bindings/src/lightning/util/string.rs @@ -6,7 +6,7 @@ // license as that which applies to the original source files from which this // source was automatically generated. -//! Utilities for strings. +//! Utilities to wrap untrusted strings and handle them (more) safely use alloc::str::FromStr; use alloc::string::String; @@ -17,200 +17,3 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; - -use lightning::util::string::UntrustedString as nativeUntrustedStringImport; -pub(crate) type nativeUntrustedString = nativeUntrustedStringImport; - -/// Struct to `Display` fields in a safe way using `PrintableString` -#[must_use] -#[repr(C)] -pub struct UntrustedString { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativeUntrustedString, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for UntrustedString { - fn drop(&mut self) { - if self.is_owned && !<*mut nativeUntrustedString>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn UntrustedString_free(this_obj: UntrustedString) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UntrustedString_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUntrustedString) }; -} -#[allow(unused)] -impl UntrustedString { - pub(crate) fn get_native_ref(&self) -> &'static nativeUntrustedString { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUntrustedString { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativeUntrustedString { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn UntrustedString_get_a(this_ptr: &UntrustedString) -> crate::c_types::Str { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - inner_val.as_str().into() -} -#[no_mangle] -pub extern "C" fn UntrustedString_set_a(this_ptr: &mut UntrustedString, mut val: crate::c_types::Str) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); -} -/// Constructs a new UntrustedString given each field -#[must_use] -#[no_mangle] -pub extern "C" fn UntrustedString_new(mut a_arg: crate::c_types::Str) -> UntrustedString { - UntrustedString { inner: ObjOps::heap_alloc(lightning::util::string::UntrustedString ( - a_arg.into_string(), - )), is_owned: true } -} -impl Clone for UntrustedString { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeUntrustedString>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } - } -} -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn UntrustedString_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUntrustedString)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the UntrustedString -pub extern "C" fn UntrustedString_clone(orig: &UntrustedString) -> UntrustedString { - orig.clone() -} -/// Get a string which allows debug introspection of a UntrustedString object -pub extern "C" fn UntrustedString_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::string::UntrustedString }).into()} -/// Checks if two UntrustedStrings contain equal inner contents. -/// This ignores pointers and is_owned flags and looks at the values in fields. -/// Two objects with NULL inner values will be considered "equal" here. -#[no_mangle] -pub extern "C" fn UntrustedString_eq(a: &UntrustedString, b: &UntrustedString) -> bool { - if a.inner == b.inner { return true; } - if a.inner.is_null() || b.inner.is_null() { return false; } - if a.get_native_ref() == b.get_native_ref() { true } else { false } -} -/// Generates a non-cryptographic 64-bit hash of the UntrustedString. -#[no_mangle] -pub extern "C" fn UntrustedString_hash(o: &UntrustedString) -> u64 { - if o.inner.is_null() { return 0; } - // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core - #[allow(deprecated)] - let mut hasher = core::hash::SipHasher::new(); - core::hash::Hash::hash(o.get_native_ref(), &mut hasher); - core::hash::Hasher::finish(&hasher) -} -#[no_mangle] -/// Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read -pub extern "C" fn UntrustedString_write(obj: &crate::lightning::util::string::UntrustedString) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) -} -#[allow(unused)] -pub(crate) extern "C" fn UntrustedString_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { - crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeUntrustedString) }) -} -#[no_mangle] -/// Read a UntrustedString from a byte array, created by UntrustedString_write -pub extern "C" fn UntrustedString_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_UntrustedStringDecodeErrorZ { - let res: Result = crate::c_types::deserialize_obj(ser); - let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; - local_res -} - -use lightning::util::string::PrintableString as nativePrintableStringImport; -pub(crate) type nativePrintableString = nativePrintableStringImport<'static>; - -/// A string that displays only printable characters, replacing control characters with -/// [`core::char::REPLACEMENT_CHARACTER`]. -#[must_use] -#[repr(C)] -pub struct PrintableString { - /// A pointer to the opaque Rust object. - - /// Nearly everywhere, inner must be non-null, however in places where - /// the Rust equivalent takes an Option, it may be set to null to indicate None. - pub inner: *mut nativePrintableString, - /// Indicates that this is the only struct which contains the same pointer. - - /// Rust functions which take ownership of an object provided via an argument require - /// this to be true and invalidate the object pointed to by inner. - pub is_owned: bool, -} - -impl Drop for PrintableString { - fn drop(&mut self) { - if self.is_owned && !<*mut nativePrintableString>::is_null(self.inner) { - let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; - } - } -} -/// Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. -#[no_mangle] -pub extern "C" fn PrintableString_free(this_obj: PrintableString) { } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn PrintableString_free_void(this_ptr: *mut c_void) { - let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrintableString) }; -} -#[allow(unused)] -impl PrintableString { - pub(crate) fn get_native_ref(&self) -> &'static nativePrintableString { - unsafe { &*ObjOps::untweak_ptr(self.inner) } - } - pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrintableString { - unsafe { &mut *ObjOps::untweak_ptr(self.inner) } - } - /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy - pub(crate) fn take_inner(mut self) -> *mut nativePrintableString { - assert!(self.is_owned); - let ret = ObjOps::untweak_ptr(self.inner); - self.inner = core::ptr::null_mut(); - ret - } -} -#[no_mangle] -pub extern "C" fn PrintableString_get_a(this_ptr: &PrintableString) -> crate::c_types::Str { - let mut inner_val = &mut this_ptr.get_native_mut_ref().0; - inner_val.into() -} -#[no_mangle] -pub extern "C" fn PrintableString_set_a(this_ptr: &mut PrintableString, mut val: crate::c_types::Str) { - unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_str(); -} -/// Constructs a new PrintableString given each field -#[must_use] -#[no_mangle] -pub extern "C" fn PrintableString_new(mut a_arg: crate::c_types::Str) -> PrintableString { - PrintableString { inner: ObjOps::heap_alloc(lightning::util::string::PrintableString ( - a_arg.into_str(), - )), is_owned: true } -} -/// Get a string which allows debug introspection of a PrintableString object -pub extern "C" fn PrintableString_debug_str_void(o: *const c_void) -> Str { - alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::string::PrintableString }).into()} diff --git a/lightning-c-bindings/src/lightning/util/sweep.rs b/lightning-c-bindings/src/lightning/util/sweep.rs new file mode 100644 index 0000000..d2dc424 --- /dev/null +++ b/lightning-c-bindings/src/lightning/util/sweep.rs @@ -0,0 +1,790 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! This module contains an [`OutputSweeper`] utility that keeps track of +//! [`SpendableOutputDescriptor`]s, i.e., persists them in a given [`KVStore`] and regularly retries +//! sweeping them. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning::util::sweep::TrackedSpendableOutput as nativeTrackedSpendableOutputImport; +pub(crate) type nativeTrackedSpendableOutput = nativeTrackedSpendableOutputImport; + +/// The state of a spendable output currently tracked by an [`OutputSweeper`]. +#[must_use] +#[repr(C)] +pub struct TrackedSpendableOutput { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeTrackedSpendableOutput, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for TrackedSpendableOutput { + type Target = nativeTrackedSpendableOutput; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for TrackedSpendableOutput { } +unsafe impl core::marker::Sync for TrackedSpendableOutput { } +impl Drop for TrackedSpendableOutput { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeTrackedSpendableOutput>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the TrackedSpendableOutput, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_free(this_obj: TrackedSpendableOutput) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TrackedSpendableOutput_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeTrackedSpendableOutput) }; +} +#[allow(unused)] +impl TrackedSpendableOutput { + pub(crate) fn get_native_ref(&self) -> &'static nativeTrackedSpendableOutput { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeTrackedSpendableOutput { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeTrackedSpendableOutput { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The tracked output descriptor. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_get_descriptor(this_ptr: &TrackedSpendableOutput) -> crate::lightning::sign::SpendableOutputDescriptor { + let mut inner_val = &mut this_ptr.get_native_mut_ref().descriptor; + crate::lightning::sign::SpendableOutputDescriptor::from_native(inner_val) +} +/// The tracked output descriptor. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_set_descriptor(this_ptr: &mut TrackedSpendableOutput, mut val: crate::lightning::sign::SpendableOutputDescriptor) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.descriptor = val.into_native(); +} +/// The channel this output belongs to. +/// +/// Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`] +/// +/// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_get_channel_id(this_ptr: &TrackedSpendableOutput) -> crate::lightning::ln::types::ChannelId { + let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_id; + let mut local_inner_val = crate::lightning::ln::types::ChannelId { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::types::ChannelId<>) as *mut _ }, is_owned: false }; + local_inner_val +} +/// The channel this output belongs to. +/// +/// Will be `None` if no `channel_id` was given to [`OutputSweeper::track_spendable_outputs`] +/// +/// Note that val (or a relevant inner pointer) may be NULL or all-0s to represent None +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_set_channel_id(this_ptr: &mut TrackedSpendableOutput, mut val: crate::lightning::ln::types::ChannelId) { + let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.channel_id = local_val; +} +/// The current status of the output spend. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_get_status(this_ptr: &TrackedSpendableOutput) -> crate::lightning::util::sweep::OutputSpendStatus { + let mut inner_val = &mut this_ptr.get_native_mut_ref().status; + crate::lightning::util::sweep::OutputSpendStatus::from_native(inner_val) +} +/// The current status of the output spend. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_set_status(this_ptr: &mut TrackedSpendableOutput, mut val: crate::lightning::util::sweep::OutputSpendStatus) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.status = val.into_native(); +} +/// Constructs a new TrackedSpendableOutput given each field +/// +/// Note that channel_id_arg (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_new(mut descriptor_arg: crate::lightning::sign::SpendableOutputDescriptor, mut channel_id_arg: crate::lightning::ln::types::ChannelId, mut status_arg: crate::lightning::util::sweep::OutputSpendStatus) -> TrackedSpendableOutput { + let mut local_channel_id_arg = if channel_id_arg.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id_arg.take_inner()) } }) }; + TrackedSpendableOutput { inner: ObjOps::heap_alloc(nativeTrackedSpendableOutput { + descriptor: descriptor_arg.into_native(), + channel_id: local_channel_id_arg, + status: status_arg.into_native(), + }), is_owned: true } +} +impl Clone for TrackedSpendableOutput { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeTrackedSpendableOutput>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn TrackedSpendableOutput_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeTrackedSpendableOutput)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the TrackedSpendableOutput +pub extern "C" fn TrackedSpendableOutput_clone(orig: &TrackedSpendableOutput) -> TrackedSpendableOutput { + orig.clone() +} +/// Get a string which allows debug introspection of a TrackedSpendableOutput object +pub extern "C" fn TrackedSpendableOutput_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::sweep::TrackedSpendableOutput }).into()} +/// Checks if two TrackedSpendableOutputs contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_eq(a: &TrackedSpendableOutput, b: &TrackedSpendableOutput) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Returns whether the output is spent in the given transaction. +#[must_use] +#[no_mangle] +pub extern "C" fn TrackedSpendableOutput_is_spent_in(this_arg: &crate::lightning::util::sweep::TrackedSpendableOutput, mut tx: crate::c_types::Transaction) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.is_spent_in(&tx.into_bitcoin()); + ret +} + +#[no_mangle] +/// Serialize the TrackedSpendableOutput object into a byte array which can be read by TrackedSpendableOutput_read +pub extern "C" fn TrackedSpendableOutput_write(obj: &crate::lightning::util::sweep::TrackedSpendableOutput) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) +} +#[allow(unused)] +pub(crate) extern "C" fn TrackedSpendableOutput_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(unsafe { &*(obj as *const crate::lightning::util::sweep::nativeTrackedSpendableOutput) }) +} +#[no_mangle] +/// Read a TrackedSpendableOutput from a byte array, created by TrackedSpendableOutput_write +pub extern "C" fn TrackedSpendableOutput_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_TrackedSpendableOutputDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::sweep::TrackedSpendableOutput { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +/// The current status of the output spend. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum OutputSpendStatus { + /// The output is tracked but an initial spending transaction hasn't been generated and + /// broadcasted yet. + PendingInitialBroadcast { + /// The height at which we will first generate and broadcast a spending transaction. + delayed_until_height: crate::c_types::derived::COption_u32Z, + }, + /// A transaction spending the output has been broadcasted but is pending its first confirmation on-chain. + PendingFirstConfirmation { + /// The hash of the chain tip when we first broadcast a transaction spending this output. + first_broadcast_hash: crate::c_types::ThirtyTwoBytes, + /// The best height when we last broadcast a transaction spending this output. + latest_broadcast_height: u32, + /// The transaction spending this output we last broadcasted. + latest_spending_tx: crate::c_types::Transaction, + }, + /// A transaction spending the output has been confirmed on-chain but will be tracked until it + /// reaches [`ANTI_REORG_DELAY`] confirmations. + PendingThresholdConfirmations { + /// The hash of the chain tip when we first broadcast a transaction spending this output. + first_broadcast_hash: crate::c_types::ThirtyTwoBytes, + /// The best height when we last broadcast a transaction spending this output. + latest_broadcast_height: u32, + /// The transaction spending this output we saw confirmed on-chain. + latest_spending_tx: crate::c_types::Transaction, + /// The height at which the spending transaction was confirmed. + confirmation_height: u32, + /// The hash of the block in which the spending transaction was confirmed. + confirmation_hash: crate::c_types::ThirtyTwoBytes, + }, +} +use lightning::util::sweep::OutputSpendStatus as OutputSpendStatusImport; +pub(crate) type nativeOutputSpendStatus = OutputSpendStatusImport; + +impl OutputSpendStatus { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeOutputSpendStatus { + match self { + OutputSpendStatus::PendingInitialBroadcast {ref delayed_until_height, } => { + let mut delayed_until_height_nonref = Clone::clone(delayed_until_height); + let mut local_delayed_until_height_nonref = if delayed_until_height_nonref.is_some() { Some( { delayed_until_height_nonref.take() }) } else { None }; + nativeOutputSpendStatus::PendingInitialBroadcast { + delayed_until_height: local_delayed_until_height_nonref, + } + }, + OutputSpendStatus::PendingFirstConfirmation {ref first_broadcast_hash, ref latest_broadcast_height, ref latest_spending_tx, } => { + let mut first_broadcast_hash_nonref = Clone::clone(first_broadcast_hash); + let mut latest_broadcast_height_nonref = Clone::clone(latest_broadcast_height); + let mut latest_spending_tx_nonref = Clone::clone(latest_spending_tx); + nativeOutputSpendStatus::PendingFirstConfirmation { + first_broadcast_hash: ::bitcoin::hash_types::BlockHash::from_slice(&first_broadcast_hash_nonref.data[..]).unwrap(), + latest_broadcast_height: latest_broadcast_height_nonref, + latest_spending_tx: latest_spending_tx_nonref.into_bitcoin(), + } + }, + OutputSpendStatus::PendingThresholdConfirmations {ref first_broadcast_hash, ref latest_broadcast_height, ref latest_spending_tx, ref confirmation_height, ref confirmation_hash, } => { + let mut first_broadcast_hash_nonref = Clone::clone(first_broadcast_hash); + let mut latest_broadcast_height_nonref = Clone::clone(latest_broadcast_height); + let mut latest_spending_tx_nonref = Clone::clone(latest_spending_tx); + let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut confirmation_hash_nonref = Clone::clone(confirmation_hash); + nativeOutputSpendStatus::PendingThresholdConfirmations { + first_broadcast_hash: ::bitcoin::hash_types::BlockHash::from_slice(&first_broadcast_hash_nonref.data[..]).unwrap(), + latest_broadcast_height: latest_broadcast_height_nonref, + latest_spending_tx: latest_spending_tx_nonref.into_bitcoin(), + confirmation_height: confirmation_height_nonref, + confirmation_hash: ::bitcoin::hash_types::BlockHash::from_slice(&confirmation_hash_nonref.data[..]).unwrap(), + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeOutputSpendStatus { + match self { + OutputSpendStatus::PendingInitialBroadcast {mut delayed_until_height, } => { + let mut local_delayed_until_height = if delayed_until_height.is_some() { Some( { delayed_until_height.take() }) } else { None }; + nativeOutputSpendStatus::PendingInitialBroadcast { + delayed_until_height: local_delayed_until_height, + } + }, + OutputSpendStatus::PendingFirstConfirmation {mut first_broadcast_hash, mut latest_broadcast_height, mut latest_spending_tx, } => { + nativeOutputSpendStatus::PendingFirstConfirmation { + first_broadcast_hash: ::bitcoin::hash_types::BlockHash::from_slice(&first_broadcast_hash.data[..]).unwrap(), + latest_broadcast_height: latest_broadcast_height, + latest_spending_tx: latest_spending_tx.into_bitcoin(), + } + }, + OutputSpendStatus::PendingThresholdConfirmations {mut first_broadcast_hash, mut latest_broadcast_height, mut latest_spending_tx, mut confirmation_height, mut confirmation_hash, } => { + nativeOutputSpendStatus::PendingThresholdConfirmations { + first_broadcast_hash: ::bitcoin::hash_types::BlockHash::from_slice(&first_broadcast_hash.data[..]).unwrap(), + latest_broadcast_height: latest_broadcast_height, + latest_spending_tx: latest_spending_tx.into_bitcoin(), + confirmation_height: confirmation_height, + confirmation_hash: ::bitcoin::hash_types::BlockHash::from_slice(&confirmation_hash.data[..]).unwrap(), + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &OutputSpendStatusImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeOutputSpendStatus) }; + match native { + nativeOutputSpendStatus::PendingInitialBroadcast {ref delayed_until_height, } => { + let mut delayed_until_height_nonref = Clone::clone(delayed_until_height); + let mut local_delayed_until_height_nonref = if delayed_until_height_nonref.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { delayed_until_height_nonref.unwrap() }) }; + OutputSpendStatus::PendingInitialBroadcast { + delayed_until_height: local_delayed_until_height_nonref, + } + }, + nativeOutputSpendStatus::PendingFirstConfirmation {ref first_broadcast_hash, ref latest_broadcast_height, ref latest_spending_tx, } => { + let mut first_broadcast_hash_nonref = Clone::clone(first_broadcast_hash); + let mut latest_broadcast_height_nonref = Clone::clone(latest_broadcast_height); + let mut latest_spending_tx_nonref = Clone::clone(latest_spending_tx); + OutputSpendStatus::PendingFirstConfirmation { + first_broadcast_hash: crate::c_types::ThirtyTwoBytes { data: *first_broadcast_hash_nonref.as_ref() }, + latest_broadcast_height: latest_broadcast_height_nonref, + latest_spending_tx: crate::c_types::Transaction::from_bitcoin(&latest_spending_tx_nonref), + } + }, + nativeOutputSpendStatus::PendingThresholdConfirmations {ref first_broadcast_hash, ref latest_broadcast_height, ref latest_spending_tx, ref confirmation_height, ref confirmation_hash, } => { + let mut first_broadcast_hash_nonref = Clone::clone(first_broadcast_hash); + let mut latest_broadcast_height_nonref = Clone::clone(latest_broadcast_height); + let mut latest_spending_tx_nonref = Clone::clone(latest_spending_tx); + let mut confirmation_height_nonref = Clone::clone(confirmation_height); + let mut confirmation_hash_nonref = Clone::clone(confirmation_hash); + OutputSpendStatus::PendingThresholdConfirmations { + first_broadcast_hash: crate::c_types::ThirtyTwoBytes { data: *first_broadcast_hash_nonref.as_ref() }, + latest_broadcast_height: latest_broadcast_height_nonref, + latest_spending_tx: crate::c_types::Transaction::from_bitcoin(&latest_spending_tx_nonref), + confirmation_height: confirmation_height_nonref, + confirmation_hash: crate::c_types::ThirtyTwoBytes { data: *confirmation_hash_nonref.as_ref() }, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeOutputSpendStatus) -> Self { + match native { + nativeOutputSpendStatus::PendingInitialBroadcast {mut delayed_until_height, } => { + let mut local_delayed_until_height = if delayed_until_height.is_none() { crate::c_types::derived::COption_u32Z::None } else { crate::c_types::derived::COption_u32Z::Some( { delayed_until_height.unwrap() }) }; + OutputSpendStatus::PendingInitialBroadcast { + delayed_until_height: local_delayed_until_height, + } + }, + nativeOutputSpendStatus::PendingFirstConfirmation {mut first_broadcast_hash, mut latest_broadcast_height, mut latest_spending_tx, } => { + OutputSpendStatus::PendingFirstConfirmation { + first_broadcast_hash: crate::c_types::ThirtyTwoBytes { data: *first_broadcast_hash.as_ref() }, + latest_broadcast_height: latest_broadcast_height, + latest_spending_tx: crate::c_types::Transaction::from_bitcoin(&latest_spending_tx), + } + }, + nativeOutputSpendStatus::PendingThresholdConfirmations {mut first_broadcast_hash, mut latest_broadcast_height, mut latest_spending_tx, mut confirmation_height, mut confirmation_hash, } => { + OutputSpendStatus::PendingThresholdConfirmations { + first_broadcast_hash: crate::c_types::ThirtyTwoBytes { data: *first_broadcast_hash.as_ref() }, + latest_broadcast_height: latest_broadcast_height, + latest_spending_tx: crate::c_types::Transaction::from_bitcoin(&latest_spending_tx), + confirmation_height: confirmation_height, + confirmation_hash: crate::c_types::ThirtyTwoBytes { data: *confirmation_hash.as_ref() }, + } + }, + } + } +} +/// Frees any resources used by the OutputSpendStatus +#[no_mangle] +pub extern "C" fn OutputSpendStatus_free(this_ptr: OutputSpendStatus) { } +/// Creates a copy of the OutputSpendStatus +#[no_mangle] +pub extern "C" fn OutputSpendStatus_clone(orig: &OutputSpendStatus) -> OutputSpendStatus { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutputSpendStatus_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const OutputSpendStatus)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutputSpendStatus_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut OutputSpendStatus) }; +} +#[no_mangle] +/// Utility method to constructs a new PendingInitialBroadcast-variant OutputSpendStatus +pub extern "C" fn OutputSpendStatus_pending_initial_broadcast(delayed_until_height: crate::c_types::derived::COption_u32Z) -> OutputSpendStatus { + OutputSpendStatus::PendingInitialBroadcast { + delayed_until_height, + } +} +#[no_mangle] +/// Utility method to constructs a new PendingFirstConfirmation-variant OutputSpendStatus +pub extern "C" fn OutputSpendStatus_pending_first_confirmation(first_broadcast_hash: crate::c_types::ThirtyTwoBytes, latest_broadcast_height: u32, latest_spending_tx: crate::c_types::Transaction) -> OutputSpendStatus { + OutputSpendStatus::PendingFirstConfirmation { + first_broadcast_hash, + latest_broadcast_height, + latest_spending_tx, + } +} +#[no_mangle] +/// Utility method to constructs a new PendingThresholdConfirmations-variant OutputSpendStatus +pub extern "C" fn OutputSpendStatus_pending_threshold_confirmations(first_broadcast_hash: crate::c_types::ThirtyTwoBytes, latest_broadcast_height: u32, latest_spending_tx: crate::c_types::Transaction, confirmation_height: u32, confirmation_hash: crate::c_types::ThirtyTwoBytes) -> OutputSpendStatus { + OutputSpendStatus::PendingThresholdConfirmations { + first_broadcast_hash, + latest_broadcast_height, + latest_spending_tx, + confirmation_height, + confirmation_hash, + } +} +/// Get a string which allows debug introspection of a OutputSpendStatus object +pub extern "C" fn OutputSpendStatus_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::sweep::OutputSpendStatus }).into()} +/// Checks if two OutputSpendStatuss contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +#[no_mangle] +pub extern "C" fn OutputSpendStatus_eq(a: &OutputSpendStatus, b: &OutputSpendStatus) -> bool { + if &a.to_native() == &b.to_native() { true } else { false } +} +#[no_mangle] +/// Serialize the OutputSpendStatus object into a byte array which can be read by OutputSpendStatus_read +pub extern "C" fn OutputSpendStatus_write(obj: &crate::lightning::util::sweep::OutputSpendStatus) -> crate::c_types::derived::CVec_u8Z { + crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) +} +#[allow(unused)] +pub(crate) extern "C" fn OutputSpendStatus_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + OutputSpendStatus_write(unsafe { &*(obj as *const OutputSpendStatus) }) +} +#[no_mangle] +/// Read a OutputSpendStatus from a byte array, created by OutputSpendStatus_write +pub extern "C" fn OutputSpendStatus_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_OutputSpendStatusDecodeErrorZ { + let res: Result = crate::c_types::deserialize_obj(ser); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::sweep::OutputSpendStatus::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} + +use lightning::util::sweep::OutputSweeper as nativeOutputSweeperImport; +pub(crate) type nativeOutputSweeper = nativeOutputSweeperImport; + +/// A utility that keeps track of [`SpendableOutputDescriptor`]s, persists them in a given +/// [`KVStore`] and regularly retries sweeping them based on a callback given to the constructor +/// methods. +/// +/// Users should call [`Self::track_spendable_outputs`] for any [`SpendableOutputDescriptor`]s received via [`Event::SpendableOutputs`]. +/// +/// This needs to be notified of chain state changes either via its [`Listen`] or [`Confirm`] +/// implementation and hence has to be connected with the utilized chain data sources. +/// +/// If chain data is provided via the [`Confirm`] interface or via filtered blocks, users are +/// required to give their chain data sources (i.e., [`Filter`] implementation) to the respective +/// constructor. +/// +/// [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs +#[must_use] +#[repr(C)] +pub struct OutputSweeper { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOutputSweeper, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OutputSweeper { + type Target = nativeOutputSweeper; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OutputSweeper { } +unsafe impl core::marker::Sync for OutputSweeper { } +impl Drop for OutputSweeper { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOutputSweeper>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OutputSweeper, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OutputSweeper_free(this_obj: OutputSweeper) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OutputSweeper_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOutputSweeper) }; +} +#[allow(unused)] +impl OutputSweeper { + pub(crate) fn get_native_ref(&self) -> &'static nativeOutputSweeper { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOutputSweeper { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOutputSweeper { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Constructs a new [`OutputSweeper`]. +/// +/// If chain data is provided via the [`Confirm`] interface or via filtered blocks, users also +/// need to register their [`Filter`] implementation via the given `chain_data_source`. +#[must_use] +#[no_mangle] +pub extern "C" fn OutputSweeper_new(mut best_block: crate::lightning::chain::BestBlock, mut broadcaster: crate::lightning::chain::chaininterface::BroadcasterInterface, mut fee_estimator: crate::lightning::chain::chaininterface::FeeEstimator, mut chain_data_source: crate::c_types::derived::COption_FilterZ, mut output_spender: crate::lightning::sign::OutputSpender, mut change_destination_source: crate::lightning::sign::ChangeDestinationSource, mut kv_store: crate::lightning::util::persist::KVStore, mut logger: crate::lightning::util::logger::Logger) -> crate::lightning::util::sweep::OutputSweeper { + let mut local_chain_data_source = { /*chain_data_source*/ let chain_data_source_opt = chain_data_source; if chain_data_source_opt.is_none() { None } else { Some({ { { chain_data_source_opt.take() } }})} }; + let mut ret = lightning::util::sweep::OutputSweeper::new(*unsafe { Box::from_raw(best_block.take_inner()) }, broadcaster, fee_estimator, local_chain_data_source, output_spender, change_destination_source, kv_store, logger); + crate::lightning::util::sweep::OutputSweeper { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Tells the sweeper to track the given outputs descriptors. +/// +/// Usually, this should be called based on the values emitted by the +/// [`Event::SpendableOutputs`]. +/// +/// The given `exclude_static_outputs` flag controls whether the sweeper will filter out +/// [`SpendableOutputDescriptor::StaticOutput`]s, which may be handled directly by the on-chain +/// wallet implementation. +/// +/// If `delay_until_height` is set, we will delay the spending until the respective block +/// height is reached. This can be used to batch spends, e.g., to reduce on-chain fees. +/// +/// Returns `Err` on persistence failure, in which case the call may be safely retried. +/// +/// [`Event::SpendableOutputs`]: crate::events::Event::SpendableOutputs +/// +/// Note that channel_id (or a relevant inner pointer) may be NULL or all-0s to represent None +#[must_use] +#[no_mangle] +pub extern "C" fn OutputSweeper_track_spendable_outputs(this_arg: &crate::lightning::util::sweep::OutputSweeper, mut output_descriptors: crate::c_types::derived::CVec_SpendableOutputDescriptorZ, mut channel_id: crate::lightning::ln::types::ChannelId, mut exclude_static_outputs: bool, mut delay_until_height: crate::c_types::derived::COption_u32Z) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut local_output_descriptors = Vec::new(); for mut item in output_descriptors.into_rust().drain(..) { local_output_descriptors.push( { item.into_native() }); }; + let mut local_channel_id = if channel_id.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(channel_id.take_inner()) } }) }; + let mut local_delay_until_height = if delay_until_height.is_some() { Some( { delay_until_height.take() }) } else { None }; + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.track_spendable_outputs(local_output_descriptors, local_channel_id, exclude_static_outputs, local_delay_until_height); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Returns a list of the currently tracked spendable outputs. +#[must_use] +#[no_mangle] +pub extern "C" fn OutputSweeper_tracked_spendable_outputs(this_arg: &crate::lightning::util::sweep::OutputSweeper) -> crate::c_types::derived::CVec_TrackedSpendableOutputZ { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.tracked_spendable_outputs(); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::util::sweep::TrackedSpendableOutput { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + local_ret.into() +} + +/// Gets the latest best block which was connected either via the [`Listen`] or +/// [`Confirm`] interfaces. +#[must_use] +#[no_mangle] +pub extern "C" fn OutputSweeper_current_best_block(this_arg: &crate::lightning::util::sweep::OutputSweeper) -> crate::lightning::chain::BestBlock { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.current_best_block(); + crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +impl From for crate::lightning::chain::Listen { + fn from(obj: nativeOutputSweeper) -> Self { + let rust_obj = crate::lightning::util::sweep::OutputSweeper { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = OutputSweeper_as_Listen(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(OutputSweeper_free_void); + ret + } +} +/// Constructs a new Listen which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is +#[no_mangle] +pub extern "C" fn OutputSweeper_as_Listen(this_arg: &OutputSweeper) -> crate::lightning::chain::Listen { + crate::lightning::chain::Listen { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + filtered_block_connected: OutputSweeper_Listen_filtered_block_connected, + block_connected: OutputSweeper_Listen_block_connected, + block_disconnected: OutputSweeper_Listen_block_disconnected, + } +} + +extern "C" fn OutputSweeper_Listen_filtered_block_connected(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + ::filtered_block_connected(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} +extern "C" fn OutputSweeper_Listen_block_connected(this_arg: *const c_void, mut block: crate::c_types::u8slice, mut height: u32) { + ::block_connected(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::consensus::encode::deserialize(block.to_slice()).unwrap(), height) +} +extern "C" fn OutputSweeper_Listen_block_disconnected(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + ::block_disconnected(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} + +impl From for crate::lightning::chain::Confirm { + fn from(obj: nativeOutputSweeper) -> Self { + let rust_obj = crate::lightning::util::sweep::OutputSweeper { inner: ObjOps::heap_alloc(obj), is_owned: true }; + let mut ret = OutputSweeper_as_Confirm(&rust_obj); + // We want to free rust_obj when ret gets drop()'d, not rust_obj, so forget it and set ret's free() fn + core::mem::forget(rust_obj); + ret.free = Some(OutputSweeper_free_void); + ret + } +} +/// Constructs a new Confirm which calls the relevant methods on this_arg. +/// This copies the `inner` pointer in this_arg and thus the returned Confirm must be freed before this_arg is +#[no_mangle] +pub extern "C" fn OutputSweeper_as_Confirm(this_arg: &OutputSweeper) -> crate::lightning::chain::Confirm { + crate::lightning::chain::Confirm { + this_arg: unsafe { ObjOps::untweak_ptr((*this_arg).inner) as *mut c_void }, + free: None, + transactions_confirmed: OutputSweeper_Confirm_transactions_confirmed, + transaction_unconfirmed: OutputSweeper_Confirm_transaction_unconfirmed, + best_block_updated: OutputSweeper_Confirm_best_block_updated, + get_relevant_txids: OutputSweeper_Confirm_get_relevant_txids, + } +} + +extern "C" fn OutputSweeper_Confirm_transactions_confirmed(this_arg: *const c_void, header: *const [u8; 80], mut txdata: crate::c_types::derived::CVec_C2Tuple_usizeTransactionZZ, mut height: u32) { + let mut local_txdata = Vec::new(); for mut item in txdata.into_rust().drain(..) { local_txdata.push( { let (mut orig_txdata_0_0, mut orig_txdata_0_1) = item.to_rust(); let mut local_txdata_0 = (orig_txdata_0_0, orig_txdata_0_1.into_bitcoin()); local_txdata_0 }); }; + ::transactions_confirmed(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), &local_txdata.iter().map(|(a, b)| (*a, b)).collect::>()[..], height) +} +extern "C" fn OutputSweeper_Confirm_transaction_unconfirmed(this_arg: *const c_void, txid: *const [u8; 32]) { + ::transaction_unconfirmed(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::hash_types::Txid::from_slice(&unsafe { &*txid }[..]).unwrap()) +} +extern "C" fn OutputSweeper_Confirm_best_block_updated(this_arg: *const c_void, header: *const [u8; 80], mut height: u32) { + ::best_block_updated(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, &::bitcoin::consensus::encode::deserialize(unsafe { &*header }).unwrap(), height) +} +#[must_use] +extern "C" fn OutputSweeper_Confirm_get_relevant_txids(this_arg: *const c_void) -> crate::c_types::derived::CVec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ { + let mut ret = ::get_relevant_txids(unsafe { &mut *(this_arg as *mut nativeOutputSweeper) }, ); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_2 = if orig_ret_0_2.is_none() { crate::c_types::derived::COption_ThirtyTwoBytesZ::None } else { crate::c_types::derived::COption_ThirtyTwoBytesZ::Some( { crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_2.unwrap().as_ref() } }) }; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: *orig_ret_0_0.as_ref() }, orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); }; + local_ret.into() +} + +/// A `enum` signalling to the [`OutputSweeper`] that it should delay spending an output until a +/// future block height is reached. +#[derive(Clone)] +#[must_use] +#[repr(C)] +pub enum SpendingDelay { + /// A relative delay indicating we shouldn't spend the output before `cur_height + num_blocks` + /// is reached. + Relative { + /// The number of blocks until we'll generate and broadcast the spending transaction. + num_blocks: u32, + }, + /// An absolute delay indicating we shouldn't spend the output before `height` is reached. + Absolute { + /// The height at which we'll generate and broadcast the spending transaction. + height: u32, + }, +} +use lightning::util::sweep::SpendingDelay as SpendingDelayImport; +pub(crate) type nativeSpendingDelay = SpendingDelayImport; + +impl SpendingDelay { + #[allow(unused)] + pub(crate) fn to_native(&self) -> nativeSpendingDelay { + match self { + SpendingDelay::Relative {ref num_blocks, } => { + let mut num_blocks_nonref = Clone::clone(num_blocks); + nativeSpendingDelay::Relative { + num_blocks: num_blocks_nonref, + } + }, + SpendingDelay::Absolute {ref height, } => { + let mut height_nonref = Clone::clone(height); + nativeSpendingDelay::Absolute { + height: height_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn into_native(self) -> nativeSpendingDelay { + match self { + SpendingDelay::Relative {mut num_blocks, } => { + nativeSpendingDelay::Relative { + num_blocks: num_blocks, + } + }, + SpendingDelay::Absolute {mut height, } => { + nativeSpendingDelay::Absolute { + height: height, + } + }, + } + } + #[allow(unused)] + pub(crate) fn from_native(native: &SpendingDelayImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeSpendingDelay) }; + match native { + nativeSpendingDelay::Relative {ref num_blocks, } => { + let mut num_blocks_nonref = Clone::clone(num_blocks); + SpendingDelay::Relative { + num_blocks: num_blocks_nonref, + } + }, + nativeSpendingDelay::Absolute {ref height, } => { + let mut height_nonref = Clone::clone(height); + SpendingDelay::Absolute { + height: height_nonref, + } + }, + } + } + #[allow(unused)] + pub(crate) fn native_into(native: nativeSpendingDelay) -> Self { + match native { + nativeSpendingDelay::Relative {mut num_blocks, } => { + SpendingDelay::Relative { + num_blocks: num_blocks, + } + }, + nativeSpendingDelay::Absolute {mut height, } => { + SpendingDelay::Absolute { + height: height, + } + }, + } + } +} +/// Frees any resources used by the SpendingDelay +#[no_mangle] +pub extern "C" fn SpendingDelay_free(this_ptr: SpendingDelay) { } +/// Creates a copy of the SpendingDelay +#[no_mangle] +pub extern "C" fn SpendingDelay_clone(orig: &SpendingDelay) -> SpendingDelay { + orig.clone() +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn SpendingDelay_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const SpendingDelay)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn SpendingDelay_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut SpendingDelay) }; +} +#[no_mangle] +/// Utility method to constructs a new Relative-variant SpendingDelay +pub extern "C" fn SpendingDelay_relative(num_blocks: u32) -> SpendingDelay { + SpendingDelay::Relative { + num_blocks, + } +} +#[no_mangle] +/// Utility method to constructs a new Absolute-variant SpendingDelay +pub extern "C" fn SpendingDelay_absolute(height: u32) -> SpendingDelay { + SpendingDelay::Absolute { + height, + } +} +/// Get a string which allows debug introspection of a SpendingDelay object +pub extern "C" fn SpendingDelay_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::util::sweep::SpendingDelay }).into()} +#[no_mangle] +/// Read a OutputSweeper from a byte array, created by OutputSweeper_write +pub extern "C" fn OutputSweeper_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::chain::chaininterface::BroadcasterInterface, arg_b: crate::lightning::chain::chaininterface::FeeEstimator, arg_c: crate::c_types::derived::COption_FilterZ, arg_d: crate::lightning::sign::OutputSpender, arg_e: crate::lightning::sign::ChangeDestinationSource, arg_f: crate::lightning::util::persist::KVStore, arg_g: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_OutputSweeperDecodeErrorZ { + let arg_a_conv = arg_a; + let arg_b_conv = arg_b; + let mut local_arg_c = { /*arg_c*/ let arg_c_opt = arg_c; if arg_c_opt.is_none() { None } else { Some({ { { arg_c_opt.take() } }})} }; + let arg_c_conv = local_arg_c; + let arg_d_conv = arg_d; + let arg_e_conv = arg_e; + let arg_f_conv = arg_f; + let arg_g_conv = arg_g; + let arg_conv = (arg_a_conv, arg_b_conv, arg_c_conv, arg_d_conv, arg_e_conv, arg_f_conv, arg_g_conv); + let res: Result, lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::util::sweep::OutputSweeper { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} +#[no_mangle] +/// Read a C2Tuple_BestBlockOutputSweeperZ from a byte array, created by C2Tuple_BestBlockOutputSweeperZ_write +pub extern "C" fn C2Tuple_BestBlockOutputSweeperZ_read(ser: crate::c_types::u8slice, arg_a: crate::lightning::chain::chaininterface::BroadcasterInterface, arg_b: crate::lightning::chain::chaininterface::FeeEstimator, arg_c: crate::c_types::derived::COption_FilterZ, arg_d: crate::lightning::sign::OutputSpender, arg_e: crate::lightning::sign::ChangeDestinationSource, arg_f: crate::lightning::util::persist::KVStore, arg_g: crate::lightning::util::logger::Logger) -> crate::c_types::derived::CResult_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ { + let arg_a_conv = arg_a; + let arg_b_conv = arg_b; + let mut local_arg_c = { /*arg_c*/ let arg_c_opt = arg_c; if arg_c_opt.is_none() { None } else { Some({ { { arg_c_opt.take() } }})} }; + let arg_c_conv = local_arg_c; + let arg_d_conv = arg_d; + let arg_e_conv = arg_e; + let arg_f_conv = arg_f; + let arg_g_conv = arg_g; + let arg_conv = (arg_a_conv, arg_b_conv, arg_c_conv, arg_d_conv, arg_e_conv, arg_f_conv, arg_g_conv); + let res: Result<(lightning::chain::BestBlock, lightning::util::sweep::OutputSweeper), lightning::ln::msgs::DecodeError> = crate::c_types::deserialize_obj_arg(ser, arg_conv); + let mut local_res = match res { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_res_0_0, mut orig_res_0_1) = o; let mut local_res_0 = (crate::lightning::chain::BestBlock { inner: ObjOps::heap_alloc(orig_res_0_0), is_owned: true }, crate::lightning::util::sweep::OutputSweeper { inner: ObjOps::heap_alloc(orig_res_0_1), is_owned: true }).into(); local_res_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::DecodeError::native_into(e) }).into() }; + local_res +} diff --git a/lightning-c-bindings/src/lightning/util/wakers.rs b/lightning-c-bindings/src/lightning/util/wakers.rs index bf85828..1376de5 100644 --- a/lightning-c-bindings/src/lightning/util/wakers.rs +++ b/lightning-c-bindings/src/lightning/util/wakers.rs @@ -58,17 +58,24 @@ impl rustFutureCallback for FutureCallback { } } +pub struct FutureCallbackRef(FutureCallback); +impl rustFutureCallback for FutureCallbackRef { + fn call(&self) { + (self.0.call)(self.0.this_arg) + } +} + // We're essentially a pointer already, or at least a set of pointers, so allow us to be used // directly as a Deref trait in higher-level structs: impl core::ops::Deref for FutureCallback { - type Target = Self; - fn deref(&self) -> &Self { - self + type Target = FutureCallbackRef; + fn deref(&self) -> &Self::Target { + unsafe { &*(self as *const _ as *const FutureCallbackRef) } } } impl core::ops::DerefMut for FutureCallback { - fn deref_mut(&mut self) -> &mut Self { - self + fn deref_mut(&mut self) -> &mut FutureCallbackRef { + unsafe { &mut *(self as *mut _ as *mut FutureCallbackRef) } } } /// Calls the free function if one is set @@ -86,8 +93,6 @@ use lightning::util::wakers::Future as nativeFutureImport; pub(crate) type nativeFuture = nativeFutureImport; /// A simple future which can complete once, and calls some callback(s) when it does so. -/// -/// Clones can be made and all futures cloned from the same source will complete at the same time. #[must_use] #[repr(C)] pub struct Future { @@ -103,6 +108,12 @@ pub struct Future { pub is_owned: bool, } +impl core::ops::Deref for Future { + type Target = nativeFuture; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Future { } +unsafe impl core::marker::Sync for Future { } impl Drop for Future { fn drop(&mut self) { if self.is_owned && !<*mut nativeFuture>::is_null(self.inner) { @@ -133,26 +144,10 @@ impl Future { self.inner = core::ptr::null_mut(); ret } -} -impl Clone for Future { - fn clone(&self) -> Self { - Self { - inner: if <*mut nativeFuture>::is_null(self.inner) { core::ptr::null_mut() } else { - ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, - is_owned: true, - } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } } } -#[allow(unused)] -/// Used only if an object of this type is returned as a trait impl by a method -pub(crate) extern "C" fn Future_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeFuture)).clone() })) as *mut c_void -} -#[no_mangle] -/// Creates a copy of the Future -pub extern "C" fn Future_clone(orig: &Future) -> Future { - orig.clone() -} /// Registers a callback to be called upon completion of this future. If the future has already /// completed, the callback will be called immediately. #[no_mangle] @@ -162,8 +157,8 @@ pub extern "C" fn Future_register_callback_fn(this_arg: &crate::lightning::util: /// Waits until this [`Future`] completes. #[no_mangle] -pub extern "C" fn Future_wait(mut this_arg: crate::lightning::util::wakers::Future) { - (*unsafe { Box::from_raw(this_arg.take_inner()) }).wait() +pub extern "C" fn Future_wait(this_arg: &crate::lightning::util::wakers::Future) { + unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.wait() } /// Waits until this [`Future`] completes or the given amount of time has elapsed. @@ -171,8 +166,8 @@ pub extern "C" fn Future_wait(mut this_arg: crate::lightning::util::wakers::Futu /// Returns true if the [`Future`] completed, false if the time elapsed. #[must_use] #[no_mangle] -pub extern "C" fn Future_wait_timeout(mut this_arg: crate::lightning::util::wakers::Future, mut max_wait: u64) -> bool { - let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).wait_timeout(core::time::Duration::from_secs(max_wait)); +pub extern "C" fn Future_wait_timeout(this_arg: &crate::lightning::util::wakers::Future, mut max_wait: u64) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.wait_timeout(core::time::Duration::from_secs(max_wait)); ret } @@ -197,6 +192,12 @@ pub struct Sleeper { pub is_owned: bool, } +impl core::ops::Deref for Sleeper { + type Target = nativeSleeper; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Sleeper { } +unsafe impl core::marker::Sync for Sleeper { } impl Drop for Sleeper { fn drop(&mut self) { if self.is_owned && !<*mut nativeSleeper>::is_null(self.inner) { @@ -227,20 +228,32 @@ impl Sleeper { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new sleeper from one future, allowing blocking on it. #[must_use] #[no_mangle] -pub extern "C" fn Sleeper_from_single_future(mut future: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { - let mut ret = lightning::util::wakers::Sleeper::from_single_future(*unsafe { Box::from_raw(future.take_inner()) }); +pub extern "C" fn Sleeper_from_single_future(future: &crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_single_future(future.get_native_ref()); crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Constructs a new sleeper from two futures, allowing blocking on both at once. #[must_use] #[no_mangle] -pub extern "C" fn Sleeper_from_two_futures(mut fut_a: crate::lightning::util::wakers::Future, mut fut_b: crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { - let mut ret = lightning::util::wakers::Sleeper::from_two_futures(*unsafe { Box::from_raw(fut_a.take_inner()) }, *unsafe { Box::from_raw(fut_b.take_inner()) }); +pub extern "C" fn Sleeper_from_two_futures(fut_a: &crate::lightning::util::wakers::Future, fut_b: &crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_two_futures(fut_a.get_native_ref(), fut_b.get_native_ref()); + crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a new sleeper from three futures, allowing blocking on all three at once. +/// +#[must_use] +#[no_mangle] +pub extern "C" fn Sleeper_from_three_futures(fut_a: &crate::lightning::util::wakers::Future, fut_b: &crate::lightning::util::wakers::Future, fut_c: &crate::lightning::util::wakers::Future) -> crate::lightning::util::wakers::Sleeper { + let mut ret = lightning::util::wakers::Sleeper::from_three_futures(fut_a.get_native_ref(), fut_b.get_native_ref(), fut_c.get_native_ref()); crate::lightning::util::wakers::Sleeper { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning_background_processor.rs b/lightning-c-bindings/src/lightning_background_processor.rs index eb8c0f1..259996a 100644 --- a/lightning-c-bindings/src/lightning_background_processor.rs +++ b/lightning-c-bindings/src/lightning_background_processor.rs @@ -45,6 +45,8 @@ pub(crate) type nativeBackgroundProcessor = nativeBackgroundProcessorImport; /// However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for /// unilateral chain closure fees are at risk. /// +/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager +/// [`ChannelManager::timer_tick_occurred`]: lightning::ln::channelmanager::ChannelManager::timer_tick_occurred /// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor /// [`Event`]: lightning::events::Event /// [`PeerManager::timer_tick_occurred`]: lightning::ln::peer_handler::PeerManager::timer_tick_occurred @@ -65,6 +67,12 @@ pub struct BackgroundProcessor { pub is_owned: bool, } +impl core::ops::Deref for BackgroundProcessor { + type Target = nativeBackgroundProcessor; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BackgroundProcessor { } +unsafe impl core::marker::Sync for BackgroundProcessor { } impl Drop for BackgroundProcessor { fn drop(&mut self) { if self.is_owned && !<*mut nativeBackgroundProcessor>::is_null(self.inner) { @@ -95,6 +103,9 @@ impl BackgroundProcessor { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Either [`P2PGossipSync`] or [`RapidGossipSync`]. #[must_use] @@ -112,7 +123,7 @@ pub enum GossipSync { None, } use lightning_background_processor::GossipSync as GossipSyncImport; -pub(crate) type nativeGossipSync = GossipSyncImport<&'static lightning::routing::gossip::P2PGossipSync<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger>, &'static lightning_rapid_gossip_sync::RapidGossipSync<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger>, &'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger>; +pub(crate) type nativeGossipSync = GossipSyncImport<&'static lightning::routing::gossip::P2PGossipSync<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger>, &'static lightning_rapid_gossip_sync::RapidGossipSync<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger>, &'static lightning::routing::gossip::NetworkGraph, crate::lightning::routing::utxo::UtxoLookup, crate::lightning::util::logger::Logger, >; impl GossipSync { #[allow(unused)] @@ -216,9 +227,9 @@ pub extern "C" fn GossipSync_none() -> GossipSync { /// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable #[must_use] #[no_mangle] -pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::c_types::derived::COption_WriteableScoreZ) -> crate::lightning_background_processor::BackgroundProcessor { +pub extern "C" fn BackgroundProcessor_start(mut persister: crate::lightning::util::persist::Persister, mut event_handler: crate::lightning::events::EventHandler, chain_monitor: &crate::lightning::chain::chainmonitor::ChainMonitor, channel_manager: &crate::lightning::ln::channelmanager::ChannelManager, onion_messenger: &crate::lightning::onion_message::messenger::OnionMessenger, mut gossip_sync: crate::lightning_background_processor::GossipSync, peer_manager: &crate::lightning::ln::peer_handler::PeerManager, mut logger: crate::lightning::util::logger::Logger, mut scorer: crate::c_types::derived::COption_WriteableScoreZ) -> crate::lightning_background_processor::BackgroundProcessor { let mut local_scorer = { /*scorer*/ let scorer_opt = scorer; if scorer_opt.is_none() { None } else { Some({ { { scorer_opt.take() } }})} }; - let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.get_native_ref(), gossip_sync.into_native(), peer_manager.get_native_ref(), logger, local_scorer); + let mut ret = lightning_background_processor::BackgroundProcessor::start(persister, event_handler, chain_monitor.get_native_ref(), channel_manager.as_ref_to(), onion_messenger.as_ref_to(), gossip_sync.into_native(), peer_manager.as_ref_to(), logger, local_scorer); crate::lightning_background_processor::BackgroundProcessor { inner: ObjOps::heap_alloc(ret), is_owned: true } } diff --git a/lightning-c-bindings/src/lightning_invoice/mod.rs b/lightning-c-bindings/src/lightning_invoice/mod.rs index 4c8a964..25f6a63 100644 --- a/lightning-c-bindings/src/lightning_invoice/mod.rs +++ b/lightning-c-bindings/src/lightning_invoice/mod.rs @@ -26,8 +26,6 @@ use crate::c_types::*; #[cfg(feature="no-std")] use alloc::{vec::Vec, boxed::Box}; -pub mod payment; -pub mod utils; pub mod constants; mod de { @@ -626,11 +624,9 @@ pub static MAX_TIMESTAMP: u64 = lightning_invoice::MAX_TIMESTAMP; pub static DEFAULT_EXPIRY_TIME: u64 = lightning_invoice::DEFAULT_EXPIRY_TIME; /// Default minimum final CLTV expiry as defined by [BOLT 11]. /// -/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry, which is -/// provided in [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. +/// Note that this is *not* the same value as rust-lightning's minimum CLTV expiry. /// /// [BOLT 11]: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA #[no_mangle] pub static DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; @@ -661,6 +657,12 @@ pub struct Bolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for Bolt11Invoice { + type Target = nativeBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11Invoice { } +unsafe impl core::marker::Sync for Bolt11Invoice { } impl Drop for Bolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt11Invoice>::is_null(self.inner) { @@ -691,6 +693,9 @@ impl Bolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two Bolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -757,6 +762,12 @@ pub struct SignedRawBolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for SignedRawBolt11Invoice { + type Target = nativeSignedRawBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for SignedRawBolt11Invoice { } +unsafe impl core::marker::Sync for SignedRawBolt11Invoice { } impl Drop for SignedRawBolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeSignedRawBolt11Invoice>::is_null(self.inner) { @@ -787,6 +798,9 @@ impl SignedRawBolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two SignedRawBolt11Invoices contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -853,6 +867,12 @@ pub struct RawBolt11Invoice { pub is_owned: bool, } +impl core::ops::Deref for RawBolt11Invoice { + type Target = nativeRawBolt11Invoice; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RawBolt11Invoice { } +unsafe impl core::marker::Sync for RawBolt11Invoice { } impl Drop for RawBolt11Invoice { fn drop(&mut self) { if self.is_owned && !<*mut nativeRawBolt11Invoice>::is_null(self.inner) { @@ -883,6 +903,9 @@ impl RawBolt11Invoice { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// data part #[no_mangle] @@ -956,6 +979,12 @@ pub struct RawDataPart { pub is_owned: bool, } +impl core::ops::Deref for RawDataPart { + type Target = nativeRawDataPart; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RawDataPart { } +unsafe impl core::marker::Sync for RawDataPart { } impl Drop for RawDataPart { fn drop(&mut self) { if self.is_owned && !<*mut nativeRawDataPart>::is_null(self.inner) { @@ -986,6 +1015,9 @@ impl RawDataPart { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// generation time of the invoice #[no_mangle] @@ -1064,6 +1096,12 @@ pub struct PositiveTimestamp { pub is_owned: bool, } +impl core::ops::Deref for PositiveTimestamp { + type Target = nativePositiveTimestamp; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PositiveTimestamp { } +unsafe impl core::marker::Sync for PositiveTimestamp { } impl Drop for PositiveTimestamp { fn drop(&mut self) { if self.is_owned && !<*mut nativePositiveTimestamp>::is_null(self.inner) { @@ -1094,6 +1132,9 @@ impl PositiveTimestamp { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Checks if two PositiveTimestamps contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. @@ -1385,6 +1426,12 @@ pub struct Sha256 { pub is_owned: bool, } +impl core::ops::Deref for Sha256 { + type Target = nativeSha256; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Sha256 { } +unsafe impl core::marker::Sync for Sha256 { } impl Drop for Sha256 { fn drop(&mut self) { if self.is_owned && !<*mut nativeSha256>::is_null(self.inner) { @@ -1415,6 +1462,9 @@ impl Sha256 { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Sha256 { fn clone(&self) -> Self { @@ -1489,6 +1539,12 @@ pub struct Description { pub is_owned: bool, } +impl core::ops::Deref for Description { + type Target = nativeDescription; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Description { } +unsafe impl core::marker::Sync for Description { } impl Drop for Description { fn drop(&mut self) { if self.is_owned && !<*mut nativeDescription>::is_null(self.inner) { @@ -1519,6 +1575,9 @@ impl Description { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for Description { fn clone(&self) -> Self { @@ -1581,6 +1640,12 @@ pub struct PayeePubKey { pub is_owned: bool, } +impl core::ops::Deref for PayeePubKey { + type Target = nativePayeePubKey; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PayeePubKey { } +unsafe impl core::marker::Sync for PayeePubKey { } impl Drop for PayeePubKey { fn drop(&mut self) { if self.is_owned && !<*mut nativePayeePubKey>::is_null(self.inner) { @@ -1611,6 +1676,9 @@ impl PayeePubKey { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn PayeePubKey_get_a(this_ptr: &PayeePubKey) -> crate::c_types::PublicKey { @@ -1691,6 +1759,12 @@ pub struct ExpiryTime { pub is_owned: bool, } +impl core::ops::Deref for ExpiryTime { + type Target = nativeExpiryTime; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ExpiryTime { } +unsafe impl core::marker::Sync for ExpiryTime { } impl Drop for ExpiryTime { fn drop(&mut self) { if self.is_owned && !<*mut nativeExpiryTime>::is_null(self.inner) { @@ -1721,6 +1795,9 @@ impl ExpiryTime { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for ExpiryTime { fn clone(&self) -> Self { @@ -1783,6 +1860,12 @@ pub struct MinFinalCltvExpiryDelta { pub is_owned: bool, } +impl core::ops::Deref for MinFinalCltvExpiryDelta { + type Target = nativeMinFinalCltvExpiryDelta; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for MinFinalCltvExpiryDelta { } +unsafe impl core::marker::Sync for MinFinalCltvExpiryDelta { } impl Drop for MinFinalCltvExpiryDelta { fn drop(&mut self) { if self.is_owned && !<*mut nativeMinFinalCltvExpiryDelta>::is_null(self.inner) { @@ -1813,6 +1896,9 @@ impl MinFinalCltvExpiryDelta { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } #[no_mangle] pub extern "C" fn MinFinalCltvExpiryDelta_get_a(this_ptr: &MinFinalCltvExpiryDelta) -> u64 { @@ -1905,13 +1991,13 @@ impl Fallback { Fallback::PubKeyHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::PubKeyHash ( - bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), + bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), ) }, Fallback::ScriptHash (ref a, ) => { let mut a_nonref = Clone::clone(a); nativeFallback::ScriptHash ( - bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), + bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a_nonref.data)), ) }, } @@ -1928,12 +2014,12 @@ impl Fallback { }, Fallback::PubKeyHash (mut a, ) => { nativeFallback::PubKeyHash ( - bitcoin::hash_types::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), + bitcoin::PubkeyHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), ) }, Fallback::ScriptHash (mut a, ) => { nativeFallback::ScriptHash ( - bitcoin::hash_types::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), + bitcoin::ScriptHash::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(a.data)), ) }, } @@ -2062,6 +2148,12 @@ pub struct Bolt11InvoiceSignature { pub is_owned: bool, } +impl core::ops::Deref for Bolt11InvoiceSignature { + type Target = nativeBolt11InvoiceSignature; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11InvoiceSignature { } +unsafe impl core::marker::Sync for Bolt11InvoiceSignature { } impl Drop for Bolt11InvoiceSignature { fn drop(&mut self) { if self.is_owned && !<*mut nativeBolt11InvoiceSignature>::is_null(self.inner) { @@ -2092,6 +2184,26 @@ impl Bolt11InvoiceSignature { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_get_a(this_ptr: &Bolt11InvoiceSignature) -> crate::c_types::RecoverableSignature { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + crate::c_types::RecoverableSignature::from_rust(&inner_val) +} +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_set_a(this_ptr: &mut Bolt11InvoiceSignature, mut val: crate::c_types::RecoverableSignature) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_rust(); +} +/// Constructs a new Bolt11InvoiceSignature given each field +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceSignature_new(mut a_arg: crate::c_types::RecoverableSignature) -> Bolt11InvoiceSignature { + Bolt11InvoiceSignature { inner: ObjOps::heap_alloc(lightning_invoice::Bolt11InvoiceSignature ( + a_arg.into_rust(), + )), is_owned: true } } impl Clone for Bolt11InvoiceSignature { fn clone(&self) -> Self { @@ -2158,6 +2270,12 @@ pub struct PrivateRoute { pub is_owned: bool, } +impl core::ops::Deref for PrivateRoute { + type Target = nativePrivateRoute; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrivateRoute { } +unsafe impl core::marker::Sync for PrivateRoute { } impl Drop for PrivateRoute { fn drop(&mut self) { if self.is_owned && !<*mut nativePrivateRoute>::is_null(self.inner) { @@ -2188,6 +2306,9 @@ impl PrivateRoute { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } impl Clone for PrivateRoute { fn clone(&self) -> Self { @@ -2372,9 +2493,9 @@ pub extern "C" fn RawBolt11Invoice_payment_metadata(this_arg: &crate::lightning_ /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { +pub extern "C" fn RawBolt11Invoice_features(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::lightning_types::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2386,6 +2507,7 @@ pub extern "C" fn RawBolt11Invoice_private_routes(this_arg: &crate::lightning_in local_ret.into() } +/// Returns `None` if no amount is set or on overflow. #[must_use] #[no_mangle] pub extern "C" fn RawBolt11Invoice_amount_pico_btc(this_arg: &crate::lightning_invoice::RawBolt11Invoice) -> crate::c_types::derived::COption_u64Z { @@ -2574,9 +2696,9 @@ pub extern "C" fn Bolt11Invoice_payment_metadata(this_arg: &crate::lightning_inv /// Note that the return value (or a relevant inner pointer) may be NULL or all-0s to represent None #[must_use] #[no_mangle] -pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning::ln::features::Bolt11InvoiceFeatures { +pub extern "C" fn Bolt11Invoice_features(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::lightning_types::features::Bolt11InvoiceFeatures { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features(); - let mut local_ret = crate::lightning::ln::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; + let mut local_ret = crate::lightning_types::features::Bolt11InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_types::features::Bolt11InvoiceFeatures<>) as *mut _ }, is_owned: false }; local_ret } @@ -2588,6 +2710,15 @@ pub extern "C" fn Bolt11Invoice_recover_payee_pub_key(this_arg: &crate::lightnin crate::c_types::PublicKey::from_rust(&ret) } +/// Recover the payee's public key if one was included in the invoice, otherwise return the +/// recovered public key from the signature +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11Invoice_get_payee_pub_key(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::PublicKey { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.get_payee_pub_key(); + crate::c_types::PublicKey::from_rust(&ret) +} + /// Returns the Duration since the Unix epoch at which the invoice expires. /// Returning None if overflow occurred. #[must_use] @@ -2672,7 +2803,7 @@ pub extern "C" fn Bolt11Invoice_private_routes(this_arg: &crate::lightning_invoi #[no_mangle] pub extern "C" fn Bolt11Invoice_route_hints(this_arg: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CVec_RouteHintZ { let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.route_hints(); - let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(item), is_owned: true } }); }; local_ret.into() } @@ -2693,8 +2824,8 @@ pub extern "C" fn Bolt11Invoice_amount_milli_satoshis(this_arg: &crate::lightnin local_ret } -/// Creates a new `Description` if `description` is at most 1023 __bytes__ long, -/// returns [`CreationError::DescriptionTooLong`] otherwise +/// Creates a new `Description` if `description` is at most 1023 * 5 bits (i.e., 639 bytes) +/// long, and returns [`CreationError::DescriptionTooLong`] otherwise. /// /// Please note that single characters may use more than one byte due to UTF8 encoding. #[must_use] @@ -2708,9 +2839,17 @@ pub extern "C" fn Description_new(mut description: crate::c_types::Str) -> crate /// Returns the underlying description [`UntrustedString`] #[must_use] #[no_mangle] -pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::lightning::util::string::UntrustedString { +pub extern "C" fn Description_into_inner(mut this_arg: crate::lightning_invoice::Description) -> crate::lightning_types::string::UntrustedString { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); - crate::lightning::util::string::UntrustedString { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::string::UntrustedString { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Get a reference to the underlying description [`UntrustedString`] +#[must_use] +#[no_mangle] +pub extern "C" fn Description_as_inner(this_arg: &crate::lightning_invoice::Description) -> crate::lightning_types::string::UntrustedString { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.as_inner(); + crate::lightning_types::string::UntrustedString { inner: unsafe { ObjOps::nonnull_ptr_to_inner((ret as *const lightning_types::string::UntrustedString<>) as *mut _) }, is_owned: false } } #[no_mangle] @@ -2753,7 +2892,7 @@ pub extern "C" fn ExpiryTime_as_duration(this_arg: &crate::lightning_invoice::Ex /// Creates a new (partial) route from a list of hops #[must_use] #[no_mangle] -pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ { +pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning_types::routing::RouteHint) -> crate::c_types::derived::CResult_PrivateRouteCreationErrorZ { let mut ret = lightning_invoice::PrivateRoute::new(*unsafe { Box::from_raw(hops.take_inner()) }); let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::PrivateRoute { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() }; local_ret @@ -2762,9 +2901,9 @@ pub extern "C" fn PrivateRoute_new(mut hops: crate::lightning::routing::router:: /// Returns the underlying list of hops #[must_use] #[no_mangle] -pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning::routing::router::RouteHint { +pub extern "C" fn PrivateRoute_into_inner(mut this_arg: crate::lightning_invoice::PrivateRoute) -> crate::lightning_types::routing::RouteHint { let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).into_inner(); - crate::lightning::routing::router::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } + crate::lightning_types::routing::RouteHint { inner: ObjOps::heap_alloc(ret), is_owned: true } } /// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] @@ -2780,14 +2919,9 @@ pub enum CreationError { TimestampOutOfBounds, /// The supplied millisatoshi amount was greater than the total bitcoin supply. InvalidAmount, - /// Route hints were required for this invoice and were missing. Applies to - /// [phantom invoices]. - /// - /// [phantom invoices]: crate::utils::create_phantom_invoice + /// Route hints were required for this invoice and were missing. MissingRouteHints, - /// The provided `min_final_cltv_expiry_delta` was less than [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. - /// - /// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA + /// The provided `min_final_cltv_expiry_delta` was less than rust-lightning's minimum. MinFinalCltvExpiryDeltaTooShort, } use lightning_invoice::CreationError as CreationErrorImport; diff --git a/lightning-c-bindings/src/lightning_invoice/payment.rs b/lightning-c-bindings/src/lightning_invoice/payment.rs deleted file mode 100644 index de0ea57..0000000 --- a/lightning-c-bindings/src/lightning_invoice/payment.rs +++ /dev/null @@ -1,56 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Convenient utilities for paying Lightning invoices. - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -/// Builds the necessary parameters to pay or pre-flight probe the given zero-amount -/// [`Bolt11Invoice`] using [`ChannelManager::send_payment`] or -/// [`ChannelManager::send_preflight_probes`]. -/// -/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the -/// same [`PaymentHash`] has never been paid before. -/// -/// Will always succeed unless the invoice has an amount specified, in which case -/// [`payment_parameters_from_invoice`] should be used. -/// -/// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment -/// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes -#[no_mangle] -pub extern "C" fn payment_parameters_from_zero_amount_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice, mut amount_msat: u64) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - let mut ret = lightning_invoice::payment::payment_parameters_from_zero_amount_invoice(invoice.get_native_ref(), amount_msat); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - -/// Builds the necessary parameters to pay or pre-flight probe the given [`Bolt11Invoice`] using -/// [`ChannelManager::send_payment`] or [`ChannelManager::send_preflight_probes`]. -/// -/// Prior to paying, you must ensure that the [`Bolt11Invoice::payment_hash`] is unique and the -/// same [`PaymentHash`] has never been paid before. -/// -/// Will always succeed unless the invoice has no amount specified, in which case -/// [`payment_parameters_from_zero_amount_invoice`] should be used. -/// -/// [`ChannelManager::send_payment`]: lightning::ln::channelmanager::ChannelManager::send_payment -/// [`ChannelManager::send_preflight_probes`]: lightning::ln::channelmanager::ChannelManager::send_preflight_probes -#[no_mangle] -pub extern "C" fn payment_parameters_from_invoice(invoice: &crate::lightning_invoice::Bolt11Invoice) -> crate::c_types::derived::CResult_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ { - let mut ret = lightning_invoice::payment::payment_parameters_from_invoice(invoice.get_native_ref()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = o; let mut local_ret_0 = (crate::c_types::ThirtyTwoBytes { data: orig_ret_0_0.0 }, crate::lightning::ln::outbound_payment::RecipientOnionFields { inner: ObjOps::heap_alloc(orig_ret_0_1), is_owned: true }, crate::lightning::routing::router::RouteParameters { inner: ObjOps::heap_alloc(orig_ret_0_2), is_owned: true }).into(); local_ret_0 }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/lightning_invoice/utils.rs b/lightning-c-bindings/src/lightning_invoice/utils.rs deleted file mode 100644 index 63295d6..0000000 --- a/lightning-c-bindings/src/lightning_invoice/utils.rs +++ /dev/null @@ -1,205 +0,0 @@ -// This file is Copyright its original authors, visible in version control -// history and in the source files from which this was generated. -// -// This file is licensed under the license available in the LICENSE or LICENSE.md -// file in the root of this repository or, if no such file exists, the same -// license as that which applies to the original source files from which this -// source was automatically generated. - -//! Convenient utilities to create an invoice. - -use alloc::str::FromStr; -use alloc::string::String; -use core::ffi::c_void; -use core::convert::Infallible; -use bitcoin::hashes::Hash; -use crate::c_types::*; -#[cfg(feature="no-std")] -use alloc::{vec::Vec, boxed::Box}; - -/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" -/// See [`PhantomKeysManager`] for more information on phantom node payments. -/// -/// `phantom_route_hints` parameter: -/// * Contains channel info for all nodes participating in the phantom invoice -/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each -/// participating node -/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is -/// updated when a channel becomes disabled or closes -/// * Note that if too many channels are included in [`PhantomRouteHints::channels`], the invoice -/// may be too long for QR code scanning. To fix this, `PhantomRouteHints::channels` may be pared -/// down -/// -/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference -/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). -/// If `None` is provided for `payment_hash`, then one will be created. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// `duration_since_epoch` is the current time since epoch in seconds. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`] - 3. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom -/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this -/// requirement). -/// -/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager -/// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints -/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment -/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash -/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA -/// -/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not -/// available and the current time is supplied by the caller. -#[no_mangle] -pub extern "C" fn create_phantom_invoice(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; - let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice::(local_amt_msat, local_payment_hash, description.into_string(), invoice_expiry_delta_secs, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// Utility to create an invoice that can be paid to one of multiple nodes, or a \"phantom invoice.\" -/// See [`PhantomKeysManager`] for more information on phantom node payments. -/// -/// `phantom_route_hints` parameter: -/// * Contains channel info for all nodes participating in the phantom invoice -/// * Entries are retrieved from a call to [`ChannelManager::get_phantom_route_hints`] on each -/// participating node -/// * It is fine to cache `phantom_route_hints` and reuse it across invoices, as long as the data is -/// updated when a channel becomes disabled or closes -/// * Note that the route hints generated from `phantom_route_hints` will be limited to a maximum -/// of 3 hints to ensure that the invoice can be scanned in a QR code. These hints are selected -/// in the order that the nodes in `PhantomRouteHints` are specified, selecting one hint per node -/// until the maximum is hit. Callers may provide as many `PhantomRouteHints::channels` as -/// desired, but note that some nodes will be trimmed if more than 3 nodes are provided. -/// -/// `description_hash` is a SHA-256 hash of the description text -/// -/// `payment_hash` can be specified if you have a specific need for a custom payment hash (see the difference -/// between [`ChannelManager::create_inbound_payment`] and [`ChannelManager::create_inbound_payment_for_hash`]). -/// If `None` is provided for `payment_hash`, then one will be created. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// `duration_since_epoch` is the current time since epoch in seconds. -/// -/// Note that the provided `keys_manager`'s `NodeSigner` implementation must support phantom -/// invoices in its `sign_invoice` implementation ([`PhantomKeysManager`] satisfies this -/// requirement). -/// -/// [`PhantomKeysManager`]: lightning::sign::PhantomKeysManager -/// [`ChannelManager::get_phantom_route_hints`]: lightning::ln::channelmanager::ChannelManager::get_phantom_route_hints -/// [`ChannelManager::create_inbound_payment`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment -/// [`ChannelManager::create_inbound_payment_for_hash`]: lightning::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash -/// [`PhantomRouteHints::channels`]: lightning::ln::channelmanager::PhantomRouteHints::channels -/// -/// This can be used in a `no_std` environment, where [`std::time::SystemTime`] is not -/// available and the current time is supplied by the caller. -#[no_mangle] -pub extern "C" fn create_phantom_invoice_with_description_hash(mut amt_msat: crate::c_types::derived::COption_u64Z, mut payment_hash: crate::c_types::derived::COption_ThirtyTwoBytesZ, mut invoice_expiry_delta_secs: u32, mut description_hash: crate::lightning_invoice::Sha256, mut phantom_route_hints: crate::c_types::derived::CVec_PhantomRouteHintsZ, mut entropy_source: crate::lightning::sign::EntropySource, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z, mut duration_since_epoch: u64) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_payment_hash = { /*payment_hash*/ let payment_hash_opt = payment_hash; if payment_hash_opt.is_none() { None } else { Some({ { ::lightning::ln::PaymentHash({ payment_hash_opt.take() }.data) }})} }; - let mut local_phantom_route_hints = Vec::new(); for mut item in phantom_route_hints.into_rust().drain(..) { local_phantom_route_hints.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_phantom_invoice_with_description_hash::(local_amt_msat, local_payment_hash, invoice_expiry_delta_secs, *unsafe { Box::from_raw(description_hash.take_inner()) }, local_phantom_route_hints, entropy_source, node_signer, logger, network.into_native(), local_min_final_cltv_expiry_delta, core::time::Duration::from_secs(duration_since_epoch)); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// Utility to construct an invoice. Generally, unless you want to do something like a custom -/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this -/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user -/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify -/// that the payment secret is valid when the invoice is paid. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA -#[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// Utility to construct an invoice. Generally, unless you want to do something like a custom -/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this -/// method stores the invoice's payment secret and preimage in `ChannelManager`, so (a) the user -/// doesn't have to store preimage/payment secret information and (b) `ChannelManager` can verify -/// that the payment secret is valid when the invoice is paid. -/// Use this variant if you want to pass the `description_hash` to the invoice. -/// -/// `invoice_expiry_delta_secs` describes the number of seconds that the invoice is valid for -/// in excess of the current time. -/// -/// You can specify a custom `min_final_cltv_expiry_delta`, or let LDK default it to -/// [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. The provided expiry must be at least [`MIN_FINAL_CLTV_EXPIRY_DELTA`]. -/// Note that LDK will add a buffer of 3 blocks to the delta to allow for up to a few new block -/// confirmations during routing. -/// -/// [`MIN_FINAL_CLTV_EXPIRY_DETLA`]: lightning::ln::channelmanager::MIN_FINAL_CLTV_EXPIRY_DELTA -#[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// See [`create_invoice_from_channelmanager_with_description_hash`] -/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not -/// available and the current time is supplied by the caller. -#[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description_hash: crate::lightning_invoice::Sha256, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, *unsafe { Box::from_raw(description_hash.take_inner()) }, core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// See [`create_invoice_from_channelmanager`] -/// This version can be used in a `no_std` environment, where [`std::time::SystemTime`] is not -/// available and the current time is supplied by the caller. -#[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - -/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`] -/// This version allows for providing a custom [`PaymentHash`] for the invoice. -/// This may be useful if you're building an on-chain swap or involving another protocol where -/// the payment hash is also involved outside the scope of lightning. -#[no_mangle] -pub extern "C" fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(channelmanager: &crate::lightning::ln::channelmanager::ChannelManager, mut node_signer: crate::lightning::sign::NodeSigner, mut logger: crate::lightning::util::logger::Logger, mut network: crate::lightning_invoice::Currency, mut amt_msat: crate::c_types::derived::COption_u64Z, mut description: crate::c_types::Str, mut duration_since_epoch: u64, mut invoice_expiry_delta_secs: u32, mut payment_hash: crate::c_types::ThirtyTwoBytes, mut min_final_cltv_expiry_delta: crate::c_types::derived::COption_u16Z) -> crate::c_types::derived::CResult_Bolt11InvoiceSignOrCreationErrorZ { - let mut local_amt_msat = if amt_msat.is_some() { Some( { amt_msat.take() }) } else { None }; - let mut local_min_final_cltv_expiry_delta = if min_final_cltv_expiry_delta.is_some() { Some( { min_final_cltv_expiry_delta.take() }) } else { None }; - let mut ret = lightning_invoice::utils::create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash::(channelmanager.get_native_ref(), node_signer, logger, network.into_native(), local_amt_msat, description.into_string(), core::time::Duration::from_secs(duration_since_epoch), invoice_expiry_delta_secs, ::lightning::ln::PaymentHash(payment_hash.data), local_min_final_cltv_expiry_delta); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::Bolt11Invoice { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::SignOrCreationError::native_into(e) }).into() }; - local_ret -} - diff --git a/lightning-c-bindings/src/lightning_persister/fs_store.rs b/lightning-c-bindings/src/lightning_persister/fs_store.rs index 073d9d9..46c355d 100644 --- a/lightning-c-bindings/src/lightning_persister/fs_store.rs +++ b/lightning-c-bindings/src/lightning_persister/fs_store.rs @@ -37,6 +37,12 @@ pub struct FilesystemStore { pub is_owned: bool, } +impl core::ops::Deref for FilesystemStore { + type Target = nativeFilesystemStore; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for FilesystemStore { } +unsafe impl core::marker::Sync for FilesystemStore { } impl Drop for FilesystemStore { fn drop(&mut self) { if self.is_owned && !<*mut nativeFilesystemStore>::is_null(self.inner) { @@ -67,6 +73,9 @@ impl FilesystemStore { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Constructs a new [`FilesystemStore`]. #[must_use] @@ -110,26 +119,26 @@ pub extern "C" fn FilesystemStore_as_KVStore(this_arg: &FilesystemStore) -> crat #[must_use] extern "C" fn FilesystemStore_KVStore_read(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str) -> crate::c_types::derived::CResult_CVec_u8ZIOErrorZ { - let mut ret = >::read(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut ret = ::read(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_write(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str, mut buf: crate::c_types::u8slice) -> crate::c_types::derived::CResult_NoneIOErrorZ { - let mut ret = >::write(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), buf.to_slice()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut ret = ::write(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), buf.to_slice()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_remove(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str, mut key: crate::c_types::Str, mut lazy: bool) -> crate::c_types::derived::CResult_NoneIOErrorZ { - let mut ret = >::remove(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), lazy); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut ret = ::remove(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str(), key.into_str(), lazy); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } #[must_use] extern "C" fn FilesystemStore_KVStore_list(this_arg: *const c_void, mut primary_namespace: crate::c_types::Str, mut secondary_namespace: crate::c_types::Str) -> crate::c_types::derived::CResult_CVec_StrZIOErrorZ { - let mut ret = >::list(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str()); - let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_rust(e) }).into() }; + let mut ret = ::list(unsafe { &mut *(this_arg as *mut nativeFilesystemStore) }, primary_namespace.into_str(), secondary_namespace.into_str()); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { let mut local_ret_0 = Vec::new(); for mut item in o.drain(..) { local_ret_0.push( { item.into() }); }; local_ret_0.into() }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::c_types::IOError::from_bitcoin(e) }).into() }; local_ret } diff --git a/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs b/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs index 591f26c..4286473 100644 --- a/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs +++ b/lightning-c-bindings/src/lightning_rapid_gossip_sync.rs @@ -37,7 +37,7 @@ //! from disk, which we do by calling [`RapidGossipSync::update_network_graph`]: //! //! ``` -//! use bitcoin::blockdata::constants::genesis_block; +//! use bitcoin::constants::genesis_block; //! use bitcoin::Network; //! use lightning::routing::gossip::NetworkGraph; //! use lightning_rapid_gossip_sync::RapidGossipSync; @@ -196,7 +196,7 @@ pub extern "C" fn GraphSyncError_debug_str_void(o: *const c_void) -> Str { alloc::format!("{:?}", unsafe { o as *const crate::lightning_rapid_gossip_sync::GraphSyncError }).into()} use lightning_rapid_gossip_sync::RapidGossipSync as nativeRapidGossipSyncImport; -pub(crate) type nativeRapidGossipSync = nativeRapidGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger>; +pub(crate) type nativeRapidGossipSync = nativeRapidGossipSyncImport<&'static lightning::routing::gossip::NetworkGraph, crate::lightning::util::logger::Logger, >; /// The main Rapid Gossip Sync object. /// @@ -218,6 +218,12 @@ pub struct RapidGossipSync { pub is_owned: bool, } +impl core::ops::Deref for RapidGossipSync { + type Target = nativeRapidGossipSync; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RapidGossipSync { } +unsafe impl core::marker::Sync for RapidGossipSync { } impl Drop for RapidGossipSync { fn drop(&mut self) { if self.is_owned && !<*mut nativeRapidGossipSync>::is_null(self.inner) { @@ -248,6 +254,9 @@ impl RapidGossipSync { self.inner = core::ptr::null_mut(); ret } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } } /// Instantiate a new [`RapidGossipSync`] instance. #[must_use] diff --git a/lightning-c-bindings/src/lightning_types/features.rs b/lightning-c-bindings/src/lightning_types/features.rs new file mode 100644 index 0000000..a7cfa21 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/features.rs @@ -0,0 +1,3614 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Feature flag definitions for the Lightning protocol according to [BOLT #9]. +//! +//! Lightning nodes advertise a supported set of operation through feature flags. Features are +//! applicable for a specific context. [`Features`] encapsulates behavior for specifying and +//! checking feature flags for a particular context. Each feature is defined internally by a trait +//! specifying the corresponding flags (i.e., even and odd bits). +//! +//! Whether a feature is considered \"known\" or \"unknown\" is relative to the implementation, whereas +//! the term \"supports\" is used in reference to a particular set of [`Features`]. That is, a node +//! supports a feature if it advertises the feature (as either required or optional) to its peers. +//! And the implementation can interpret a feature if the feature is known to it. +//! +//! The following features are currently required in the LDK: +//! - `VariableLengthOnion` - requires/supports variable-length routing onion payloads +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). +//! - `StaticRemoteKey` - requires/supports static key for remote output +//! (see [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more information). +//! +//! The following features are currently supported in the LDK: +//! - `DataLossProtect` - requires/supports that a node which has somehow fallen behind, e.g., has been restored from an old backup, +//! can detect that it has fallen behind +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `InitialRoutingSync` - requires/supports that the sending node needs a complete routing information dump +//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#initial-sync) for more information). +//! - `UpfrontShutdownScript` - commits to a shutdown scriptpubkey when opening a channel +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). +//! - `GossipQueries` - requires/supports more sophisticated gossip control +//! (see [BOLT-7](https://github.com/lightning/bolts/blob/master/07-routing-gossip.md) for more information). +//! - `PaymentSecret` - requires/supports that a node supports payment_secret field +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md) for more information). +//! - `BasicMPP` - requires/supports that a node can receive basic multi-part payments +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#basic-multi-part-payments) for more information). +//! - `Wumbo` - requires/supports that a node create large channels. Called `option_support_large_channel` in the spec. +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-open_channel-message) for more information). +//! - `AnchorsZeroFeeHtlcTx` - requires/supports that commitment transactions include anchor outputs +//! and HTLC transactions are pre-signed with zero fee (see +//! [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more +//! information). +//! - `RouteBlinding` - requires/supports that a node can relay payments over blinded paths +//! (see [BOLT-4](https://github.com/lightning/bolts/blob/master/04-onion-routing.md#route-blinding) for more information). +//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown` +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `OnionMessages` - requires/supports forwarding onion messages +//! (see [BOLT-7](https://github.com/lightning/bolts/pull/759/files) for more information). +//! - `ChannelType` - node supports the channel_type field in open/accept +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `SCIDPrivacy` - supply channel aliases for routing +//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). +//! - `PaymentMetadata` - include additional data in invoices which is passed to recipients in the +//! onion. +//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for +//! more). +//! - `ZeroConf` - supports accepting HTLCs and using channels prior to funding confirmation +//! (see +//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) +//! for more info). +//! - `Keysend` - send funds to a node without an invoice +//! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information). +//! - `Trampoline` - supports receiving and forwarding Trampoline payments +//! (see the [`Trampoline` feature proposal](https://github.com/lightning/bolts/pull/836) for more information). +//! +//! LDK knows about the following features, but does not support them: +//! - `AnchorsNonzeroFeeHtlcTx` - the initial version of anchor outputs, which was later found to be +//! vulnerable (see this +//! [mailing list post](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html) +//! for more information). +//! +//! [BOLT #9]: https://github.com/lightning/bolts/blob/master/09-features.md + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +mod sealed { + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_data_loss_protect_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_data_loss_protect_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_data_loss_protect(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_data_loss_protect_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_data_loss_protect_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_data_loss_protect_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_data_loss_protect_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_data_loss_protect(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_data_loss_protect(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_data_loss_protect(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_data_loss_protect(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_data_loss_protect(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_initial_routing_sync_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_initial_routing_sync_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_initial_routing_sync_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_initial_routing_sync_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_initial_routing_sync(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.initial_routing_sync(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_upfront_shutdown_script_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_upfront_shutdown_script_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_upfront_shutdown_script_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_upfront_shutdown_script_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_upfront_shutdown_script(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_upfront_shutdown_script(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_upfront_shutdown_script(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_upfront_shutdown_script(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_gossip_queries_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_gossip_queries_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_gossip_queries(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_gossip_queries_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_gossip_queries_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_gossip_queries_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_gossip_queries_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_gossip_queries(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_gossip_queries(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_gossip_queries(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_gossip_queries(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_gossip_queries(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_variable_length_onion_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_variable_length_onion_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_variable_length_onion(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_variable_length_onion(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_variable_length_onion(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_static_remote_key_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_static_remote_key_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_static_remote_key_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_static_remote_key(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_static_remote_key(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_static_remote_key(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_secret_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_secret_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_secret(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_secret(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_secret(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_optional(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_basic_mpp_required(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_basic_mpp_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_basic_mpp(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_basic_mpp(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_basic_mpp(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_wumbo_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_wumbo_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_wumbo_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_wumbo_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_wumbo(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_wumbo_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_wumbo_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_wumbo_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_wumbo_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_wumbo(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_wumbo(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_wumbo(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_wumbo(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_wumbo(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_nonzero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_nonzero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_anchors_zero_fee_htlc_tx_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_anchors_zero_fee_htlc_tx(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_route_blinding_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_route_blinding_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_route_blinding_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_route_blinding(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_route_blinding_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_route_blinding_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_route_blinding_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_route_blinding_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_route_blinding(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_route_blinding(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_route_blinding(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_route_blinding(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_route_blinding(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_shutdown_any_segwit_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_shutdown_any_segwit_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_shutdown_any_segwit_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_shutdown_any_segwit_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_shutdown_anysegwit(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_shutdown_anysegwit(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_shutdown_anysegwit(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_shutdown_anysegwit(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_taproot(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_taproot(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_taproot_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_taproot_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_taproot_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_taproot_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_taproot(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_taproot(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_taproot(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_taproot(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_taproot(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_onion_messages_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_onion_messages_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_onion_messages_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_onion_messages(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_onion_messages_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_onion_messages_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_onion_messages_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_onion_messages_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_onion_messages(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_onion_messages(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_onion_messages(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_onion_messages(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_onion_messages(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_channel_type_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_channel_type_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_channel_type_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_channel_type_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_channel_type(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_channel_type_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_channel_type_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_channel_type_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_channel_type_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_channel_type(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_channel_type(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_channel_type(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_channel_type(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_channel_type(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_scid_privacy_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_scid_privacy_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_scid_privacy_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_scid_privacy(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_scid_privacy(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_scid_privacy(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_payment_metadata_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_payment_metadata_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_payment_metadata(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_payment_metadata(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_payment_metadata(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_payment_metadata(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_zero_conf_optional(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_zero_conf_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_zero_conf_required(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_zero_conf_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_zero_conf(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_zero_conf(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_zero_conf(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_keysend_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_keysend_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_keysend_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_keysend_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_keysend(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_keysend(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_keysend(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_keysend(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn InitFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn InitFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn NodeFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Set this feature as optional. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_optional(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_trampoline_routing_optional() +} + +/// Set this feature as required. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_trampoline_routing_required(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_trampoline_routing_required() +} + +/// Checks if this feature is supported. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_trampoline_routing(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +/// Checks if this feature is required. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_trampoline_routing(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_trampoline_routing(); + ret +} + +} +/// Checks if two InitFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn InitFeatures_eq(a: &InitFeatures, b: &InitFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two NodeFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn NodeFeatures_eq(a: &NodeFeatures, b: &NodeFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two ChannelFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelFeatures_eq(a: &ChannelFeatures, b: &ChannelFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two Bolt11InvoiceFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_eq(a: &Bolt11InvoiceFeatures, b: &Bolt11InvoiceFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two OfferFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn OfferFeatures_eq(a: &OfferFeatures, b: &OfferFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two InvoiceRequestFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_eq(a: &InvoiceRequestFeatures, b: &InvoiceRequestFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two Bolt12InvoiceFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_eq(a: &Bolt12InvoiceFeatures, b: &Bolt12InvoiceFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two BlindedHopFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_eq(a: &BlindedHopFeatures, b: &BlindedHopFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Checks if two ChannelTypeFeaturess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_eq(a: &ChannelTypeFeatures, b: &ChannelTypeFeatures) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +impl Clone for InitFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInitFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InitFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInitFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InitFeatures +pub extern "C" fn InitFeatures_clone(orig: &InitFeatures) -> InitFeatures { + orig.clone() +} +impl Clone for NodeFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeNodeFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the NodeFeatures +pub extern "C" fn NodeFeatures_clone(orig: &NodeFeatures) -> NodeFeatures { + orig.clone() +} +impl Clone for ChannelFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelFeatures +pub extern "C" fn ChannelFeatures_clone(orig: &ChannelFeatures) -> ChannelFeatures { + orig.clone() +} +impl Clone for Bolt11InvoiceFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt11InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt11InvoiceFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt11InvoiceFeatures +pub extern "C" fn Bolt11InvoiceFeatures_clone(orig: &Bolt11InvoiceFeatures) -> Bolt11InvoiceFeatures { + orig.clone() +} +impl Clone for OfferFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeOfferFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeOfferFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the OfferFeatures +pub extern "C" fn OfferFeatures_clone(orig: &OfferFeatures) -> OfferFeatures { + orig.clone() +} +impl Clone for InvoiceRequestFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeInvoiceRequestFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the InvoiceRequestFeatures +pub extern "C" fn InvoiceRequestFeatures_clone(orig: &InvoiceRequestFeatures) -> InvoiceRequestFeatures { + orig.clone() +} +impl Clone for Bolt12InvoiceFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12InvoiceFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBolt12InvoiceFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the Bolt12InvoiceFeatures +pub extern "C" fn Bolt12InvoiceFeatures_clone(orig: &Bolt12InvoiceFeatures) -> Bolt12InvoiceFeatures { + orig.clone() +} +impl Clone for BlindedHopFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeBlindedHopFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedHopFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeBlindedHopFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the BlindedHopFeatures +pub extern "C" fn BlindedHopFeatures_clone(orig: &BlindedHopFeatures) -> BlindedHopFeatures { + orig.clone() +} +impl Clone for ChannelTypeFeatures { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeChannelTypeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelTypeFeatures_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeChannelTypeFeatures)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the ChannelTypeFeatures +pub extern "C" fn ChannelTypeFeatures_clone(orig: &ChannelTypeFeatures) -> ChannelTypeFeatures { + orig.clone() +} +/// Generates a non-cryptographic 64-bit hash of the InitFeatures. +#[no_mangle] +pub extern "C" fn InitFeatures_hash(o: &InitFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the NodeFeatures. +#[no_mangle] +pub extern "C" fn NodeFeatures_hash(o: &NodeFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the ChannelFeatures. +#[no_mangle] +pub extern "C" fn ChannelFeatures_hash(o: &ChannelFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the Bolt11InvoiceFeatures. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_hash(o: &Bolt11InvoiceFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the OfferFeatures. +#[no_mangle] +pub extern "C" fn OfferFeatures_hash(o: &OfferFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the InvoiceRequestFeatures. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_hash(o: &InvoiceRequestFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the Bolt12InvoiceFeatures. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_hash(o: &Bolt12InvoiceFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the BlindedHopFeatures. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_hash(o: &BlindedHopFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Generates a non-cryptographic 64-bit hash of the ChannelTypeFeatures. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_hash(o: &ChannelTypeFeatures) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Get a string which allows debug introspection of a InitFeatures object +pub extern "C" fn InitFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::InitFeatures }).into()} +/// Get a string which allows debug introspection of a NodeFeatures object +pub extern "C" fn NodeFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::NodeFeatures }).into()} +/// Get a string which allows debug introspection of a ChannelFeatures object +pub extern "C" fn ChannelFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::ChannelFeatures }).into()} +/// Get a string which allows debug introspection of a Bolt11InvoiceFeatures object +pub extern "C" fn Bolt11InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::Bolt11InvoiceFeatures }).into()} +/// Get a string which allows debug introspection of a OfferFeatures object +pub extern "C" fn OfferFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::OfferFeatures }).into()} +/// Get a string which allows debug introspection of a InvoiceRequestFeatures object +pub extern "C" fn InvoiceRequestFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::InvoiceRequestFeatures }).into()} +/// Get a string which allows debug introspection of a Bolt12InvoiceFeatures object +pub extern "C" fn Bolt12InvoiceFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::Bolt12InvoiceFeatures }).into()} +/// Get a string which allows debug introspection of a BlindedHopFeatures object +pub extern "C" fn BlindedHopFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::BlindedHopFeatures }).into()} +/// Get a string which allows debug introspection of a ChannelTypeFeatures object +pub extern "C" fn ChannelTypeFeatures_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::features::ChannelTypeFeatures }).into()} + +use lightning_types::features::InitFeatures as nativeInitFeaturesImport; +pub(crate) type nativeInitFeatures = nativeInitFeaturesImport; + +/// Features used within an `init` message. +#[must_use] +#[repr(C)] +pub struct InitFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInitFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InitFeatures { + type Target = nativeInitFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InitFeatures { } +unsafe impl core::marker::Sync for InitFeatures { } +impl Drop for InitFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInitFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InitFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InitFeatures_free(this_obj: InitFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InitFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInitFeatures) }; +} +#[allow(unused)] +impl InitFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInitFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInitFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::NodeFeatures as nativeNodeFeaturesImport; +pub(crate) type nativeNodeFeatures = nativeNodeFeaturesImport; + +/// Features used within a `node_announcement` message. +#[must_use] +#[repr(C)] +pub struct NodeFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeNodeFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for NodeFeatures { + type Target = nativeNodeFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for NodeFeatures { } +unsafe impl core::marker::Sync for NodeFeatures { } +impl Drop for NodeFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeNodeFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the NodeFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn NodeFeatures_free(this_obj: NodeFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NodeFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeNodeFeatures) }; +} +#[allow(unused)] +impl NodeFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeNodeFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeNodeFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::ChannelFeatures as nativeChannelFeaturesImport; +pub(crate) type nativeChannelFeatures = nativeChannelFeaturesImport; + +/// Features used within a `channel_announcement` message. +#[must_use] +#[repr(C)] +pub struct ChannelFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ChannelFeatures { + type Target = nativeChannelFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelFeatures { } +unsafe impl core::marker::Sync for ChannelFeatures { } +impl Drop for ChannelFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelFeatures_free(this_obj: ChannelFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelFeatures) }; +} +#[allow(unused)] +impl ChannelFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::Bolt11InvoiceFeatures as nativeBolt11InvoiceFeaturesImport; +pub(crate) type nativeBolt11InvoiceFeatures = nativeBolt11InvoiceFeaturesImport; + +/// Features used within an invoice. +#[must_use] +#[repr(C)] +pub struct Bolt11InvoiceFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt11InvoiceFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Bolt11InvoiceFeatures { + type Target = nativeBolt11InvoiceFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt11InvoiceFeatures { } +unsafe impl core::marker::Sync for Bolt11InvoiceFeatures { } +impl Drop for Bolt11InvoiceFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt11InvoiceFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt11InvoiceFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_free(this_obj: Bolt11InvoiceFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt11InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt11InvoiceFeatures) }; +} +#[allow(unused)] +impl Bolt11InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt11InvoiceFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt11InvoiceFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt11InvoiceFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::OfferFeatures as nativeOfferFeaturesImport; +pub(crate) type nativeOfferFeatures = nativeOfferFeaturesImport; + +/// Features used within an `offer`. +#[must_use] +#[repr(C)] +pub struct OfferFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeOfferFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for OfferFeatures { + type Target = nativeOfferFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for OfferFeatures { } +unsafe impl core::marker::Sync for OfferFeatures { } +impl Drop for OfferFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeOfferFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the OfferFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn OfferFeatures_free(this_obj: OfferFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn OfferFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeOfferFeatures) }; +} +#[allow(unused)] +impl OfferFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeOfferFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeOfferFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeOfferFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::InvoiceRequestFeatures as nativeInvoiceRequestFeaturesImport; +pub(crate) type nativeInvoiceRequestFeatures = nativeInvoiceRequestFeaturesImport; + +/// Features used within an `invoice_request`. +#[must_use] +#[repr(C)] +pub struct InvoiceRequestFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeInvoiceRequestFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for InvoiceRequestFeatures { + type Target = nativeInvoiceRequestFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for InvoiceRequestFeatures { } +unsafe impl core::marker::Sync for InvoiceRequestFeatures { } +impl Drop for InvoiceRequestFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeInvoiceRequestFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the InvoiceRequestFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_free(this_obj: InvoiceRequestFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn InvoiceRequestFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeInvoiceRequestFeatures) }; +} +#[allow(unused)] +impl InvoiceRequestFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeInvoiceRequestFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeInvoiceRequestFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceRequestFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::Bolt12InvoiceFeatures as nativeBolt12InvoiceFeaturesImport; +pub(crate) type nativeBolt12InvoiceFeatures = nativeBolt12InvoiceFeaturesImport; + +/// Features used within an `invoice`. +#[must_use] +#[repr(C)] +pub struct Bolt12InvoiceFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBolt12InvoiceFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for Bolt12InvoiceFeatures { + type Target = nativeBolt12InvoiceFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for Bolt12InvoiceFeatures { } +unsafe impl core::marker::Sync for Bolt12InvoiceFeatures { } +impl Drop for Bolt12InvoiceFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBolt12InvoiceFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the Bolt12InvoiceFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_free(this_obj: Bolt12InvoiceFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Bolt12InvoiceFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBolt12InvoiceFeatures) }; +} +#[allow(unused)] +impl Bolt12InvoiceFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBolt12InvoiceFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBolt12InvoiceFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBolt12InvoiceFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::BlindedHopFeatures as nativeBlindedHopFeaturesImport; +pub(crate) type nativeBlindedHopFeatures = nativeBlindedHopFeaturesImport; + +/// Features used within BOLT 4 encrypted_data_tlv and BOLT 12 blinded_payinfo +#[must_use] +#[repr(C)] +pub struct BlindedHopFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeBlindedHopFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for BlindedHopFeatures { + type Target = nativeBlindedHopFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for BlindedHopFeatures { } +unsafe impl core::marker::Sync for BlindedHopFeatures { } +impl Drop for BlindedHopFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeBlindedHopFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the BlindedHopFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_free(this_obj: BlindedHopFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn BlindedHopFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeBlindedHopFeatures) }; +} +#[allow(unused)] +impl BlindedHopFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeBlindedHopFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeBlindedHopFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeBlindedHopFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} + +use lightning_types::features::ChannelTypeFeatures as nativeChannelTypeFeaturesImport; +pub(crate) type nativeChannelTypeFeatures = nativeChannelTypeFeaturesImport; + +/// Features used within the channel_type field in an OpenChannel message. +/// +/// A channel is always of some known \"type\", describing the transaction formats used and the exact +/// semantics of our interaction with our peer. +/// +/// Note that because a channel is a specific type which is proposed by the opener and accepted by +/// the counterparty, only required features are allowed here. +/// +/// This is serialized differently from other feature types - it is not prefixed by a length, and +/// thus must only appear inside a TLV where its length is known in advance. +#[must_use] +#[repr(C)] +pub struct ChannelTypeFeatures { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeChannelTypeFeatures, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for ChannelTypeFeatures { + type Target = nativeChannelTypeFeatures; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for ChannelTypeFeatures { } +unsafe impl core::marker::Sync for ChannelTypeFeatures { } +impl Drop for ChannelTypeFeatures { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeChannelTypeFeatures>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the ChannelTypeFeatures, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_free(this_obj: ChannelTypeFeatures) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelTypeFeatures_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeChannelTypeFeatures) }; +} +#[allow(unused)] +impl ChannelTypeFeatures { + pub(crate) fn get_native_ref(&self) -> &'static nativeChannelTypeFeatures { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeChannelTypeFeatures { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeChannelTypeFeatures { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Getting a route for a keysend payment to a private node requires providing the payee's +/// features (since they were not announced in a node announcement). However, keysend payments +/// don't have an invoice to pull the payee's features from, so this method is provided for use +/// when a [`Bolt11InvoiceFeatures`] is required in a route. +/// +/// MPP keysend is not widely supported yet, so we parameterize support to allow the user to +/// choose whether their router should find multi-part routes. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_for_keysend(mut allow_mpp: bool) -> crate::lightning_types::features::Bolt11InvoiceFeatures { + let mut ret = lightning_types::features::Bolt11InvoiceFeatures::for_keysend(allow_mpp); + crate::lightning_types::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a ChannelTypeFeatures with only static_remotekey set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_only_static_remote_key() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::only_static_remote_key(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Constructs a ChannelTypeFeatures with anchors support +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_anchors_zero_htlc_fee_and_dependencies() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_empty() -> crate::lightning_types::features::InitFeatures { + let mut ret = lightning_types::features::InitFeatures::empty(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_le_flags(this_arg: &crate::lightning_types::features::InitFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::InitFeatures, other: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::InitFeatures, other: &crate::lightning_types::features::InitFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::InitFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::InitFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_empty() -> crate::lightning_types::features::NodeFeatures { + let mut ret = lightning_types::features::NodeFeatures::empty(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_le_flags(this_arg: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::NodeFeatures, other: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::NodeFeatures, other: &crate::lightning_types::features::NodeFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::NodeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::NodeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_empty() -> crate::lightning_types::features::ChannelFeatures { + let mut ret = lightning_types::features::ChannelFeatures::empty(); + crate::lightning_types::features::ChannelFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_le_flags(this_arg: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelFeatures, other: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelFeatures, other: &crate::lightning_types::features::ChannelFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::ChannelFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::ChannelFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_empty() -> crate::lightning_types::features::Bolt11InvoiceFeatures { + let mut ret = lightning_types::features::Bolt11InvoiceFeatures::empty(); + crate::lightning_types::features::Bolt11InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_le_flags(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures, other: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures, other: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::Bolt11InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt11InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::Bolt11InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt11InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_empty() -> crate::lightning_types::features::OfferFeatures { + let mut ret = lightning_types::features::OfferFeatures::empty(); + crate::lightning_types::features::OfferFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_le_flags(this_arg: &crate::lightning_types::features::OfferFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::OfferFeatures, other: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::OfferFeatures, other: &crate::lightning_types::features::OfferFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::OfferFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeOfferFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeOfferFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeOfferFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn OfferFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::OfferFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeOfferFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_empty() -> crate::lightning_types::features::InvoiceRequestFeatures { + let mut ret = lightning_types::features::InvoiceRequestFeatures::empty(); + crate::lightning_types::features::InvoiceRequestFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_le_flags(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures, other: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures, other: &crate::lightning_types::features::InvoiceRequestFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::InvoiceRequestFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInvoiceRequestFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInvoiceRequestFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInvoiceRequestFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn InvoiceRequestFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::InvoiceRequestFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInvoiceRequestFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_empty() -> crate::lightning_types::features::Bolt12InvoiceFeatures { + let mut ret = lightning_types::features::Bolt12InvoiceFeatures::empty(); + crate::lightning_types::features::Bolt12InvoiceFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_le_flags(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures, other: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures, other: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::Bolt12InvoiceFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn Bolt12InvoiceFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::Bolt12InvoiceFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBolt12InvoiceFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_empty() -> crate::lightning_types::features::BlindedHopFeatures { + let mut ret = lightning_types::features::BlindedHopFeatures::empty(); + crate::lightning_types::features::BlindedHopFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_le_flags(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::BlindedHopFeatures, other: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::BlindedHopFeatures, other: &crate::lightning_types::features::BlindedHopFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::BlindedHopFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBlindedHopFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBlindedHopFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBlindedHopFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn BlindedHopFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::BlindedHopFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeBlindedHopFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Create a blank Features with no features set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_empty() -> crate::lightning_types::features::ChannelTypeFeatures { + let mut ret = lightning_types::features::ChannelTypeFeatures::empty(); + crate::lightning_types::features::ChannelTypeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Returns the feature set as a list of bytes, in little-endian. This is in reverse byte order +/// from most on-the-wire encodings. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_le_flags(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::u8slice { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.le_flags(); + let mut local_ret = crate::c_types::u8slice::from_slice(ret); + local_ret +} + +/// Returns true if this `Features` has any optional flags set +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_any_optional_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_any_optional_bits(); + ret +} + +/// Returns true if this `Features` object contains required features unknown by `other`. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelTypeFeatures, other: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits_from(other.get_native_ref()); + ret +} + +/// Returns the set of required features unknown by `other`, as their bit position. +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_required_unknown_bits_from(this_arg: &crate::lightning_types::features::ChannelTypeFeatures, other: &crate::lightning_types::features::ChannelTypeFeatures) -> crate::c_types::derived::CVec_u64Z { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.required_unknown_bits_from(other.get_native_ref()); + let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { item }); }; + local_ret.into() +} + +/// Returns true if this `Features` object contains unknown feature flags which are set as +/// \"required\". +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_requires_unknown_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.requires_unknown_bits(); + ret +} + +/// Returns true if this `Features` supports any bits which we do not know of +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_supports_unknown_bits(this_arg: &crate::lightning_types::features::ChannelTypeFeatures) -> bool { + let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.supports_unknown_bits(); + ret +} + +/// Sets a required feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_required_feature_bit(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_required_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional feature bit. Errors if `bit` is outside the feature range as defined +/// by [BOLT 9]. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [BOLT 9]: https://github.com/lightning/bolts/blob/master/09-features.md +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_optional_feature_bit(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_optional_feature_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets a required custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Required bits are even. If an odd bit is given, then the corresponding even bit will +/// be set instead (i.e., `bit - 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_required_custom_bit(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_required_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Sets an optional custom feature bit. Errors if `bit` is outside the custom range as defined +/// by [bLIP 2] or if it is a known `T` feature. +/// +/// Note: Optional bits are odd. If an even bit is given, then the corresponding odd bit will be +/// set instead (i.e., `bit + 1`). +/// +/// [bLIP 2]: https://github.com/lightning/blips/blob/master/blip-0002.md#feature-bits +#[must_use] +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_set_optional_custom_bit(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures, mut bit: usize) -> crate::c_types::derived::CResult_NoneNoneZ { + let mut ret = unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.set_optional_custom_bit(bit); + let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { () /*e*/ }).into() }; + local_ret +} + +/// Unsets the `upfront_shutdown_script` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_upfront_shutdown_script(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_upfront_shutdown_script(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `upfront_shutdown_script` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_upfront_shutdown_script(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_upfront_shutdown_script(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `shutdown_anysegwit` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_shutdown_anysegwit(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_shutdown_anysegwit(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `shutdown_anysegwit` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_shutdown_anysegwit(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_shutdown_anysegwit(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `wumbo` feature +#[must_use] +#[no_mangle] +pub extern "C" fn InitFeatures_clear_wumbo(mut this_arg: crate::lightning_types::features::InitFeatures) -> crate::lightning_types::features::InitFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_wumbo(); + crate::lightning_types::features::InitFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `wumbo` feature +#[must_use] +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_wumbo(mut this_arg: crate::lightning_types::features::NodeFeatures) -> crate::lightning_types::features::NodeFeatures { + let mut ret = (*unsafe { Box::from_raw(this_arg.take_inner()) }).clear_wumbo(); + crate::lightning_types::features::NodeFeatures { inner: ObjOps::heap_alloc(ret), is_owned: true } +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `scid_privacy` feature +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_clear_scid_privacy(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.clear_scid_privacy() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `anchors_zero_fee_htlc_tx` feature +#[no_mangle] +pub extern "C" fn ChannelTypeFeatures_clear_anchors_zero_fee_htlc_tx(this_arg: &mut crate::lightning_types::features::ChannelTypeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeChannelTypeFeatures)) }.clear_anchors_zero_fee_htlc_tx() +} + +/// Unsets the `route_blinding` feature +#[no_mangle] +pub extern "C" fn InitFeatures_clear_route_blinding(this_arg: &mut crate::lightning_types::features::InitFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeInitFeatures)) }.clear_route_blinding() +} + +/// Unsets the `route_blinding` feature +#[no_mangle] +pub extern "C" fn NodeFeatures_clear_route_blinding(this_arg: &mut crate::lightning_types::features::NodeFeatures) { + unsafe { &mut (*ObjOps::untweak_ptr(this_arg.inner as *mut crate::lightning_types::features::nativeNodeFeatures)) }.clear_route_blinding() +} + diff --git a/lightning-c-bindings/src/lightning_types/mod.rs b/lightning-c-bindings/src/lightning_types/mod.rs new file mode 100644 index 0000000..a815433 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/mod.rs @@ -0,0 +1,26 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//!lightning_types +//! Various types which are used in the lightning network. +//! +//! See the `lightning` crate for usage of these. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + +pub mod features; +pub mod payment; +pub mod routing; +pub mod string; diff --git a/lightning-c-bindings/src/lightning_types/payment.rs b/lightning-c-bindings/src/lightning_types/payment.rs new file mode 100644 index 0000000..06d78e5 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/payment.rs @@ -0,0 +1,19 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Types which describe payments in lightning. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + diff --git a/lightning-c-bindings/src/lightning_types/routing.rs b/lightning-c-bindings/src/lightning_types/routing.rs new file mode 100644 index 0000000..a9d86b2 --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/routing.rs @@ -0,0 +1,465 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Various types which describe routes or information about partial routes within the lightning +//! network. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_types::routing::RoutingFees as nativeRoutingFeesImport; +pub(crate) type nativeRoutingFees = nativeRoutingFeesImport; + +/// Fees for routing via a given channel or a node +#[must_use] +#[repr(C)] +pub struct RoutingFees { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRoutingFees, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RoutingFees { + type Target = nativeRoutingFees; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RoutingFees { } +unsafe impl core::marker::Sync for RoutingFees { } +impl Drop for RoutingFees { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRoutingFees>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RoutingFees, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RoutingFees_free(this_obj: RoutingFees) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RoutingFees_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRoutingFees) }; +} +#[allow(unused)] +impl RoutingFees { + pub(crate) fn get_native_ref(&self) -> &'static nativeRoutingFees { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRoutingFees { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// Flat routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn RoutingFees_get_base_msat(this_ptr: &RoutingFees) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().base_msat; + *inner_val +} +/// Flat routing fee in millisatoshis. +#[no_mangle] +pub extern "C" fn RoutingFees_set_base_msat(this_ptr: &mut RoutingFees, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.base_msat = val; +} +/// Liquidity-based routing fee in millionths of a routed amount. +/// In other words, 10000 is 1%. +#[no_mangle] +pub extern "C" fn RoutingFees_get_proportional_millionths(this_ptr: &RoutingFees) -> u32 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().proportional_millionths; + *inner_val +} +/// Liquidity-based routing fee in millionths of a routed amount. +/// In other words, 10000 is 1%. +#[no_mangle] +pub extern "C" fn RoutingFees_set_proportional_millionths(this_ptr: &mut RoutingFees, mut val: u32) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.proportional_millionths = val; +} +/// Constructs a new RoutingFees given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RoutingFees_new(mut base_msat_arg: u32, mut proportional_millionths_arg: u32) -> RoutingFees { + RoutingFees { inner: ObjOps::heap_alloc(nativeRoutingFees { + base_msat: base_msat_arg, + proportional_millionths: proportional_millionths_arg, + }), is_owned: true } +} +/// Checks if two RoutingFeess contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn RoutingFees_eq(a: &RoutingFees, b: &RoutingFees) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +impl Clone for RoutingFees { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RoutingFees_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRoutingFees)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RoutingFees +pub extern "C" fn RoutingFees_clone(orig: &RoutingFees) -> RoutingFees { + orig.clone() +} +/// Get a string which allows debug introspection of a RoutingFees object +pub extern "C" fn RoutingFees_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RoutingFees }).into()} +/// Generates a non-cryptographic 64-bit hash of the RoutingFees. +#[no_mangle] +pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} + +use lightning_types::routing::RouteHint as nativeRouteHintImport; +pub(crate) type nativeRouteHint = nativeRouteHintImport; + +/// A list of hops along a payment path terminating with a channel to the recipient. +#[must_use] +#[repr(C)] +pub struct RouteHint { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRouteHint, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RouteHint { + type Target = nativeRouteHint; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHint { } +unsafe impl core::marker::Sync for RouteHint { } +impl Drop for RouteHint { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHint>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RouteHint, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHint_free(this_obj: RouteHint) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHint_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHint) }; +} +#[allow(unused)] +impl RouteHint { + pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHint { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHint { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn RouteHint_get_a(this_ptr: &RouteHint) -> crate::c_types::derived::CVec_RouteHintHopZ { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + let mut local_inner_val = Vec::new(); for item in inner_val.iter() { local_inner_val.push( { crate::lightning_types::routing::RouteHintHop { inner: unsafe { ObjOps::nonnull_ptr_to_inner((item as *const lightning_types::routing::RouteHintHop<>) as *mut _) }, is_owned: false } }); }; + local_inner_val.into() +} +#[no_mangle] +pub extern "C" fn RouteHint_set_a(this_ptr: &mut RouteHint, mut val: crate::c_types::derived::CVec_RouteHintHopZ) { + let mut local_val = Vec::new(); for mut item in val.into_rust().drain(..) { local_val.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = local_val; +} +/// Constructs a new RouteHint given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHint_new(mut a_arg: crate::c_types::derived::CVec_RouteHintHopZ) -> RouteHint { + let mut local_a_arg = Vec::new(); for mut item in a_arg.into_rust().drain(..) { local_a_arg.push( { *unsafe { Box::from_raw(item.take_inner()) } }); }; + RouteHint { inner: ObjOps::heap_alloc(lightning_types::routing::RouteHint ( + local_a_arg, + )), is_owned: true } +} +impl Clone for RouteHint { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHint_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHint)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHint +pub extern "C" fn RouteHint_clone(orig: &RouteHint) -> RouteHint { + orig.clone() +} +/// Get a string which allows debug introspection of a RouteHint object +pub extern "C" fn RouteHint_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RouteHint }).into()} +/// Generates a non-cryptographic 64-bit hash of the RouteHint. +#[no_mangle] +pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two RouteHints contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn RouteHint_eq(a: &RouteHint, b: &RouteHint) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} + +use lightning_types::routing::RouteHintHop as nativeRouteHintHopImport; +pub(crate) type nativeRouteHintHop = nativeRouteHintHopImport; + +/// A channel descriptor for a hop along a payment path. +/// +/// While this generally comes from BOLT 11's `r` field, this struct includes more fields than are +/// available in BOLT 11. Thus, encoding and decoding this via `lightning-invoice` is lossy, as +/// fields not supported in BOLT 11 will be stripped. +#[must_use] +#[repr(C)] +pub struct RouteHintHop { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeRouteHintHop, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for RouteHintHop { + type Target = nativeRouteHintHop; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for RouteHintHop { } +unsafe impl core::marker::Sync for RouteHintHop { } +impl Drop for RouteHintHop { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeRouteHintHop>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the RouteHintHop, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn RouteHintHop_free(this_obj: RouteHintHop) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHintHop_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeRouteHintHop) }; +} +#[allow(unused)] +impl RouteHintHop { + pub(crate) fn get_native_ref(&self) -> &'static nativeRouteHintHop { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeRouteHintHop { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +/// The node_id of the non-target end of the route +#[no_mangle] +pub extern "C" fn RouteHintHop_get_src_node_id(this_ptr: &RouteHintHop) -> crate::c_types::PublicKey { + let mut inner_val = &mut this_ptr.get_native_mut_ref().src_node_id; + crate::c_types::PublicKey::from_rust(&inner_val) +} +/// The node_id of the non-target end of the route +#[no_mangle] +pub extern "C" fn RouteHintHop_set_src_node_id(this_ptr: &mut RouteHintHop, mut val: crate::c_types::PublicKey) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.src_node_id = val.into_rust(); +} +/// The short_channel_id of this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_get_short_channel_id(this_ptr: &RouteHintHop) -> u64 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().short_channel_id; + *inner_val +} +/// The short_channel_id of this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_set_short_channel_id(this_ptr: &mut RouteHintHop, mut val: u64) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.short_channel_id = val; +} +/// The fees which must be paid to use this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_get_fees(this_ptr: &RouteHintHop) -> crate::lightning_types::routing::RoutingFees { + let mut inner_val = &mut this_ptr.get_native_mut_ref().fees; + crate::lightning_types::routing::RoutingFees { inner: unsafe { ObjOps::nonnull_ptr_to_inner((inner_val as *const lightning_types::routing::RoutingFees<>) as *mut _) }, is_owned: false } +} +/// The fees which must be paid to use this channel +#[no_mangle] +pub extern "C" fn RouteHintHop_set_fees(this_ptr: &mut RouteHintHop, mut val: crate::lightning_types::routing::RoutingFees) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.fees = *unsafe { Box::from_raw(val.take_inner()) }; +} +/// The difference in CLTV values between this node and the next node. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_cltv_expiry_delta(this_ptr: &RouteHintHop) -> u16 { + let mut inner_val = &mut this_ptr.get_native_mut_ref().cltv_expiry_delta; + *inner_val +} +/// The difference in CLTV values between this node and the next node. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_cltv_expiry_delta(this_ptr: &mut RouteHintHop, mut val: u16) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.cltv_expiry_delta = val; +} +/// The minimum value, in msat, which must be relayed to the next hop. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_htlc_minimum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_minimum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The minimum value, in msat, which must be relayed to the next hop. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_htlc_minimum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_minimum_msat = local_val; +} +/// The maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHintHop_get_htlc_maximum_msat(this_ptr: &RouteHintHop) -> crate::c_types::derived::COption_u64Z { + let mut inner_val = &mut this_ptr.get_native_mut_ref().htlc_maximum_msat; + let mut local_inner_val = if inner_val.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { inner_val.unwrap() }) }; + local_inner_val +} +/// The maximum value in msat available for routing with a single HTLC. +#[no_mangle] +pub extern "C" fn RouteHintHop_set_htlc_maximum_msat(this_ptr: &mut RouteHintHop, mut val: crate::c_types::derived::COption_u64Z) { + let mut local_val = if val.is_some() { Some( { val.take() }) } else { None }; + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.htlc_maximum_msat = local_val; +} +/// Constructs a new RouteHintHop given each field +#[must_use] +#[no_mangle] +pub extern "C" fn RouteHintHop_new(mut src_node_id_arg: crate::c_types::PublicKey, mut short_channel_id_arg: u64, mut fees_arg: crate::lightning_types::routing::RoutingFees, mut cltv_expiry_delta_arg: u16, mut htlc_minimum_msat_arg: crate::c_types::derived::COption_u64Z, mut htlc_maximum_msat_arg: crate::c_types::derived::COption_u64Z) -> RouteHintHop { + let mut local_htlc_minimum_msat_arg = if htlc_minimum_msat_arg.is_some() { Some( { htlc_minimum_msat_arg.take() }) } else { None }; + let mut local_htlc_maximum_msat_arg = if htlc_maximum_msat_arg.is_some() { Some( { htlc_maximum_msat_arg.take() }) } else { None }; + RouteHintHop { inner: ObjOps::heap_alloc(nativeRouteHintHop { + src_node_id: src_node_id_arg.into_rust(), + short_channel_id: short_channel_id_arg, + fees: *unsafe { Box::from_raw(fees_arg.take_inner()) }, + cltv_expiry_delta: cltv_expiry_delta_arg, + htlc_minimum_msat: local_htlc_minimum_msat_arg, + htlc_maximum_msat: local_htlc_maximum_msat_arg, + }), is_owned: true } +} +impl Clone for RouteHintHop { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RouteHintHop_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRouteHintHop)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the RouteHintHop +pub extern "C" fn RouteHintHop_clone(orig: &RouteHintHop) -> RouteHintHop { + orig.clone() +} +/// Get a string which allows debug introspection of a RouteHintHop object +pub extern "C" fn RouteHintHop_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::routing::RouteHintHop }).into()} +/// Generates a non-cryptographic 64-bit hash of the RouteHintHop. +#[no_mangle] +pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +/// Checks if two RouteHintHops contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn RouteHintHop_eq(a: &RouteHintHop, b: &RouteHintHop) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} diff --git a/lightning-c-bindings/src/lightning_types/string.rs b/lightning-c-bindings/src/lightning_types/string.rs new file mode 100644 index 0000000..db3a5fd --- /dev/null +++ b/lightning-c-bindings/src/lightning_types/string.rs @@ -0,0 +1,228 @@ +// This file is Copyright its original authors, visible in version control +// history and in the source files from which this was generated. +// +// This file is licensed under the license available in the LICENSE or LICENSE.md +// file in the root of this repository or, if no such file exists, the same +// license as that which applies to the original source files from which this +// source was automatically generated. + +//! Utilities for strings. + +use alloc::str::FromStr; +use alloc::string::String; +use core::ffi::c_void; +use core::convert::Infallible; +use bitcoin::hashes::Hash; +use crate::c_types::*; +#[cfg(feature="no-std")] +use alloc::{vec::Vec, boxed::Box}; + + +use lightning_types::string::UntrustedString as nativeUntrustedStringImport; +pub(crate) type nativeUntrustedString = nativeUntrustedStringImport; + +/// Struct to `Display` fields in a safe way using `PrintableString` +#[must_use] +#[repr(C)] +pub struct UntrustedString { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativeUntrustedString, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for UntrustedString { + type Target = nativeUntrustedString; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for UntrustedString { } +unsafe impl core::marker::Sync for UntrustedString { } +impl Drop for UntrustedString { + fn drop(&mut self) { + if self.is_owned && !<*mut nativeUntrustedString>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the UntrustedString, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn UntrustedString_free(this_obj: UntrustedString) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UntrustedString_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativeUntrustedString) }; +} +#[allow(unused)] +impl UntrustedString { + pub(crate) fn get_native_ref(&self) -> &'static nativeUntrustedString { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativeUntrustedString { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativeUntrustedString { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn UntrustedString_get_a(this_ptr: &UntrustedString) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.as_str().into() +} +#[no_mangle] +pub extern "C" fn UntrustedString_set_a(this_ptr: &mut UntrustedString, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_string(); +} +/// Constructs a new UntrustedString given each field +#[must_use] +#[no_mangle] +pub extern "C" fn UntrustedString_new(mut a_arg: crate::c_types::Str) -> UntrustedString { + UntrustedString { inner: ObjOps::heap_alloc(lightning_types::string::UntrustedString ( + a_arg.into_string(), + )), is_owned: true } +} +impl Clone for UntrustedString { + fn clone(&self) -> Self { + Self { + inner: if <*mut nativeUntrustedString>::is_null(self.inner) { core::ptr::null_mut() } else { + ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn UntrustedString_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeUntrustedString)).clone() })) as *mut c_void +} +#[no_mangle] +/// Creates a copy of the UntrustedString +pub extern "C" fn UntrustedString_clone(orig: &UntrustedString) -> UntrustedString { + orig.clone() +} +/// Get a string which allows debug introspection of a UntrustedString object +pub extern "C" fn UntrustedString_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::string::UntrustedString }).into()} +/// Checks if two UntrustedStrings contain equal inner contents. +/// This ignores pointers and is_owned flags and looks at the values in fields. +/// Two objects with NULL inner values will be considered "equal" here. +#[no_mangle] +pub extern "C" fn UntrustedString_eq(a: &UntrustedString, b: &UntrustedString) -> bool { + if a.inner == b.inner { return true; } + if a.inner.is_null() || b.inner.is_null() { return false; } + if a.get_native_ref() == b.get_native_ref() { true } else { false } +} +/// Generates a non-cryptographic 64-bit hash of the UntrustedString. +#[no_mangle] +pub extern "C" fn UntrustedString_hash(o: &UntrustedString) -> u64 { + if o.inner.is_null() { return 0; } + // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core + #[allow(deprecated)] + let mut hasher = core::hash::SipHasher::new(); + core::hash::Hash::hash(o.get_native_ref(), &mut hasher); + core::hash::Hasher::finish(&hasher) +} +#[no_mangle] +/// Get the string representation of a UntrustedString object +pub extern "C" fn UntrustedString_to_str(o: &crate::lightning_types::string::UntrustedString) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +} + +use lightning_types::string::PrintableString as nativePrintableStringImport; +pub(crate) type nativePrintableString = nativePrintableStringImport<'static, >; + +/// A string that displays only printable characters, replacing control characters with +/// [`core::char::REPLACEMENT_CHARACTER`]. +#[must_use] +#[repr(C)] +pub struct PrintableString { + /// A pointer to the opaque Rust object. + + /// Nearly everywhere, inner must be non-null, however in places where + /// the Rust equivalent takes an Option, it may be set to null to indicate None. + pub inner: *mut nativePrintableString, + /// Indicates that this is the only struct which contains the same pointer. + + /// Rust functions which take ownership of an object provided via an argument require + /// this to be true and invalidate the object pointed to by inner. + pub is_owned: bool, +} + +impl core::ops::Deref for PrintableString { + type Target = nativePrintableString; + fn deref(&self) -> &Self::Target { unsafe { &*ObjOps::untweak_ptr(self.inner) } } +} +unsafe impl core::marker::Send for PrintableString { } +unsafe impl core::marker::Sync for PrintableString { } +impl Drop for PrintableString { + fn drop(&mut self) { + if self.is_owned && !<*mut nativePrintableString>::is_null(self.inner) { + let _ = unsafe { Box::from_raw(ObjOps::untweak_ptr(self.inner)) }; + } + } +} +/// Frees any resources used by the PrintableString, if is_owned is set and inner is non-NULL. +#[no_mangle] +pub extern "C" fn PrintableString_free(this_obj: PrintableString) { } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PrintableString_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut nativePrintableString) }; +} +#[allow(unused)] +impl PrintableString { + pub(crate) fn get_native_ref(&self) -> &'static nativePrintableString { + unsafe { &*ObjOps::untweak_ptr(self.inner) } + } + pub(crate) fn get_native_mut_ref(&self) -> &'static mut nativePrintableString { + unsafe { &mut *ObjOps::untweak_ptr(self.inner) } + } + /// When moving out of the pointer, we have to ensure we aren't a reference, this makes that easy + pub(crate) fn take_inner(mut self) -> *mut nativePrintableString { + assert!(self.is_owned); + let ret = ObjOps::untweak_ptr(self.inner); + self.inner = core::ptr::null_mut(); + ret + } + pub(crate) fn as_ref_to(&self) -> Self { + Self { inner: self.inner, is_owned: false } + } +} +#[no_mangle] +pub extern "C" fn PrintableString_get_a(this_ptr: &PrintableString) -> crate::c_types::Str { + let mut inner_val = &mut this_ptr.get_native_mut_ref().0; + inner_val.into() +} +#[no_mangle] +pub extern "C" fn PrintableString_set_a(this_ptr: &mut PrintableString, mut val: crate::c_types::Str) { + unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.0 = val.into_str(); +} +/// Constructs a new PrintableString given each field +#[must_use] +#[no_mangle] +pub extern "C" fn PrintableString_new(mut a_arg: crate::c_types::Str) -> PrintableString { + PrintableString { inner: ObjOps::heap_alloc(lightning_types::string::PrintableString ( + a_arg.into_str(), + )), is_owned: true } +} +/// Get a string which allows debug introspection of a PrintableString object +pub extern "C" fn PrintableString_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning_types::string::PrintableString }).into()} +#[no_mangle] +/// Get the string representation of a PrintableString object +pub extern "C" fn PrintableString_to_str(o: &crate::lightning_types::string::PrintableString) -> Str { + alloc::format!("{}", o.get_native_ref()).into() +}